use crate::{KernelRefusal, KernelStage};
pub(super) const NO_RETAINED_FACE: &str = "offset_shell_no_retained_face";
pub(super) const UNWELDED_CURVED_RIM: &str = "offset_shell_unwelded_curved_rim";
pub(super) const EMPTY_SHELL: &str = "offset_shell_empty_shell";
pub(super) const SHARP_SIDE_CONTINUATION: &str = "offset_shell_sharp_side_continuation";
pub(super) const REGULARITY_UNCERTAIN: &str = "offset_shell_regularity_uncertain";
pub(super) const FOLD_BETWEEN_SAMPLES: &str = "offset_shell_fold_between_samples";
pub(super) fn fold_between_samples(
face_id: u64,
distance: f64,
sample: crate::offset_regularity::FoldSample,
) -> KernelRefusal {
KernelRefusal::unsupported(
KernelStage::Classify,
FOLD_BETWEEN_SAMPLES,
format!(
"offset_shell: the offset of source face {face_id} by {distance:.6} folds between the \
regularity scan's samples — the certainty step read 1 − δ·κ = {:.3e} at (u={:.6}, \
v={:.6}), curvature radius {:.6} against the offset {:.6}, where the census and the \
carve had found nothing to divide. The support is refused rather than built whole",
sample.factor,
sample.u,
sample.v,
sample.radius(),
sample.displacement.abs()
),
)
}
pub(super) fn regularity_uncertain(
face_id: u64,
distance: f64,
unresolved: usize,
budget_exhausted: bool,
least: Option<crate::offset_regularity::FoldSample>,
) -> KernelRefusal {
let because = match (unresolved, budget_exhausted) {
(0, _) => "the refinement budget ran out with prominent dips of the fold factor still \
unexplored"
.to_string(),
(cells, false) => format!(
"{cells} cell(s) of the scan were still risky at its finest spacing — the fold \
factor sits within a hair of the level over an area no sampling can decide"
),
(cells, true) => format!(
"{cells} cell(s) of the scan were still risky at its finest spacing and the \
refinement budget ran out"
),
};
let least = least
.map(|least| {
format!(
"; the least 1 − δ·κ seen is {:.3e} at (u={:.6}, v={:.6}), curvature radius {:.6} \
against the offset {:.6}",
least.factor,
least.u,
least.v,
least.radius(),
least.displacement.abs()
)
})
.unwrap_or_default();
KernelRefusal::unsupported(
KernelStage::Classify,
REGULARITY_UNCERTAIN,
format!(
"offset_shell: the offset of source face {face_id} by {distance:.6} cannot be \
certified regular over the face's trim — nothing collapsed at any sample, but \
{because}{least}. The support is refused rather than built whole, because a \
carrier folded between the samples welds into a shell that validates and bounds \
the wrong solid"
),
)
}
pub(super) fn no_retained_face() -> KernelRefusal {
KernelRefusal::input(
KernelStage::Collect,
NO_RETAINED_FACE,
"offset_shell: removing every face cannot produce a shell",
)
}
pub(super) fn unwelded_curved_rim(edge_id: u64, anchor: crate::Vec3) -> KernelRefusal {
KernelRefusal::unsupported(
KernelStage::Sew,
UNWELDED_CURVED_RIM,
format!(
"offset_shell: unwelded rim leaves a non-watertight shell \
(one-use closed edge {} near ({:.3},{:.3},{:.3})); this \
curved-solid opening is not yet supported",
edge_id, anchor.x, anchor.y, anchor.z
),
)
}
pub(super) fn empty_shell(shells: usize, empty: usize, floor: f64) -> KernelRefusal {
KernelRefusal::internal(
KernelStage::Validate,
EMPTY_SHELL,
format!(
"offset_shell: the outward shell assembled {shells} shells, {empty} of which enclose no volume \
(under {floor:.1e}); those are fragments of an assembly that cannot be built as it stands"
),
)
}
pub(crate) fn is_offset_shell_no_retained_face(refusal: &KernelRefusal) -> bool {
matches!(&refusal.class, crate::RefusalClass::InvalidInput { what } if what == NO_RETAINED_FACE)
}
pub(crate) fn is_offset_shell_open_curved_rim(refusal: &KernelRefusal) -> bool {
match &refusal.class {
crate::RefusalClass::NonIntegralGenus { .. } => true,
crate::RefusalClass::UnsupportedGeometry { what } => what == UNWELDED_CURVED_RIM,
_ => false,
}
}