BREP_blend 0.29.0

Rust B-rep CAD kernel (next.BREP.io): fillets, chamfers and blends.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
//! General rolling-ball blends (Golovanov §4.9 + §6.9 surgery).
//!
//! The blend surface is the rational surface (4.9.1) built from three
//! curves: the two support curves cr(t) ⊂ F1 and cs(t) ⊂ F2 where a
//! sphere of radius ρ touches both faces, and the middle curve at the
//! intersection of the two tangent planes, weighted w(t) = cos(α/2)
//! (4.9.3).  The tangency system (4.9.2) + the section-plane constraint
//! (4.9.5) — the sphere center pinned to the normal plane of the edge —
//! is solved per station by Newton with a finite-difference Jacobian.
//!
//! Topology is rebuilt the §6.9 way, with NO tool solid and NO boolean:
//! each mating face's loop swaps the blended edge's coedge for a coedge
//! on its support curve (trimming the adjacent seam edge when the face
//! is a closed carrier with seam-in-one-loop topology), and the blend
//! face is inserted with its own seam.  Open edges take the same route
//! (`edge/open.rs`), and a whole SELECTION goes through `network.rs`, which
//! marches every stripe against the original solid and solves each shared
//! corner from its ball before anything is cut.

pub mod carve;
pub mod chain;
pub mod collapse;
pub mod convex_parallel;
pub mod corner;
pub mod creased_rim;
pub mod edge;
pub mod fold;
pub mod miter;
pub mod network;
pub use network::STRIPE_PINCH_TAPER_WHAT;
pub mod planar_chart;
pub mod same_parameter;
pub use same_parameter::same_parameter_trims;
mod restrict;
pub mod rollover;
pub mod rollover_surgery;
pub mod setback;
pub mod setback_corner;
pub mod runout;
pub mod split_rim;
pub mod turned_rim;
pub mod sheet_ends;
pub mod stations;
pub mod rows;
pub mod track_fit;

/// A transverse end with parallel normals needs a tapered runout, not cutter
/// composition. The network tries that runout before propagating this refusal.
pub const TANGENTIAL_TRANSVERSE_END: &str = "tangential_transverse_end";

pub fn is_tangential_transverse_end(refusal: &crate::KernelRefusal) -> bool {
    matches!(&refusal.class, crate::RefusalClass::UnsupportedGeometry { what }
        if what == TANGENTIAL_TRANSVERSE_END)
}

/// Whether the open march's local station refinement runs. Escape hatch
/// `BREP_BLEND_REFINE=0` restores the uniform ladder exactly; a test turns it
/// off for its own thread with `set_refinement_off_for_test`.
pub fn station_refinement_on() -> bool {
    switch!(live "BREP_BLEND_REFINE", true)
}

thread_local! {
    static BLEND_NOTES: std::cell::RefCell<Vec<String>> = const { std::cell::RefCell::new(Vec::new()) };
}

thread_local! {
    /// Set only while the open-pad composition (`fillet/edges.rs`, the
    /// 2026-10-17 face-ring report) builds its two stages on this thread.
    static OPEN_PAD_NETWORK: std::cell::Cell<bool> = const { std::cell::Cell::new(false) };
}

/// Runs `build` as the open-pad composition's network: the open march takes
/// a station where a contact crosses its carrier's domain boundary and the
/// row fit breaks there (`march_open_stations_core`), and the march extends
/// past a section end that lies outside the overshoot
/// (`open_station_parameters`). Both are what the composition's walls need
/// (the F6 blend rail of the reported ring stood 7.1e-5 off its carrier at
/// the boundary; the pads' stripes start before their trims) and both move
/// a body the plain network already built (2026-10-18: the reported model's
/// F6 moved by a refinement rung and a broken row), so outside the
/// composition every network is built exactly as before. Restores the flag
/// after.
pub fn with_open_pad_network<T>(build: impl FnOnce() -> T) -> T {
    /// Restores the previous flag on every exit path, an unwinding panic
    /// included, so a later network on this thread never inherits it.
    struct Reset(bool);
    impl Drop for Reset {
        fn drop(&mut self) {
            OPEN_PAD_NETWORK.with(|flag| flag.set(self.0));
        }
    }
    let _reset = Reset(OPEN_PAD_NETWORK.with(|flag| flag.replace(true)));
    build()
}

