Skip to main content

Crate brep_topology

Crate brep_topology 

Source
Expand description

Topology layer of the BREP kernel: B-rep solids, validation, soundness, classification, mass properties and tessellation.

It is one of the implementation crates the kernel is built from. Applications should depend on BREP_kernel, which re-exports the public API of every kernel crate at its root (brep_kernel::…) and adds the feature pipeline and the STEP, IGES, Parasolid (import), 3MF, GLB, STL and OBJ exchange. Many items here are public only so the other kernel crates can reach them; those are hidden from the documentation and carry no stability promise beyond the kernel’s own. The kernel crates are released together, at one version.

It contains:

  • the B-rep records (BrepSolid and its vertices, edges, coedges, loops, faces and shells) and their arena and serialized form;
  • structural and geometric validation and the soundness checks;
  • primitive solids (box, cylinder, cone, sphere, torus) and affine transforms, recentring and rescaling;
  • mass properties integrated from the B-rep;
  • tessellation, including the watertight display mesh, and mesh welding;
  • point-in-solid and pair classification;
  • entity tolerances, canonical carriers, edge sub-curves, orientation and face names.

Kernel crates it requires: BREP_RANSAC, BREP_geometry. It is required by BREP_surface_offset, BREP_boolean, BREP_solvers, BREP_construction, BREP_blend, BREP_offset, BREP_direct_edit, BREP_kernel.

§Building

The crate builds natively and for wasm32-unknown-unknown. The parallel feature runs some per-face loops on rayon; profile-wall turns on a diagnostic wall-time partition. Both are off by default, and BREP_kernel forwards them.

The packaged crate ships the library sources, the README, the licence and the manifest; it carries no test suite.

§License

The Autodrop3d licence in LICENSE.md, shipped in the crate (license-file in the manifest). Source: https://github.com/mmiscool/next.BREP.io_RUST_BREP_KERNEL

Re-exports§

pub use boundary_query::nearest_boundary_point;
pub use boundary_query::solid_closest_points;
pub use boundary_query::solid_gap;
pub use boundary_query::solid_least_box;
pub use boundary_query::solid_outward_normals;
pub use boundary_query::solid_principal_curvatures;
pub use boundary_query::BoundaryFoot;
pub use boundary_query::BoundaryPlace;
pub use brep_geometry::*;

Modules§

boundary_query
Point queries against a solid’s boundary, on its exact geometry: the boundary points nearest a point, the outward normal there, and the principal curvatures there; and the least box with sides square to the axes round the solid.

Structs§

