Skip to content

Commit a184377

Browse files
authored
fix intersection ValueError
checks if intersection_segment_plane returns the mesh vertex (u or v of the edge ). if True appends the mesh vertex itself to intersections instead of calculating t. otherwise when mesh.split_edge is executed, it raises ValueError: t should be greater than 0.0. or ValueError: t should be smaller than 1.0.
1 parent e21947a commit a184377

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/compas/datastructures/mesh/slice.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,16 @@ def intersect(self):
146146
x = intersection_segment_plane((a, b), self.plane)
147147
if not x:
148148
continue
149-
L_ax = length_vector(subtract_vectors(x, a))
150-
L_ab = length_vector(subtract_vectors(b, a))
151-
t = L_ax / L_ab
152-
key = self.mesh.split_edge(u, v, t=t, allow_boundary=True)
153-
intersections.append(key)
149+
if len(x) == sum([1 for i, j in zip(x, a) if i == j]):
150+
intersections.append(u)
151+
elif len(x) == sum([1 for i, j in zip(x, b) if i == j]):
152+
intersections.append(v)
153+
else:
154+
L_ax = length_vector(subtract_vectors(x, a))
155+
L_ab = length_vector(subtract_vectors(b, a))
156+
t = L_ax / L_ab
157+
key = self.mesh.split_edge(u, v, t=t, allow_boundary=True)
158+
intersections.append(key)
154159
self._intersections = intersections
155160

156161
def split(self):

0 commit comments

Comments
 (0)