/// Whether the march runs as the open-pad composition's network (see
/// [`with_open_pad_network`]).
pub(in crate::blend) fn open_pad_network_on() -> bool {
    OPEN_PAD_NETWORK.with(|flag| flag.get())
}

/// An equal-radius convex star on four planar faces with no common ball closes
/// as the rolling ball does: a ridge cylinder between two sphere triangles.
/// `BREP_BLEND_RIDGE_STAR=0` restores the ribbon fill.
const RIDGE_STAR_DEFAULT: bool = true;

pub fn ridge_star_on() -> bool {
    switch!(live "BREP_BLEND_RIDGE_STAR", RIDGE_STAR_DEFAULT)
}

/// The STOPPED-END rollover of an open stripe (user bug F10, 2026-11-02):
/// a track that leaves its mate across a tangent edge before the stripe's
/// own vertex and never comes back — the F10 fillet's rails run 1.1e-2 past
/// faces 13/23's boundaries onto the F8 blend faces 19/26 — has its tail
/// re-marched on the neighbour from the crossing station and the cap's
/// legs drawn on the neighbours. Default OFF: `BREP_BLEND_STOPPED_END_ROLLOVER=1`
/// turns it on. Promotion owes the blend/fillet filters and both censuses
/// with the switch on.
const STOPPED_END_ROLLOVER_DEFAULT: bool = false;

pub fn stopped_end_rollover_on() -> bool {
    switch!(live "BREP_BLEND_STOPPED_END_ROLLOVER", STOPPED_END_ROLLOVER_DEFAULT)
}

/// Equal-length chains are unchanged either way; unequal ones move their
/// stations, so it lands behind this switch until its census:
/// `BREP_BLEND_CHAIN_ARC_STATIONS=1` turns it on, `=0` off;
/// `set_chain_arc_stations_for_test` forces it on a test's own thread.
const CHAIN_ARC_STATIONS_DEFAULT: bool = false;

pub fn chain_arc_stations_on() -> bool {
    switch!(live "BREP_BLEND_CHAIN_ARC_STATIONS", CHAIN_ARC_STATIONS_DEFAULT)
}

#[derive(Clone, Debug, PartialEq)]
pub enum StripeRadius {
    Constant(f64),
    /// `(edge fraction, radius)` stops sorted by fraction, interpolated
    /// linearly between and held flat past the ends: `blend_edge_variable`'s
    /// convention, which the law entries sample into.
    Stops(Vec<(f64, f64)>),
}

impl StripeRadius {
    /// From a stop list: one constant when every stop carries the same
    /// radius (to 1e-12 relative, the single-edge lane's own test).
    pub fn from_stops(stops: &[(f64, f64)]) -> Self {
        let mut sorted = stops.to_vec();
        sorted.sort_by(|a, b| a.0.total_cmp(&b.0));
        match sorted.first() {
            Some(&(_, first)) if sorted.iter().all(|(_, r)| (r - first).abs() <= 1e-12 * (1.0 + first.abs())) => {
                StripeRadius::Constant(first)
            }
            _ => StripeRadius::Stops(sorted),
        }
    }

    /// The radius at an edge fraction in `[0, 1]` (clamped).
    pub fn at_fraction(&self, fraction: f64) -> f64 {
        match self {
            StripeRadius::Constant(radius) => *radius,
            StripeRadius::Stops(stops) => {
                let fraction = fraction.clamp(0.0, 1.0);
                if fraction <= stops[0].0 {
                    return stops[0].1;
                }
                for pair in stops.windows(2) {
                    if fraction <= pair[1].0 {
                        let width = (pair[1].0 - pair[0].0).max(1e-12);
                        return pair[0].1 + (pair[1].1 - pair[0].1) * (fraction - pair[0].0) / width;
                    }
                }
                stops[stops.len() - 1].1
            }
        }
    }

    /// The constant, for a constant law.
    pub fn constant(&self) -> Option<f64> {
        match self {
            StripeRadius::Constant(radius) => Some(*radius),
            StripeRadius::Stops(_) => None,
        }
    }

