Skip to content

Commit

Permalink
fix too many nested loops
Browse files Browse the repository at this point in the history
  • Loading branch information
WirajanDASILVA committed Nov 23, 2023
1 parent 5f06d5f commit 51f5c9b
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions volmdlr/shells.py
Original file line number Diff line number Diff line change
Expand Up @@ -987,22 +987,25 @@ def is_shell_open(faces, faces_graph=None):
if faces_graph is None:
vertices_points = Shell3D._helper_getter_vertices_points(faces)
faces_graph = Shell3D._helper_create_faces_graph(faces, vertices_points, False)

def is_primitive_on_neighbor_face(prim, neighbor_face):
"""Verifies if primitive is on a neighbor face."""
return any(
neighbor_face_contour.is_primitive_section_over_wire(prim)
for neighbor_face_contour in [neighbor_face.outer_contour3d] + neighbor_face.inner_contours3d
)

for n_index in faces_graph.nodes:
face = faces[n_index]
for contour in [face.outer_contour3d] + face.inner_contours3d:
for prim in contour.primitives:
primitive_on_neighbor_face = False
for neighbor in faces_graph.neighbors(n_index):
neighbor_face = faces[neighbor]
for neighbor_face_contour in [neighbor_face.outer_contour3d] + neighbor_face.inner_contours3d:
if neighbor_face_contour.is_primitive_section_over_wire(prim):
primitive_on_neighbor_face = True
break
if not primitive_on_neighbor_face:
continue
break
if not primitive_on_neighbor_face:
return True
if any(
not any(
is_primitive_on_neighbor_face(prim, faces[neighbor])
for neighbor in faces_graph.neighbors(n_index)
)
for prim in [prim for contour in [face.outer_contour3d] + face.inner_contours3d
for prim in contour.primitives]
):
return True

return False

Expand Down

0 comments on commit 51f5c9b

Please sign in to comment.