Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter out None element from vertices for clipping_polygon #1113

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/ezdxf/math/clipping.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,15 @@ def clip_polygon(self, polygon: Sequence[Vec2]) -> Sequence[Sequence[Vec2]]:
"""Returns the parts of the clipped polygon. A polygon is a closed polyline."""

def is_inside(point: Vec2) -> bool:
# is point left of line:
# is point left of line (0.0 is used as tolerance for the check):
return (clip_end.x - clip_start.x) * (point.y - clip_start.y) - (
clip_end.y - clip_start.y
) * (point.x - clip_start.x) > 0.0

def edge_intersection() -> Vec2:
# use consistent tolerance for `is_inside()` and `edge_intersection()`
return intersection_line_line_2d(
(edge_start, edge_end), (clip_start, clip_end)
(edge_start, edge_end), (clip_start, clip_end), abs_tol=0.0
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix for this is to change the algorithm and check for None values!

)

# The clipping polygon is always treated as a closed polyline!
Expand Down