Clipping

Clipping module: ezdxf.math.clipping

ezdxf.math.clipping.greiner_hormann_union(p1: Iterable[UVec], p2: Iterable[UVec]) list[list[Vec2]]

Returns the UNION of polygon p1 | polygon p2. This algorithm works only for polygons with real intersection points and line end points on face edges are not considered as such intersection points!

ezdxf.math.clipping.greiner_hormann_difference(p1: Iterable[UVec], p2: Iterable[UVec]) list[list[Vec2]]

Returns the DIFFERENCE of polygon p1 - polygon p2. This algorithm works only for polygons with real intersection points and line end points on face edges are not considered as such intersection points!

ezdxf.math.clipping.greiner_hormann_intersection(p1: Iterable[UVec], p2: Iterable[UVec]) list[list[Vec2]]

Returns the INTERSECTION of polygon p1 & polygon p2. This algorithm works only for polygons with real intersection points and line end points on face edges are not considered as such intersection points!

class ezdxf.math.clipping.ConvexClippingPolygon2d(vertices: Iterable[Vec2], ccw_check=True, abs_tol=TOLERANCE)

The clipping path is an arbitrary convex 2D polygon.

clip_polygon(polygon: Sequence[Vec2]) Sequence[Sequence[Vec2]]

Returns the parts of the clipped polygon. A polygon is a closed polyline.

clip_polyline(polyline: Sequence[Vec2]) Sequence[Sequence[Vec2]]

Returns the parts of the clipped polyline.

clip_line(start: Vec2, end: Vec2) Sequence[tuple[Vec2, Vec2]]

Returns the parts of the clipped line.

is_inside(point: Vec2) bool

Returns True if point is inside the clipping polygon.

class ezdxf.math.clipping.ClippingRect2d(bottom_left: Vec2, top_right: Vec2, abs_tol=TOLERANCE)

The clipping path is an axis-aligned rectangle, where all sides are parallel to the x- and y-axis.

clip_polygon(polygon: Sequence[Vec2]) Sequence[Sequence[Vec2]]

Returns the parts of the clipped polygon. A polygon is a closed polyline.

clip_polyline(polyline: Sequence[Vec2]) Sequence[Sequence[Vec2]]

Returns the parts of the clipped polyline.

clip_line(start: Vec2, end: Vec2) Sequence[tuple[Vec2, Vec2]]

Returns the clipped line.

is_inside(point: Vec2) bool

Returns True if point is inside the clipping rectangle.

class ezdxf.math.clipping.ConcaveClippingPolygon2d(vertices: Iterable[Vec2], abs_tol=TOLERANCE)

The clipping path is an arbitrary concave 2D polygon.

clip_polygon(polygon: Sequence[Vec2]) Sequence[Sequence[Vec2]]

Returns the parts of the clipped polygon. A polygon is a closed polyline.

clip_polyline(polyline: Sequence[Vec2]) Sequence[Sequence[Vec2]]

Returns the parts of the clipped polyline.

clip_line(start: Vec2, end: Vec2) Sequence[tuple[Vec2, Vec2]]

Returns the clipped line.

is_inside(point: Vec2) bool

Returns True if point is inside the clipping polygon.

class ezdxf.math.clipping.InvertedClippingPolygon2d(inner_polygon: Iterable[Vec2], outer_bounds: BoundingBox2d, abs_tol=TOLERANCE)

This class represents an inverted clipping path. Everything between the inner polygon and the outer extents is considered as inside. The inner clipping path is an arbitrary 2D polygon.

Important

The outer_bounds must be larger than the content to clip to work correctly.

clip_polygon(polygon: Sequence[Vec2]) Sequence[Sequence[Vec2]]

Returns the parts of the clipped polygon. A polygon is a closed polyline.

clip_polyline(polyline: Sequence[Vec2]) Sequence[Sequence[Vec2]]

Returns the parts of the clipped polyline.

clip_line(start: Vec2, end: Vec2) Sequence[tuple[Vec2, Vec2]]

Returns the clipped line.

is_inside(point: Vec2) bool

Returns True if point is inside the clipping polygon.