ladybug-tools / ladybug-geometry

šŸž šŸ“¦ A library with geometry objects used throughout the Ladybug Tools core libraries
https://www.ladybug.tools/ladybug-geometry/docs/
GNU Affero General Public License v3.0
23 stars 22 forks source link

Add Splitting of one Polygon2D with Another #56

Closed chriswmackey closed 1 year ago

chriswmackey commented 4 years ago

It would be extremely valuable to have this functionality within ladybug-geometry since this is ultimately what is needed to ensure matching adjacent surfaces in an energy model (and by extension, ensure matching heat flow across those surfaces).

We have known for a while that the OpenStudio team has figured this out and @saeranv has even put together a Grasshopper component that uses the OpenStudio SDK to perform this splitting: https://discourse.ladybug.tools/t/masses-intersections-issues/3262/5

I believe that this is the most relevant code that is performing this operation of polygon intersections in the OpenStudio code base: https://github.com/NREL/OpenStudio/blob/778c0c38ad4efee6fc67b0f8c0fcf7e8deef2bd0/openstudiocore/src/utilities/geometry/Intersection.cpp#L862-L960 In that method there, you can see all of the different checks for the types of intersection events that can happen, which is really helpful to know.

It looks like that code there is also leveraging the polypartition.cpp file, which is performing a lot of the hard core math of the intersection: https://github.com/NREL/OpenStudio/blob/8c81faf8bc80b0e8f96a4b2764e5958cd060a625/openstudiocore/src/polypartition/polypartition.cpp Essentially all of the functionality of this polypartition.cpp file should already exist with ladybug-geometry here (as far as I can tell).

Lastly, I would note that OpenStudio seems to be using a bounding box method to determine if Faces are close enough to make the intersection calculation worth it: https://github.com/NREL/OpenStudio/blob/778c0c38ad4efee6fc67b0f8c0fcf7e8deef2bd0/openstudiocore/src/model/Space.cpp#L3523-L3541

If we could implement this type of solution within ladybug-geometry here, it would go a long way towards helping us with the following:

  1. Not having to change the representation of the geometry to an OpenStudio model or Rhino SDK representation just to perform the intersection (this should be a significant speed improvement).
  2. We can perform intersections in a cross-platform manner, making it possible to import geometry with non-matching surfaces to a honeybee format, intesect the Faces, solve adjacencies, set custom properties of those adjacent Faces, and then ultimately export a fully-simulate-able model.
chriswmackey commented 1 year ago

This has been addressed!

https://github.com/ladybug-tools/ladybug-geometry/pull/366