    /// The largest radius the law takes.
    pub fn largest(&self) -> f64 {
        match self {
            StripeRadius::Constant(radius) => *radius,
            StripeRadius::Stops(stops) => stops.iter().map(|(_, r)| *r).fold(0.0, f64::max),
        }
    }

    /// The law's END value at the edge's start (`at_start`) or finish: what
    /// the user asked for at that vertex, and the constant every corner solve
    /// there uses (C2).
    pub fn end(&self, at_start: bool) -> f64 {
        self.at_fraction(if at_start { 0.0 } else { 1.0 })
    }

    /// Whether every radius is positive and finite.
    pub fn is_positive(&self) -> bool {
        match self {
            StripeRadius::Constant(radius) => radius.is_finite() && *radius > 0.0,
            StripeRadius::Stops(stops) => !stops.is_empty() && stops.iter().all(|(_, r)| r.is_finite() && *r > 0.0),
        }
    }
}


/// Record what a blend that SHIPS needs its feature to say about it — today,
/// a march whose rails still stand off their carriers after its station
/// ladder and local refinement ran out. Drained per feature by the history
/// loop ([`take_blend_notes`]), beside the soundness acceptance's repairs.
pub fn record_blend_note(note: String) {
    BLEND_NOTES.with(|notes| notes.borrow_mut().push(note));
}

/// Take every blend note recorded on this thread since the last call.
/// Blending runs on the feature's own thread (no parallel march), so the
/// history loop's drain sees every note its feature recorded.
pub fn take_blend_notes() -> Vec<String> {
    BLEND_NOTES.with(|notes| std::mem::take(&mut *notes.borrow_mut()))
}

/// The ledger's length, and a way back to it: a lane that refuses takes back
/// the notes it recorded, so a note never describes a wall that did not ship.
pub fn blend_notes_mark() -> usize {
    BLEND_NOTES.with(|notes| notes.borrow().len())
}

pub fn blend_notes_truncate(mark: usize) {
    BLEND_NOTES.with(|notes| notes.borrow_mut().truncate(mark));
}

/// A fillet chain wall that SHIPPED short of the construction request its
/// accepted rung made (`KernelTolerances::model` on the wall between its
/// rails): which wall — the blend face's name and its exact surface — what
/// was asked, what the wall reads, and the typed budget that ran out.
#[derive(Clone, Debug)]
pub struct WallModelReport {
    pub name: Option<String>,
    pub surface: crate::NurbsSurface,
    pub request: f64,
    pub residual: f64,
    /// What else the lane measured that the message must say (an unaccepted
    /// rung's deficit, a ladder rung's local refinement), verbatim.
    pub detail: Option<String>,
    pub budget: crate::ApproximationBudget,
}

thread_local! {
    static BLEND_APPROXIMATIONS: std::cell::RefCell<Vec<WallModelReport>> = const { std::cell::RefCell::new(Vec::new()) };
}

thread_local! {
    static BLEND_OPERATION_DEPTH: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
}

/// One blend OPERATION's scope on this thread: every public blend entry point
/// (and the history loop, around each feature) holds one. The OUTERMOST
/// entry drops whatever an earlier operation recorded and nobody consumed —
/// a direct API caller consumes ([`take_blend_approximations`]) after the
/// operation whose reports it wants, before starting the next — while a
/// nested entry (a fillet's per-edge chain blend) clears nothing, so every
/// report of the operation in flight is kept, however many there are.
pub struct BlendOperation;

impl BlendOperation {
    pub fn enter() -> BlendOperation {
        BLEND_OPERATION_DEPTH.with(|depth| {
            if depth.get() == 0 {
                BLEND_APPROXIMATIONS.with(|reports| reports.borrow_mut().clear());
                timing::begin_operation();
            }
            depth.set(depth.get() + 1);
        });
        BlendOperation
    }
}

/// Whether the innermost open blend operation is the outermost one (no
/// nested operation inside another).
pub fn blend_operation_outermost() -> bool {
    BLEND_OPERATION_DEPTH.with(|depth| depth.get() <= 1)
}

impl Drop for BlendOperation {
    fn drop(&mut self) {
        BLEND_OPERATION_DEPTH.with(|depth| {
            depth.set(depth.get().saturating_sub(1));
            if depth.get() == 0 {
                timing::end_operation();
            }
        });
    }
}
pub use crate::blend_timing as timing;
pub use timing::{blend_timing_capture, take_blend_timings, BlendTiming};
pub use timing::{record_count, BlendTimer};

