Skip to content

Commit

Permalink
fix clipping empty data #1096
Browse files Browse the repository at this point in the history
  • Loading branch information
mozman committed May 30, 2024
1 parent 8eac297 commit 8db35cd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions notes/pages/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
- {{issue 1085}}
- BUGFIX: `clipping.is_inside_polygon()` function was incorrect
- {{issue 1094}}
- BUGFIX: `ClippingPolygon` raises exception clipping empty data
- {{issue 1096}}
-
- ## Version 1.3.0 - 2024-05-01
id:: 65e30c28-021e-4c24-ab6e-a9e9fa7c6a51
Expand Down
6 changes: 6 additions & 0 deletions src/ezdxf/tools/clipping_portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ def clip_line(self, start: Vec2, end: Vec2) -> Sequence[tuple[Vec2, Vec2]]:

def clip_polyline(self, points: NumpyPoints2d) -> Sequence[NumpyPoints2d]:
clipper = self.clipper
if len(points) == 0:
return tuple()
polyline_bbox = BoundingBox2d(points.extents())
if self.is_completely_outside(polyline_bbox):
return tuple()
Expand All @@ -260,6 +262,8 @@ def clip_polyline(self, points: NumpyPoints2d) -> Sequence[NumpyPoints2d]:

def clip_polygon(self, points: NumpyPoints2d) -> Sequence[NumpyPoints2d]:
clipper = self.clipper
if len(points) < 2:
return tuple()
polygon_bbox = BoundingBox2d(points.extents())
if self.is_completely_outside(polygon_bbox):
return tuple()
Expand All @@ -278,6 +282,8 @@ def clip_paths(
for path in paths:
for sub_path in path.sub_paths():
path_bbox = BoundingBox2d(sub_path.control_vertices())
if not path_bbox.has_data:
continue
if self.is_completely_inside(path_bbox):
yield sub_path
continue
Expand Down

0 comments on commit 8db35cd

Please sign in to comment.