BREP_kernel 0.3.1

A boundary representation (BREP) geometry kernel for building CAD applications.
Documentation
    use super::*;
    use crate::{make_box_brep, make_cylinder_brep, make_line, solid_mass_properties, Vec4};

    mod validation;
    mod basic_ops;
    mod nary;
    mod boss_fillet;
    mod conform_repair;
    mod sphere_tangent;
    mod rescue_section;
    mod fixtures;

    fn load_corpus_operand(dir: &str, file: &str) -> BrepSolid {
        let path = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))
            .join("boolean_fuzz_corpus")
            .join(dir)
            .join(file);
        let text = std::fs::read_to_string(&path)
            .unwrap_or_else(|error| panic!("read {}: {error}", path.display()));
        serde_json::from_str(&text).expect("deserialize corpus operand")
    }

    /// Regression for the imported-geometry endpoint-sliver conform CHURN — the
    /// helmet user report (`STEP_ABC_00000011` − cube), validated natively
    /// against the scratchpad operands. Its small committed proxy is
    /// `10_regression_step269_cone` (fuzz seed 424242 trial 553; the only pool
    /// member exhibiting this signature, already pinned as fixture 10).
    ///
    /// Mechanism: when a keyless (imprint/derived) guide vertex sits just
    /// OUTSIDE the assembler weld band of a SHORT boundary edge's ENDPOINT (a
    /// near-miss the assembler declined to fuse), its projection lands a few
    /// 1e-8 from that endpoint. `conform_overlapping_one_use_edges_pass` then
    /// split the boundary edge there every pass, minting a sub-weld-tolerance
    /// piece `Assembler::edge` stamps degenerate on arrival (it can never weld;
    /// the rest is re-fit unchanged). The re-projected split fraction drifts a
    /// hair between re-fits, so the fractional 1e-7 guard never trips and the
    /// loop exhausts its 8 passes (`one-use edge conformance did not converge`).
    /// The endpoint-sliver guard rejects any split landing within
    /// `assembler_weld` of either endpoint, so the loop reaches a fixpoint
    /// deterministically.
    ///
    /// NOTE — this proxy (and the helmet) is COMPOUND: a deeper near-tangent
    /// 3-plane corner-cut fragment defect (holes / open loops, unrelated to the
    /// conform loop) leaves the assembly genus-invalid even once the loop
    /// converges, so the boolean still returns Err here. The guard fixes only
    /// the CHURN — the residual error is no longer the non-convergence — so we
    /// assert the mechanism predicate, forward-compatible if the fragment defect
    /// is later fixed and the op starts returning Ok.
    ///
    /// Tamper-verify by setting `BREP_CONFORM_ENDPOINT_GUARD=0`: the churn
    /// returns, the error reverts to "one-use edge conformance did not
    /// converge", and this assert fails (mirrors fixture 10's
    /// `BREP_IMPRINT_RESIDUAL_MERGE=0` pattern).
    #[test]
    fn conform_endpoint_sliver_guard_reaches_fixpoint() {
        let a = load_corpus_operand("10_regression_step269_cone", "a.json");
        let b = load_corpus_operand("10_regression_step269_cone", "b.json");
        for op in [
            BooleanOperation::Subtract,
            BooleanOperation::Union,
            BooleanOperation::Intersect,
        ] {
            if let Err(error) = boolean_operation(&a, &b, op, &BooleanOptions::default()) {
                assert!(
                    !error.contains("did not converge"),
                    "endpoint-sliver guard must converge the conform loop for {op:?}, got: {error}"
                );
            }
        }
    }