Skip to content

Commit

Permalink
fix(boolean): Catch cases of degenerate Polygons from boolean
Browse files Browse the repository at this point in the history
It seems that this is something that can get returned in certain cases.
  • Loading branch information
chriswmackey authored and Chris Mackey committed Mar 14, 2023
1 parent a2c5338 commit 9fc7667
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ladybug_geometry/geometry2d/polygon.py
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,7 @@ def _to_bool_poly(self):
def _from_bool_poly(bool_polygon):
"""Get a list of Polygon2D from a BooleanPolygon object."""
return [Polygon2D(tuple(Point2D(pt.x, pt.y) for pt in new_poly))
for new_poly in bool_polygon.regions]
for new_poly in bool_polygon.regions if len(new_poly) > 2]

def boolean_union(self, polygon, tolerance):
"""Get a list of Polygon2D for the union of this Polygon and another.
Expand Down
2 changes: 1 addition & 1 deletion ladybug_geometry/geometry3d/face.py
Original file line number Diff line number Diff line change
Expand Up @@ -1798,7 +1798,7 @@ def _from_bool_poly(bool_polygon, plane):
"""
# serialize the BooleanPolygon into Polygon2D
polys = [Polygon2D(tuple(Point2D(pt.x, pt.y) for pt in new_poly))
for new_poly in bool_polygon.regions]
for new_poly in bool_polygon.regions if len(new_poly) > 2]
if len(polys) == 0:
return []
if len(polys) == 1:
Expand Down

0 comments on commit 9fc7667

Please sign in to comment.