AffineTransform
ArenaCoedge
ArenaEdge
ArenaFace
ArenaLoop
ArenaShell
ArenaVertex
BrepSolid
CarrierDimensions
A carrier’s classification and its named dimensions in display order (millimetres, or degrees for an angle key ending in Deg).
CellRecord
A declared closed region of a Cellular body. Face senses are relative to the body’s face records; a shared wall has opposite senses in its two cells. void distinguishes a void region from material.
CertificateScope
Explicit scope of an opt-in analytic pair scan. Original counters describe only examined pairs. Same-face fold work is retained in this first row.
CertifiedFacePair
Separating support of one omitted distinct-face pair. Bounds are signed coordinates on the named world axis; no adjacency inference is involved.
CoedgeId
CoedgeRecord
ConnectivityReport
Outcome of solid_connectivity.
ControlCage
The cage: see the module docs for the layout.
DensityMassProperties
Mass properties scaled to a physical density (Golovanov §8.11). The underlying FullMassProperties is a UNIT-density geometric result; here mass = density * volume and every inertia quantity scales linearly with density (inertia = density * geometric_inertia). The centroid and the principal AXES are density-independent; only the principal MOMENTS and the mass scale with density.
EdgeChordError
Failure to certify an edge’s requested chord tolerance.
EdgeId
EntityTolerances
Lazily-measured, capped per-entity tolerances for one solid.
EulerReport
Outcome of solid_euler.
FaceCrossing
One confirmed face-versus-face crossing.
FaceFold
One confirmed place a face FOLDS THROUGH ITSELF in 3D: its own surface carries two DISTINCT trimmed parameter feet to ONE point in space.
FaceId
FaceRecord
FaceSetIdentity
The 128-bit content identity of a solid’s face set.
FaceVectorArea
One face’s vector area ∫ n dA, as its TRIMS claim it and as its EDGES claim it, and the difference between the two.
FullMassProperties
KindReport
Outcome of topology_kind: the kind and the census it was read from.
LoopCrossing
One place a face’s trim loop crosses ITSELF in the face’s parameter domain.
LoopCrossingReport
Outcome of loop_self_crossings.
LoopId
LoopRecord
MassCaller
Names the call site for every integrator call made while it is alive, so the mass.identity line can say WHO paid for the integral rather than leaving a log reader to infer it from the neighbouring profile lines.
MassProperties
MassPropertiesCache
A bounded, per-solid memo for exact area and volume. Geometry edits are detected by the face-set content identity; callers never invalidate it. The contents are private so external code cannot supply a fabricated result.
PointClassification
SelfIntersectionOptions
Knobs for solid_self_intersections. SelfIntersectionOptions::for_solid derives every one from the solid’s own size.
SelfIntersectionReport
Outcome of solid_self_intersections.
ShellConnectivity
One shell’s connectivity: how many edge-connected pieces its faces form.
ShellId
ShellVectorArea
One shell’s vector-area closure: shell_vector_areas’ per-shell verdict.
SolidClassifier
Point-in-solid classification with per-solid precomputation: face bounds, the solid box, and a face BVH are built once so repeated queries (boolean fragment selection asks once per fragment) prune to the few faces a probe point or ray can actually touch.
SolidNames
SurfaceClassifyData
Per-surface data the pair classifier needs, precomputable once per face and reused across every pair that face participates in.
SurfacePairClassification
TessellationOptions
TopologyArena
Type-safe mutable topology used inside the kernel. The JSON/WASM record model remains the stable wire format; conversion happens at that boundary.
UndecidedCrossing
One candidate the scan could not decide, after resolution.
ValidationReport
VectorAreaReport
Outcome of shell_vector_areas.
VertexId
VertexWeld
A tolerance weld over points given one at a time (weld_vertex with its own vertex list and cells), for callers outside the kernel.

Enums§

BodyKind
The kind a body DECLARES, as distinct from the kind topology_kind READS from its edge uses. Nothing infers it: a producer sets it, the wire carries it, and consumers that branch by kind (the boolean’s operand gate first) read the declaration. Every body built today is Solid, the default, and a Solid serialises byte for byte as before: the JSON skips the key, the flat codec keeps its version-1.0 header (solid_codec.rs).
CagePoint
Where a linear point index lands in the cage.
CagePrimitive
The primitive the initial cage is wrapped around.
ClosureReading
What a shell’s closure scan came back with — a measurement, or nothing.
ContainmentLane
The lane containment_lane finds a face in.
CrossingConfirmation
Which confirmation convicted a FaceCrossing.
CrossingUndecidedCause
Why the mesh confirmation left a candidate undecided.
EdgeChordFailure
IssueKind
The closed kind of a ValidationIssue. Only the kinds a dispatcher needs are minted (the boolean’s endpoint-gap repair lane keys on CurveVertexGap); everything else is Other and carries its message as the payload. A dispatcher matches the kind, never the message text.
PointClass
PolygonClass
SurfacePairRelation
TessellationError
A checked tessellation either meets its edge chord budget or names the failing edge. Errors from face triangulation retain their original detail.
TopologyKind

Constants§