/// Record a wall that ships with its request unmet. Written by the rung that
/// keeps its body; whether the body reaches a caller is decided at
/// consumption ([`take_blend_approximations`]), not here. Every report of
/// the operation in flight is kept (see [`BlendOperation`]).
pub fn record_wall_model_report(report: WallModelReport) {
    BLEND_APPROXIMATIONS.with(|reports| reports.borrow_mut().push(report));
}


/// Whether any wall-model report is waiting (the history loop reads the
/// returned bodies only then).
pub fn blend_approximations_pending() -> bool {
    BLEND_APPROXIMATIONS.with(|reports| !reports.borrow().is_empty())
}

/// Bit-identical surfaces: the same degrees, knots and homogeneous control
/// points, compared by their bits.
pub fn same_surface(a: &crate::NurbsSurface, b: &crate::NurbsSurface) -> bool {
    let bits = |values: &[f64]| values.iter().map(|value| value.to_bits()).collect::<Vec<_>>();
    a.degree_u == b.degree_u
        && a.degree_v == b.degree_v
        && bits(&a.knots_u) == bits(&b.knots_u)
        && bits(&a.knots_v) == bits(&b.knots_v)
        && a.control_points.len() == b.control_points.len()
        && a.control_points.iter().zip(&b.control_points).all(|(row_a, row_b)| {
            row_a.len() == row_b.len()
                && row_a.iter().zip(row_b).all(|(p, q)| {
                    [p.x, p.y, p.z, p.w].map(f64::to_bits) == [q.x, q.y, q.z, q.w].map(f64::to_bits)
                })
        })
}

/// Whether `face_name` names the report's wall: its exact name, or that
/// name with the `[k]` (decimal) suffix `ensure_unique_face_names` gives a
/// colliding name at registration. Nothing else: no prefix, no other suffix.
fn names_the_wall(face_name: &Option<String>, report_name: &Option<String>) -> bool {
    match (face_name, report_name) {
        (Some(face), Some(report)) => {
            face == report
                || face.strip_prefix(report.as_str()).and_then(|rest| rest.strip_prefix('[')).and_then(|rest| rest.strip_suffix(']')).is_some_and(
                    |index| !index.is_empty() && index.bytes().all(|byte| byte.is_ascii_digit()),
                )
        }
        (None, None) => true,
        _ => false,
    }
}

