Skip to content

Commit

Permalink
Merge pull request #1156 from Dessia-tech/fix_is_shell_open
Browse files Browse the repository at this point in the history
Fix: Shell3D.is_shell_open
  • Loading branch information
WirajanDASILVA authored Nov 23, 2023
2 parents 4f19bac + 51f5c9b commit cbd1fd6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

#### shells.py
- Fixes to boolean operations. Added some tolerance parameters to some methods.
- Shell3D: get_geo_lines (consider edge.inverse in get_edge_index_in_list check)
- Shell3D: get_geo_lines (consider edge.inverse in get_edge_index_in_list check), is_shell_open

#### surfaces.py
- SphericalSurface3D: use circle 3d instead of polygon3D for plotting.
Expand Down
2 changes: 1 addition & 1 deletion volmdlr/edges.py
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ def get_shared_section(self, other_linesegment, abs_tol: float = 1e-6):
if self.__class__ == other_linesegment.simplify.__class__:
return self.get_shared_section(other_linesegment.simplify)
return []
if not self.direction_vector().is_colinear_to(other_linesegment.direction_vector()) or \
if not self.direction_vector().is_colinear_to(other_linesegment.direction_vector(), 1e-5) or \
(not any(self.point_belongs(point, abs_tol)
for point in [other_linesegment.start, other_linesegment.end]) and
not any(other_linesegment.point_belongs(point, abs_tol) for point in [self.start, self.end])):
Expand Down
26 changes: 19 additions & 7 deletions volmdlr/shells.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def _helper_create_faces_graph(faces, vertices_points=None, verify_connected_com
face_vertices = {}

for face_index, face in enumerate(faces):
face_contour_primitives = face.outer_contour3d.primitives
face_contour_primitives = face.outer_contour3d.primitives[:]
for inner_contour in face.inner_contours3d:
face_contour_primitives.extend(inner_contour.primitives)
for edge in face_contour_primitives:
Expand Down Expand Up @@ -987,14 +987,26 @@ 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 prim in face.outer_contour3d.primitives:
for neihgbor in faces_graph.neighbors(n_index):
if faces[neihgbor].outer_contour3d.is_primitive_section_over_wire(prim):
break
else:
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

@classmethod
Expand Down

0 comments on commit cbd1fd6

Please sign in to comment.