Skip to content

Commit

Permalink
Merge pull request #13 from jplumail/fix-bug-when-removing
Browse files Browse the repository at this point in the history
fix bug when removing a box
  • Loading branch information
bauerdavid authored Feb 20, 2024
2 parents 1d54c12 + 11e5860 commit d655299
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,8 @@ def bounding_boxes_in_box(self, corners):
bounding_boxes : list
List of bounding boxes that are inside the box.
"""

if len(self._mesh.vertices) == 0:
return []
triangles = self._mesh.vertices[self._mesh.displayed_triangles]
intersects = triangles_intersect_box(triangles, corners)
bounding_boxes = self._mesh.displayed_triangles_index[intersects, 0]
Expand All @@ -717,6 +718,8 @@ def inside(self, coord):
Index of bounding box if any that is at the coordinates. Returns `None`
if no bounding box is found.
"""
if len(self._mesh.vertices) == 0:
return None
triangles = self._mesh.vertices[self._mesh.displayed_triangles]
indices = inside_triangles(triangles - coord)
bounding_boxes = self._mesh.displayed_triangles_index[indices, 0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,8 @@ def bounding_boxes_in_box(self, corners):
bounding_boxes : list
List of bounding boxes that are inside the box.
"""

if len(self._mesh.vertices) == 0:
return []
triangles = self._mesh.vertices[self._mesh.displayed_triangles]
intersects = triangles_intersect_box(triangles, corners)
bounding_boxes = self._mesh.displayed_triangles_index[intersects, 0]
Expand All @@ -975,6 +976,8 @@ def inside(self, coord):
Index of bounding box if any that is at the coordinates. Returns `None`
if no bounding box is found.
"""
if len(self._mesh.vertices) == 0:
return None
triangles = self._mesh.vertices[self._mesh.displayed_triangles]
indices = inside_triangles(triangles - coord)
bounding_boxes = self._mesh.displayed_triangles_index[indices, 0]
Expand Down Expand Up @@ -1010,6 +1013,8 @@ def _inside_3d(self, ray_position: np.ndarray, ray_direction: np.ndarray):
The point where the ray intersects the mesh face. If there was
no intersection, returns None.
"""
if len(self._mesh.vertices) == 0:
return None, None
triangles = self._mesh.vertices[self._mesh.displayed_triangles]
inside = line_in_triangles_3d(
line_point=ray_position,
Expand Down Expand Up @@ -1058,6 +1063,8 @@ def _triangle_intersection(
(n x 3) array of the intersection of the ray with each of the specified bounding boxes in layer coordinates.
Only the 3 displayed dimensions are provided.
"""
if len(self._mesh.vertices) == 0:
return np.empty((0, 3))
triangles = self._mesh.vertices[self._mesh.displayed_triangles]
intersected_triangles = triangles[triangle_indices]
intersection_points = intersect_line_with_triangles(
Expand Down

0 comments on commit d655299

Please sign in to comment.