Mesh ¶
Triangulated surface or solid with per-vertex and per-face attributes.
length_unit
property
¶
length_unit
Unit of the coordinates, such as m or ft; None when not declared.
volume
property
¶
volume
Enclosed volume of a closed mesh, positive when wound outward.
Raises:
| Type | Description |
|---|---|
InvalidInput
|
If the mesh is not closed or not consistently wound; |
contains
method descriptor
¶
contains(points)
Whether each point is inside, by generalized winding number.
cut
method descriptor
¶
cut(origin, normal)
The part of the mesh behind a plane.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
origin
|
sequence of float
|
A point on the plane, |
required |
normal
|
sequence of float
|
Points away from the part kept, so it is the outward normal of the cut face; any non-zero length. |
required |
Returns:
| Type | Description |
|---|---|
Mesh
|
The part where |
Raises:
| Type | Description |
|---|---|
InvalidInput
|
With a zero or non-finite normal, or when the capped mesh would not close, as when the mesh crosses itself. |
distance
method descriptor
¶
distance(points, *, signed=False)
Distance to the surface; signed makes inside points negative.
fill_holes
method descriptor
¶
fill_holes()
Closes each hole with a fan of triangles from its first vertex.
Returns:
| Type | Description |
|---|---|
Mesh
|
A new mesh with the fans appended, wound like the faces around each hole, with null face attributes. A hole is a loop of boundary edges; a loop through a vertex that starts two boundary edges stays open. A fan suits small, nearly planar, convex holes; others can come out folded, so validate the result. |
merge
method descriptor
¶
merge(other)
The solid inside this mesh or other.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
Mesh
|
A closed mesh in the same CRS and length unit, when both declare one. |
required |
Returns:
| Type | Description |
|---|---|
Mesh
|
A closed mesh wound outward. Faces keep the columns of the face they came from, the union of both meshes' face columns with nulls where a mesh lacks one; vertex columns carry over the same way, null on vertices made where the surfaces cross. Where faces of both meshes lie in one plane facing the same way, the first mesh's face is kept. Empty when nothing is kept. |
Raises:
| Type | Description |
|---|---|
InvalidInput
|
When a mesh is open, the CRSs or length units differ, a column has different types in the two meshes, or the result would not be a closed solid, such as two solids meeting only along an edge. |
Notes
The surfaces are corefined: triangles that cross are split along their intersection, found with exact orientation predicates, and each piece is kept by whether it lies inside the other mesh. Points closer than 1e-9 of the size of both meshes weld together, or 1e-6 where faces lying within rounding of each other need it to close.
overlap
method descriptor
¶
overlap(other)
The solid inside both this mesh and other.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
Mesh
|
A closed mesh in the same CRS and length unit, when both declare one. |
required |
Returns:
| Type | Description |
|---|---|
Mesh
|
A closed mesh, with columns carried over as in |
Raises:
| Type | Description |
|---|---|
InvalidInput
|
As |
proportion
method descriptor
¶
proportion(targets, *, size=None, discretization=Ellipsis)
Proportion of each block inside, from a grid of points per block
where the surface may cut it: discretization per axis, or one count
for all three. targets is a BlockModel, whose rotation and sub-block
extents count, or axis-aligned centroids with a shared size, finite
and positive. A discretization of more than 10 000 000 points per
block raises InvalidInput.
repair
method descriptor
¶
repair(*, tolerance=0.0)
Weld close vertices, drop degenerate and duplicate triangles, and wind the triangles consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tolerance
|
float
|
Vertices within this distance of an earlier vertex merge into it; 0 merges exact duplicates only. |
0.0
|
Returns:
| Type | Description |
|---|---|
Mesh
|
A new mesh without unused vertices, each connected piece wound one
way. A closed piece inside an even number of other closed pieces
winds outward; inside an odd number it is a cavity and winds
inward, so the volume is outer minus cavities. Kept vertices and
triangles keep their order and attributes. Repairing it again
changes nothing. Crossing faces stay; |
section
method descriptor
¶
section(origin, normal, *, offsets=None)
Lines where one or more parallel planes cut the mesh.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
origin
|
sequence of float
|
A point on the plane, |
required |
normal
|
sequence of float
|
The plane's normal, any non-zero length. |
required |
offsets
|
sequence of float
|
Distances along the unit normal to move the plane by, one section
each; defaults to |
None
|
Returns:
| Type | Description |
|---|---|
Polylines
|
One feature per line, with an |
Raises:
| Type | Description |
|---|---|
InvalidInput
|
With a zero or non-finite normal, non-finite offsets, or a face
column named |
subtract
method descriptor
¶
subtract(other)
The solid inside this mesh and outside other.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
Mesh
|
A closed mesh in the same CRS and length unit, when both declare one. |
required |
Returns:
| Type | Description |
|---|---|
Mesh
|
A closed mesh, with columns carried over as in |
Raises:
| Type | Description |
|---|---|
InvalidInput
|
As |
to_crs
method descriptor
¶
to_crs(target)
A copy in the CRS target, an EPSG code such as EPSG:4326.
Geographic and UTM CRSs on WGS 84, SIRGAS 2000, SAD69, NAD83, ETRS89 and GDA2020 are supported, with datum changes by the published EPSG 7-parameter Helmert transformations. Geographic coordinates are longitude and latitude in degrees, projected ones are in metres; heights are kept.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
The CRS to convert to, |
required |
Returns:
| Type | Description |
|---|---|
Mesh
|
The mesh in |
Raises:
| Type | Description |
|---|---|
InvalidInput
|
Without a CRS, or with a CRS outside the supported set. |
to_length_unit
method descriptor
¶
to_length_unit(unit, *, crs=None)
A copy with the coordinates converted to unit, the new length unit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unit
|
str
|
A length unit, such as |
required |
crs
|
str
|
The CRS of the converted coordinates; required when the coordinates have a CRS, which a change of unit changes. |
None
|
Raises:
| Type | Description |
|---|---|
InvalidInput
|
Without a length unit to convert from, or with a CRS and no |
validate
method descriptor
¶
validate(*, tolerance=0.0)
Everything that keeps the mesh from being a clean closed solid.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tolerance
|
float
|
A vertex within this distance of an earlier vertex is a duplicate; 0 finds exact duplicates only. |
0.0
|
Returns:
| Type | Description |
|---|---|
MeshReport
|
Counts in |
vertical_distance
method descriptor
¶
vertical_distance(points)
Signed vertical distance to a surface such as topography.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
(array_like, PointSet or BlockModel)
|
|
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Point elevation minus surface elevation at the same (x, y): positive above, negative below. NaN where a coordinate is NaN or no triangle covers the point in plan; where the surface overlaps itself, the highest counts. |
with_face_column
method descriptor
¶
with_face_column(name, values)
New mesh with the per-triangle attribute name added or replaced.
with_vertex_column
method descriptor
¶
with_vertex_column(name, values)
New mesh with the per-vertex attribute name added or replaced.
Used in