CAGE_DEGREE
The B-spline degree in both directions: bicubic, the subdivision-surface smoothness (C² everywhere a knot is simple).
COVERING_RIM_STRIP_SWITCH
BREP_COVERING_RIM_STRIP: set to "0", the covering-rim-strip lane declines every face. Read when a face is prepared; part of the cache key.
EDGE_CAP_FRACTION
Fraction of an edge’s own length that bounds its measured band.
HORIZON_CONTAINMENT_SWITCH
BREP_HORIZON_CONTAINMENT: set to "0", the wrapped-horizon lane declines every face. Read when a face is prepared; part of the cache key.
HORIZON_CROSS_FRAME_SWITCH
BREP_HORIZON_CROSS_FRAME: set to "0", the wrapped-horizon lane combines its period images per image (Inside when any image counts odd) instead of summing each loop’s parity over the images. Read per QUERY, not when the face is prepared; see horizon_cross_frame.
HORIZON_SINGLE_LOOP_SWITCH
BREP_HORIZON_SINGLE_LOOP: set to "0", the wrapped-horizon lane declines a face of one or two loops (compared: face.loops.len() <= 2). Read when a face is prepared; part of the cache key.
MAX_LISTED_UNDECIDED
How many undecided candidates a report lists by name.
MAX_RINGS
MAX_SEGMENTS
Caps on the initial cage so a typo cannot ask for a million handles.
MIN_RINGS
The fewest rings: with the two poles that is degree + 1 rows, one span.
MIN_SEGMENTS
The fewest points a ring may have: a cubic periodic ring needs four.
NO_SPHERE_CHART_TRIM_SWITCH
BREP_NO_SPHERE_CHART_TRIM: SET to any value (compared: present in the environment), the sphere-chart lane stops substituting for the generic scan’s parity count. BREP_NO_SPHERE_CHARTS, which turns every sphere-chart path off, does the same here. Read per query.
SEAM_BAND_MERGED_SWITCH
BREP_SEAM_BAND_MERGED: set to "0" (the only value compared), the doubly-periodic seam-band lane stops unwrapping a single merged seam-carrying loop, and that face goes on to the two-loop analyses or the generic scan. Read when a face is prepared; part of the prepared-face cache key.
SOLID_CODEC_VERSION
The header a Solid body writes, and the oldest version the reader accepts. The snapshot container (io/snapshot.rs) names this format durable: a Solid keeps writing 1.0 so no stored payload moves.
SOLID_CODEC_VERSION_KIND
The header a body of any other kind writes: the kind slot follows genus.
VERTEX_CAP_FRACTION
Fraction of the SHORTEST incident edge that bounds a vertex’s band.

Functions§

