Aller au contenu principal

raygeo.mesh.build

Uniform mesh (top) and Laplace gradient field (bottom) from build_uniform_mesh.

Uniform mesh (top) and Laplace gradient field (bottom) from build_uniform_mesh.

Functions

build_prism_mesh()

build_prism_mesh(
outer: Sequence[tuple[float, float]],
holes: Sequence[Sequence[tuple[float, float]]] = (),
thickness: float = 18,
uv_scale: float = 300,
z_top: float = 0,
) -> types.PrismMesh

Build a closed prism mesh by extruding a polygon downward.

The top face is triangulated with ear clipping (holes carved out) and placed at z_top; the bottom cap sits at z_top - thickness; every boundary ring gets outward-facing side walls. UVs are planar: uv = xy / uv_scale.

ParameterTypeDescription
outerSequence[tuple[float, float]]Outer boundary polygon vertices as (x, y) tuples.
holesSequence[Sequence[tuple[float, float]]] = ()Sequence of hole/island polygons.
thicknessfloat = 18Extrusion depth below z_top.
uv_scalefloat = 300World units per UV tile.
z_topfloat = 0Z of the top face.
Returnstypes.PrismMeshPrismMesh with positions, normals, uvs and indices.
ComplexityO(n^2) worst case where n = total ring vertices

Earcut triangulation of the prism top face with hole

Earcut triangulation of the prism top face with hole

build_triangle_mesh()

build_triangle_mesh(
outer: Sequence[tuple[float, float]],
holes: Sequence[Sequence[tuple[float, float]]] = (),
tool_radius: float = 0,
min_angle: float = 20,
) -> types.TriangleMesh

Build a constrained Delaunay triangle mesh from polygon boundaries.

ParameterTypeDescription
outerSequence[tuple[float, float]]Outer boundary polygon vertices as (x, y) tuples.
holesSequence[Sequence[tuple[float, float]]] = ()Sequence of hole/island polygons.
tool_radiusfloat = 0Tool radius for offsetting the outer boundary inwards.
min_anglefloat = 20Minimum triangle angle for Steiner point refinement.
Returnstypes.TriangleMeshTriangleMesh with boundary tags.
ComplexityO(n log n) where n = number of Steiner points

CDT triangulation of a square pocket with centred hole

CDT triangulation of a square pocket with centred hole

CDT triangulation of an L-shaped pocket

CDT triangulation of an L-shaped pocket

CDT triangulation of a square pocket with multiple islands

CDT triangulation of a square pocket with multiple islands

build_uniform_mesh()

build_uniform_mesh(
outer: Sequence[tuple[float, float]],
holes: Sequence[Sequence[tuple[float, float]]] = (),
tool_radius: float = 0,
target_edge_len: float = 1,
) -> types.TriangleMesh

Build a triangle mesh with approximately uniform edge length.

Computes the Steiner point density needed to achieve target_edge_len and delegates to build_triangle_mesh.

ParameterTypeDescription
outerSequence[tuple[float, float]]Outer boundary polygon.
holesSequence[Sequence[tuple[float, float]]] = ()List of hole/island polygons.
tool_radiusfloat = 0Offsets outer boundary inward.
target_edge_lenfloat = 1Desired edge length.
Returnstypes.TriangleMeshTriangleMesh with uniform-sized elements.
ComplexityO(n log n) where n = number of Steiner points