-
Notifications
You must be signed in to change notification settings - Fork 18
pygeo.clean_polygon_2d_ex
fabian-flassig edited this page Jun 8, 2026
·
3 revisions
Cleans one or more 2D polygon loops and returns the cleaned result as loops.
This function is located in the pygeo module.
The function is intended for 2D polygon cleanup in the local u/v plane. The input format follows the loop structure of pytha.create_polygon_ex: each loop contains a point table and may optionally contain a segment table. Arc definitions are segmented internally before the cleanup step. The returned result contains only plain point loops.
pygeo.clean_polygon_2d_ex(
{{loop_points_1, loop_segments_1} [,{loop_points_2, loop_segments_2} [,...]] }
[, options]
)| Parameter | Type | Description |
|---|---|---|
loop_points_i |
{{u,v}, ...} |
Coordinates of the loop points in 2D. |
loop_segments_i |
{segment_1, segment_2, ...} |
Optional specification of the segments. Each segment may be a table with the following fields: |
segment_i.angle |
number |
Angle of the arc, positive for counter-clockwise arcs. |
segment_i.radius |
number |
Radius of the arc. |
segment_i.orientation |
"cw" or "ccw"
|
For radius specification: clockwise or counter-clockwise orientation. |
segment_i.select_arc |
"small", "large"
|
For radius specification: select the small or large arc. |
segment_i.bulge |
number |
Maximum distance between the secant and the arc, positive for counter-clockwise arcs. |
segment_i.segments |
integer |
Number of edge segments used for arc segmentation. |
options |
{...} |
Optional: a table that may contain the following options: |
options.minimum_winding |
integer |
Minimum winding number a region must reach to be kept in the result. Default 1. With 2, only regions covered by at least two loops remain, which corresponds to a boolean intersection of two polygons (each loop contributing winding 1). |
| Type | Description |
|---|---|
loops |
{{{u,v}, ...}, ...} |
- This is a purely 2D cleanup function. Input and output use
u/vcoordinates only. - The input format is analogous to
pytha.create_polygon_ex, but the function does not create geometry. It only cleans the loops and returns point coordinates. - Segment definitions are resolved internally into point sequences before cleanup.
- The returned loops contain only point coordinates. Arc, radius, angle and bulge information is not preserved in the result.
- The result may contain multiple loops even if the input contains only one loop.
- The outer loop is returned in CCW orientation, inner loops in CW orientation.
-
options.minimum_windingcontrols how overlapping loops are resolved:1(default) keeps every region inside any loop (union-like cleanup), while higher values keep only regions covered by at least that many windings. Passing two overlapping loops withminimum_winding = 2therefore yields their boolean intersection.
Boolean intersection of two overlapping squares (the result is the shared region):
local intersection = pygeo.clean_polygon_2d_ex(
{
{ {{0, 0}, {10, 0}, {10, 10}, {0, 10}} }, -- first square
{ {{5, 5}, {15, 5}, {15, 15}, {5, 15}} }, -- second square, overlapping
},
{ minimum_winding = 2 }
)
-- intersection -> single loop around {5,5} .. {10,10}Minimum PYTHA Version: V26
pygeo, pygeo.clean_polygon_2d, pytha.create_polygon_ex, pytha.create_polyline_ex