Skip to content

Commit

Permalink
feat(network): Add a DirectedGraphNetwork class for splitting polygons
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswmackey committed Aug 30, 2024
1 parent 5a99778 commit daeef8e
Show file tree
Hide file tree
Showing 3 changed files with 824 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ladybug_geometry/geometry2d/polygon.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ def split_through_self_intersection(self, tolerance):
for i, _s in enumerate(_segs):
# loop over the other segments and find any intersection points
if i == 0:
_skip = (len(_segs) - 1, i, i + 1)
_skip = (len(_segs) - 1, i, i + 1)
elif i == seg_count - 1:
_skip = (i - 1, i, 0)
else:
Expand Down
43 changes: 43 additions & 0 deletions ladybug_geometry/geometry3d/face.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,26 @@ def is_horizontal(self, tolerance):
"""
return self.max.z - self.min.z <= tolerance

def is_coplanar(self, face, tolerance):
"""Check whether a this face is coplanar with another given tolerance.
This method will only evaluate the distance between the other face's
vertices and this face's plane so it does not rely on a check based
on angle tolerance.
Args:
face: A neighboring Face3D for which co-planarity will be checked.
tolerance: The minimum difference between the coordinate values of two
vertices at which they can be considered equivalent.
Returns:
True if the face is coplanar with this one. False if it is not.
"""
for pt in face.vertices:
if self.plane.distance_to_point(pt) > tolerance:
return False
return True

def is_geometrically_equivalent(self, face, tolerance):
"""Check whether a given face is geometrically equivalent to this Face.
Expand Down Expand Up @@ -786,6 +806,29 @@ def is_centered_adjacent(self, face, tolerance):
return True
return False

def is_overlapping(self, face, tolerance):
"""Check whether a this face overlaps with another given tolerance.
Overlapping faces must not only be coplanar but they also have overlapping
polygons when evaluated within the same plane. Note that, if the face
is a sub-face of this one, this method will return True.
Args:
face: A neighboring Face3D for which overlaps will be checked.
tolerance: The minimum difference between the coordinate values of two
vertices at which they can be considered equivalent.
Returns:
True if the face is overlapping with this one. False if it is not.
"""
if not self.is_coplanar(face, tolerance):
return False
verts2d = tuple(self.plane.xyz_to_xy(_v) for _v in face.vertices)
other_poly = Polygon2D(verts2d)
if self.polygon2d.polygon_relationship(other_poly, tolerance) == -1:
return False
return True

def is_sub_face(self, face, tolerance, angle_tolerance):
"""Check whether a given face is a sub-face of this face.
Expand Down
Loading

0 comments on commit daeef8e

Please sign in to comment.