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 UNWELDED_CURVED_RIM: &str = "offset_shell_unwelded_curved_rim";
33pub(super) const EMPTY_SHELL: &str = "offset_shell_empty_shell";
34pub(super) const SHARP_SIDE_CONTINUATION: &str = "offset_shell_sharp_side_continuation";
37pub(super) const REGULARITY_UNCERTAIN: &str = "offset_shell_regularity_uncertain";
41
42pub(super) const FOLD_BETWEEN_SAMPLES: &str = "offset_shell_fold_between_samples";
45
46pub(super) fn fold_between_samples(
47 face_id: u64,
48 distance: f64,
49 sample: crate::offset_regularity::FoldSample,
50) -> KernelRefusal {
51 KernelRefusal::unsupported(
52 KernelStage::Classify,
53 FOLD_BETWEEN_SAMPLES,
54 format!(
55 "offset_shell: the offset of source face {face_id} by {distance:.6} folds between the \
56 regularity scan's samples — the certainty step read 1 − δ·κ = {:.3e} at (u={:.6}, \
57 v={:.6}), curvature radius {:.6} against the offset {:.6}, where the census and the \
58 carve had found nothing to divide. The support is refused rather than built whole",
59 sample.factor,
60 sample.u,
61 sample.v,
62 sample.radius(),
63 sample.displacement.abs()
64 ),
65 )
66}
67
68pub(super) fn regularity_uncertain(
73 face_id: u64,
74 distance: f64,
75 unresolved: usize,
76 budget_exhausted: bool,
77 least: Option<crate::offset_regularity::FoldSample>,
78) -> KernelRefusal {
79 let because = match (unresolved, budget_exhausted) {
80 (0, _) => "the refinement budget ran out with prominent dips of the fold factor still \
81 unexplored"
82 .to_string(),
83 (cells, false) => format!(
84 "{cells} cell(s) of the scan were still risky at its finest spacing — the fold \
85 factor sits within a hair of the level over an area no sampling can decide"
86 ),
87 (cells, true) => format!(
88 "{cells} cell(s) of the scan were still risky at its finest spacing and the \
89 refinement budget ran out"
90 ),
91 };
92 let least = least
93 .map(|least| {
94 format!(
95 "; the least 1 − δ·κ seen is {:.3e} at (u={:.6}, v={:.6}), curvature radius {:.6} \
96 against the offset {:.6}",
97 least.factor,
98 least.u,
99 least.v,
100 least.radius(),
101 least.displacement.abs()
102 )
103 })
104 .unwrap_or_default();
105 KernelRefusal::unsupported(
106 KernelStage::Classify,
107 REGULARITY_UNCERTAIN,
108 format!(
109 "offset_shell: the offset of source face {face_id} by {distance:.6} cannot be \
110 certified regular over the face's trim — nothing collapsed at any sample, but \
111 {because}{least}. The support is refused rather than built whole, because a \
112 carrier folded between the samples welds into a shell that validates and bounds \
113 the wrong solid"
114 ),
115 )
116}
117
118pub fn no_retained_face() -> KernelRefusal {
120 KernelRefusal::input(
121 KernelStage::Collect,
122 NO_RETAINED_FACE,
123 "offset_shell: removing every face cannot produce a shell",
124 )
125}
126
127pub fn unwelded_curved_rim(edge_id: u64, anchor: crate::Vec3) -> KernelRefusal {
129 KernelRefusal::unsupported(
130 KernelStage::Sew,
131 UNWELDED_CURVED_RIM,
132 format!(
133 "offset_shell: unwelded rim leaves a non-watertight shell \
134 (one-use closed edge {} near ({:.3},{:.3},{:.3})); this \
135 curved-solid opening is not yet supported",
136 edge_id, anchor.x, anchor.y, anchor.z
137 ),
138 )
139}
140
141pub fn empty_shell(shells: usize, empty: usize, floor: f64) -> KernelRefusal {
144 KernelRefusal::internal(
149 KernelStage::Validate,
150 EMPTY_SHELL,
151 format!(
152 "offset_shell: the outward shell assembled {shells} shells, {empty} of which enclose no volume \
153 (under {floor:.1e}); those are fragments of an assembly that cannot be built as it stands"
154 ),
155 )
156}
157
158pub fn is_offset_shell_no_retained_face(refusal: &KernelRefusal) -> bool {
161 matches!(&refusal.class, crate::RefusalClass::InvalidInput { what } if what == NO_RETAINED_FACE)
162}
163
164pub fn is_offset_shell_open_curved_rim(refusal: &KernelRefusal) -> bool {
170 match &refusal.class {
171 crate::RefusalClass::NonIntegralGenus { .. } => true,
172 crate::RefusalClass::UnsupportedGeometry { what } => what == UNWELDED_CURVED_RIM,
173 _ => false,
174 }
175}