/// Consume EVERY wall-model report recorded on this thread since the last
/// call, in ONE snapshot, against ALL the bodies a call returned
/// (`(body name, solid)`): a report becomes a typed `blend.wall_model`
/// [`crate::Approximation`] on each body carrying its wall — a face with a
/// bit-identical surface AND the report's name, exactly or as registration
/// renamed it (`NAME[k]`) — and is dropped when no returned body carries it
/// (a lane that refused, a body a later step discarded). A wall carried by
/// two returned bodies (one surface, bit for bit, in both) is reported on
/// both: the reading is a property of that surface. Reports for one wall
/// collapse to the last. Never a match by name alone.
/// `take_blend_approximations(&[])` discards everything recorded (the
/// history loop's stale drain before a feature runs).
pub fn take_blend_approximations(bodies: &[(&str, &crate::BrepSolid)]) -> Vec<crate::Approximation> {
    let snapshot = BLEND_APPROXIMATIONS.with(|reports| std::mem::take(&mut *reports.borrow_mut()));
    let mut unique: Vec<WallModelReport> = Vec::new();
    for report in snapshot {
        unique.retain(|kept| !(kept.name == report.name && same_surface(&kept.surface, &report.surface)));
        unique.push(report);
    }
    let mut approximations = Vec::new();
    for (body, solid) in bodies {
        for report in &unique {
            let carried = solid.shells.iter().flat_map(|shell| &shell.faces).any(|face| {
                names_the_wall(&face.name, &report.name) && same_surface(&face.surface, &report.surface)
            });
            if carried {
                let wall = report.name.as_deref().unwrap_or("(unnamed)");
                let unaccepted = matches!(report.budget.reason, crate::BudgetReason::Unaccepted | crate::BudgetReason::Unread);
                let budget = match report.budget.mechanism {
                    crate::BudgetMechanism::LocalRounds => format!(
                        "local refinement stopped: {:?} after {} of {} rounds, {} of {} stations per segment",
                        report.budget.reason, report.budget.rounds_used, report.budget.rounds_limit,
                        report.budget.stations, report.budget.station_limit,
                    ),
                    crate::BudgetMechanism::StationRungs => format!(
                        "the open march's station ladder stopped: {:?} after {} of {} global station rungs, {} of {} stations",
                        report.budget.reason, report.budget.rounds_used, report.budget.rounds_limit,
                        report.budget.stations, report.budget.station_limit,
                    ),
                };
                let unknown = report.budget.unread > 0;
                let rails = report.budget.measured_component == crate::MeasuredComponent::Rails;
                let mut message = if !unaccepted && (rails || unknown) {
                    // A request that covers the rails and the wall says WHICH
                    // it measured, and never offers a partial reading as the
                    // worst: with unread intervals the worst is unknown.
                    let what = if rails {
                        format!("the fillet wall {wall}'s support rails stand")
                    } else {
                        format!("the fillet wall {wall} stands")
                    };
                    let against = if rails {
                        "off their exact construction (their carriers / the exact ball contacts)"
                    } else {
                        "from the rolling ball between its rails"
                    };
                    let reading = if unknown {
                        format!(
                            "an UNKNOWN distance {against}: {} interval(s) could not be read (the largest READABLE reading is {:.3e} mm, not the worst)",
                            report.budget.unread, report.residual
                        )
                    } else {
                        format!("{:.3e} mm {against}", report.residual)
                    };
                    format!(
                        "{what} {reading}, against a construction request of {:.3e} mm (accepted at the intersection-fit bar); {budget}",
                        report.request,
                    )
                } else if unaccepted {
                    format!(
                        "the blend wall {wall} ships from a rung that never met acceptance: its worst reading \
                         {:.3e} mm against its acceptance bar {:.3e} mm; {budget}",
                        report.residual, report.request,
                    )
                } else {
                    format!(
                        "the fillet wall {wall} stands {:.3e} mm from the rolling ball between its rails, against a \
                         construction request of {:.3e} mm (accepted at the intersection-fit bar); {budget}",
                        report.residual, report.request,
                    )
                };
                if let Some(detail) = &report.detail {
                    message = format!("{message} ({detail})");
                }
                approximations.push(crate::Approximation {
                    code: if unaccepted { "blend.wall_acceptance" } else { "blend.wall_model" }.to_string(),
                    body: body.to_string(),
                    measured: report.residual,
                    bar: report.request,
                    volume_bound: None,
                    edges: Vec::new(),
                    budget: Some(report.budget.clone()),
                    message,
                });
            }
        }
    }
    approximations
}


pub use chain::{blend_smooth_chain, blend_smooth_chain_if_closed};
pub use chain::smooth_chain_members;
pub use corner::round_concave_chain_corner;
pub use corner::round_convex_corner;
pub use corner::{is_n_sided_undercut_refusal, N_SIDED_FOLD_WHAT, N_SIDED_UNDERCUT_WHAT};
pub use edge::{blend_closed_edge, blend_closed_edge_knot_aware, blend_edge_variable, blend_open_edge, is_pcurve_floor_refusal, with_pcurve_knot_retry};
pub(crate) use edge::{blend_closed_edge_reusing, remember_closed_refusal, ClosedRefusalScope};
pub use collapse::is_full_width_collapse;
pub use planar_chart::{
    chart_fitted_for_gate, fit_planar_charts_to_trims, is_planar_chart_refusal, planar_chart_overrun,
};
pub use track_fit::PCURVE_OFF_FLOOR;
pub use edge::{consumed_band, is_consumed_snap, is_rail_collapse};
pub use network::{
    blend_star_network, blend_star_network_laws, blend_star_network_with_corner_policy, degenerate_corner_setbacks, mixed_convexity_corner, mixed_convexity_corners, selection_convexity, MixedCorner,
};
pub use miter::{is_marched_fit_off_carriers, is_miter_support_overrun};
/// The two faces each selected edge lies on, in the network's mate order
/// (the open-pad composition reads which is planar and which is the boss).
pub fn selection_mates<'a>(
    solid: &'a crate::topology::BrepSolid,
    edge_ids: &[u64],
    radius: f64,
) -> Result<Vec<(&'a crate::topology::EdgeRecord, [&'a crate::topology::FaceRecord; 2])>, crate::KernelRefusal> {
    Ok(network::stripe_mates(solid, edge_ids, radius)?
        .into_iter()
        .map(|(edge, first, second)| (edge, [first.face, second.face]))
        .collect())
}

