brep_offset/offset/offset_shell/
refusals.rs1use crate::{KernelRefusal, KernelStage};
24
25pub(super) const NO_RETAINED_FACE: &str = "offset_shell_no_retained_face";
26pub(super) const TANGENT_OFFSETS: &str = "offset_shell_tangent_offsets";
29pub(super) const SEALED_HOLLOW: &str = "offset_shell_sealed_hollow";
32pub(super) const SHADOW_RETRY_STALLED: &str = "offset_shell_shadow_retry_stalled";
35pub(super) const PASS_BUDGET: &str = "offset_shell_pass_budget";
37pub(super) const UNWELDED_CURVED_RIM: &str = "offset_shell_unwelded_curved_rim";
38pub(super) const EMPTY_SHELL: &str = "offset_shell_empty_shell";
39pub(super) const SHARP_SIDE_CONTINUATION: &str = "offset_shell_sharp_side_continuation";
42pub(super) const REGULARITY_UNCERTAIN: &str = "offset_shell_regularity_uncertain";
46
47pub(super) const FOLD_BETWEEN_SAMPLES: &str = "offset_shell_fold_between_samples";
50
51pub(super) fn fold_between_samples(
52 face_id: u64,
53 distance: f64,
54 sample: crate::offset_regularity::FoldSample,
55) -> KernelRefusal {
56 KernelRefusal::unsupported(
57 KernelStage::Classify,
58 FOLD_BETWEEN_SAMPLES,
59 format!(
60 "offset_shell: the offset of source face {face_id} by {distance:.6} folds between the \
61 regularity scan's samples — the certainty step read 1 − δ·κ = {:.3e} at (u={:.6}, \
62 v={:.6}), curvature radius {:.6} against the offset {:.6}, where the census and the \
63 carve had found nothing to divide. The support is refused rather than built whole",
64 sample.factor,
65 sample.u,
66 sample.v,
67 sample.radius(),
68 sample.displacement.abs()
69 ),
70 )
71}
72
73pub(super) fn regularity_uncertain(
78 face_id: u64,
79 distance: f64,
80 unresolved: usize,
81 budget_exhausted: bool,
82 least: Option<crate::offset_regularity::FoldSample>,
83) -> KernelRefusal {
84 let because = match (unresolved, budget_exhausted) {
85 (0, _) => "the refinement budget ran out with prominent dips of the fold factor still \
86 unexplored"
87 .to_string(),
88 (cells, false) => format!(
89 "{cells} cell(s) of the scan were still risky at its finest spacing — the fold \
90 factor sits within a hair of the level over an area no sampling can decide"
91 ),
92 (cells, true) => format!(
93 "{cells} cell(s) of the scan were still risky at its finest spacing and the \
94 refinement budget ran out"
95 ),
96 };
97 let least = least
98 .map(|least| {
99 format!(
100 "; the least 1 − δ·κ seen is {:.3e} at (u={:.6}, v={:.6}), curvature radius {:.6} \
101 against the offset {:.6}",
102 least.factor,
103 least.u,
104 least.v,
105 least.radius(),
106 least.displacement.abs()
107 )
108 })
109 .unwrap_or_default();
110 KernelRefusal::unsupported(
111 KernelStage::Classify,
112 REGULARITY_UNCERTAIN,
113 format!(
114 "offset_shell: the offset of source face {face_id} by {distance:.6} cannot be \
115 certified regular over the face's trim — nothing collapsed at any sample, but \
116 {because}{least}. The support is refused rather than built whole, because a \
117 carrier folded between the samples welds into a shell that validates and bounds \
118 the wrong solid"
119 ),
120 )
121}
122
123pub fn no_retained_face() -> KernelRefusal {
125 KernelRefusal::input(
126 KernelStage::Collect,
127 NO_RETAINED_FACE,
128 "offset_shell: removing every face cannot produce a shell",
129 )
130}
131
132pub fn unwelded_curved_rim(edge_id: u64, anchor: crate::Vec3) -> KernelRefusal {
134 KernelRefusal::unsupported(
135 KernelStage::Sew,
136 UNWELDED_CURVED_RIM,
137 format!(
138 "offset_shell: unwelded rim leaves a non-watertight shell \
139 (one-use closed edge {} near ({:.3},{:.3},{:.3})); this \
140 curved-solid opening is not yet supported",
141 edge_id, anchor.x, anchor.y, anchor.z
142 ),
143 )
144}
145
146pub fn empty_shell(shells: usize, empty: usize, floor: f64) -> KernelRefusal {
149 KernelRefusal::internal(
154 KernelStage::Validate,
155 EMPTY_SHELL,
156 format!(
157 "offset_shell: the outward shell assembled {shells} shells, {empty} of which enclose no volume \
158 (under {floor:.1e}); those are fragments of an assembly that cannot be built as it stands"
159 ),
160 )
161}
162
163pub fn is_offset_shell_no_retained_face(refusal: &KernelRefusal) -> bool {
166 matches!(&refusal.class, crate::RefusalClass::InvalidInput { what } if what == NO_RETAINED_FACE)
167}
168
169pub fn is_offset_shell_open_curved_rim(refusal: &KernelRefusal) -> bool {
175 match &refusal.class {
176 crate::RefusalClass::NonIntegralGenus { .. } => true,
177 crate::RefusalClass::UnsupportedGeometry { what } => what == UNWELDED_CURVED_RIM,
178 _ => false,
179 }
180}
181
182pub(super) fn fold_band_uncovered(face_id: u64, distance: f64, pieces: usize) -> KernelRefusal {
186 KernelRefusal::unsupported(
187 KernelStage::Refine,
188 "offset_shell_fold_band",
189 format!(
190 "offset_shell: the offset of source face {face_id} by {distance:.6} folds in a BAND across its \
191 trim, dividing it into {pieces} regular piece(s), and a fold boundary's image is not nearer than \
192 the distance to the source: the pieces' offsets would end on a cusp of the body's boundary \
193 instead of crossing before it, and nothing here re-solves that cusp"
194 ),
195 )
196}