shore.geometry.stl
STL backend of the Geometry protocol (ADR 0002).
Wraps a trimesh.Trimesh. The body is the only entity; there is no parametrisation. Ray casts go through the existing Projector (one cached BVH per anchor), so points, distances and ray casts are bit-identical to the pre-protocol code.
Normals are crease-aware (ADR 0014): each triangle corner gets the corner-angle-weighted mean of the normals of the faces around its vertex that lie within crease_deg of the triangle's own, and the corners of an open boundary that lies in a plane (a half model's cut) get their normal projected into that plane. They differ from the legacy volume.hyperbolic._stl_normals wherever faces meet at a sharp edge.
StlGeometry class
StlGeometry(mesh: trimesh.Trimesh, crease_deg: float = 30.0)Triangulated body surface as a Geometry.
Parameters
mesh— Triangulated body surface;load_stl(used byfrom_file) cleans it so that face orientation and normals are consistent.crease_deg— Faces whose normals differ by more than this angle are not averaged into each other's corner normals (sharp edges). 180 on a closed mesh gives trimesh's vertex normals.
Raises
ParameterError— crease_deg outside (0, 180].
StlGeometry.from_file classmethod
from_file(
path: str | Path,
skip_hygiene: bool = False,
crease_deg: float = 30.0,
) -> StlGeometryLoad an STL file (see shore.surface.io.load_stl).
StlGeometry.bounds property
bounds: np.ndarrayStlGeometry.display method
display() -> DisplayThe mesh as drawn (ADR 0038): every triangle belongs to the body; the feature curves and their junctions (ADR 0049) drawn over it.
StlGeometry.entities method
entities(kind: EntityKind) -> tuple[EntityRef, ...]StlGeometry.features method
features() -> tuple[list[np.ndarray], np.ndarray]Feature curves and points (ADR 0049), computed once.
Feature edges are the mesh edges whose two facets' normals differ by more than crease_deg, and the open-boundary edges. They are chained into polylines (the CURVE entities) split at every vertex where other than two feature edges meet; those vertices are the POINT entities. Chains, and the points, are ordered by their lowest vertex index, closed loops starting there.
StlGeometry.ray_cast method
ray_cast(
anchor: np.ndarray,
dirs: np.ndarray,
on_failure: str = 'raise',
) -> ProjectionResultStlGeometry.project method
project(
points: np.ndarray,
entity: EntityRef | None = None,
*,
exact: bool = False,
) -> ProjectionClosest point on the triangulation.
The facets are the geometry of an STL, so the answer is exact for either value of exact. Normals are barycentric blends of the crease-aware corner normals of the closest triangle (ADR 0014); on a crease edge the closest triangle, and so the normal, is either side's.
StlGeometry.evaluate method
evaluate(entity: EntityRef, params: np.ndarray) -> np.ndarrayStlGeometry.fingerprint method
fingerprint(entity: EntityRef) -> EntityKeyFingerprint of the body (area-weighted facet centroid, area, bbox), a feature curve (length-weighted centroid, length, bbox) or a point.
StlGeometry.projector method
projector(anchor: np.ndarray) -> ProjectorThe cached Projector for anchor (one BVH build per anchor).