Skip to main content

brep_topology/
lib.rs

1//! Topology layer of the BREP kernel: B-rep solids, validation, soundness, classification, mass properties and tessellation.
2//!
3//! It is one of the implementation crates the kernel is built from. Applications
4//! should depend on [`BREP_kernel`](https://crates.io/crates/BREP_kernel), which
5//! re-exports the public API of every kernel crate at its root (`brep_kernel::…`)
6//! and adds the feature pipeline and the STEP, IGES, Parasolid (import), 3MF,
7//! GLB, STL and OBJ exchange.
8//! Many items here are public only so the other kernel crates can reach them;
9//! those are hidden from the documentation and carry no stability promise beyond
10//! the kernel's own. The kernel crates are released together, at one version.
11//!
12//! It contains:
13//!
14//! - the B-rep records (`BrepSolid` and its vertices, edges, coedges, loops, faces and shells) and their arena and serialized form;
15//! - structural and geometric validation and the soundness checks;
16//! - primitive solids (box, cylinder, cone, sphere, torus) and affine transforms, recentring and rescaling;
17//! - mass properties integrated from the B-rep;
18//! - tessellation, including the watertight display mesh, and mesh welding;
19//! - point-in-solid and pair classification;
20//! - entity tolerances, canonical carriers, edge sub-curves, orientation and face names.
21//!
22//! Kernel crates it requires: [`BREP_RANSAC`](https://crates.io/crates/BREP_RANSAC), [`BREP_geometry`](https://crates.io/crates/BREP_geometry). It is required by [`BREP_surface_offset`](https://crates.io/crates/BREP_surface_offset), [`BREP_boolean`](https://crates.io/crates/BREP_boolean), [`BREP_solvers`](https://crates.io/crates/BREP_solvers), [`BREP_construction`](https://crates.io/crates/BREP_construction), [`BREP_blend`](https://crates.io/crates/BREP_blend), [`BREP_offset`](https://crates.io/crates/BREP_offset), [`BREP_direct_edit`](https://crates.io/crates/BREP_direct_edit), [`BREP_kernel`](https://crates.io/crates/BREP_kernel).
23//!
24//! ## Building
25//!
26//! The crate builds natively and for `wasm32-unknown-unknown`. The `parallel`
27//! feature runs some per-face loops on rayon; `profile-wall` turns on a diagnostic
28//! wall-time partition. Both are off by default, and `BREP_kernel` forwards them.
29//!
30//! The packaged crate ships the library sources, the README, the licence and the
31//! manifest; it carries no test suite.
32//!
33//! ## License
34//!
35//! The Autodrop3d licence in `LICENSE.md`, shipped in the crate (`license-file` in
36//! the manifest). Source: <https://github.com/mmiscool/next.BREP.io_RUST_BREP_KERNEL>
37// Implementation crate of the kernel: its formerly crate-private items are public for the crates above
38// (documented hidden), and their docs may name private helpers.
39#![allow(rustdoc::private_intra_doc_links)]
40use serde::{Deserialize, Serialize};
41#[allow(unused_imports)]
42use wasm_bindgen::prelude::*;
43#[macro_use]
44extern crate brep_geometry;
45#[allow(unused_imports)]
46#[doc(no_inline)]
47pub use brep_geometry::*;
48
49// Per-entity measured tolerances: the lazy, capped band an individual edge or
50// vertex earns from its own redundant representations, on top of the global
51// policy above. Measurement only — no record field, no serialization; see the
52// module doc for invariants I1/I2.
53#[path = "geometry/entity_tolerance.rs"]
54#[doc(hidden)]
55pub mod entity_tolerance;
56pub use entity_tolerance::{EntityTolerances, EDGE_CAP_FRACTION, VERTEX_CAP_FRACTION};
57#[path = "geometry/control_cage.rs"]
58#[doc(hidden)]
59pub mod control_cage;
60pub use control_cage::{
61    CagePoint, CagePrimitive, ControlCage, CAGE_DEGREE, MAX_RINGS, MAX_SEGMENTS, MIN_RINGS,
62    MIN_SEGMENTS,
63};
64#[path = "brep/solid_codec.rs"]
65#[doc(hidden)]
66pub mod solid_codec;
67pub use solid_codec::{decode_solid, encode_solid, SolidNames, SOLID_CODEC_VERSION, SOLID_CODEC_VERSION_KIND};
68#[path = "brep/topology.rs"]
69#[doc(hidden)]
70pub mod topology;
71pub use topology::{
72    make_box_brep, make_cylinder_brep, make_pyramid_brep, topology_kind, BodyKind, BrepSolid, CellRecord, CoedgeRecord,
73    FaceRecord, IssueKind, KindReport, LoopRecord, TopologyKind, ValidationReport,
74};
75#[path = "brep/soundness.rs"]
76#[doc(hidden)]
77pub mod soundness;
78pub use soundness::{
79    face_self_intersections, loop_self_crossings, shell_vector_areas, solid_connectivity,
80    solid_euler, solid_self_intersections, ConnectivityReport, CrossingConfirmation, EulerReport,
81    CertificateScope, CertifiedFacePair, FaceCrossing, FaceFold, FaceVectorArea,
82    LoopCrossing, LoopCrossingReport, SelfIntersectionOptions, SelfIntersectionReport,
83    ClosureReading, ShellConnectivity, ShellVectorArea, VectorAreaReport, CrossingUndecidedCause, UndecidedCrossing,
84    MAX_LISTED_UNDECIDED,
85};
86#[path = "brep/topology_arena.rs"]
87#[doc(hidden)]
88pub mod topology_arena;
89pub use topology_arena::{
90    ArenaCoedge, ArenaEdge, ArenaFace, ArenaLoop, ArenaShell, ArenaVertex, CoedgeId, EdgeId,
91    FaceId, LoopId, ShellId, TopologyArena, VertexId,
92};
93#[path = "brep/analytic_topology.rs"]
94#[doc(hidden)]
95pub mod analytic_topology;
96pub use analytic_topology::{
97    make_cone_brep, make_sphere_brep, make_sphere_brep_framed, make_torus_brep,
98};
99#[path = "geometry/curve_chain.rs"]
100#[doc(hidden)]
101pub mod curve_chain;
102pub use curve_chain::{join_curve_chain, split_surface};
103#[path = "brep/transform_topology.rs"]
104#[doc(hidden)]
105pub mod transform_topology;
106#[path = "brep/recentre.rs"]
107#[doc(hidden)]
108pub mod recentre;
109#[path = "brep/boundary_query.rs"]
110pub mod boundary_query;
111pub use boundary_query::{
112    nearest_boundary_point, solid_closest_points, solid_gap, solid_least_box, solid_outward_normals, solid_principal_curvatures, BoundaryFoot,
113    BoundaryPlace,
114};
115#[path = "brep/rescale.rs"]
116#[doc(hidden)]
117pub mod rescale;
118pub use transform_topology::{mirror_brep, transform_brep, AffineTransform};
119#[path = "props/mass_properties.rs"]
120#[doc(hidden)]
121pub mod mass_properties;
122pub use mass_properties::{
123    curve_arc_length, edge_arc_length, face_area, face_boundary_length, face_volume_contribution,
124    face_set_identity, mass_caller, parameter_space_area, solid_edge_length_total,
125    solid_mass_properties,
126    solid_mass_properties_full, signed_volume_against, solid_signed_volume, solid_signed_volume_for_sign, trim_polygons,
127    DensityMassProperties,
128    FaceSetIdentity, FullMassProperties, MassCaller, MassProperties, MassPropertiesCache,
129};
130#[path = "props/carrier_dimensions.rs"]
131#[doc(hidden)]
132pub mod carrier_dimensions;
133pub use carrier_dimensions::{curve_carrier_dimensions, surface_carrier_dimensions, CarrierDimensions};
134#[path = "meshing/tessellation.rs"]
135#[doc(hidden)]
136pub mod tessellation;
137pub use tessellation::{tessellate_brep, tessellate_face, TessellationOptions};
138#[path = "meshing/watertight_tessellation/mod.rs"]
139#[doc(hidden)]
140pub mod watertight_tessellation;
141pub use watertight_tessellation::{
142    sample_edge_polyline_checked, EdgeChordError, EdgeChordFailure, TessellationError,
143    tessellate_brep_watertight_checked,
144    sample_edge_polylines, sample_edges_encoded, tessellate_brep_watertight,
145    tessellate_brep_watertight_face_stride, tessellate_brep_watertight_face_stride_with_samples,
146};
147#[path = "brep/classification.rs"]
148#[doc(hidden)]
149pub mod classification;
150pub use classification::{
151    classify_point, containment_lane, horizon_cross_frame, parameter_point_in_face,
152    trim_sample_count, trim_station, ContainmentLane, PointClass, PointClassification,
153    PolygonClass, SolidClassifier, COVERING_RIM_STRIP_SWITCH, HORIZON_CONTAINMENT_SWITCH,
154    HORIZON_CROSS_FRAME_SWITCH, HORIZON_SINGLE_LOOP_SWITCH, NO_SPHERE_CHART_TRIM_SWITCH,
155    SEAM_BAND_MERGED_SWITCH,
156};
157#[doc(hidden)]
158pub use classification::parameter_point_in_face_scan;
159#[path = "brep/pair_classification.rs"]
160#[doc(hidden)]
161pub mod pair_classification;
162pub use pair_classification::{
163    classify_surface_pair, classify_surface_pair_cached, SurfaceClassifyData,
164    SurfacePairClassification, SurfacePairRelation,
165};
166// The content-keyed memo of the per-coedge readings the heal pre-pass and
167// the assembly's inherited-trim challenger take on every boolean.
168#[path = "healing/reading_memo.rs"]
169#[doc(hidden)]
170pub mod reading_memo;
171// The MEASURED half of the tolerance model: the deviation actually observed
172// between an offset construction and the geometry it was built to reproduce.
173// Everything in `geometry/tolerance.rs` above `MeasuredTolerance` DERIVES a
174// band from a size before the geometry exists; this measures what the
175// construction then did, and compares it against that band. The comparison is
176// not itself a gate: the deviation rides the transient construction result
177// (`OffsetFaceCarrier::deviation`, `#[serde(skip)]`) and refusing on an
178// exceedance is the caller's call, not this module's. Declared before `offset`
179// because that module is its first consumer.
180#[path = "offset/measure.rs"]
181#[doc(hidden)]
182pub mod offset_measure;
183pub use offset_measure::{
184    measure_edge_against_pcurve_image, measure_surface_fit_against_pointwise_offset,
185    span_midpoint_error, vertex_endpoint_gap,
186};
187#[path = "meshing/mesh_weld.rs"]
188#[doc(hidden)]
189pub mod mesh_weld;
190pub use mesh_weld::{canonical_bits, VertexWeld};
191
192/// Hash of this crate's source (`build.rs`), one part of the kernel's source stamp.
193#[doc(hidden)]
194pub const SOURCE_HASH: Option<&str> = option_env!("BREP_KERNEL_SOURCE_HASH");
195#[doc(hidden)]
196#[path = "brep/canonical_carriers.rs"]
197pub mod canonical_carriers;
198pub use canonical_carriers::{canonical_carriers_enabled, canonicalise_carriers};
199#[doc(hidden)]
200#[path = "brep/edge_subcurve.rs"]
201pub mod edge_subcurve;
202#[doc(hidden)]
203#[path = "brep/solid_tolerance.rs"]
204pub mod solid_tolerance;
205pub use solid_tolerance::{display_chord_tolerance, solid_model_scale, solid_scale};
206#[doc(hidden)]
207#[path = "brep/construction_profile.rs"]
208pub mod construction_profile;
209#[doc(hidden)]
210#[path = "brep/orientation.rs"]
211pub mod orientation;
212#[doc(hidden)]
213#[path = "brep/face_names.rs"]
214pub mod face_names;