Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boost difference issue #4804

Closed
ggartside opened this issue Feb 23, 2023 · 3 comments · Fixed by #4777
Closed

Boost difference issue #4804

ggartside opened this issue Feb 23, 2023 · 3 comments · Fixed by #4777

Comments

@ggartside
Copy link
Collaborator

Issue overview

[
[
[4.572, 0, 0],
[0, 0, 0],
[0, 0.3048, 0],
[4.572, 0.304799, 0],
],
[
[-13.4112, 0.3048, 0],
[5.1816, 0.3048, 0],
[5.1816, 0, 0],
[-10.668, -2.66454e-15, 0],
],
]

Subtracting the first polygon from the second results in of 0 polygons

Input polygons:
image

Current Behavior

The subtraction results in 0 polygons

Expected Behavior

Expected result:
image

Steps to Reproduce

  1. Running regression test test_intersect_136_osm
  2. Check the log file for the following error
  3. [openstudio.model.Surface] <1> Initial area of other surface 'Surface 109' 5.24902 does not equal post intersection area 1.39354

Possible Solution

Details

Environment

Some additional details about your environment for this issue (if relevant):

  • Platform (Operating system, version):
  • Version of OpenStudio (if using an intermediate build, include SHA):

Context

@ggartside ggartside added component - Utilities Geometry Triage Issue needs to be assessed and labeled, further information on reported might be needed labels Feb 23, 2023
@ggartside ggartside self-assigned this Feb 23, 2023
@tijcolem
Copy link
Collaborator

Thanks for reporting @ggartside I think we should open an issue with https://github.com/boostorg/geometry is this is bug associates with boost.

@tijcolem tijcolem added severity - Normal Bug and removed Triage Issue needs to be assessed and labeled, further information on reported might be needed labels Feb 24, 2023
@ggartside
Copy link
Collaborator Author

@tijcolem I think I may have found a solution for this. I was reading through a similar bug report on boost geometry repository, boostorg/geometry#1034

In this bug report the developer replied to the initial report as follows

I can reproduce it, and I am looking into it. If I make all coordinates 10 times larger, the output looks similar but is valid. My theory is that because of the intersection points (which are rounded to the integer grid), in some cases invalid parts can appear. I will look further into this next week, but this is not easy to fix.

My reading of this is that their coordinates are rounded to an integer value, integer grid, and if he had scaled the input values by 10, effectively increasing the resolution of the integer grid, and achieved a better result by doing that and given that all our input values are in meters and so are relatively small numbers, why not try scaling the input values by 1000 to make them millimeters?

So I tried that and scaled the coordinates up in boostPointFromPoint3d and back down in verticesFromBoostPolygon and then ran my test and the result is that the original issue with subtraction has been resolved and now there are no Initial Area differs errors in the output.

@ggartside
Copy link
Collaborator Author

Further development. I found a couple more places where length values need to be scaled and now all the unit tests run clean, however regression test 356 is now failing so I looked in to this further.

We have these two polygons that we are going to intersect
image
They appear to be maybe just touching if the vertex on the green polygon is co-linear with the edge on the blue polygon, will have to figure out if it is on the line, just outside or just inside. However the intersection result from boost is
image
Which is definitely not what we would expect at all

So either way with our without scaling we have a boost boolean operation failure which is unfortunate. I'm going to log both issues with boost now to see if we get any traction from them

@ggartside ggartside linked a pull request Mar 1, 2023 that will close this issue
19 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants