meshing.export.merge_planar_faces

meshing.export.merge_planar_faces(
    mesh,
    *,
    angle_degrees=1.0,
    plane_tolerance=None,
)

Merge coplanar mesh quads into large polygon faces.

Regions are grown across shared quad edges while each candidate quad’s normal stays within angle_degrees of the region seed’s normal, then accepted only if every region vertex lies within a small tolerance of the region’s mean plane. An accepted region with exactly one boundary loop becomes a single n-gon wound counterclockwise around its outward normal; regions with holes (multiple boundary loops), non-simple boundaries, failed planarity, or a single quad (merging gains nothing, which keeps curved meshes fully triangulated) fall back to their triangles.

Parameters

Name Type Description Default
mesh Mesh A dual-contour :class:~cadjoint.meshing.dual_contouring.Mesh. required
angle_degrees float Maximum angle between a quad normal and its region seed’s normal during region growth. 1.0
plane_tolerance float | None Maximum vertex distance from a region’s mean plane; defaults to 1e-5 times the mesh bounding-box diagonal. None

Returns

Name Type Description
tuple[list[list[int]], np.ndarray] (polygons, triangles): ordered vertex-index loops (one simple polygon each, indices into mesh.vertices) and the leftover triangles (t, 3) covering every quad not absorbed by a polygon.