Skip to main content

Crate fast_mesh_ops

Crate fast_mesh_ops 

Source
Expand description

Repair operations on meshes stored in fast_mesh_store.

Operations read the mesh through a transaction’s tx.mesh(), build the maps they need from its triangles, compute and validate their whole plan, and only then write. Positions are read as the stored f32 local coordinates and all geometry is computed in f64, without the origin. Every growable temporary is reserved fallibly, so that running out of memory is OpsError::Store with StoreError::OutOfMemory. Results do not depend on hash iteration order: every list is sorted explicitly.

  • Edges: an undirected edge is keyed (min, max). It is a boundary edge when one triangle uses it, interior with two and non-manifold with three or more (EdgeKind). Triangles with a repeated vertex id are skipped.
  • Components: triangles connect through shared edges of any kind (Component).
  • Boundary loops: boundary_loops chains the boundary edges into BoundaryLoops by walking each vertex’s triangle fan, so that two holes touching at one vertex come out as two loops. Each loop has a content fingerprint, a LoopId, that callers use to pick loops to fill.
  • Analysis: analyze reports a mesh’s defects without changing it, as an Analysis: loops, coincident vertices, degenerate and duplicate triangles, non-manifold edges and vertices, pinch vertices, components, orientation conflicts and, given a BVH, self-intersection.
  • Orientation: orient() makes the winding consistent patch by patch and turns closed components outward.
  • Booleans: boolean_plan splits every triangle of mesh A that mesh B crosses (and vice versa) so that each piece lies strictly on one side of the other mesh, classifies the pieces for BooleanOp and apply_boolean writes the plan, stitching both rims without any winding assumption. Inputs must be closed, manifold and consistently wound.
  • Offsetting and shells: offset moves a surface along its smooth normals by a signed distance, and shell solidifies a mesh into a printable shell of wall thickness by adding a reversed inner copy and stitching every rim; both drop pinched triangles and report them.
  • Hole filling: fill_holes closes the boundary loops chosen by size or by id with triangle patches that agree with their neighbours’ winding and never make an edge non-manifold, refined to the surrounding density and faired to continue the surrounding curvature. Run orient() first on meshes that may contain flipped triangles: a hole whose rim crosses an orientation seam is not clean and is skipped.
  • Auto repair: auto_repair() runs the standard cleanup pipeline (weld, remove degenerate, orient, remove small components, fill holes) in one transaction, with a report per stage.
  • Measurement: measure reports a mesh’s surface area (always) and enclosed volume (when watertight, with the reason otherwise).
  • Simplification: simplify shrinks a mesh toward a target triangle count by quadric-error edge collapses, keeping boundary vertices in place when asked.
  • Subdivision: subdivide refines every triangle into four per level by Loop’s scheme, with boundary vertices relaxing along their own curve and other creases holding their midpoints.
  • Registration: icp() aligns points to a mesh by rigid, point-to-plane ICP with trimmed outlier rejection, and reports how far it got.
  • Brush deformation: inflate and smooth move the vertices under a brush along their smooth normals or toward their neighbours, and grab drags them along one vector.
  • UVs: every operation either keeps a mesh’s UV channel aligned or drops it undoably, never leaving stale values; the per-operation table is in docs/uv-channel.md.

Re-exports§

pub use append::AppendReport;
pub use append::AppendSource;
pub use append::append_mesh;
pub use append::append_mesh_with_uvs;
pub use boolean::BooleanOp;
pub use boolean::BooleanPlan;
pub use boolean::BooleanReport;
pub use boolean::apply_boolean;
pub use boolean::boolean_plan;
pub use bridge::BridgeOptions;
pub use bridge::BridgeOptionsBuilder;
pub use bridge::BridgeReport;
pub use bridge::bridge_loops;
pub use deform::Brush;
pub use deform::Falloff;
pub use deform::InflateOptions;
pub use deform::InflateOptionsBuilder;
pub use deform::InflateReport;
pub use deform::inflate;
pub use icp::IcpMotion;
pub use icp::IcpOptions;
pub use icp::IcpReport;
pub use icp::IcpStatus;
pub use icp::icp;
pub use icp::sample_surface;

Modules§

append
Appending copied geometry to a mesh.
boolean
Boolean operations (union, subtract, intersect) between two closed meshes.
bridge
Bridging two boundary loops with a triangle tube.
deform
Brush deformation: moving vertices along their normals under a falloff.
icp
Rigid registration: point-to-plane ICP against a mesh and its BVH.
remesh
Region remeshing: matching a brush region’s density to a target edge length.
simplify
Mesh simplification by quadric-error edge collapse.
subdivide
Mesh subdivision by Loop’s scheme.

