Expand description
Clean-room, topology-aware analytic surface recognition for CAD meshes.
This crate is a pure geometry leaf. It does not parse or write STEP, call subprocess oracles, download corpora, or depend on a BREP kernel.
It finds plane, cylinder, cone, sphere and torus carriers in an indexed
triangle Mesh. Main entry points:
recognize_surfaces/recognize_surfaces_with_unresolvedfor mesh-wide recognition;reconstruct_surface/reconstruct_surface_from_verticesto fit a selected support, guided by aSurfaceHint;- the
constrain_*design-intent helpers, which build constrained hints from neighbouring analytic geometry; export_debug_objfor Wavefront OBJ debug output.
Behaviour is configured through RecognitionOptions. See the README for
an overview.
Re-exports§
pub use recognize::recognize_surfaces;pub use recognize::recognize_surfaces_with_attempt_budget;pub use recognize::recognize_surfaces_with_candidates;pub use recognize::recognize_surfaces_with_unresolved;pub use recognize::ComponentCandidate;pub use recognize::RecognitionWork;pub use recognize::reconstruct_surface;pub use recognize::reconstruct_surface_from_vertices;
Structs§
- Analyzed
Mesh - A validated mesh with cached geometry, topology, and sampling weights.
- Component
Candidate - A carrier another stage already fitted to exactly the triangles of one
connected component, offered to
recognize_surfaces_with_candidates. - Cone
Refine Policy - Iteration and acceptance policy of
refine_cone. - Cone
Surface - One nappe of a right circular cone.
- Constraint
Mask - Parameter-level constraints. Vector fields constrain all three components; axis origins/centers still use the conventional along-axis gauge freedom.
- Cylinder
Surface - An infinite circular cylinder.
- Debug
ObjExport - In-memory Wavefront OBJ geometry and its companion material library.
- FitDiagnostics
- Provenance and execution details for a fitted surface.
- FitMetrics
- Residual and support measurements for a fitted surface.
- Geometric
Error - Residual-only snapshot used to compare a supplied/initialized carrier with the final refined carrier without duplicating support bookkeeping.
- Mesh
- An indexed triangle mesh and optional recognition metadata.
- Mesh
Analysis Options - Controls mesh validation and feature-edge classification.
- Phase
Timings - Optional wall-clock phase measurements. Timing is disabled by default so deterministic results remain bit-for-bit comparable.
- Plane
Surface - A plane represented by a point and unit normal.
- Recognition
Options - Controls surface recognition, refinement, and region discovery.
- Recognition
Result - All recognized regions and triangles left unresolved by discovery.
- Recognition
Work - Work spent by
recognize_surfaces_with_attempt_budget. - Source
Metadata - Versioned sidecar metadata. Stable source IDs are deliberately distinct from sequential tessellation face indices.
- Sphere
Surface - A sphere represented by its center and radius.
- Surface
Constraints - Initial surface parameters and the subset held fixed during fitting.
- Surface
FitResult - The fitted carrier and quality information for one requested selection.
- Surface
Parameter Delta - Gauge-aware change from an initial/supplied carrier to its final carrier.
Fields that do not apply to a primitive remain
None. - Surface
Region - A recognized surface and the mesh triangles assigned to it.
- Torus
Surface - A circular torus represented by its center, axis, and radii.
- Triangle
Data - Geometry and topology derived for one input triangle.
- Unresolved
Region Diagnostic - Why a metadata-associated triangle subset remained unresolved after both metadata-guided reconstruction and generic analytic fallback failed.
- Vec3
- A three-dimensional vector with double-precision components.
Enums§
- Analytic
Surface - Parameters for one supported analytic surface.
- Design
Intent Error - Failure to express a requested design-intent relation with the current parameter-group constraint model.
- FitPath
- The recognition or refinement route that produced a fit.
- Jacobi
Zero Turn - How
jacobi_eigen_symmetric3turns a pivot pair with equal diagonals (tau= ±0, where(1 + tau²)givest = ±1). - Metadata
Trust - Describes how strongly imported metadata should influence fitting.
- Recognition
Error - An error produced while validating geometry or recognizing a surface.
- Sampling
Mode - Selects which geometric samples are used during fitting.
- Surface
Hint - Optional source knowledge used to guide surface recognition.
- Surface
Type - The supported analytic primitive families.
Functions§
- constrain_
concentric_ centers - Fix sphere or torus centers to an existing sphere/torus center.
- constrain_
cylinder_ coaxial - Constrain a cylinder to the complete axis line of another axial carrier. This is safe because a cylinder’s axis origin has gauge freedom along the line; cone apex and torus center locations do not, so those target types are intentionally unsupported here.
- constrain_
equal_ radii - Fix equal radius groups for two carriers of the same type. For tori this copies and fixes both major and minor radii; mixed-type radius semantics are deliberately rejected.
- constrain_
plane_ perpendicular_ to_ axis - Constrain a plane to be perpendicular to a known axis. The plane normal is the axis direction; its offset remains free.
- constrain_
planes_ coplanar - Fix a plane to the same infinite carrier as a reference plane. Tangential origin coordinates are a gauge and are preserved from the target.
- constrain_
planes_ parallel - Preserve parallelism to a reference plane while leaving plane offset free.
- constrain_
planes_ perpendicular - Preserve perpendicularity to a reference plane using the target’s current normal to select the otherwise non-unique perpendicular direction.
- constrain_
shared_ axis - Fix a target cylinder, cone, or torus axis direction to an existing axial carrier. Cone-to-nondirected-carrier transfer is rejected because a cone’s nappe direction is not sign-equivalent.
- constrain_
tangent - Derive exact sphere/plane tangency from the target’s current side and orientation. Other tangency pairs require coupled parameters and are rejected explicitly.
- export_
debug_ obj - Export an input mesh and recognition result as Wavefront OBJ/MTL text.
- jacobi_
eigen_ symmetric3 - Dependency-free Jacobi eigensolver for real symmetric 3x3 matrices.
- recognize_
surfaces - Discover and reconstruct analytic regions in an entire mesh.
- recognize_
surfaces_ with_ attempt_ budget recognize_surfaces_with_unresolvedwith a cap on the generic hypotheses drawn over the whole call, and optionally fewer primitive kinds to draw them for.- recognize_
surfaces_ with_ candidates recognize_surfaces_with_unresolved, except that a connected component whose own whole fit is refused is first validated on a supplied candidate carrier for exactly its triangles before generic extraction divides it.- recognize_
surfaces_ with_ unresolved - Discover analytic regions and retain triangles that no model accepted.
- reconstruct_
surface - Reconstruct one selected triangle region using an explicit metadata hint.
- reconstruct_
surface_ from_ vertices - Reconstruct one surface from an explicit subset of mesh vertices.
- refine_
cone - Gauss-Newton refinement of a cone over a point slice: apex, unit axis
into the nappe, and half angle, with the six parameters apex (3), two
axis tilts along an orthonormal frame of the axis, and the angle. The
residual of a point is
rho cos(a) - h sin(a)(h along the axis, rho from it). Each step solves the normal equations withsolve_linear.Nonewhen the axis cannot be normalised, a step is singular, or the result is not finite.