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) 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,
}
}