Skip to content

Planar Regions¤

compas_model.geometry.planar_region ¤

Classes¤

NonCoplanarRegionsError ¤

Error raised when planar-region operands do not share a plane.

PlanarRegion ¤

PlanarRegion(
    exterior: Polygon,
    holes: Iterable[Polygon] | None = None,
    frame: Frame | None = None,
    name: str | None = None,
)

A connected planar region with an exterior boundary and optional holes.

Parameters:

  • exterior (Polygon) –

    The exterior boundary of the region.

  • holes (Iterable[Polygon] | None, default: None ) –

    The interior boundaries of the region.

  • frame (Frame | None, default: None ) –

    The oriented plane of the region. If omitted, a best-fit frame is computed and aligned with the exterior polygon normal.

  • name (str | None, default: None ) –

    A human-readable name.

Raises:

  • ValueError –

    If a boundary is degenerate, the boundaries are not coplanar, or they do not form a valid positive-area polygonal region.

Notes

The exterior is oriented with the frame normal. Hole boundaries are oriented oppositely. Area is the exterior area minus all hole areas.

Attributes¤
area property ¤
area: float

float: The net area after subtracting holes.

centroid property ¤
centroid: Point

Point: The area centroid of the region.

points property ¤
points: list[Point]

list[Point]: All exterior and hole boundary points.

Methods:¤
compute_aabb ¤
compute_aabb() -> Box

Compute the axis-aligned bounding box of the region.

compute_obb ¤
compute_obb() -> Box

Compute a principal-component oriented bounding box of the region.

to_mesh ¤
to_mesh() -> Mesh

Convert the region to a triangle mesh while preserving holes.

Returns:

  • Mesh –

    A constrained Delaunay triangulation of the region.

transform ¤
transform(transformation: Transformation) -> None

Transform the region and its oriented plane.

Parameters:

Functions:¤

intersection_planar_region_planar_region ¤

intersection_planar_region_planar_region(
    region_a: PlanarRegion,
    region_b: PlanarRegion,
    tolerance: float = 1e-06,
    minimum_area: float = 0.0,
) -> list[PlanarRegion]

Compute the connected overlap regions of two coplanar planar regions.

Parameters:

  • region_a (PlanarRegion) –

    The first planar region. Its frame determines result orientation.

  • region_b (PlanarRegion) –

    The second planar region.

  • tolerance (float, default: 1e-06 ) –

    Maximum deviation from the plane of region_a.

  • minimum_area (float, default: 0.0 ) –

    Minimum net area of each returned connected component.

Returns:

  • list[PlanarRegion] –

    Connected positive-area intersection regions in deterministic order. Boundary-only intersection returns an empty list.

Raises:

  • ValueError –

    If a tolerance is negative or the regions are not coplanar within the requested tolerance.

Notes

The planar topology operation is performed by Shapely in the local XY coordinates of region_a. Results inherit the frame orientation of region_a and preserve all interior rings.