Skip to main content

brep_blend/blending/blend/
mod.rs

1//! General rolling-ball blends (Golovanov §4.9 + §6.9 surgery).
2//!
3//! The blend surface is the rational surface (4.9.1) built from three
4//! curves: the two support curves cr(t) ⊂ F1 and cs(t) ⊂ F2 where a
5//! sphere of radius ρ touches both faces, and the middle curve at the
6//! intersection of the two tangent planes, weighted w(t) = cos(α/2)
7//! (4.9.3).  The tangency system (4.9.2) + the section-plane constraint
8//! (4.9.5) — the sphere center pinned to the normal plane of the edge —
9//! is solved per station by Newton with a finite-difference Jacobian.
10//!
11//! Topology is rebuilt the §6.9 way, with NO tool solid and NO boolean:
12//! each mating face's loop swaps the blended edge's coedge for a coedge
13//! on its support curve (trimming the adjacent seam edge when the face
14//! is a closed carrier with seam-in-one-loop topology), and the blend
15//! face is inserted with its own seam.  Open edges take the same route
16//! (`edge/open.rs`), and a whole SELECTION goes through `network.rs`, which
17//! marches every stripe against the original solid and solves each shared
18//! corner from its ball before anything is cut.
19
20pub mod carve;
21pub mod chain;
22pub mod collapse;
23pub mod convex_parallel;
24pub mod corner;
25pub mod creased_rim;
26pub mod edge;
27pub mod fold;
28pub mod miter;
29pub mod network;
30pub use network::STRIPE_PINCH_TAPER_WHAT;
31pub mod planar_chart;
32pub mod same_parameter;
33pub use same_parameter::same_parameter_trims;
34mod restrict;
35pub mod rollover;
36pub mod rollover_surgery;
37pub mod setback;
38pub mod runout;
39pub mod split_rim;
40pub mod turned_rim;
41pub mod sheet_ends;
42pub mod stations;
43pub mod rows;
44pub mod track_fit;
45
46/// A transverse end with parallel normals needs a tapered runout, not cutter
47/// composition. The network tries that runout before propagating this refusal.
48pub const TANGENTIAL_TRANSVERSE_END: &str = "tangential_transverse_end";
49
50pub fn is_tangential_transverse_end(refusal: &crate::KernelRefusal) -> bool {
51    matches!(&refusal.class, crate::RefusalClass::UnsupportedGeometry { what }
52        if what == TANGENTIAL_TRANSVERSE_END)
53}
54
55/// Whether the open march's local station refinement runs. Escape hatch
56/// `BREP_BLEND_REFINE=0` restores the uniform ladder exactly; a test turns it
57/// off for its own thread with `set_refinement_off_for_test`.
58pub fn station_refinement_on() -> bool {
59    switch!(live "BREP_BLEND_REFINE", true)
60}
61
62thread_local! {
63    static BLEND_NOTES: std::cell::RefCell<Vec<String>> = const { std::cell::RefCell::new(Vec::new()) };
64}
65
66thread_local! {
67    /// Set only while the open-pad composition (`fillet/edges.rs`, the
68    /// 2026-10-17 face-ring report) builds its two stages on this thread.
69    static OPEN_PAD_NETWORK: std::cell::Cell<bool> = const { std::cell::Cell::new(false) };
70}
71
72/// Runs `build` as the open-pad composition's network: the open march takes
73/// a station where a contact crosses its carrier's domain boundary and the
74/// row fit breaks there (`march_open_stations_core`), and the march extends
75/// past a section end that lies outside the overshoot
76/// (`open_station_parameters`). Both are what the composition's walls need
77/// (the F6 blend rail of the reported ring stood 7.1e-5 off its carrier at
78/// the boundary; the pads' stripes start before their trims) and both move
79/// a body the plain network already built (2026-10-18: the reported model's
80/// F6 moved by a refinement rung and a broken row), so outside the
81/// composition every network is built exactly as before. Restores the flag
82/// after.
83pub fn with_open_pad_network<T>(build: impl FnOnce() -> T) -> T {
84    /// Restores the previous flag on every exit path, an unwinding panic
85    /// included, so a later network on this thread never inherits it.
86    struct Reset(bool);
87    impl Drop for Reset {
88        fn drop(&mut self) {
89            OPEN_PAD_NETWORK.with(|flag| flag.set(self.0));
90        }
91    }
92    let _reset = Reset(OPEN_PAD_NETWORK.with(|flag| flag.replace(true)));
93    build()
94}
95
96/// Whether the march runs as the open-pad composition's network (see
97/// [`with_open_pad_network`]).
98pub(in crate::blend) fn open_pad_network_on() -> bool {
99    OPEN_PAD_NETWORK.with(|flag| flag.get())
100}
101
102/// An equal-radius convex star on four planar faces with no common ball closes
103/// as the rolling ball does: a ridge cylinder between two sphere triangles.
104/// `BREP_BLEND_RIDGE_STAR=0` restores the ribbon fill.
105const RIDGE_STAR_DEFAULT: bool = true;
106
107pub fn ridge_star_on() -> bool {
108    switch!(live "BREP_BLEND_RIDGE_STAR", RIDGE_STAR_DEFAULT)
109}
110
111/// The STOPPED-END rollover of an open stripe (user bug F10, 2026-11-02):
112/// a track that leaves its mate across a tangent edge before the stripe's
113/// own vertex and never comes back — the F10 fillet's rails run 1.1e-2 past
114/// faces 13/23's boundaries onto the F8 blend faces 19/26 — has its tail
115/// re-marched on the neighbour from the crossing station and the cap's
116/// legs drawn on the neighbours. Default OFF: `BREP_BLEND_STOPPED_END_ROLLOVER=1`
117/// turns it on. Promotion owes the blend/fillet filters and both censuses
118/// with the switch on.
119const STOPPED_END_ROLLOVER_DEFAULT: bool = false;
120
121pub fn stopped_end_rollover_on() -> bool {
122    switch!(live "BREP_BLEND_STOPPED_END_ROLLOVER", STOPPED_END_ROLLOVER_DEFAULT)
123}
124
125/// Equal-length chains are unchanged either way; unequal ones move their
126/// stations, so it lands behind this switch until its census:
127/// `BREP_BLEND_CHAIN_ARC_STATIONS=1` turns it on, `=0` off;
128/// `set_chain_arc_stations_for_test` forces it on a test's own thread.
129const CHAIN_ARC_STATIONS_DEFAULT: bool = false;
130
131pub fn chain_arc_stations_on() -> bool {
132    switch!(live "BREP_BLEND_CHAIN_ARC_STATIONS", CHAIN_ARC_STATIONS_DEFAULT)
133}
134
135#[derive(Clone, Debug, PartialEq)]
136pub enum StripeRadius {
137    Constant(f64),
138    /// `(edge fraction, radius)` stops sorted by fraction, interpolated
139    /// linearly between and held flat past the ends: `blend_edge_variable`'s
140    /// convention, which the law entries sample into.
141    Stops(Vec<(f64, f64)>),
142}
143
144impl StripeRadius {
145    /// From a stop list: one constant when every stop carries the same
146    /// radius (to 1e-12 relative, the single-edge lane's own test).
147    pub fn from_stops(stops: &[(f64, f64)]) -> Self {
148        let mut sorted = stops.to_vec();
149        sorted.sort_by(|a, b| a.0.total_cmp(&b.0));
150        match sorted.first() {
151            Some(&(_, first)) if sorted.iter().all(|(_, r)| (r - first).abs() <= 1e-12 * (1.0 + first.abs())) => {
152                StripeRadius::Constant(first)
153            }
154            _ => StripeRadius::Stops(sorted),
155        }
156    }
157
158    /// The radius at an edge fraction in `[0, 1]` (clamped).
159    pub fn at_fraction(&self, fraction: f64) -> f64 {
160        match self {
161            StripeRadius::Constant(radius) => *radius,
162            StripeRadius::Stops(stops) => {
163                let fraction = fraction.clamp(0.0, 1.0);
164                if fraction <= stops[0].0 {
165                    return stops[0].1;
166                }
167                for pair in stops.windows(2) {
168                    if fraction <= pair[1].0 {
169                        let width = (pair[1].0 - pair[0].0).max(1e-12);
170                        return pair[0].1 + (pair[1].1 - pair[0].1) * (fraction - pair[0].0) / width;
171                    }
172                }
173                stops[stops.len() - 1].1
174            }
175        }
176    }
177
178    /// The constant, for a constant law.
179    pub fn constant(&self) -> Option<f64> {
180        match self {
181            StripeRadius::Constant(radius) => Some(*radius),
182            StripeRadius::Stops(_) => None,
183        }
184    }
185
186    /// The largest radius the law takes.
187    pub fn largest(&self) -> f64 {
188        match self {
189            StripeRadius::Constant(radius) => *radius,
190            StripeRadius::Stops(stops) => stops.iter().map(|(_, r)| *r).fold(0.0, f64::max),
191        }
192    }
193
194    /// The law's END value at the edge's start (`at_start`) or finish: what
195    /// the user asked for at that vertex, and the constant every corner solve
196    /// there uses (C2).
197    pub fn end(&self, at_start: bool) -> f64 {
198        self.at_fraction(if at_start { 0.0 } else { 1.0 })
199    }
200
201    /// Whether every radius is positive and finite.
202    pub fn is_positive(&self) -> bool {
203        match self {
204            StripeRadius::Constant(radius) => radius.is_finite() && *radius > 0.0,
205            StripeRadius::Stops(stops) => !stops.is_empty() && stops.iter().all(|(_, r)| r.is_finite() && *r > 0.0),
206        }
207    }
208}
209
210
211/// Record what a blend that SHIPS needs its feature to say about it — today,
212/// a march whose rails still stand off their carriers after its station
213/// ladder and local refinement ran out. Drained per feature by the history
214/// loop ([`take_blend_notes`]), beside the soundness acceptance's repairs.
215pub fn record_blend_note(note: String) {
216    BLEND_NOTES.with(|notes| notes.borrow_mut().push(note));
217}
218
219/// Take every blend note recorded on this thread since the last call.
220/// Blending runs on the feature's own thread (no parallel march), so the
221/// history loop's drain sees every note its feature recorded.
222pub fn take_blend_notes() -> Vec<String> {
223    BLEND_NOTES.with(|notes| std::mem::take(&mut *notes.borrow_mut()))
224}
225
226/// The ledger's length, and a way back to it: a lane that refuses takes back
227/// the notes it recorded, so a note never describes a wall that did not ship.
228pub fn blend_notes_mark() -> usize {
229    BLEND_NOTES.with(|notes| notes.borrow().len())
230}
231
232pub fn blend_notes_truncate(mark: usize) {
233    BLEND_NOTES.with(|notes| notes.borrow_mut().truncate(mark));
234}
235
236/// A fillet chain wall that SHIPPED short of the construction request its
237/// accepted rung made (`KernelTolerances::model` on the wall between its
238/// rails): which wall — the blend face's name and its exact surface — what
239/// was asked, what the wall reads, and the typed budget that ran out.
240#[derive(Clone, Debug)]
241pub struct WallModelReport {
242    pub name: Option<String>,
243    pub surface: crate::NurbsSurface,
244    pub request: f64,
245    pub residual: f64,
246    /// What else the lane measured that the message must say (an unaccepted
247    /// rung's deficit, a ladder rung's local refinement), verbatim.
248    pub detail: Option<String>,
249    pub budget: crate::ApproximationBudget,
250}
251
252thread_local! {
253    static BLEND_APPROXIMATIONS: std::cell::RefCell<Vec<WallModelReport>> = const { std::cell::RefCell::new(Vec::new()) };
254}
255
256thread_local! {
257    static BLEND_OPERATION_DEPTH: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
258}
259
260/// One blend OPERATION's scope on this thread: every public blend entry point
261/// (and the history loop, around each feature) holds one. The OUTERMOST
262/// entry drops whatever an earlier operation recorded and nobody consumed —
263/// a direct API caller consumes ([`take_blend_approximations`]) after the
264/// operation whose reports it wants, before starting the next — while a
265/// nested entry (a fillet's per-edge chain blend) clears nothing, so every
266/// report of the operation in flight is kept, however many there are.
267pub struct BlendOperation;
268
269impl BlendOperation {
270    pub fn enter() -> BlendOperation {
271        BLEND_OPERATION_DEPTH.with(|depth| {
272            if depth.get() == 0 {
273                BLEND_APPROXIMATIONS.with(|reports| reports.borrow_mut().clear());
274                timing::begin_operation();
275            }
276            depth.set(depth.get() + 1);
277        });
278        BlendOperation
279    }
280}
281
282/// Whether the innermost open blend operation is the outermost one (no
283/// nested operation inside another).
284pub fn blend_operation_outermost() -> bool {
285    BLEND_OPERATION_DEPTH.with(|depth| depth.get() <= 1)
286}
287
288impl Drop for BlendOperation {
289    fn drop(&mut self) {
290        BLEND_OPERATION_DEPTH.with(|depth| {
291            depth.set(depth.get().saturating_sub(1));
292            if depth.get() == 0 {
293                timing::end_operation();
294            }
295        });
296    }
297}
298pub use crate::blend_timing as timing;
299pub use timing::{blend_timing_capture, take_blend_timings, BlendTiming};
300pub use timing::{record_count, BlendTimer};
301
302/// Record a wall that ships with its request unmet. Written by the rung that
303/// keeps its body; whether the body reaches a caller is decided at
304/// consumption ([`take_blend_approximations`]), not here. Every report of
305/// the operation in flight is kept (see [`BlendOperation`]).
306pub fn record_wall_model_report(report: WallModelReport) {
307    BLEND_APPROXIMATIONS.with(|reports| reports.borrow_mut().push(report));
308}
309
310
311/// Whether any wall-model report is waiting (the history loop reads the
312/// returned bodies only then).
313pub fn blend_approximations_pending() -> bool {
314    BLEND_APPROXIMATIONS.with(|reports| !reports.borrow().is_empty())
315}
316
317/// Bit-identical surfaces: the same degrees, knots and homogeneous control
318/// points, compared by their bits.
319pub fn same_surface(a: &crate::NurbsSurface, b: &crate::NurbsSurface) -> bool {
320    let bits = |values: &[f64]| values.iter().map(|value| value.to_bits()).collect::<Vec<_>>();
321    a.degree_u == b.degree_u
322        && a.degree_v == b.degree_v
323        && bits(&a.knots_u) == bits(&b.knots_u)
324        && bits(&a.knots_v) == bits(&b.knots_v)
325        && a.control_points.len() == b.control_points.len()
326        && a.control_points.iter().zip(&b.control_points).all(|(row_a, row_b)| {
327            row_a.len() == row_b.len()
328                && row_a.iter().zip(row_b).all(|(p, q)| {
329                    [p.x, p.y, p.z, p.w].map(f64::to_bits) == [q.x, q.y, q.z, q.w].map(f64::to_bits)
330                })
331        })
332}
333
334/// Whether `face_name` names the report's wall: its exact name, or that
335/// name with the `[k]` (decimal) suffix `ensure_unique_face_names` gives a
336/// colliding name at registration. Nothing else: no prefix, no other suffix.
337fn names_the_wall(face_name: &Option<String>, report_name: &Option<String>) -> bool {
338    match (face_name, report_name) {
339        (Some(face), Some(report)) => {
340            face == report
341                || face.strip_prefix(report.as_str()).and_then(|rest| rest.strip_prefix('[')).and_then(|rest| rest.strip_suffix(']')).is_some_and(
342                    |index| !index.is_empty() && index.bytes().all(|byte| byte.is_ascii_digit()),
343                )
344        }
345        (None, None) => true,
346        _ => false,
347    }
348}
349
350/// Consume EVERY wall-model report recorded on this thread since the last
351/// call, in ONE snapshot, against ALL the bodies a call returned
352/// (`(body name, solid)`): a report becomes a typed `blend.wall_model`
353/// [`crate::Approximation`] on each body carrying its wall — a face with a
354/// bit-identical surface AND the report's name, exactly or as registration
355/// renamed it (`NAME[k]`) — and is dropped when no returned body carries it
356/// (a lane that refused, a body a later step discarded). A wall carried by
357/// two returned bodies (one surface, bit for bit, in both) is reported on
358/// both: the reading is a property of that surface. Reports for one wall
359/// collapse to the last. Never a match by name alone.
360/// `take_blend_approximations(&[])` discards everything recorded (the
361/// history loop's stale drain before a feature runs).
362pub fn take_blend_approximations(bodies: &[(&str, &crate::BrepSolid)]) -> Vec<crate::Approximation> {
363    let snapshot = BLEND_APPROXIMATIONS.with(|reports| std::mem::take(&mut *reports.borrow_mut()));
364    let mut unique: Vec<WallModelReport> = Vec::new();
365    for report in snapshot {
366        unique.retain(|kept| !(kept.name == report.name && same_surface(&kept.surface, &report.surface)));
367        unique.push(report);
368    }
369    let mut approximations = Vec::new();
370    for (body, solid) in bodies {
371        for report in &unique {
372            let carried = solid.shells.iter().flat_map(|shell| &shell.faces).any(|face| {
373                names_the_wall(&face.name, &report.name) && same_surface(&face.surface, &report.surface)
374            });
375            if carried {
376                let wall = report.name.as_deref().unwrap_or("(unnamed)");
377                let unaccepted = matches!(report.budget.reason, crate::BudgetReason::Unaccepted | crate::BudgetReason::Unread);
378                let budget = match report.budget.mechanism {
379                    crate::BudgetMechanism::LocalRounds => format!(
380                        "local refinement stopped: {:?} after {} of {} rounds, {} of {} stations per segment",
381                        report.budget.reason, report.budget.rounds_used, report.budget.rounds_limit,
382                        report.budget.stations, report.budget.station_limit,
383                    ),
384                    crate::BudgetMechanism::StationRungs => format!(
385                        "the open march's station ladder stopped: {:?} after {} of {} global station rungs, {} of {} stations",
386                        report.budget.reason, report.budget.rounds_used, report.budget.rounds_limit,
387                        report.budget.stations, report.budget.station_limit,
388                    ),
389                };
390                let unknown = report.budget.unread > 0;
391                let rails = report.budget.measured_component == crate::MeasuredComponent::Rails;
392                let mut message = if !unaccepted && (rails || unknown) {
393                    // A request that covers the rails and the wall says WHICH
394                    // it measured, and never offers a partial reading as the
395                    // worst: with unread intervals the worst is unknown.
396                    let what = if rails {
397                        format!("the fillet wall {wall}'s support rails stand")
398                    } else {
399                        format!("the fillet wall {wall} stands")
400                    };
401                    let against = if rails {
402                        "off their exact construction (their carriers / the exact ball contacts)"
403                    } else {
404                        "from the rolling ball between its rails"
405                    };
406                    let reading = if unknown {
407                        format!(
408                            "an UNKNOWN distance {against}: {} interval(s) could not be read (the largest READABLE reading is {:.3e} mm, not the worst)",
409                            report.budget.unread, report.residual
410                        )
411                    } else {
412                        format!("{:.3e} mm {against}", report.residual)
413                    };
414                    format!(
415                        "{what} {reading}, against a construction request of {:.3e} mm (accepted at the intersection-fit bar); {budget}",
416                        report.request,
417                    )
418                } else if unaccepted {
419                    format!(
420                        "the blend wall {wall} ships from a rung that never met acceptance: its worst reading \
421                         {:.3e} mm against its acceptance bar {:.3e} mm; {budget}",
422                        report.residual, report.request,
423                    )
424                } else {
425                    format!(
426                        "the fillet wall {wall} stands {:.3e} mm from the rolling ball between its rails, against a \
427                         construction request of {:.3e} mm (accepted at the intersection-fit bar); {budget}",
428                        report.residual, report.request,
429                    )
430                };
431                if let Some(detail) = &report.detail {
432                    message = format!("{message} ({detail})");
433                }
434                approximations.push(crate::Approximation {
435                    code: if unaccepted { "blend.wall_acceptance" } else { "blend.wall_model" }.to_string(),
436                    body: body.to_string(),
437                    measured: report.residual,
438                    bar: report.request,
439                    volume_bound: None,
440                    edges: Vec::new(),
441                    budget: Some(report.budget.clone()),
442                    message,
443                });
444            }
445        }
446    }
447    approximations
448}
449
450
451pub use chain::{blend_smooth_chain, blend_smooth_chain_if_closed};
452pub use chain::smooth_chain_members;
453pub use corner::round_concave_chain_corner;
454pub use corner::round_convex_corner;
455pub use corner::{is_n_sided_undercut_refusal, N_SIDED_FOLD_WHAT, N_SIDED_UNDERCUT_WHAT};
456pub use edge::{blend_closed_edge, blend_closed_edge_knot_aware, blend_edge_variable, blend_open_edge, is_pcurve_floor_refusal, with_pcurve_knot_retry};
457pub use collapse::is_full_width_collapse;
458pub use planar_chart::{
459    chart_fitted_for_gate, fit_planar_charts_to_trims, is_planar_chart_refusal, planar_chart_overrun,
460};
461pub use track_fit::PCURVE_OFF_FLOOR;
462pub use edge::{consumed_band, is_consumed_snap, is_rail_collapse};
463pub use network::{
464    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,
465};
466pub use miter::{is_marched_fit_off_carriers, is_miter_support_overrun};
467/// The two faces each selected edge lies on, in the network's mate order
468/// (the open-pad composition reads which is planar and which is the boss).
469pub fn selection_mates<'a>(
470    solid: &'a crate::topology::BrepSolid,
471    edge_ids: &[u64],
472    radius: f64,
473) -> Result<Vec<(&'a crate::topology::EdgeRecord, [&'a crate::topology::FaceRecord; 2])>, crate::KernelRefusal> {
474    Ok(network::stripe_mates(solid, edge_ids, radius)?
475        .into_iter()
476        .map(|(edge, first, second)| (edge, [first.face, second.face]))
477        .collect())
478}
479
480pub use runout::{build_runout_walls, plan_runout, RunoutPlan};
481pub use fold::{is_rail_fold, is_wall_fold, wall_loop_refusal, WALL_FOLDS};
482pub use stations::is_ball_off_carrier;
483pub use network::is_ball_does_not_fit;
484pub use network::{body_carries_wrapped_corner, reject_wrapped_network, with_wrap_sharp_corners, wrap_sharp_corners_on, WrapOutcome};
485
486/// Off the switch every closed rim's two support pcurves are refitted to their
487/// rail's projected track (`edge/closed.rs::refit_closed_support_pcurve`, the
488/// closed chain's support-piece fitter: a dense track of analytic feet, a
489/// verified fit ladder and the shipped read), 96 of the half torus's 98 ms of
490/// rows. On the switch each trim is first READ as shipped at the same floor
491/// (`track_fit::read_shipped_pcurve`, `PCURVE_REFINEMENT_TOLERANCE`): a plane
492/// mate's trim is the rail's own control points through the plane's affine
493/// chart (exact by construction, the exact revolution lane's rule); any other
494/// mate's trim, or an image that misses, takes the refit as before (the
495/// march's own interpolated pcurve was measured as a candidate and dropped:
496/// 8.5e-5 off on the half torus's torus mate). The shipped contract is
497/// unchanged (every trim read within the floor); the bytes are not, so it
498/// landed OFF and was promoted by its census (the kernel battery, the case
499/// manifest and hlr_tests with the switch on). ON by default;
500/// `BREP_BLEND_CLOSED_TRIM_READ_FIRST=0` is the escape hatch back to the refit
501/// road, `=1` forces it on; `set_closed_trim_read_first_for_test` forces
502/// either way on a test's thread.
503const CLOSED_TRIM_READ_FIRST_DEFAULT: bool = true;
504
505pub fn closed_trim_read_first_on() -> bool {
506    switch!(live "BREP_BLEND_CLOSED_TRIM_READ_FIRST", CLOSED_TRIM_READ_FIRST_DEFAULT)
507}
508
509
510/// The check solves 31 centres per interval by continuation from the
511/// neighbour, each a full station Newton with a finite-difference Jacobian
512/// rebuilt at every iteration (eleven evaluations of the tangency system a
513/// centre, 89 of the half torus's 169 ms of march). On the switch each centre
514/// is seeded by a quadratic extrapolation through the last three and solved
515/// by the chord method with the Jacobian carried from centre to centre
516/// (`stations::solve_station_state_chord`), to the plain solver's own stop;
517/// the plain solver from the neighbour is the fall-back for anything the
518/// chord cannot finish. The centres are the same roots to the same tolerance,
519/// not the same bits: the declared wall reading moves in its last digits, its
520/// verdict and the body do not, which is why it landed OFF and was promoted
521/// by its census. ON by default; `BREP_BLEND_CLOSED_WALL_PREDICT=0` is the
522/// escape hatch back to the plain continuation solves, `=1` forces it on;
523/// `set_closed_wall_predict_for_test` forces either way on a test's thread.
524const CLOSED_WALL_PREDICT_DEFAULT: bool = true;
525
526pub fn closed_wall_predict_on() -> bool {
527    switch!(live "BREP_BLEND_CLOSED_WALL_PREDICT", CLOSED_WALL_PREDICT_DEFAULT)
528}
529
530
531// BREP lane L: begin keyway_floor_open_mixed_corner_20261014
532pub use corner::round_mixed_concave_open_corner;
533// BREP lane L: end keyway_floor_open_mixed_corner_20261014
534
535
536
537// Lane R7 (2026-10-19): the tapered cusp runout; `BREP_BLEND_TAPER_RUNOUT`.
538pub mod taper_runout;
539
540// 2026-10-21: the local radius relief of a folding constant fillet;
541// `BREP_BLEND_RADIUS_RELIEF`.
542pub mod relief;