-
Notifications
You must be signed in to change notification settings - Fork 18
pygeo.offset_polygon_ex
Computes the parallel offset of a 2D polygon with optional holes and arc segments, and returns both the offset polygon and the mantle faces between the original and the offset boundary.
This function is located in the pygeo module.
The mantle faces are the strips of material that lie between the original polygon boundary and the offset boundary, with their ends mitered along the angle bisectors of the original corners. They are useful for constructing frames, ribbed structures or any other geometry that requires the connecting material between an inset and its source.
pygeo.offset_polygon_ex extends pygeo.offset_polygon by accepting a multi-loop input (e.g. outer boundary plus holes) and arc segment descriptions in the same format as pytha.create_polygon_ex. Arc segments are tessellated internally before the offset is computed.
Internally pygeo.offset_polygon_ex is implemented on top of PYTHA's median-axis-based parallel-offset algorithm, so it handles short edges, self-intersection collapse and similar degeneracies cleanly.
offset_loops, mantle_faces = pygeo.offset_polygon_ex(
{{loop_points_1, loop_segments_1} [, {loop_points_2, loop_segments_2} [, ...]] },
distance
)| 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 tessellation. |
distance |
number |
Offset distance. Positive values move the contour outward, negative values move it inward. |
| Type | Description |
|---|---|
offset_loops |
{{loop_points_1} [, {loop_points_2}, ...]} |
mantle_faces |
{{loop_points_1} [, {loop_points_2}, ...]} |
- The function performs a purely 2D operation in the local
u/vplane and does not create any elements in the project. - Arc segments in the input are tessellated into edges before the offset is computed; the returned loops contain only plain point coordinates. Arc, radius, angle and bulge information is not preserved in the result.
- The result follows the loop orientation convention used elsewhere in
pygeo: outer loops counter-clockwise, hole loops clockwise. - For a single-loop input without arc segments, prefer
pygeo.offset_polygon, which additionally provides a per-mantle index back to the original edge.
local outer = {
{0, 0},
{200, 0},
{200, 100},
{0, 100},
}
local hole = {
{50, 30},
{150, 30},
{150, 70},
{50, 70},
}
local offset_loops, mantle_faces = pygeo.offset_polygon_ex(
{ { outer }, { hole } },
-5
)
-- offset_loops contains the inset outer loop and the (expanded) hole loop.
-- mantle_faces contains all mantle strips along both the outer and the
-- hole boundary, mitered at the corners.Minimum PYTHA Version: V27
pygeo, pygeo.offset_polygon, pygeo.offset_polyline_ex, pygeo.clean_polygon_2d_ex, pytha.create_polygon_ex