pub use runout::{build_runout_walls, plan_runout, RunoutPlan};
pub use fold::{is_rail_fold, is_wall_fold, wall_loop_refusal, WALL_FOLDS};
pub use stations::is_ball_off_carrier;
pub use network::is_ball_does_not_fit;
pub use network::{body_carries_wrapped_corner, reject_wrapped_network, with_wrap_sharp_corners, wrap_sharp_corners_on, WrapOutcome};

/// Off the switch every closed rim's two support pcurves are refitted to their
/// rail's projected track (`edge/closed.rs::refit_closed_support_pcurve`, the
/// closed chain's support-piece fitter: a dense track of analytic feet, a
/// verified fit ladder and the shipped read), 96 of the half torus's 98 ms of
/// rows. On the switch each trim is first READ as shipped at the same floor
/// (`track_fit::read_shipped_pcurve`, `PCURVE_REFINEMENT_TOLERANCE`): a plane
/// mate's trim is the rail's own control points through the plane's affine
/// chart (exact by construction, the exact revolution lane's rule); any other
/// mate's trim, or an image that misses, takes the refit as before (the
/// march's own interpolated pcurve was measured as a candidate and dropped:
/// 8.5e-5 off on the half torus's torus mate). The shipped contract is
/// unchanged (every trim read within the floor); the bytes are not, so it
/// landed OFF and was promoted by its census (the kernel battery, the case
/// manifest and hlr_tests with the switch on). ON by default;
/// `BREP_BLEND_CLOSED_TRIM_READ_FIRST=0` is the escape hatch back to the refit
/// road, `=1` forces it on; `set_closed_trim_read_first_for_test` forces
/// either way on a test's thread.
const CLOSED_TRIM_READ_FIRST_DEFAULT: bool = true;

pub fn closed_trim_read_first_on() -> bool {
    switch!(live "BREP_BLEND_CLOSED_TRIM_READ_FIRST", CLOSED_TRIM_READ_FIRST_DEFAULT)
}


/// The check solves 31 centres per interval by continuation from the
/// neighbour, each a full station Newton with a finite-difference Jacobian
/// rebuilt at every iteration (eleven evaluations of the tangency system a
/// centre, 89 of the half torus's 169 ms of march). On the switch each centre
/// is seeded by a quadratic extrapolation through the last three and solved
/// by the chord method with the Jacobian carried from centre to centre
/// (`stations::solve_station_state_chord`), to the plain solver's own stop;
/// the plain solver from the neighbour is the fall-back for anything the
/// chord cannot finish. The centres are the same roots to the same tolerance,
/// not the same bits: the declared wall reading moves in its last digits, its
/// verdict and the body do not, which is why it landed OFF and was promoted
/// by its census. ON by default; `BREP_BLEND_CLOSED_WALL_PREDICT=0` is the
/// escape hatch back to the plain continuation solves, `=1` forces it on;
/// `set_closed_wall_predict_for_test` forces either way on a test's thread.
const CLOSED_WALL_PREDICT_DEFAULT: bool = true;

pub fn closed_wall_predict_on() -> bool {
    switch!(live "BREP_BLEND_CLOSED_WALL_PREDICT", CLOSED_WALL_PREDICT_DEFAULT)
}


// BREP lane L: begin keyway_floor_open_mixed_corner_20261014
pub use corner::round_mixed_concave_open_corner;
// BREP lane L: end keyway_floor_open_mixed_corner_20261014



// Lane R7 (2026-10-19): the tapered cusp runout; `BREP_BLEND_TAPER_RUNOUT`.
pub mod taper_runout;

// 2026-10-21: the local radius relief of a folding constant fillet;
// `BREP_BLEND_RADIUS_RELIEF`.
pub mod relief;