cadrum/lib.rs
1//! # cadrum
2//!
3//! Rust CAD library powered by OpenCASCADE (OCCT 8.0.0-rc5).
4//!
5//! ## Core Types
6//! - [`Solid`] — a single solid shape (wraps `TopoDS_Shape` / `TopAbs_SOLID`)
7//! - [`Solid`] has all methods directly (no trait import needed)
8
9pub mod common;
10#[cfg(not(feature = "pure"))]
11pub mod occt;
12#[cfg(feature = "pure")]
13pub mod pure;
14pub(crate) mod traits;
15// `Transform` is intentionally NOT re-exported. It remains reachable only as
16// `crate::traits::Transform` for internal use; external callers reach the same
17// surface through `Compound` / `Wire` forwarder default methods. See the
18// `Transform` doc comment in `traits.rs` for the rationale and the future
19// auto-delegation plan.
20pub use traits::{BSplineEnd, Compound, ProfileOrient, Wire};
21
22// Re-export backend types at crate root
23#[cfg(not(feature = "pure"))]
24pub use occt::edge::Edge;
25#[cfg(not(feature = "pure"))]
26pub use occt::face::Face;
27#[cfg(not(feature = "pure"))]
28use occt::io::Io; // private: used by generated delegation, not exposed to users
29#[cfg(not(feature = "pure"))]
30pub use occt::solid::Solid;
31
32// Re-export common types
33#[cfg(feature = "color")]
34pub use common::color::Color;
35pub use common::error::Error;
36pub use common::mesh::{EdgeData, Mesh};
37// Re-export glam types used in cadrum's public API. Users should reach glam
38// through these re-exports (or the `cadrum::glam` module below) instead of
39// adding a direct `glam` dependency — otherwise a mismatched glam minor
40// version pulls in two incompatible `glam` crates and call sites fail with
41// "expected `cadrum::DVec3`, found `glam::DVec3`".
42pub use glam::{DMat3, DMat4, DQuat, DVec2, DVec3};
43pub use glam;
44
45// ==================== Boolean metadata helpers ====================
46//
47// Free functions over the active backend's concrete `Face`. They live here
48// (not in `traits.rs`) so the trait layer stays free of backend type names.
49
50/// Check if a face came from the tool (b-side) of a boolean operation.
51pub fn is_tool_face(metadata: &[Vec<u64>; 2], face: &Face) -> bool {
52 metadata[1].contains(&face.tshape_id())
53}
54
55/// Check if a face came from the shape (a-side) of a boolean operation.
56pub fn is_shape_face(metadata: &[Vec<u64>; 2], face: &Face) -> bool {
57 metadata[0].contains(&face.tshape_id())
58}
59
60// Auto-generated inherent method delegations (trait methods → pub fn on concrete types)
61include!(concat!(env!("OUT_DIR"), "/generated_delegation.rs"));