Structs§

Analysis
What analyze found.
AnalyzeOptions
Options for analyze.
AnalyzeOptionsBuilder
A builder for AnalyzeOptions, see AnalyzeOptions::builder.
AutoRepairOptions
Options for auto_repair().
AutoRepairOptionsBuilder
A builder for AutoRepairOptions, see AutoRepairOptions::builder.
AutoRepairReport
What auto_repair() did, stage by stage.
BoundaryLoop
A chain of boundary edges, closed unless the walk could not close it.
Component
A set of triangles connected through shared edges of any kind.
ComponentOptions
Options for remove_small_components().
ComponentOptionsBuilder
A builder for ComponentOptions, see ComponentOptions::builder.
CutOptions
Options for cut_by_plane.
CutOutput
The - side of cut_by_plane: a mesh with the input’s origin, ready to add to the scene with the same placement.
CutReport
What cut_by_plane did.
DegenerateOptions
Options for remove_degenerate().
DegenerateOptionsBuilder
A builder for DegenerateOptions, see DegenerateOptions::builder.
DegenerateReport
What remove_degenerate() did.
FillOptions
Options for fill_holes.
FillOptionsBuilder
A builder for FillOptions, see FillOptions::builder.
FillReport
What fill_holes did, each list in loop order.
FilledLoop
A loop that was filled.
LoopId
A content fingerprint of a boundary loop, valid across edits and transactions for as long as the loop’s vertex sequence is unchanged.
MeasureReport
Scalar measurements of a mesh, see measure.
OffsetOptions
Options for offset.
OffsetOptionsBuilder
A builder for OffsetOptions, see OffsetOptions::builder.
OffsetReport
What offset did.
OrientReport
What orient() did.
RemoveReport
What remove_small_components() did.
ShellOptions
Options for shell.
ShellOptionsBuilder
A builder for ShellOptions, see ShellOptions::builder.
ShellReport
What shell did.
WeldReport
What weld() did.

Enums§

AutoRepairStage
One stage’s report in an AutoRepairReport.
EdgeKind
How many triangles share an edge. Re-exported from fast_mesh_store, whose corner table uses the same three kinds with the same meaning, so that callers of both crates see one type. Kind of the edge opposite a corner.
FailReason
Why a selected loop could not be filled; it is left open.
FairWeights
The edge weights of the Laplacian used to fair a patch.
OpsError
Why a repair operation could not run.
SkipReason
Why a loop was left out of the fill.
VolumeReason
Why MeasureReport::volume is None.

Functions§

analyze
Reports the defects of mesh without changing it.
auto_repair
Repairs a mesh with the standard cleanup pipeline: weld() → remove_degenerate() → orient() → remove_small_components() → fill_holes(), all in tx, so committing it makes one undo step.
boundary_loops
The boundary loops of mesh, sorted by smallest vertex, then by vertex sequence (for a closed loop, the vertex after the smallest).
cut_by_plane
Splits the mesh of tx with plane: the + side stays, the - side is returned as a mesh with the same origin. Triangles crossing the plane are split along it; with options.cap both openings are closed with flat, unfaired fill_holes patches over the cut rim.
fill_holes
Fills boundary loops with triangle patches, chosen by size or by id.
measure
Measures mesh in its local units: total area always, enclosed volume when watertight. See the module docs for the tolerant volume convention.
measure_placed
Measures mesh with each mesh point (the origin plus a local position) mapped through place first, so with a placement the report is in world units, exact under any positive scale. Flags and the watertight verdict are placement independent and match measure.
offset
Moves every live vertex along its smooth normal by distance.
orient
Makes triangle winding consistent, reversing triangles by swapping their last two vertices.
remove_degenerate
Removes triangles with a repeated vertex id, triangles whose area is at most area_epsilon times their longest edge squared, and duplicates: of triangles with the same vertex set, all but the one with the smallest id.
remove_small_components
Removes the connected components (triangles joined through shared edges of any kind) that are below any bound that is set, and the vertices left unused. Triangles with a repeated vertex id belong to no component and stay.
shell
Solidifies the mesh into a printable shell of wall thickness.
weld
Merges vertices at most tolerance apart (local units).

Type Aliases§

Result
Result with OpsError as the error type.