BREP_kernel 0.3.0

A boundary representation (BREP) geometry kernel for building CAD applications.
Documentation
use crate::boolean::{assemble_open_fragments, edge_interior_lies_on, finalize_assembled_solid};
use crate::classification::{parameter_point_in_face, PolygonClass};
use crate::face_merge::merge_same_surface_faces_open;
use crate::fragment::{fragment_solid, FaceFragmentRecord, FragmentEdgeSource};
use crate::imprint::{
    EdgeSplitRecord, FaceImprints, FaceKey, FacePcurve, ImprintOptions, ImprintPieceRecord,
    ImprintResultRecord, ImprintVertex,
};
use crate::mass_properties::parameter_space_area;
use crate::project_point_to_surface;
use crate::topology::{
    BrepSolid, CoedgeRecord, EdgeRecord, FaceRecord, LoopRecord, ShellRecord, VertexRecord,
};
use crate::{
    apply_edge_splits, build_imprints, classify_point, offset_face_carrier, DiagnosticSeverity,
    KernelDiagnostics, KernelOutcome, KernelStage, KernelTolerances, PointClass, Vec2, Vec3,
};
use rustc_hash::{FxHashMap as HashMap, FxHashSet as HashSet};
use serde::Serialize;

const SOURCE_OPERAND: u8 = 250;

fn debug_enabled() -> bool {
    std::env::var("BREP_OS_DEBUG").is_ok_and(|value| !value.is_empty() && value != "0")
}

macro_rules! os_debug {
    ($($arg:tt)*) => {
        if debug_enabled() {
            eprintln!($($arg)*);
        }
    };
}

#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize)]
#[serde(rename_all = "lowercase")]
pub enum OffsetFaceRole {
    Source,
    Offset,
    Wall,
}

#[derive(Clone, Debug, Serialize)]
pub struct OffsetShellResultRecord {
    pub solid: BrepSolid,
    pub face_images: Vec<OffsetShellFaceImageRecord>,
}

#[derive(Clone, Debug, Serialize)]
pub struct OffsetShellFaceImageRecord {
    pub role: OffsetFaceRole,
    pub source_face_id: u64,
}

#[derive(Clone)]
struct Carrier {
    solid: BrepSolid,
    source_face_id: u64,
    kind: OffsetFaceRole,
}

// ---------------------------------------------------------------------------
// Module map — offset_shell is split into topic submodules (moves only).
// This file stays the module root: shared imports, the `os_debug!` macro, the
// public result/record types, and the `Carrier` type live here.
//
//   carriers.rs        — carrier construction, pair imprinting, fragment/skin
//                        classification helpers
//   smooth_sync.rs     — carrier bounds/extent sampling, adjacency/tangency
//                        probes, smooth-boundary synchronization
//   carrier_rebuild.rs — carrier trim rebuilds: hole-rim extension, fall-short
//                        curved carriers, full-domain + reflex-rim rebuilds,
//                        opening-wall seeds
//   connectors.rs      — open-boundary tracing: sharp offset connectors,
//                        duplicate-arc welds, opening-boundary cycle completion
//   orientation.rs     — open-solid orientation, orphan-rim welds, face/shell
//                        flip helpers
//   rim_welds.rs       — rim-circle fitting, cap faces, ruled offset rim
//                        welds, coplanar rim-pair annuli
//   pipeline.rs        — the offset_shell entry points and the
//                        offset_shell_impl assembly/validation pipeline
//   tests.rs           — the `#[cfg(test)]` battery
// ---------------------------------------------------------------------------

#[path = "offset_shell/carriers.rs"]
mod carriers;
#[path = "offset_shell/smooth_sync.rs"]
mod smooth_sync;
#[path = "offset_shell/carrier_rebuild.rs"]
mod carrier_rebuild;
#[path = "offset_shell/connectors.rs"]
mod connectors;
#[path = "offset_shell/orientation.rs"]
mod orientation;
#[path = "offset_shell/rim_welds.rs"]
mod rim_welds;
#[path = "offset_shell/pipeline.rs"]
mod pipeline;
#[cfg(test)]
#[path = "offset_shell/tests.rs"]
mod tests;

use carrier_rebuild::*;
use carriers::*;
use connectors::*;
use orientation::*;
use rim_welds::*;
use smooth_sync::*;

pub use pipeline::{offset_shell, offset_shell_with_diagnostics};
pub(crate) use orientation::{flip_all_faces, flip_shell_faces, orient_open_solid_faces};