diff --git a/CHANGELOG.md b/CHANGELOG.md index 409fd7f43..be9b64163 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/volmdlr/edges.py b/volmdlr/edges.py index 2b0a37df2..3b1efa373 100644 --- a/volmdlr/edges.py +++ b/volmdlr/edges.py @@ -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])): diff --git a/volmdlr/shells.py b/volmdlr/shells.py index 38c730aeb..eefa66674 100644 --- a/volmdlr/shells.py +++ b/volmdlr/shells.py @@ -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: @@ -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