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 (
BrepSolidand 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§
- Affine
Transform - Arena
Coedge - Arena
Edge - Arena
Face - Arena
Loop - Arena
Shell - Arena
Vertex - Brep
Solid - Carrier
Dimensions - A carrier’s classification and its named dimensions in display order
(millimetres, or degrees for an angle key ending in
Deg). - Cell
Record - 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.
voiddistinguishes a void region from material. - Certificate
Scope - 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.
- Certified
Face Pair - Separating support of one omitted distinct-face pair. Bounds are signed coordinates on the named world axis; no adjacency inference is involved.
- Coedge
Id - Coedge
Record - Connectivity
Report - Outcome of
solid_connectivity. - Control
Cage - The cage: see the module docs for the layout.
- Density
Mass Properties - Mass properties scaled to a physical density (Golovanov §8.11). The
underlying
FullMassPropertiesis a UNIT-density geometric result; heremass = density * volumeand 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. - Edge
Chord Error - Failure to certify an edge’s requested chord tolerance.
- EdgeId
- Entity
Tolerances - Lazily-measured, capped per-entity tolerances for one solid.
- Euler
Report - Outcome of
solid_euler. - Face
Crossing - One confirmed face-versus-face crossing.
- Face
Fold - 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
- Face
Record - Face
SetIdentity - The 128-bit content identity of a solid’s face set.
- Face
Vector Area - One face’s vector area
∫ n dA, as its TRIMS claim it and as its EDGES claim it, and the difference between the two. - Full
Mass Properties - Kind
Report - Outcome of
topology_kind: the kind and the census it was read from. - Loop
Crossing - One place a face’s trim loop crosses ITSELF in the face’s parameter domain.
- Loop
Crossing Report - Outcome of
loop_self_crossings. - LoopId
- Loop
Record - Mass
Caller - Names the call site for every integrator call made while it is alive, so
the
mass.identityline can say WHO paid for the integral rather than leaving a log reader to infer it from the neighbouring profile lines. - Mass
Properties - Mass
Properties Cache - 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.
- Point
Classification - Self
Intersection Options - Knobs for
solid_self_intersections.SelfIntersectionOptions::for_solidderives every one from the solid’s own size. - Self
Intersection Report - Outcome of
solid_self_intersections. - Shell
Connectivity - One shell’s connectivity: how many edge-connected pieces its faces form.
- ShellId
- Shell
Vector Area - One shell’s vector-area closure:
shell_vector_areas’ per-shell verdict. - Solid
Classifier - 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.
- Solid
Names - Surface
Classify Data - Per-surface data the pair classifier needs, precomputable once per face and reused across every pair that face participates in.
- Surface
Pair Classification - Tessellation
Options - Topology
Arena - Type-safe mutable topology used inside the kernel. The JSON/WASM record model remains the stable wire format; conversion happens at that boundary.
- Undecided
Crossing - One candidate the scan could not decide, after resolution.
- Validation
Report - Vector
Area Report - Outcome of
shell_vector_areas. - Vertex
Id - Vertex
Weld - A tolerance weld over points given one at a time (
weld_vertexwith its own vertex list and cells), for callers outside the kernel.
Enums§
- Body
Kind - The kind a body DECLARES, as distinct from the kind
topology_kindREADS 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 isSolid, 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). - Cage
Point - Where a linear point index lands in the cage.
- Cage
Primitive - The primitive the initial cage is wrapped around.
- Closure
Reading - What a shell’s closure scan came back with — a measurement, or nothing.
- Containment
Lane - The lane
containment_lanefinds a face in. - Crossing
Confirmation - Which confirmation convicted a
FaceCrossing. - Crossing
Undecided Cause - Why the mesh confirmation left a candidate undecided.
- Edge
Chord Failure - Issue
Kind - The closed kind of a
ValidationIssue. Only the kinds a dispatcher needs are minted (the boolean’s endpoint-gap repair lane keys onCurveVertexGap); everything else isOtherand carries its message as the payload. A dispatcher matches the kind, never the message text. - Point
Class - Polygon
Class - Surface
Pair Relation - Tessellation
Error - A checked tessellation either meets its edge chord budget or names the failing edge. Errors from face triangulation retain their original detail.
- Topology
Kind
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; seehorizon_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 + 1rows, 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
Solidbody 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
valuewith negative zero read as positive zero, for exact (bitwise) point keys:-0.0and0.0are the same coordinate. - canonical_
carriers_ enabled - Whether the import lanes canonicalise carriers: on unless
BREP_CANONICAL_CARRIERS=0restores the verbatim import. - canonicalise_
carriers - Rewrites every non-canonical, exactly analytic face of
solidin 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
Candidaterather than being incorrectly culled. - classify_
surface_ pair_ cached classify_surface_pairwith the per-surface work hoisted out — callers with many pairs per face build each face’sSurfaceClassifyDataonce.- containment_
lane - Which lane of
parameter_point_in_facea 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. Returns0.0for 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), elseNone. - 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 measure0. - 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 onsurface, recorded againstband.- 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 againstband.- mirror_
brep - Reflect an exact BREP across the plane through
plane_pointwith unit normaln = plane_normal.normalized(). The reflection is the affine mapp' = R p + twith linear partR = I - 2 n nᵀand translationt = 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 withreverse_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_signfor a caller that compares the result withbarand 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=1restores 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 − Hover 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_scaleof a solid’s vertices — the RAW bounding-box diagonal, with no>= 1.0floor. This is what direct-edit wants: a sub-unit part must keep sub-unit bands. (BrepSolid::validatewants the same thing and still hand-rolls it, for the reason its own comment gives — it answers0.0, not1.0, for a vertexless solid. Reconciling that contract is a follow-up, not a free ride-along.) Usesolid_scalefor the floored variant the tolerance policy is built on.- solid_
scale solid_model_scalefloored at 1.0 — the characteristic lengthKernelTolerances::for_solidand 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 unflooredmodel_scalefamily 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_volumeread for its SIGN againstbar, 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 surfacecut along the parameter lineat(avline whenalong_v, else auline) 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
Nonefor 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
isatisfiesi % 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) bysample_edges_encoded. The worker-pool split uses this sosample_all_edgesruns 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_orientationis 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),kthe pcurve’s distinct interior knots (two knots are one when they differ by no more thanKNOT_DEDUP_EPS, and a knot that close to an end of the active domain is not interior) andpits 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
indexofcountover[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.