canonical_bits
Bits of value with negative zero read as positive zero, for exact (bitwise) point keys: -0.0 and 0.0 are the same coordinate.
canonical_carriers_enabled
Whether the import lanes canonicalise carriers: on unless BREP_CANONICAL_CARRIERS=0 restores the verbatim import.
canonicalise_carriers
Rewrites every non-canonical, exactly analytic face of solid in place.
classify_point
classify_surface_pair
Classify a pair before generic SSI runs. The classifier is conservative: only separated control hulls are declared disjoint; uncertain pairs stay Candidate rather than being incorrectly culled.
classify_surface_pair_cached
classify_surface_pair with the per-surface work hoisted out — callers with many pairs per face build each face’s SurfaceClassifyData once.
containment_lane
Which lane of parameter_point_in_face a face’s questions go to, read off the face alone — the kernel’s own lane selection, through the same prepared data the query uses, for a caller that answers some containment questions ahead of the kernel and must know which rule the kernel applies.
curve_arc_length
Exact 3D arc length of a NURBS curve over the parameter range [t0, t1] — ∫|C’(t)| dt evaluated with a composite 8-point Gauss–Legendre rule paneled at the curve’s interior knots (each knot span further halved for headroom). The speed integrand |C'(t)| is polynomial-exact for the line/circle-arc curves the kernel emits and converges tightly for general NURBS. Returns 0.0 for a zero-width (or inverted) range.
curve_carrier_dimensions
The dimensions of a curve over [t0, t1] when it is a circle or an arc of one (radius, diameter, and an arc’s sweep), else None.
decode_solid
display_chord_tolerance
The app’s display chord tolerance (BetterSolid._kernelTessellationOptions): vertex |coord| extent — falling back to the control-point hull / sqrt(2) for vertex-free solids (full spheres/tori) — times 1.5e-3, times the render-LOD factor (1.0 = the app’s “Normal” preset).
edge_arc_length
Exact 3D arc length of one edge over its active parameter range [t0, t1] (the same range the display sampler walks). Degenerate edges measure 0.
encode_solid
face_area
face_boundary_length
Total 3D arc length of a face’s boundary edges: the unique edges referenced by the face’s loop coedges, resolved against the owning solid’s edge table and summed once each. An edge referenced twice by the same face (e.g. a seam) is still counted once.
face_self_intersections
Which of this solid’s faces FOLD THROUGH THEMSELVES in 3D — a face whose surface carries two distinct trimmed parameter feet to one point in space: an offset taken past the source’s curvature radius, a section swept through a bend tighter than its own half-width, a carrier fitted through a swallowtail.
face_set_identity
Hash exactly what the integrator reads, in the order it reads it.
face_volume_contribution
horizon_cross_frame
Whether the wrapped-horizon lane sums each loop’s parity over the query’s period images (true, the default) or keeps the per-image combining (false, HORIZON_CROSS_FRAME_SWITCH = "0"). Read from the environment on every call, as the lane reads it on every query.
join_curve_chain
The chain pieces, curves that follow one another head to tail, as one curve: exactly the same points, each piece on a stretch of the parameter as long as the piece itself, so the joined curve runs at an even pace from piece to piece. Its joints are knots of full multiplicity (the curve is as smooth there as the chain is).
loop_self_crossings
Does any face’s trim loop cross ITSELF in its own parameter domain — a bowtie?
make_box_brep
make_cone_brep
make_cylinder_brep
make_pyramid_brep
make_sphere_brep
make_sphere_brep_framed
A sphere solid whose SEAM direction is chosen as well as its polar axis — see make_sphere_surface_framed. The topology is identical either way (one face, one pole-to-pole seam edge, two degenerate pole edges); only WHERE on the ball the seam and the poles sit changes. A caller that will trim the ball uses it to hide both inside the removed region, so the surviving face has no edge bordering itself.
make_torus_brep
mass_caller
measure_edge_against_pcurve_image
max_t ‖C_3d(t) − S(p(t))‖ — how far the edge’s own 3D curve sits from the locus its pcurve traces on surface, recorded against band.
measure_surface_fit_against_pointwise_offset
max_{u,v} ‖S_fit(u,v) − offset(u,v)‖ — how far a fitted offset carrier sits from the pointwise offset it was fitted to, recorded against band.
mirror_brep
Reflect an exact BREP across the plane through plane_point with unit normal n = plane_normal.normalized(). The reflection is the affine map p' = R p + t with linear part R = I - 2 n nᵀ and translation t = 2 (plane_point·n) n, so points on the plane map to themselves. A reflection has negative determinant (it flips handedness), so faces are re-oriented via the existing transform with reverse_orientation = true, keeping outward normals.
parameter_point_in_face
parameter_space_area
sample_edge_polyline_checked
Certify the full rational curve, rather than a finite set of sag probes. Positive homogeneous weights place each Bezier arc inside its control hull; distance to a segment is convex, so the largest control-point distance bounds the entire arc. Subdivision tightens that bound without omitting knot spans. Endpoints are the shared topology vertices, including their displacement from the curve. Unsupported representations fail closed.
sample_edge_polylines
Display edge polylines for native in-process consumers (brep-render): every NON-degenerate edge’s chord-tolerance samples as (edge_id, points), sorted by edge id so the output is deterministic (the sample map is a HashMap). The samples are the same shared samples the watertight tessellation uses, so the displayed edges lie exactly on the mesh’s face boundaries.
sample_edges_encoded
Compute every edge’s shared samples and serialize them into a flat f64 buffer for transfer to face-range workers. Layout: [edge_count, (edge_id, sample_count, frac_0..n, x_0,y_0,z_0, ...), ...] (fractions.len() == positions.len(), so one count per edge). Edge ids ride as f64 exactly as the solid codec already carries them.
shell_vector_areas
Does a closed shell’s boundary enclose the vector area it should — zero?
signed_volume_against
solid_signed_volume_for_sign for a caller that compares the result with bar and nothing else (the boolean assembly’s closed tail, the shell’s orientation, the direct edit’s inversion check — 2026-10-17): the memoised sign reading, whose verdict against the bar is the exact integral’s. BREP_SIGN_READERS_EXACT=1 restores the exact read at those call sites, for an on/off census. Read once.
solid_connectivity
Connectivity of a solid’s topology: are each shell’s faces reachable from one another across shared edges, do any two shells share an edge, and does any vertex pinch two otherwise-separate fans together.
solid_edge_length_total
Total 3D arc length of every non-degenerate edge of a solid (each shared edge counted ONCE — the solid’s edge table is already edge-unique). This is the solid’s “total edge length” measurement.
solid_euler
Closedness and Euler parity: V − E + F − H over the reduced complex, and whether the counts can belong to a closed orientable surface at all.
solid_mass_properties
solid_mass_properties_full
Area, volume, centroid, and centroidal inertia (unit density). Area and volume use the same exact paths as solid_mass_properties; the moment integrals use divergence-theorem surface quadrature (exact for untrimmed spans, trim-polygon scanline accuracy for trimmed faces).
solid_model_scale
model_scale of a solid’s vertices — the RAW bounding-box diagonal, with no >= 1.0 floor. This is what direct-edit wants: a sub-unit part must keep sub-unit bands. (BrepSolid::validate wants the same thing and still hand-rolls it, for the reason its own comment gives — it answers 0.0, not 1.0, for a vertexless solid. Reconciling that contract is a follow-up, not a free ride-along.) Use solid_scale for the floored variant the tolerance policy is built on.
solid_scale
solid_model_scale floored at 1.0 — the characteristic length KernelTolerances::for_solid and the boolean/imprint/heal sites are tuned against. The floor keeps a unit-and-below part on the historical bands those call sites were fitted to; new size-relative sites should prefer the unfloored model_scale family and floor explicitly where they mean to.
solid_self_intersections
Does this solid pass through itself? Tessellates every face once, walks a triangle BVH for mesh crossings, and confirms each candidate against the two carrier SURFACES so tangent neighbours and chord error cannot manufacture a finding. See the module docs for the design and its one documented blind spot.
solid_signed_volume
Exact signed volume. A single nonempty shell shares its area/volume measurement with subsequent property queries. Multiple shells retain the original per-shell compensated sum: substituting the across-face sum can change the last bits and an orientation gate must not change its answer.
solid_signed_volume_for_sign
solid_signed_volume read for its SIGN against bar, as the boolean’s assembly reads it (volume <= tolerance³ refuses an inverted shell).
span_midpoint_error
The same comparison as measure_edge_against_pcurve_image, sampled once at the midpoint of every knot span of the edge’s own 3D curve.
split_surface
surface cut along the parameter line at (a v line when along_v, else a u line) into the part before it and the part after it. Exact: knot insertion on each row of poles across the cut.
surface_carrier_dimensions
The dimensions of a surface’s recognised carrier, or None for a plane, a free-form patch, or a revolution whose generatrix is neither straight nor circular.
tessellate_brep
tessellate_brep_watertight
Watertight tessellation of a closed solid: coincident triangulation along every shared edge, density driven by chord_tolerance.
tessellate_brep_watertight_checked
Tessellate with certified shared edge samples and typed edge failures. This opt-in entry point does not depend on environment switches.
tessellate_brep_watertight_face_stride
Tessellate only the faces whose global sequential index i satisfies i % stride == offset, leaving every other face out of the returned mesh.
tessellate_brep_watertight_face_stride_with_samples
As tessellate_brep_watertight_face_stride, but the caller supplies edge samples already computed (and serialized) by sample_edges_encoded. The worker-pool split uses this so sample_all_edges runs ONCE (in the prepare step) instead of redundantly in every face-range worker. The samples are deterministic, so meshing against a shared copy is identical to recomputing them locally.
tessellate_face
topology_kind
Classify a body record by its edge uses (module docs for the predicates).
transform_brep
Transform exact BREP geometry without changing entity IDs or parameter ranges. reverse_orientation is required for negative-determinant maps.
trim_polygons
The chord polygons of face’s trim loops, as sampled for integration.
trim_sample_count
How many chords the containment lanes sample ONE pcurve at: max(2, (k + 1)(p + 1)·4), k the pcurve’s distinct interior knots (two knots are one when they differ by no more than KNOT_DEDUP_EPS, and a knot that close to an end of the active domain is not interior) and p its degree. Knot- and degree-aware, so a spline trim is resolved wherever its shape can bend and a line is two chords.
trim_station
The pcurve parameter of trim station index of count over [start, end]: start + (end − start)·index / count, evaluated in exactly that order.
vertex_endpoint_gap
|p_V − c_E(t_end)| — how far a curve end sits from the vertex point the topology says it meets.