Skip to content

Mesh Sections and Clips¤

compas_model.geometry.mesh_section ¤

Functions:¤

clip_mesh ¤

clip_mesh(
    mesh: Mesh,
    frame: Frame,
    source_guid: str,
    tolerance: float = 1e-06,
    minimum_area: float = 0.0,
    cap: bool = True,
) -> ClipElementResult

Clip a mesh and retain everything behind an oriented plane.

Entirely-behind meshes are copied unchanged. Intersected closed meshes are capped when requested; open input meshes remain open.

clip_mesh_halfspace ¤

clip_mesh_halfspace(
    mesh: Mesh, frame: Frame, side: str, tolerance: float = 1e-06
) -> Mesh | None

Clip a mesh to one half-space without modifying the input.

Parameters:

  • mesh (Mesh) –

    The mesh to clip.

  • frame (Frame) –

    The clipping-plane frame.

  • side (str) –

    "front" for the positive half-space or "behind" for the negative half-space.

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

    Absolute distance treated as lying on the plane.

Returns:

  • Mesh or None –

    The uncapped clipped mesh, or None if no polygonal geometry remains.

Raises:

  • ValueError –

    If side is unsupported or tolerance is negative.

intersection_mesh_plane ¤

intersection_mesh_plane(
    mesh: Mesh, frame: Frame, tolerance: float = 1e-06, minimum_area: float = 0.0
) -> tuple[list[PlanarRegion], list[Polyline]]

Intersect a mesh with a plane and reconstruct closed and open curves.

Parameters:

  • mesh (Mesh) –

    The input mesh.

  • frame (Frame) –

    The oriented cutting-plane frame.

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

    Absolute plane and endpoint-welding tolerance.

  • minimum_area (float, default: 0.0 ) –

    Minimum net area of returned closed regions.

Returns:

reconstruct_planar_regions ¤

reconstruct_planar_regions(
    polylines: Iterable[Polyline],
    frame: Frame,
    tolerance: float = 1e-06,
    minimum_area: float = 0.0,
) -> tuple[list[PlanarRegion], list[Polyline]]

Reconstruct planar regions and open chains from unordered polylines.

Parameters:

  • polylines (Iterable[Polyline]) –

    Curve approximations lying on the target plane.

  • frame (Frame) –

    The oriented plane used for projection and region orientation.

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

    Absolute coplanarity and endpoint-welding tolerance.

  • minimum_area (float, default: 0.0 ) –

    Minimum net area of returned regions.

Returns:

Raises:

  • ValueError –

    If options are invalid or a polyline deviates from the plane.

section_mesh ¤

section_mesh(
    mesh: Mesh,
    frame: Frame,
    source_guid: str,
    tolerance: float = 1e-06,
    minimum_area: float = 0.0,
) -> SectionElementResult

Section a mesh with an oriented plane.

Parameters:

  • mesh (Mesh) –

    The mesh to section. The input is not modified.

  • frame (Frame) –

    The cutting-plane frame. Its Z axis points toward the front side.

  • source_guid (str) –

    String representation of the source element GUID.

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

    Absolute distance used for plane classification and endpoint welding.

  • minimum_area (float, default: 0.0 ) –

    Minimum net area of returned closed section regions.

Returns:

Raises:

  • ValueError –

    If an option is invalid or the mesh has no vertices.

Notes

Closed regions are reconstructed from welded triangle-plane segments using Shapely line merging and ring nesting. This function never clips the input mesh.