diff --git a/solidcore/crates/solidcore/src/error/blend.rs b/solidcore/crates/solidcore/src/error/blend.rs index ee38d0c718c..22625ed2415 100644 --- a/solidcore/crates/solidcore/src/error/blend.rs +++ b/solidcore/crates/solidcore/src/error/blend.rs @@ -12,76 +12,19 @@ //! where it is on the caller's body and its [`super::Fit`] the size that builds, where the //! check computed one. //! -//! | Cause | Class ([`ErrorKind`]) | -//! |----------------------------------------|-----------------------------------------------| -//! | [`BlendFailure::NoRoom`] | the reason's ([`no_room_class`]), 101 to 124, 128 or 129 | -//! | [`BlendFailure::RemovalRefused`] | the reason's ([`removal_class`]), 130 or 131 | -//! | [`BlendFailure::StationDidNotConverge`]| [`ErrorKind::StationDidNotConverge`] (125) | -//! | [`BlendFailure::TrimLoopOpen`], [`BlendFailure::TrimLoopDoesNotSeparate`] | [`ErrorKind::TrimLeaks`] (126) | -//! | [`BlendFailure::StageFailed`], [`BlendFailure::Defect`], [`BlendFailure::SkinMeasureNotFinite`], [`BlendFailure::PlaneCurveStepVanished`] | [`ErrorKind::StageFailed`] (127) | -//! | [`BlendFailure::SkinPastStationCap`], [`BlendFailure::PlaneCurveFitCap`] | [`ErrorKind::NotWithinTolerance`] (9) | -//! | [`BlendFailure::PlaneCurveTouches`] | [`ErrorKind::Degenerate`] (3) | -//! | [`BlendFailure::PlaneCurveEndOff`], [`BlendFailure::LawCornerNotFound`], [`BlendFailure::CornerPatchFaceNotFound`] | [`ErrorKind::NotFound`] (2) | -//! | [`BlendFailure::PlaneCurveLeavesDomain`] | [`ErrorKind::OutsideDomain`] (8) | -//! | [`BlendFailure::BallsNest`] | [`ErrorKind::BallsFold`] (105) | -//! | [`BlendFailure::MixedCornerUnbuildable`] | the step's ([`MixedStep::class`]): [`ErrorKind::NotFound`] (2), [`ErrorKind::Degenerate`] (3) or [`ErrorKind::Unsupported`] (5) | -//! | [`BlendFailure::CornerUnbuildable`] | the step's ([`CornerStep::class`]): [`ErrorKind::NotFound`] (2), [`ErrorKind::Degenerate`] (3), [`ErrorKind::Unsupported`] (5) or [`ErrorKind::NotWithinTolerance`] (9) | -//! | the corner entry points' checks of the caller's corner, fillet B-rep and body ([`BlendFailure::CornerInputInvalid`]), and the checks of the fillet structures' links ([`BlendFailure::FilletSetUpInvalid`]) | [`ErrorKind::InvalidInput`] (1) | -//! | [`BlendFailure::CreasePieceEndUnbuildable`], [`BlendFailure::BallTriangleNotOnePatch`], [`BlendFailure::CornerShapeNotBuilt`] | [`ErrorKind::Unsupported`] (5) | -//! | [`BlendFailure::CornerPointDropUnresolved`] | [`ErrorKind::NotFound`] (2) | -//! | [`BlendFailure::NotCertified`], [`BlendFailure::SectionNotProved`] | [`ErrorKind::NotWithinTolerance`] (9): neither defect nor refusal | -//! | [`BlendFailure::SectionDegenerate`] | [`ErrorKind::Degenerate`] (3) | -//! | [`BlendFailure::SectionUnsupported`] | [`ErrorKind::Unsupported`] (5) | -//! | [`BlendFailure::RadiusLawNotPositive`], [`BlendFailure::SectionInputInvalid`] | [`ErrorKind::InvalidInput`] (1): neither defect nor refusal | -//! | [`BlendFailure::BandInputMissing`] | [`ErrorKind::Missing`]: neither defect nor refusal | -//! | [`BlendFailure::Solver`] | its cause's ([`SolverFailure::class`]) | -//! | the fillet executive's checks of the caller's arguments and body ([`BlendFailure::NoEdgesGiven`], [`BlendFailure::SizeBelowResolution`], [`BlendFailure::PerEdgeListLength`], [`BlendFailure::ParameterListSizes`], [`BlendFailure::FaceHasNoSurface`], [`BlendFailure::NoFirstBody`], [`BlendFailure::TargetNotGiven`], [`BlendFailure::EdgeNotInTarget`], [`BlendFailure::EdgeNotFilletable`], [`BlendFailure::ChamferSizeInvalid`], [`BlendFailure::ChamferFaceNotOfEdge`], [`BlendFailure::SolverFaceIndexInvalid`], [`BlendFailure::GnSectionInvalid`], [`BlendFailure::CrossSectionTypeUnknown`], [`BlendFailure::RadiusTypeNotForEdges`], [`BlendFailure::VariableRadiusLawsNotGiven`], [`BlendFailure::VariableRadiusLawMissing`], [`BlendFailure::BevelVertexNotFilleted`], [`BlendFailure::LawIntervalEmpty`], [`BlendFailure::EdgeWithoutCurve`], [`BlendFailure::EdgeUseWithoutEdge`], [`BlendFailure::BoundSurfaceRemoved`]) | [`ErrorKind::InvalidInput`] (1) | -//! | [`BlendFailure::ExactBlendAxisCannotPlaceEdge`], the rational round's check of the exact blend it is given | [`ErrorKind::InvalidInput`] (1) | -//! | [`BlendFailure::LawHasNoValue`], [`BlendFailure::SequenceCurveNotBSpline`], [`BlendFailure::FilletCrossesItself`] | [`ErrorKind::Unsupported`] (5) | -//! | [`BlendFailure::CornerRefused`], [`BlendFailure::ExecutiveStepFailed`], [`BlendFailure::EdgeSplitDeclined`] | [`ErrorKind::Failed`] (6): neither defect nor refusal, so a kept cause decides | -//! | [`BlendFailure::CrossingInputMissing`] | [`ErrorKind::Missing`]: neither defect nor refusal | -//! | [`BlendFailure::CrossingNotFinite`] | [`ErrorKind::StageFailed`] (127) | -//! | [`BlendFailure::EaseInputMissing`], [`BlendFailure::OverflowInputMissing`] | [`ErrorKind::Missing`]: neither defect nor refusal | -//! | [`BlendFailure::EaseNotBuilt`] | its stop's kind ([`EaseStop`]): [`ErrorKind::NotFound`] (2), [`ErrorKind::Degenerate`] (3), [`ErrorKind::Unsupported`] (5) or [`ErrorKind::OutsideDomain`] (8) | -//! | [`BlendFailure::EaseGeometryNotBSpline`], [`BlendFailure::ExtensionEndOnTwoSideLines`] | [`ErrorKind::Unsupported`] (5) | -//! | [`BlendFailure::ArcLengthNotConverged`] | [`ErrorKind::NotConverged`] (4) | -//! | [`BlendFailure::OverflowPointDoesNotDrop`], [`BlendFailure::NoBlendedEdgeNearExtension`] | [`ErrorKind::NotFound`] (2) | -//! | [`BlendFailure::WeldNotBuilt`] | [`ErrorKind::Unsupported`] (5): neither defect nor refusal | -//! | [`BlendFailure::KeptFeatureNotBuilt`] | its stop's kind ([`KeepStop`]): [`ErrorKind::NotFound`] (2), [`ErrorKind::Unsupported`] (5) or [`ErrorKind::Failed`] (6) | -//! | [`BlendFailure::CreaseTrimNotBuilt`] | its stop's kind ([`CreaseTrimStop`]): [`ErrorKind::NotFound`] (2), [`ErrorKind::Degenerate`] (3), [`ErrorKind::Unsupported`] (5) or [`ErrorKind::Failed`] (6) | -//! | [`BlendFailure::Trace`] | the cause's ([`TraceFailure::class`]) | -//! | the phrase causes ([`BlendFailure::Failed`], [`BlendFailure::Missing`], ...) | their status's kind, as before the record; neither defect nor refusal | +//! **Layout.** Each cause's doc names its class and the status difftest compares; the arms +//! of [`BlendFailure::class`] and `comparison_status` are the source. The enums that detail +//! a cause live in their own files under `error/blend/`. Every enum's variants and the arms +//! of every match on them are kept in name order, one arm per pattern, so changes that each +//! add a cause touch different lines unless their names fall next to each other; a test +//! checks the order. //! //! **Statuses.** Each failure also records, for difftest and the goldens only, the status //! the C++ reports for it (crate-private, read through [`crate::SolidError::sm_status`] and //! `upstream_status`); it never decides the type. The status a cause gives unless its -//! site says otherwise: +//! site says otherwise is named in its doc. //! -//! | Rust | Status difftest compares | -//! |----------------------------------------|-----------------------------------| -//! | [`BlendFailure::NoRoom`], [`BlendFailure::RemovalRefused`], [`BlendFailure::StationDidNotConverge`], [`BlendFailure::TrimLoopOpen`], [`BlendFailure::TrimLoopDoesNotSeparate`], [`BlendFailure::StageFailed`], [`BlendFailure::Defect`], [`BlendFailure::SkinPastStationCap`], [`BlendFailure::SkinMeasureNotFinite`], [`BlendFailure::BallsNest`], [`BlendFailure::CreasePieceEndUnbuildable`], [`BlendFailure::BallTriangleNotOnePatch`], [`BlendFailure::MixedCornerUnbuildable`], [`BlendFailure::CornerUnbuildable`], [`BlendFailure::PlaneCurveTouches`], [`BlendFailure::PlaneCurveEndOff`], [`BlendFailure::PlaneCurveLeavesDomain`], [`BlendFailure::PlaneCurveStepVanished`], [`BlendFailure::PlaneCurveFitCap`], [`BlendFailure::CornerPointDropUnresolved`] | `SM_ERR` | -//! | [`BlendFailure::CornerShapeNotBuilt`] | the shape's ([`CornerShape::upstream_status`]) | -//! | [`BlendFailure::Failed`], [`BlendFailure::LawIntervalEmpty`], [`BlendFailure::LawHasNoValue`], [`BlendFailure::FilletCrossesItself`], [`BlendFailure::CornerRefused`], [`BlendFailure::ExecutiveStepFailed`], [`BlendFailure::EdgeSplitDeclined`], [`BlendFailure::ExactBlendAxisCannotPlaceEdge`] | `SM_ERR` | -//! | [`BlendFailure::EaseNotBuilt`], [`BlendFailure::OverflowPointDoesNotDrop`], [`BlendFailure::ExtensionEndOnTwoSideLines`], [`BlendFailure::NoBlendedEdgeNearExtension`], [`BlendFailure::KeptFeatureNotBuilt`], [`BlendFailure::CreaseTrimNotBuilt`] | `SM_ERR` | -//! | [`BlendFailure::Missing`], [`BlendFailure::BandInputMissing`], [`BlendFailure::VariableRadiusLawsNotGiven`], [`BlendFailure::BevelVertexNotFilleted`], [`BlendFailure::EdgeWithoutCurve`], [`BlendFailure::SequenceCurveNotBSpline`], [`BlendFailure::LawCornerNotFound`], [`BlendFailure::EdgeUseWithoutEdge`], [`BlendFailure::BoundSurfaceRemoved`], [`BlendFailure::CornerPatchFaceNotFound`], [`BlendFailure::EaseInputMissing`], [`BlendFailure::EaseGeometryNotBSpline`], [`BlendFailure::OverflowInputMissing`], [`BlendFailure::FilletSetUpInvalid`] (`SM_ERR` where its site checks the link) | `SM_ERR_NULL_POINTER` | -//! | [`BlendFailure::InvalidValue`], the fillet executive's other checks of the caller's arguments | `SM_ERR_INVALID_INPUT` | -//! | [`BlendFailure::CrossingNotFinite`] | `SM_ERR` | -//! | [`BlendFailure::CrossingInputMissing`] | `SM_ERR_NULL_POINTER` | -//! | [`BlendFailure::Trace`] | the cause's, as each [`TraceFailure`] variant says | -//! | [`BlendFailure::Inconsistent`] | `SM_ERR_ASSERT_FAILURE` | -//! | [`BlendFailure::CornerInputInvalid`] | the input's ([`CornerInput::upstream_status`]) unless the site says otherwise | -//! | [`BlendFailure::BadIntersections`] | `SM_ERR_BAD_INTERSECTIONS` | -//! | [`BlendFailure::NotConverged`] | `SM_ERR_NOT_CONVERGING` | -//! | [`BlendFailure::ArcLengthNotConverged`] | `SM_ERR_NOT_CONVERGING` | -//! | [`BlendFailure::OutsideDomain`] | `SM_ERR_OUTSIDE_OF_DOMAIN` | -//! | [`BlendFailure::NotWithinTolerance`] | `SM_ERR_NOT_WITHIN_TOLERANCE` | -//! | [`BlendFailure::PassedOn`] | the status of the stage passed on | -//! | [`BlendFailure::NotCertified`] | `SM_ERR` | -//! | [`BlendFailure::SectionNotProved`], [`BlendFailure::SectionDegenerate`], [`BlendFailure::SectionUnsupported`], [`BlendFailure::RadiusLawNotPositive`], [`BlendFailure::SectionInputInvalid`] | `SM_ERR` | -//! | [`BlendFailure::Solver`] | its cause's ([`SolverFailure`]: `SM_ERR`, or `SM_ERR_NULL_POINTER` for a missing input of the caller's, a centre line with no B-spline form, a rail curve not of a B-spline class, a surface cache not built, a side surface that misses its end plane and a side edge not on the rail's face) | -//! | [`BlendFailure::WeldNotBuilt`] | `SM_ERR` | -//! -//! **The phrase causes** ([`BlendFailure::Failed`] to [`BlendFailure::PassedOn`]) are the +//! **The phrase causes** (the nine causes `phrase_causes!` lists, [`BlendFailure::Failed`] first) are the //! shape the blend sites were converted to before the record, some of them refusals not yet //! moved onto it. Each keeps the kind of its status, as before the record, and reads as //! neither a defect nor a refusal ([`BlendFailure::is_phrase`]); its phrase stays in its @@ -107,11 +50,53 @@ use super::{ SM_ERR_INVALID_INPUT, SM_ERR_NOT_CONVERGING, SM_ERR_NOT_WITHIN_TOLERANCE, SM_ERR_NULL_POINTER, SM_ERR_OUTSIDE_OF_DOMAIN, }; -use crate::blend::fillet_exact::BlendSpine; use crate::blend::fillet_executive::NoRoomReason; +mod band; +mod cliff; +mod corner; +mod crease_trim; +mod crossing; +mod ease; +mod keep; +mod law_corner; +mod no_room; +mod overflow; +mod removal; +mod section; +mod set_up; +mod solver; pub mod trace; +mod weld; + +pub use band::BandInput; +pub use cliff::CliffInput; +pub use corner::CornerInput; +pub use corner::CornerShape; +pub use corner::CornerStep; +pub use corner::MixedStep; +pub use crease_trim::CreaseTrimStop; +pub use crossing::CrossingInput; +pub use ease::EaseGeometry; +pub use ease::EaseInput; +pub use ease::EaseStop; +pub use keep::KeepStop; +pub use law_corner::LawCornerSearch; +pub use no_room::no_room_class; +pub use overflow::OverflowDrop; +pub use overflow::OverflowInput; +pub use removal::removal_class; +pub use removal::RemovalRefusal; +pub use section::SectionDegeneracy; +pub use section::SectionInput; +pub use section::SectionLimit; +pub use section::SectionProof; +pub use set_up::FilletSetUp; +pub use solver::AnalyticShape; +pub use solver::BaseSolverMethod; +pub use solver::SolverFailure; pub use trace::TraceFailure; +pub use weld::WeldGap; /// The phrase causes, by variant name: the one list [`BlendFailure::is_phrase`] and the /// phrase-site scan's test (`phrase_sites::BLEND`) read. It only shrinks, as sites move to @@ -136,88 +121,38 @@ macro_rules! matches_phrase_cause { #[derive(Debug, Clone, Copy, PartialEq)] #[non_exhaustive] pub enum BlendFailure { - /// A blend larger than its faces allow, for the reason named (classes 101 to 124, 128 - /// and 129; [`no_room_class`]). A refusal: the failure's fit, where the - /// check computed one, is the size that builds. - NoRoom(NoRoomReason), - /// The interior section did not divide the periodic blend face. Status `SM_ERR`. - ClosedCliffWouldNotSplit { - /// The blend face in the sheet being trimmed. - face: crate::topology::FaceId, - }, - /// A cliff face lacks geometry needed to trim the blend. Status `SM_ERR_NULL_POINTER`. - CliffInputMissing { - /// The face that lacks the input. - face: crate::topology::FaceId, - /// The missing geometry. - input: CliffInput, - }, - /// A fillet removal refuses the face it is asked to remove, for the reason named - /// (classes 130 and 131; [`removal_class`]). A refusal that no size decides. - RemovalRefused(RemovalRefusal), - /// The solve of the ball's position at a station of the blend did not converge: a defect, - /// never "no root" (a solve that stops proves nothing about the root). - StationDidNotConverge { - /// The station: the blend's parameter along its spine. - s: f64, - /// The residual the solve stopped at (`None` where the solve does not report it). - residual: Option, - /// The tolerance it had to reach. - tolerance: f64, - /// The last step it took (`None` where the solve does not report it). - step: Option, - /// The iterations it took (`None` where the solve does not report them). - iterations: Option, - }, - /// The boundary loop of the faces the rails enclose is open: the failure's site vertex - /// is where. A defect ([`ErrorKind::TrimLeaks`]). - TrimLoopOpen, - /// The collection of the faces the rails enclose reached past a rail (the trim leaks): - /// the failure's site face, where the check names it, is the face it reached. A defect - /// ([`ErrorKind::TrimLeaks`]). - TrimLoopDoesNotSeparate, - /// A stage of the blend failed with no reason the kernel names: a defect. The failure - /// holds the operation, the status (for the goldens only) and where in solidcore's source - /// it was built ([`Failure::origin`]). The form not yet reviewed: new code builds - /// [`BlendFailure::Defect`], a named cause or a refusal instead. - StageFailed, - /// A failure that is the kernel's fault, reviewed at its site, with the written reason: - /// `why` names the step that failed and why that is the kernel's fault, not the - /// geometry's. A defect ([`ErrorKind::StageFailed`]); status `SM_ERR` unless its site - /// says otherwise. - Defect { - /// The step that failed, and why that is the kernel's fault. - why: &'static str, - }, - /// A variable round's skin of balls' touch circles was still measured farther than - /// `asked` from its balls when its refinement reached its most rounds or stations - /// (#15256): the worst distance measured was `reached` (infinite where a span's section - /// could not be placed on the skin to be measured), with `stations` stations after - /// `rounds` rounds. Not within the tolerance ([`ErrorKind::NotWithinTolerance`]): no - /// tolerance is loosened and the skin is not kept. - SkinPastStationCap { - /// The tolerance asked: the solver's approximation tolerance. - asked: f64, - /// The largest distance measured from the skin to its balls at the cap. - reached: f64, - /// The stations the skin had at the cap. - stations: usize, - /// The refinement rounds run. - rounds: usize, + /// The search for the parameter `length` along a curve from parameter `start` stopped + /// at parameter `stopped_at`: its Newton iteration stopped moving before the length + /// was reached (a length past the curve's end is no failure). Not converged + /// ([`ErrorKind::NotConverged`]); status `SM_ERR_NOT_CONVERGING`, as upstream's + /// `FindParameterAtArcLength` reports it. + ArcLengthNotConverged { + /// The parameter the search starts from. + start: f64, + /// The arc length asked (negative: towards the curve's start). + length: f64, + /// The parameter where the iteration stopped. + stopped_at: f64, }, - /// A quantity a variable round's skin check computes (a distance from the skin to its - /// balls, or the balls' radius rate and centre speed at a section) was still not a finite - /// number, last at the section at `s` along the trace, when the refinement reached its - /// most rounds or stations (#15256): a defect ([`ErrorKind::StageFailed`]). A value that - /// is not finite before the cap splits its span instead. - SkinMeasureNotFinite { - /// The section's parameter along the trace. - s: f64, + /// Intersections the routine needs are not usable, as the phrase says (for example "the + /// two surfaces meet in more than two points"); upstream `SM_ERR_BAD_INTERSECTIONS`. A + /// phrase cause ([`BlendFailure::is_phrase`]). + BadIntersections(&'static str), + /// The ball corner's triangle between its three contacts is not one rational patch + /// from the pole tried: the far side's image under the stereographic projection is + /// not one arc of under a half turn (the triangle is too large, or a contact lies at + /// the pole's antipode), or a weight of the patch's net is not positive. Unsupported + /// ([`ErrorKind::Unsupported`]): the corner's geometry, not the kernel's fault; a + /// triangle too large for one patch is fanned into three. + BallTriangleNotOnePatch { + /// The contact the patch's pole was put at. + pole: usize, }, /// At the section at `s` along the trace a variable round's balls change their radius at /// least as fast as their centres move (`|r'| = rate >= |c'| = speed`): each ball holds /// the next, so no rolling-ball surface exists there (#15256). A refusal /// ([`ErrorKind::BallsFold`]). + /// Status `SM_ERR`. BallsNest { /// The section's parameter along the trace. s: f64, @@ -226,38 +161,48 @@ pub enum BlendFailure { /// `|c'|`: how fast the balls' centres move along the trace. speed: f64, }, - /// The crease trim (#17673) has no construction to end a crease piece of curve kind - /// `kind` exactly on the meet at its start or end (`at_end`), at parameter `t` of the - /// crease: a curve with no control polygon (an offset, projected, composite, ... - /// curve). Unsupported - /// ([`ErrorKind::Unsupported`]): never a piece left ending short of its meet. - CreasePieceEndUnbuildable { - /// The piece's curve kind. - kind: &'static str, - /// True for the piece's end, false for its start. - at_end: bool, - /// The end's parameter on the crease. - t: f64, + /// An input the planar-band contact query reads is not there (a support, an edge use, an + /// offset, a foot of a drop, ...): the input named. Status `SM_ERR_NULL_POINTER` and the + /// kind of that status ([`ErrorKind::Missing`]), as the phrase cause it replaces; typed, + /// so not a phrase cause ([`BlendFailure::is_phrase`]). + BandInputMissing(BandInput), + /// A vertex given to bevel is not a vertex of the filleted edges. A check of the + /// caller's arguments ([`ErrorKind::InvalidInput`]); status `SM_ERR_NULL_POINTER` + /// (upstream `NER` of its corner). + BevelVertexNotFilleted, + /// A surface binding of the fillet insertion is resolved after its face's surface was + /// removed: a stale binding the caller kept past an edit of the body; the failure is at + /// the face. A check of the caller's input ([`ErrorKind::InvalidInput`]); status + /// `SM_ERR_NULL_POINTER`. + BoundSurfaceRemoved, + /// The face named for a chamfer's first size is neither of its edge's two faces; the + /// failure is at the edge. A check of the caller's arguments + /// ([`ErrorKind::InvalidInput`]); status `SM_ERR_INVALID_INPUT`. + ChamferFaceNotOfEdge, + /// The chamfer size given for an edge is not one it can take: a distance, chord or angle + /// that is not finite and positive, setbacks at the edge's wedge that are not finite and + /// positive (an angle so small the second underflows to 0), distances that fold at the + /// wedge (each must be more than the other's cosine of it), any size where the edge's + /// faces make no wedge (tangent or folded back), or on a knife edge any size but two + /// equal distances; the failure is at the edge. An angle past the room a wedge leaves + /// is [`crate::blend::blend_refusal::BlendRefusal::ChamferAngleTooLarge`] instead. A + /// check of the caller's arguments ([`ErrorKind::InvalidInput`]); status + /// `SM_ERR_INVALID_INPUT`. + ChamferSizeInvalid, + /// A cliff face lacks geometry needed to trim the blend. Status `SM_ERR_NULL_POINTER`. + /// Its class is [`ErrorKind::Missing`]. + CliffInputMissing { + /// The face that lacks the input. + face: crate::topology::FaceId, + /// The missing geometry. + input: CliffInput, }, - /// The ball corner's triangle between its three contacts is not one rational patch - /// from the pole tried: the far side's image under the stereographic projection is - /// not one arc of under a half turn (the triangle is too large, or a contact lies at - /// the pole's antipode), or a weight of the patch's net is not positive. Unsupported - /// ([`ErrorKind::Unsupported`]): the corner's geometry, not the kernel's fault; a - /// triangle too large for one patch is fanned into three. - BallTriangleNotOnePatch { - /// The contact the patch's pole was put at. - pole: usize, + /// The interior section did not divide the periodic blend face. Status `SM_ERR`. + /// Its class is [`ErrorKind::Failed`]. + ClosedCliffWouldNotSplit { + /// The blend face in the sheet being trimmed. + face: crate::topology::FaceId, }, - /// The Mixed corner (a convex and a concave blend meeting at a tangent seam) has no - /// construction for its geometry at the step named: a crossing its construction needs - /// is not there, its shape is degenerate there, or the shape is one the construction - /// does not build. The step's class ([`MixedStep::class`]); status `SM_ERR`. - MixedCornerUnbuildable(MixedStep), - /// A ball or chamfer corner has no construction at the step named: a solve that ends - /// within rounding found or proved nothing, or the geometry is one the construction - /// does not build. The step's class ([`CornerStep::class`]); status `SM_ERR`. - CornerUnbuildable(CornerStep), /// A fillet corner step is given a corner, or a pseudo-B-rep, that is not as the corner /// topology makes it: `input` names what it lacks or holds otherwise, `entity` the /// entity it is about (of the pseudo-B-rep, of the target body, or the corner's vertex) @@ -272,120 +217,92 @@ pub enum BlendFailure { /// The entity it is about, where the step has one. entity: Option, }, - /// A link of the fillet structures a routine is given (the fillet body, its corners and - /// solvers) is not there, or not as the routine needs: the link named. The caller's - /// input ([`ErrorKind::InvalidInput`]): a caller can build those structures with the - /// public API and leave the link out; status `SM_ERR_NULL_POINTER` where upstream - /// dereferences the link, `SM_ERR` where it checks it. - FilletSetUpInvalid(FilletSetUp), - /// Tracing a surface/plane crossing found a station where the surface touches the - /// plane: its tangent along the crossing has no length, so the crossing has no direction. - /// Degenerate ([`ErrorKind::Degenerate`]); status `SM_ERR`. - PlaneCurveTouches { - /// The station's surface parameter u. - u: f64, - /// The station's surface parameter v. - v: f64, - }, - /// An end given to a surface/plane crossing could not be put on the crossing within - /// tolerance. An empty search ([`ErrorKind::NotFound`]); status `SM_ERR`. - PlaneCurveEndOff { - /// True for the crossing's end, false for its start. - at_end: bool, - /// The larger of the distance from the given end to the crossing point found and - /// its distance to the plane; `None` when the drop or projection found no point. - distance: Option, + /// A corner patch surface has no live face in the intermediate body: building the face + /// on that surface gave none, or it is gone. An empty search ([`ErrorKind::NotFound`]): + /// neither a defect nor a refusal; status `SM_ERR_NULL_POINTER` (the fork's `NER` of + /// `GetPatchFaces`). + CornerPatchFaceNotFound { + /// The surface's index among the corner's patch surfaces. + surface: usize, }, - /// The crossing's trace leaves the surface's parameter domain in a direction it is not - /// closed in, before reaching its end. Outside the domain ([`ErrorKind::OutsideDomain`]); - /// status `SM_ERR`. - PlaneCurveLeavesDomain { - /// The station's surface parameter u. - u: f64, - /// The station's surface parameter v. - v: f64, + /// The drop of a degenerate corner's vertex onto one of its blend's base surfaces found + /// `solutions` points, not one, and the side of a periodic seam the face's trim lies on + /// does not pick one of them: no single foot to end the rails at. An empty search + /// ([`ErrorKind::NotFound`]); status `SM_ERR`. + CornerPointDropUnresolved { + /// The points the drop found. + solutions: usize, }, - /// A surface/plane trace's step was halved below its minimum at a station without a - /// step being accepted: the march stopped. A defect ([`ErrorKind::StageFailed`]); - /// status `SM_ERR`. - PlaneCurveStepVanished { - /// The last accepted station's surface parameter u. - u: f64, - /// The last accepted station's surface parameter v. - v: f64, - /// The step after halving. - step: f64, - /// The minimum step allowed. - minimum: f64, + /// A corner of the fillet was refused at its vertex (the fork's `bRefused`): the + /// executive's error info holds the corner's error, comment and the size that builds. + /// [`ErrorKind::Failed`], neither a defect nor a refusal on its own; status `SM_ERR`. + CornerRefused, + /// A fillet corner whose edges meet in a shape the corner topology does not build: the + /// shape named. Unsupported ([`ErrorKind::Unsupported`]), a fact of the body's edges at + /// the vertex; status that of the site it replaces ([`CornerShape::upstream_status`]). + CornerShapeNotBuilt(CornerShape), + /// A ball or chamfer corner has no construction at the step named: a solve that ends + /// within rounding found or proved nothing, or the geometry is one the construction + /// does not build. The step's class ([`CornerStep::class`]); status `SM_ERR`. + CornerUnbuildable(CornerStep), + /// The crease trim (#17673) has no construction to end a crease piece of curve kind + /// `kind` exactly on the meet at its start or end (`at_end`), at parameter `t` of the + /// crease: a curve with no control polygon (an offset, projected, composite, ... + /// curve). Unsupported + /// ([`ErrorKind::Unsupported`]): never a piece left ending short of its meet. + /// Status `SM_ERR`. + CreasePieceEndUnbuildable { + /// The piece's curve kind. + kind: &'static str, + /// True for the piece's end, false for its start. + at_end: bool, + /// The end's parameter on the crease. + t: f64, }, - /// The crossing's Hermite fit still has spans farther than a tenth of the tolerance - /// from the exact curve when its station cap or its 20 refinement passes ran out, or - /// when a pass found no point to split any of them at. - /// Not within tolerance ([`ErrorKind::NotWithinTolerance`]); status `SM_ERR`. - PlaneCurveFitCap { - /// The stations held when fitting stopped. - stations: usize, - /// The refinement passes completed. - passes: usize, - }, - /// The fillet is given no edges, or the executive asked to preview its fillet holds no - /// solver (no edge was set up). A check of the caller's arguments - /// ([`ErrorKind::InvalidInput`]); status `SM_ERR_INVALID_INPUT` (`SM_ERR` for the - /// preview). - NoEdgesGiven, - /// A fillet size (a radius, a chamfer's distance, or a setback a chamfer's angle or - /// chord gives at its edge's wedge) is below eight times the body's - /// tolerance, the smallest the fillet builds. A check of the caller's arguments - /// ([`ErrorKind::InvalidInput`]); status `SM_ERR_INVALID_INPUT`. - SizeBelowResolution { - /// The size given. - size: f64, - /// The body's tolerance. - tolerance: f64, - }, - /// A list that takes one entry per edge holds `given` entries for `edges` edges. A - /// check of the caller's arguments ([`ErrorKind::InvalidInput`]); status - /// `SM_ERR_INVALID_INPUT`. - PerEdgeListLength { - /// The edges to fillet. - edges: usize, - /// The entries the list holds. - given: usize, - }, - /// A list of the fillet's parameters (cross-section types, radius types, radii) holds - /// neither one entry nor one per edge. A check of the caller's arguments + /// A blend trimmed at its creases (the fork's `TrimAtCreases`, the bound of its open ends + /// included) is not built for a reason with no blend-too-large reason + /// ([`CreaseTrimStop`] says why, and gives the kind). The executive notes the refusal in + /// its error info as well; status `SM_ERR`. + CreaseTrimNotBuilt(CreaseTrimStop), + /// A cross-section type is given as unknown. A check of the caller's arguments /// ([`ErrorKind::InvalidInput`]); status `SM_ERR_INVALID_INPUT`. - ParameterListSizes { - /// The edges to fillet. - edges: usize, - /// The cross-section types given. - cross_sections: usize, - /// The radius types given. - radius_types: usize, - /// The radii given. - radii: usize, - }, - /// A face given to a surface fillet, or a face of the caller's body a fillet reads, has - /// no surface; the failure is at the face. A check of the caller's arguments and body - /// ([`ErrorKind::InvalidInput`]); status `SM_ERR_INVALID_INPUT` (`SM_ERR_NULL_POINTER` - /// where a stage reads the surface unchecked, upstream `NER`, and `SM_ERR` where the - /// fork's tangent roll-over returns that). - FaceHasNoSurface, - /// A surface fillet is given a face of the first surface's body where the first surface - /// has none (it is itself that face, or a free surface). A check of the caller's - /// arguments ([`ErrorKind::InvalidInput`]); status `SM_ERR_INVALID_INPUT`. - NoFirstBody, - /// The fillet executive is given no target body, or is run before one is set. A check - /// of the caller's arguments ([`ErrorKind::InvalidInput`]); status - /// `SM_ERR_INVALID_INPUT` (`SM_ERR_NULL_POINTER` where a stage finds it unset). - TargetNotGiven, - /// The edge at `index` of the edges given is not a live edge of the target body. A check - /// of the caller's arguments ([`ErrorKind::InvalidInput`]); status - /// `SM_ERR_INVALID_INPUT`. - EdgeNotInTarget { - /// The edge's index in the edges given. - index: usize, + CrossSectionTypeUnknown, + /// An input a rail's crossing of an edge is judged from is not there (the crossing's + /// budget, an edge use's radial, the side edge's curve, the crossing's place on it): the + /// input named. Status `SM_ERR_NULL_POINTER` and the kind of that status + /// ([`ErrorKind::Missing`]); typed, so not a phrase cause ([`BlendFailure::is_phrase`]). + CrossingInputMissing(CrossingInput), + /// What a rail's crossing of an edge is judged from (a face normal or binormal at the + /// crossing) was not a finite number, so the crossing is neither classed concave nor + /// convex (#17016). A defect ([`ErrorKind::StageFailed`]), status `SM_ERR`. + CrossingNotFinite, + /// A failure that is the kernel's fault, reviewed at its site, with the written reason: + /// `why` names the step that failed and why that is the kernel's fault, not the + /// geometry's. A defect ([`ErrorKind::StageFailed`]); status `SM_ERR` unless its site + /// says otherwise. + Defect { + /// The step that failed, and why that is the kernel's fault. + why: &'static str, }, + /// A curve or surface the ease of a round before a setback blends has no B-spline form + /// (the fork's `SM_CAST_PTR(SmBSplineSurface/Curve, ..)`; [`EaseGeometry`] says which). + /// A kind the ease does not build on ([`ErrorKind::Unsupported`]); status + /// `SM_ERR_NULL_POINTER` (upstream `NER` of the cast). + EaseGeometryNotBSpline(EaseGeometry), + /// A thing the ease of a round before a setback reads lacks the input named + /// ([`EaseInput`]: a corner's vertex, a round's solver, rail, surface or centre line, a + /// solver's offset surface, a face's surface, an edge's curve or an edge use's face). The + /// ease reads the caller's body and the rounds of the solvers a caller adds and drives + /// through the session's own steps (`FilletSession::new_constant_radius_solver`, + /// `load_solver`, `calc_solver_geometry`, `create_fillet_brep`) alike, so the cause names + /// what is missing and leaves the blame open, as [`BlendFailure::CliffInputMissing`] + /// does: status + /// `SM_ERR_NULL_POINTER` (upstream `NER`) and the kind of that status + /// ([`ErrorKind::Missing`]), neither a defect nor a refusal. + EaseInputMissing(EaseInput), + /// The ease of a round before a setback stops where the geometry gives it nothing to + /// build on ([`EaseStop`] says which, and gives the kind); status `SM_ERR`. + EaseNotBuilt(EaseStop), /// The edge at `index` of the edges given has no edge use the fillet can roll on (it /// does not lie between two faces it can blend). A check of the caller's arguments /// ([`ErrorKind::InvalidInput`]); status `SM_ERR_INVALID_INPUT`. @@ -393,66 +310,26 @@ pub enum BlendFailure { /// The edge's index in the edges given. index: usize, }, - /// The chamfer size given for an edge is not one it can take: a distance, chord or angle - /// that is not finite and positive, setbacks at the edge's wedge that are not finite and - /// positive (an angle so small the second underflows to 0), distances that fold at the - /// wedge (each must be more than the other's cosine of it), any size where the edge's - /// faces make no wedge (tangent or folded back), or on a knife edge any size but two - /// equal distances; the failure is at the edge. An angle past the room a wedge leaves - /// is [`crate::blend::blend_refusal::BlendRefusal::ChamferAngleTooLarge`] instead. A - /// check of the caller's arguments ([`ErrorKind::InvalidInput`]); status - /// `SM_ERR_INVALID_INPUT`. - ChamferSizeInvalid, - /// The face named for a chamfer's first size is neither of its edge's two faces; the - /// failure is at the edge. A check of the caller's arguments - /// ([`ErrorKind::InvalidInput`]); status `SM_ERR_INVALID_INPUT`. - ChamferFaceNotOfEdge, - /// The face a ball is asked to touch is named by an index past a fillet solver's two - /// faces, first (0) and second (1). A check of the caller's arguments - /// ([`ErrorKind::InvalidInput`]); status `SM_ERR_INVALID_INPUT`. - SolverFaceIndexInvalid { - /// The face index given. - index: usize, - }, - /// A G^n cross-section is asked with an order outside 2 to 4, or a thumbweight of 1 or - /// more. A check of the caller's arguments ([`ErrorKind::InvalidInput`]); status + /// The edge at `index` of the edges given is not a live edge of the target body. A check + /// of the caller's arguments ([`ErrorKind::InvalidInput`]); status /// `SM_ERR_INVALID_INPUT`. - GnSectionInvalid { - /// The continuity order asked. - order: usize, - /// The thumbweight asked. - thumbweight: f64, - }, - /// A cross-section type is given as unknown. A check of the caller's arguments - /// ([`ErrorKind::InvalidInput`]); status `SM_ERR_INVALID_INPUT`. - CrossSectionTypeUnknown, - /// The radius type of the edge at `index` is not one an edge's fillet is set up with - /// (a constant radius, a constant distance or a variable radius). A check of the - /// caller's arguments ([`ErrorKind::InvalidInput`]); status `SM_ERR_INVALID_INPUT`. - RadiusTypeNotForEdges { + EdgeNotInTarget { /// The edge's index in the edges given. index: usize, - /// The radius type given. - kind: crate::blend::fillet_solver::p1::FilletSolverType, }, - /// A variable radius is asked and no list of radius laws is given. A check of the - /// caller's arguments ([`ErrorKind::InvalidInput`]); status `SM_ERR_NULL_POINTER` - /// (upstream dereferences the list). - VariableRadiusLawsNotGiven, - /// The edge at `index` of the edges given has a variable radius and no radius law. A - /// check of the caller's arguments ([`ErrorKind::InvalidInput`]); status - /// `SM_ERR_INVALID_INPUT`. - VariableRadiusLawMissing { - /// The edge's index in the edges given. - index: usize, + /// The fillet insertion's split of an edge at `parameter` is declined by the native split + /// (`MakeVertexSplitEdge`'s `SM_ERR`): the parameter lies outside the edge or within an + /// end vertex's tolerance of an end, or the body is not open for edits. The intersector + /// that asks for the split passes over a failed one. Neither a defect nor a refusal + /// ([`ErrorKind::Failed`]); status `SM_ERR`. + EdgeSplitDeclined { + /// The edge parameter the split was asked at. + parameter: f64, }, - /// A vertex given to bevel is not a vertex of the filleted edges. A check of the - /// caller's arguments ([`ErrorKind::InvalidInput`]); status `SM_ERR_NULL_POINTER` - /// (upstream `NER` of its corner). - BevelVertexNotFilleted, - /// A radius law is evaluated over an interval of zero length. A check of the caller's - /// arguments ([`ErrorKind::InvalidInput`]); status `SM_ERR`. - LawIntervalEmpty, + /// An edge use of the caller's body a fillet reads (the first edge use of a solver the + /// caller set up) has no edge; the failure is at the edge use. A check of the caller's + /// input ([`ErrorKind::InvalidInput`]); status `SM_ERR_NULL_POINTER`. + EdgeUseWithoutEdge, /// An edge of the caller's body a fillet reads (one a smooth sequence of filleted edges /// joins, a filleted edge, an edge of a face it crosses) has no curve; the failure is at /// the edge. A check of the caller's body ([`ErrorKind::InvalidInput`]); status @@ -477,145 +354,113 @@ pub enum BlendFailure { /// the crossing was computed; not positive: behind the axis. crossing: Option, }, - /// A base radius law, which has no value of its own, is evaluated. Unsupported - /// ([`ErrorKind::Unsupported`]); status `SM_ERR`. - LawHasNoValue, - /// An edge's curve of kind `kind`, in a smooth sequence of filleted edges, has no - /// B-spline form to join; the failure is at the edge. Unsupported - /// ([`ErrorKind::Unsupported`]); status `SM_ERR_NULL_POINTER` (upstream `NER` of the - /// cast). - SequenceCurveNotBSpline { - /// The curve's kind. - kind: &'static str, - }, - /// A surface/surface fillet's offset surfaces meet in more than one curve, and the - /// curves at `first` and `second` of the intersection cross: the fillet would cross - /// itself, which it does not build. Unsupported ([`ErrorKind::Unsupported`]); status - /// `SM_ERR`. - FilletCrossesItself { - /// The first curve's index in the intersection. - first: usize, - /// The second curve's index in the intersection. - second: usize, - }, - /// A corner of the fillet was refused at its vertex (the fork's `bRefused`): the - /// executive's error info holds the corner's error, comment and the size that builds. - /// [`ErrorKind::Failed`], neither a defect nor a refusal on its own; status `SM_ERR`. - CornerRefused, /// A step of the fillet executive failed (`FILEXEC_ERR`): the executive's error info /// says which (its code and comment, and for a blend too large its reason and the size /// that builds), and the error of the stage that failed, where there is one, is kept as /// the cause. [`ErrorKind::Failed`], neither a defect nor a refusal on its own, so the /// kept cause decides ([`crate::SolidError::is_defect`]); status `SM_ERR`. ExecutiveStepFailed, - /// A thing the ease of a round before a setback reads lacks the input named - /// ([`EaseInput`]: a corner's vertex, a round's solver, rail, surface or centre line, a - /// solver's offset surface, a face's surface, an edge's curve or an edge use's face). The - /// ease reads the caller's body and the rounds of the solvers a caller adds and drives - /// through the session's own steps (`FilletSession::new_constant_radius_solver`, - /// `load_solver`, `calc_solver_geometry`, `create_fillet_brep`) alike, so the cause names - /// what is missing and leaves the blame open, as [`BlendFailure::CliffInputMissing`] - /// does: status - /// `SM_ERR_NULL_POINTER` (upstream `NER`) and the kind of that status - /// ([`ErrorKind::Missing`]), neither a defect nor a refusal. - EaseInputMissing(EaseInput), - /// The ease of a round before a setback stops where the geometry gives it nothing to - /// build on ([`EaseStop`] says which, and gives the kind); status `SM_ERR`. - EaseNotBuilt(EaseStop), - /// A curve or surface the ease of a round before a setback blends has no B-spline form - /// (the fork's `SM_CAST_PTR(SmBSplineSurface/Curve, ..)`; [`EaseGeometry`] says which). - /// A kind the ease does not build on ([`ErrorKind::Unsupported`]); status - /// `SM_ERR_NULL_POINTER` (upstream `NER` of the cast). - EaseGeometryNotBSpline(EaseGeometry), - /// The search for the parameter `length` along a curve from parameter `start` stopped - /// at parameter `stopped_at`: its Newton iteration stopped moving before the length - /// was reached (a length past the curve's end is no failure). Not converged - /// ([`ErrorKind::NotConverged`]); status `SM_ERR_NOT_CONVERGING`, as upstream's - /// `FindParameterAtArcLength` reports it. - ArcLengthNotConverged { - /// The parameter the search starts from. - start: f64, - /// The arc length asked (negative: towards the curve's start). - length: f64, - /// The parameter where the iteration stopped. - stopped_at: f64, - }, - /// The fillet trace failed, for the reason the [`TraceFailure`] names: the standard and - /// custom fillet solvers, the fillet intersector and the law corners. Its class and - /// status are the cause's ([`TraceFailure::class`]). - Trace(TraceFailure), - /// A face or edge a blend's overflow reads lacks the input named (a face's surface, an - /// edge's curve or one of its vertices). The overflows' helpers, which the trims at - /// creases and the kept features share, read the caller's body and the sheet the - /// executive built alike, so the failure names no entity, and the cause - /// names what is missing and leaves the blame open, as [`BlendFailure::CliffInputMissing`] - /// does: status `SM_ERR_NULL_POINTER` (upstream `NER`) and the kind of that status - /// ([`ErrorKind::Missing`]), neither a defect nor a refusal. - OverflowInputMissing(OverflowInput), - /// A point of the cliff overflow does not drop onto the geometry named - /// ([`OverflowDrop`]): the closest-point search found no foot (within ten tolerances, for - /// an edge's curve). An empty search ([`ErrorKind::NotFound`]); status `SM_ERR`. - OverflowPointDoesNotDrop(OverflowDrop), /// The end of a kept rail's run past a face's boundary lies on the lines of two side /// edges of the face (straight edges that are not blended), and the extension joins the /// end to one side line only. A construction the overflow /// does not build ([`ErrorKind::Unsupported`]); status `SM_ERR`. ExtensionEndOnTwoSideLines, - /// No blended edge's curve takes the drop of the middle of an extension's chain, so the - /// side the blend takes off from is not known. An empty search ([`ErrorKind::NotFound`]); - /// status `SM_ERR`. - NoBlendedEdgeNearExtension, - /// A round kept round a feature standing in its band (the fork's `KeepFeaturesInBands`) - /// is not built ([`KeepStop`] says why, and gives the kind). The executive notes the - /// refusal in its error info as well; status `SM_ERR`. - KeptFeatureNotBuilt(KeepStop), - /// A blend trimmed at its creases (the fork's `TrimAtCreases`, the bound of its open ends - /// included) is not built for a reason with no blend-too-large reason - /// ([`CreaseTrimStop`] says why, and gives the kind). The executive notes the refusal in - /// its error info as well; status `SM_ERR`. - CreaseTrimNotBuilt(CreaseTrimStop), - /// The routine could not continue, as the phrase says (for example "the fillet's law + /// A face given to a surface fillet, or a face of the caller's body a fillet reads, has + /// no surface; the failure is at the face. A check of the caller's arguments and body + /// ([`ErrorKind::InvalidInput`]); status `SM_ERR_INVALID_INPUT` (`SM_ERR_NULL_POINTER` + /// where a stage reads the surface unchecked, upstream `NER`, and `SM_ERR` where the + /// fork's tangent roll-over returns that). + FaceHasNoSurface, + /// The routine could not continue, as the phrase says (for example "the fillet's law /// has no value at the base"). Upstream `return SE(SM_ERR)`. A phrase cause /// ([`BlendFailure::is_phrase`]). Failed(&'static str), - /// Something the routine needs is missing, as the phrase says (for example "the edge - /// use's edge"). Upstream `NER(ptr)` on a `NULL` pointer, or a `NULL` it would - /// dereference. A phrase cause ([`BlendFailure::is_phrase`]). - Missing(&'static str), + /// A surface/surface fillet's offset surfaces meet in more than one curve, and the + /// curves at `first` and `second` of the intersection cross: the fillet would cross + /// itself, which it does not build. Unsupported ([`ErrorKind::Unsupported`]); status + /// `SM_ERR`. + FilletCrossesItself { + /// The first curve's index in the intersection. + first: usize, + /// The second curve's index in the intersection. + second: usize, + }, + /// A link of the fillet structures a routine is given (the fillet body, its corners and + /// solvers) is not there, or not as the routine needs: the link named. The caller's + /// input ([`ErrorKind::InvalidInput`]): a caller can build those structures with the + /// public API and leave the link out; status `SM_ERR_NULL_POINTER` where upstream + /// dereferences the link, `SM_ERR` where it checks it. + FilletSetUpInvalid(FilletSetUp), + /// A G^n cross-section is asked with an order outside 2 to 4, or a thumbweight of 1 or + /// more. A check of the caller's arguments ([`ErrorKind::InvalidInput`]); status + /// `SM_ERR_INVALID_INPUT`. + GnSectionInvalid { + /// The continuity order asked. + order: usize, + /// The thumbweight asked. + thumbweight: f64, + }, + /// A consistency check of the routine's own data did not hold, as the phrase says + /// (upstream `AERN`, `SM_ERR_ASSERT_FAILURE`). A phrase cause + /// ([`BlendFailure::is_phrase`]). + Inconsistent(&'static str), /// A value the routine is given or computes with is not usable, as the phrase says /// (for example "a G^n section's order"). Upstream returns `SM_ERR_INVALID_INPUT` as a /// status here, so its kind is [`ErrorKind::InvalidInput`]. A phrase cause /// ([`BlendFailure::is_phrase`]); an argument check is [`crate::SolidError::InvalidInput`]. InvalidValue(&'static str), - /// A consistency check of the routine's own data did not hold, as the phrase says - /// (upstream `AERN`, `SM_ERR_ASSERT_FAILURE`). A phrase cause - /// ([`BlendFailure::is_phrase`]). - Inconsistent(&'static str), - /// Intersections the routine needs are not usable, as the phrase says (for example "the - /// two surfaces meet in more than two points"); upstream `SM_ERR_BAD_INTERSECTIONS`. A - /// phrase cause ([`BlendFailure::is_phrase`]). - BadIntersections(&'static str), - /// An iteration did not converge, as the phrase says; upstream - /// `SM_ERR_NOT_CONVERGING`. A phrase cause ([`BlendFailure::is_phrase`]). - NotConverged(&'static str), - /// A parameter lies outside its domain, as the phrase says; upstream - /// `SM_ERR_OUTSIDE_OF_DOMAIN`. A phrase cause ([`BlendFailure::is_phrase`]). - OutsideDomain(&'static str), - /// A result is farther than the tolerance from where it must be, as the phrase says; - /// upstream `SM_ERR_NOT_WITHIN_TOLERANCE`. A phrase cause - /// ([`BlendFailure::is_phrase`]). - NotWithinTolerance(&'static str), - /// A stage the routine calls failed, as the phrase says, and the routine answers with - /// that stage's `status` (upstream `SER` of the stage's status, or a status chosen at - /// run time). The stage's error is not kept as a cause: it may be a solidcore-side - /// failure, which the bare status it replaces did not carry. A phrase cause - /// ([`BlendFailure::is_phrase`]). - PassedOn { - /// What failed. - what: &'static str, - /// The status the routine answers with (a comparison detail). - status: i32, + /// A round kept round a feature standing in its band (the fork's `KeepFeaturesInBands`) + /// is not built ([`KeepStop`] says why, and gives the kind). The executive notes the + /// refusal in its error info as well; status `SM_ERR`. + KeptFeatureNotBuilt(KeepStop), + /// A search the exact round at a radius law's corner makes finds nothing: the + /// [`LawCornerSearch`] `what`, at the corner at index `corner` of the round's law corners. + /// An empty search ([`ErrorKind::NotFound`]): neither a defect nor a refusal; status + /// `SM_ERR_NULL_POINTER` (the fork's `NER` of the search's result). + LawCornerNotFound { + /// The corner's index among the round's law corners. + corner: usize, + /// What the search looked for. + what: LawCornerSearch, }, + /// A base radius law, which has no value of its own, is evaluated. Unsupported + /// ([`ErrorKind::Unsupported`]); status `SM_ERR`. + LawHasNoValue, + /// A radius law is evaluated over an interval of zero length. A check of the caller's + /// arguments ([`ErrorKind::InvalidInput`]); status `SM_ERR`. + LawIntervalEmpty, + /// Something the routine needs is missing, as the phrase says (for example "the edge + /// use's edge"). Upstream `NER(ptr)` on a `NULL` pointer, or a `NULL` it would + /// dereference. A phrase cause ([`BlendFailure::is_phrase`]). + /// Status `SM_ERR_NULL_POINTER`. + Missing(&'static str), + /// The Mixed corner (a convex and a concave blend meeting at a tangent seam) has no + /// construction for its geometry at the step named: a crossing its construction needs + /// is not there, its shape is degenerate there, or the shape is one the construction + /// does not build. The step's class ([`MixedStep::class`]); status `SM_ERR`. + MixedCornerUnbuildable(MixedStep), + /// No blended edge's curve takes the drop of the middle of an extension's chain, so the + /// side the blend takes off from is not known. An empty search ([`ErrorKind::NotFound`]); + /// status `SM_ERR`. + NoBlendedEdgeNearExtension, + /// The fillet is given no edges, or the executive asked to preview its fillet holds no + /// solver (no edge was set up). A check of the caller's arguments + /// ([`ErrorKind::InvalidInput`]); status `SM_ERR_INVALID_INPUT` (`SM_ERR` for the + /// preview). + NoEdgesGiven, + /// A surface fillet is given a face of the first surface's body where the first surface + /// has none (it is itself that face, or a free surface). A check of the caller's + /// arguments ([`ErrorKind::InvalidInput`]); status `SM_ERR_INVALID_INPUT`. + NoFirstBody, + /// A blend larger than its faces allow, for the reason named (classes 100 to 124, 128 + /// and 129; [`no_room_class`]): [`ErrorKind::FilletTooLarge`] (100) for a weld bead + /// larger than its faces take ([`NoRoomReason::BeadCutsFace`], + /// [`NoRoomReason::LegPastFace`], [`NoRoomReason::NoToeAtLeg`]). A refusal, but for + /// [`NoRoomReason::CliffSubtractionLeavesNoSolid`], a defect + /// ([`ErrorKind::CliffSubtractionLeavesNoSolid`]): the failure's fit, where the check + /// computed one, is the size that builds. + /// Status `SM_ERR`. + NoRoom(NoRoomReason), /// A blend surface not certified within its tolerance in the work its certificate is /// allowed: the G^n section's certificate would halve spans past its budget /// ([`crate::blend::fillet_section::section::GN_HALVING_BUDGET`]), or has more stations @@ -634,2208 +479,464 @@ pub enum BlendFailure { /// The certificate's stations when it was refused. stations: usize, }, - /// An input the planar-band contact query reads is not there (a support, an edge use, an - /// offset, a foot of a drop, ...): the input named. Status `SM_ERR_NULL_POINTER` and the - /// kind of that status ([`ErrorKind::Missing`]), as the phrase cause it replaces; typed, - /// so not a phrase cause ([`BlendFailure::is_phrase`]). - BandInputMissing(BandInput), - /// The fillet insertion's split of an edge at `parameter` is declined by the native split - /// (`MakeVertexSplitEdge`'s `SM_ERR`): the parameter lies outside the edge or within an - /// end vertex's tolerance of an end, or the body is not open for edits. The intersector - /// that asks for the split passes over a failed one. Neither a defect nor a refusal - /// ([`ErrorKind::Failed`]); status `SM_ERR`. - EdgeSplitDeclined { - /// The edge parameter the split was asked at. - parameter: f64, + /// An iteration did not converge, as the phrase says; upstream + /// `SM_ERR_NOT_CONVERGING`. A phrase cause ([`BlendFailure::is_phrase`]). + NotConverged(&'static str), + /// A result is farther than the tolerance from where it must be, as the phrase says; + /// upstream `SM_ERR_NOT_WITHIN_TOLERANCE`. A phrase cause + /// ([`BlendFailure::is_phrase`]). + NotWithinTolerance(&'static str), + /// A parameter lies outside its domain, as the phrase says; upstream + /// `SM_ERR_OUTSIDE_OF_DOMAIN`. A phrase cause ([`BlendFailure::is_phrase`]). + OutsideDomain(&'static str), + /// A face or edge a blend's overflow reads lacks the input named (a face's surface, an + /// edge's curve or one of its vertices). The overflows' helpers, which the trims at + /// creases and the kept features share, read the caller's body and the sheet the + /// executive built alike, so the failure names no entity, and the cause + /// names what is missing and leaves the blame open, as [`BlendFailure::CliffInputMissing`] + /// does: status `SM_ERR_NULL_POINTER` (upstream `NER`) and the kind of that status + /// ([`ErrorKind::Missing`]), neither a defect nor a refusal. + OverflowInputMissing(OverflowInput), + /// A point of the cliff overflow does not drop onto the geometry named + /// ([`OverflowDrop`]): the closest-point search found no foot (within ten tolerances, for + /// an edge's curve). An empty search ([`ErrorKind::NotFound`]); status `SM_ERR`. + OverflowPointDoesNotDrop(OverflowDrop), + /// A list of the fillet's parameters (cross-section types, radius types, radii) holds + /// neither one entry nor one per edge. A check of the caller's arguments + /// ([`ErrorKind::InvalidInput`]); status `SM_ERR_INVALID_INPUT`. + ParameterListSizes { + /// The edges to fillet. + edges: usize, + /// The cross-section types given. + cross_sections: usize, + /// The radius types given. + radius_types: usize, + /// The radii given. + radii: usize, }, - /// A search the exact round at a radius law's corner makes finds nothing: the - /// [`LawCornerSearch`] `what`, at the corner at index `corner` of the round's law corners. - /// An empty search ([`ErrorKind::NotFound`]): neither a defect nor a refusal; status - /// `SM_ERR_NULL_POINTER` (the fork's `NER` of the search's result). - LawCornerNotFound { - /// The corner's index among the round's law corners. - corner: usize, - /// What the search looked for. - what: LawCornerSearch, + /// A stage the routine calls failed, as the phrase says, and the routine answers with + /// that stage's `status` (upstream `SER` of the stage's status, or a status chosen at + /// run time). The stage's error is not kept as a cause: it may be a solidcore-side + /// failure, which the bare status it replaces did not carry. A phrase cause + /// ([`BlendFailure::is_phrase`]). + PassedOn { + /// What failed. + what: &'static str, + /// The status the routine answers with (a comparison detail). + status: i32, }, - /// An edge use of the caller's body a fillet reads (the first edge use of a solver the - /// caller set up) has no edge; the failure is at the edge use. A check of the caller's - /// input ([`ErrorKind::InvalidInput`]); status `SM_ERR_NULL_POINTER`. - EdgeUseWithoutEdge, - /// A surface binding of the fillet insertion is resolved after its face's surface was - /// removed: a stale binding the caller kept past an edit of the body; the failure is at - /// the face. A check of the caller's input ([`ErrorKind::InvalidInput`]); status - /// `SM_ERR_NULL_POINTER`. - BoundSurfaceRemoved, - /// A corner patch surface has no live face in the intermediate body: building the face - /// on that surface gave none, or it is gone. An empty search ([`ErrorKind::NotFound`]): - /// neither a defect nor a refusal; status `SM_ERR_NULL_POINTER` (the fork's `NER` of - /// `GetPatchFaces`). - CornerPatchFaceNotFound { - /// The surface's index among the corner's patch surfaces. - surface: usize, + /// A list that takes one entry per edge holds `given` entries for `edges` edges. A + /// check of the caller's arguments ([`ErrorKind::InvalidInput`]); status + /// `SM_ERR_INVALID_INPUT`. + PerEdgeListLength { + /// The edges to fillet. + edges: usize, + /// The entries the list holds. + given: usize, }, - /// An input a rail's crossing of an edge is judged from is not there (the crossing's - /// budget, an edge use's radial, the side edge's curve, the crossing's place on it): the - /// input named. Status `SM_ERR_NULL_POINTER` and the kind of that status - /// ([`ErrorKind::Missing`]); typed, so not a phrase cause ([`BlendFailure::is_phrase`]). - CrossingInputMissing(CrossingInput), - /// What a rail's crossing of an edge is judged from (a face normal or binormal at the - /// crossing) was not a finite number, so the crossing is neither classed concave nor - /// convex (#17016). A defect ([`ErrorKind::StageFailed`]), status `SM_ERR`. - CrossingNotFinite, - /// A G^n section's certificate could not prove what it must (a weight or the radius - /// positive over a box, an enclosure, a bound finite): its - /// interval enclosures were too wide. Not a fact of the geometry, which a narrower box - /// may prove, nor the kernel's fault: [`ErrorKind::NotWithinTolerance`], neither defect - /// nor refusal, like [`BlendFailure::NotCertified`]. Status `SM_ERR`; a certificate - /// that reads it (with its operation) subdivides the box. - SectionNotProved(SectionProof), - /// A G^n section, its system or its stations degenerate where they are built (the - /// section's area does not fall with its thumbweight, a weight or a length is zero, an - /// arc is a half turn or more, a normal or tangent vanishes, the faces' normals agree, the - /// rails or stations have no length, ...): [`ErrorKind::Degenerate`], status `SM_ERR`. - SectionDegenerate(SectionDegeneracy), - /// A G^n section's construction or certificate does not handle its input (a face that - /// is not a NURBS surface, a weight that is not positive, a blend face whose definition - /// it does not enclose, an order past the series it holds): [`ErrorKind::Unsupported`], - /// status `SM_ERR`. - SectionUnsupported(SectionLimit), - /// The radius law of a round is not positive at `s`, where the section is built on it: - /// a check on the caller's law ([`ErrorKind::InvalidInput`]), status `SM_ERR`. - RadiusLawNotPositive { - /// The law's parameter. - s: f64, - /// The radius the law gives there. - radius: f64, + /// An end given to a surface/plane crossing could not be put on the crossing within + /// tolerance. An empty search ([`ErrorKind::NotFound`]); status `SM_ERR`. + PlaneCurveEndOff { + /// True for the crossing's end, false for its start. + at_end: bool, + /// The larger of the distance from the given end to the crossing point found and + /// its distance to the plane; `None` when the drop or projection found no point. + distance: Option, }, - /// A G^n section's inputs do not fit together (a range past the round's stations, rails - /// and a centre line over different intervals, a span past the definition's last - /// station): a check on the caller's input ([`ErrorKind::InvalidInput`]), status - /// `SM_ERR`. - SectionInputInvalid(SectionInput), - /// A failure of the fillet solver (`crate::blend::fillet_solver`): its class and status - /// are the cause's ([`SolverFailure::class`], status `SM_ERR` unless the cause says - /// otherwise). Typed, so not a phrase cause ([`BlendFailure::is_phrase`]). - Solver(SolverFailure), - /// A fillet corner whose edges meet in a shape the corner topology does not build: the - /// shape named. Unsupported ([`ErrorKind::Unsupported`]), a fact of the body's edges at - /// the vertex; status that of the site it replaces ([`CornerShape::upstream_status`]). - CornerShapeNotBuilt(CornerShape), - /// The drop of a degenerate corner's vertex onto one of its blend's base surfaces found - /// `solutions` points, not one, and the side of a periodic seam the face's trim lies on - /// does not pick one of them: no single foot to end the rails at. An empty search - /// ([`ErrorKind::NotFound`]); status `SM_ERR`. - CornerPointDropUnresolved { - /// The points the drop found. - solutions: usize, - }, - /// A weld bead the kernel does not build yet (#15129, [`crate::blend::weld_bead`]), for - /// the gap named: not a fact of the geometry and not a defect, so no size is named. Its - /// class is [`ErrorKind::Unsupported`]. Not upstream. - WeldNotBuilt(WeldGap), -} - -/// A shape of the edges at a filleted vertex that the fillet corner topology -/// (`crate::blend::fillet_corner::topology`) does not build -/// ([`BlendFailure::CornerShapeNotBuilt`]). Each is a fact of the body's edges at the vertex; -/// none is a defect. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[non_exhaustive] -pub enum CornerShape { - /// A corner of two blended edges among more than four edges. - MoreThanFourEdges, - /// A blended edge use the walk round the vertex left out of the ring of the corner's - /// edges: the walk keeps one use of each edge, so an edge that meets the vertex twice (a - /// closed edge) is in the ring by its other use. - BlendedEdgeOffRing, - /// A corner of four edges whose two blended edges are next to each other round the vertex. - AdjacentBlendedEdges, - /// Two edges next to each other in the ring of the corner's edges that share no face: - /// the ring keeps one use of each edge, so an edge that meets the vertex twice stands - /// between edges that are not on one face. - RingEdgesShareNoFace, - /// A bevel corner (every edge blended, the blends not blending) of other than three edges. - BevelNotOfThreeEdges, - /// A concave corner of four edges, two blended, whose side edges are both on the concave - /// side of the blends: no side edge is convex. - NoConvexSideEdge, - /// A Join at one closed blended edge where another edge lies on neither of the blend's - /// faces. - RingEdgeOffClosedBlendFaces, - /// A Join whose one edge between the blends on a side does not meet the first blended - /// edge in a loop of either of its faces. - SideEdgeNotBesideBlend, - /// An end corner (one blended edge) of at most three edges whose two side edges share - /// no face. - EndSideEdgesShareNoFace, - /// A corner of two edges alone at the vertex whose first blended edge does not lie - /// between exactly two faces: the blends' crossing has an end on each of its faces. - EdgeNotBetweenTwoFaces, -} - -impl CornerShape { - /// The status the site the shape replaces returned: `SM_ERR_NULL_POINTER` where the C++ - /// dereferences the face or edge use it did not find (`NER`), else `SM_ERR`. - #[must_use] - pub const fn upstream_status(self) -> i32 { - match self { - Self::RingEdgesShareNoFace | Self::NoConvexSideEdge | Self::SideEdgeNotBesideBlend => { - SM_ERR_NULL_POINTER - } - Self::MoreThanFourEdges - | Self::BlendedEdgeOffRing - | Self::AdjacentBlendedEdges - | Self::BevelNotOfThreeEdges - | Self::RingEdgeOffClosedBlendFaces - | Self::EndSideEdgesShareNoFace - | Self::EdgeNotBetweenTwoFaces => SM_ERR, - } - } -} - -/// Why the fillet solver (`crate::blend::fillet_solver`) fails ([`BlendFailure::Solver`]). -/// Each names its class ([`SolverFailure::class`]); none is a defect: the solver's defects -/// are [`BlendFailure::Defect`], with their reason. -#[derive(Debug, Clone, Copy, PartialEq)] -#[non_exhaustive] -pub enum SolverFailure { - /// The solve for the fillet's cross-section point on the plane through a rail's point - /// at parameter `t` found no point: an empty search ([`ErrorKind::NotFound`]). - CrossSectionPointNotFound { - /// The parameter of the curve the plane is taken on. - t: f64, - }, - /// A rail curve's tangent has no length at parameter `t`, so no step along it is - /// defined there ([`ErrorKind::Degenerate`]). - RailTangentZero { - /// The rail curve's parameter. - t: f64, - }, - /// The curve-blending self-intersection handler's previous and next pieces are - /// `distance` apart where they come closest, farther than the `limit` it blends across - /// (three step-back distances): not within tolerance ([`ErrorKind::NotWithinTolerance`]). - PiecesTooFarApart { - /// The closest distance between the pieces' rails. - distance: f64, - /// The largest distance blended across. - limit: f64, + /// The crossing's Hermite fit still has spans farther than a tenth of the tolerance + /// from the exact curve when its station cap or its 20 refinement passes ran out, or + /// when a pass found no point to split any of them at. + /// Not within tolerance ([`ErrorKind::NotWithinTolerance`]); status `SM_ERR`. + PlaneCurveFitCap { + /// The stations held when fitting stopped. + stations: usize, + /// The refinement passes completed. + passes: usize, }, - /// A surface was asked of the base surface generator (`SmFilletSurfaceGenerator` - /// itself), which builds none: a kind the routine cannot handle - /// ([`ErrorKind::Unsupported`]). - GeneratorBuildsNoSurface, - /// The G^n section generator was not given rail side `side`'s surface (or its uv curve, - /// where `uv_curve`): the caller's input ([`ErrorKind::InvalidInput`]); status - /// `SM_ERR_NULL_POINTER`. - GnSideInputMissing { - /// The rail side, 0 or 1. - side: usize, - /// True for the side's uv curve, false for its surface. - uv_curve: bool, + /// The crossing's trace leaves the surface's parameter domain in a direction it is not + /// closed in, before reaching its end. Outside the domain ([`ErrorKind::OutsideDomain`]); + /// status `SM_ERR`. + PlaneCurveLeavesDomain { + /// The station's surface parameter u. + u: f64, + /// The station's surface parameter v. + v: f64, }, - /// A method the base fillet solver (`SmFilletSolver` itself) does not implement was - /// called on a solver that does not override it: a kind the routine cannot handle - /// ([`ErrorKind::Unsupported`]). - BaseSolverMethod(BaseSolverMethod), - /// The extension flags need a vertex's corner and the caller gave no corners (a - /// standalone entry point): the caller's input ([`ErrorKind::InvalidInput`]); status - /// `SM_ERR_NULL_POINTER`. - ExtensionCornerMissing, - /// A solver's equations could not be loaded for the solve: the solver's error is the - /// failure's cause, and decides whether it is a defect or a refusal - /// ([`ErrorKind::Failed`]). - JacobianNotLoaded, - /// The clipped-radius search's iso curve at radius `radius` does not meet the other - /// offset surface: an empty search ([`ErrorKind::NotFound`]). - ClippedIsoMissesSurface { - /// The radius the offsets were set to. - radius: f64, + /// A surface/plane trace's step was halved below its minimum at a station without a + /// step being accepted: the march stopped. A defect ([`ErrorKind::StageFailed`]); + /// status `SM_ERR`. + PlaneCurveStepVanished { + /// The last accepted station's surface parameter u. + u: f64, + /// The last accepted station's surface parameter v. + v: f64, + /// The step after halving. + step: f64, + /// The minimum step allowed. + minimum: f64, }, - /// Offset surface `side` has no normal at `(u, v)`: its partial derivatives and its - /// evaluated normal both vanish there ([`ErrorKind::Degenerate`]). - OffsetNormalVanishes { - /// The offset surface, 0 or 1. - side: usize, - /// The surface parameter u. + /// Tracing a surface/plane crossing found a station where the surface touches the + /// plane: its tangent along the crossing has no length, so the crossing has no direction. + /// Degenerate ([`ErrorKind::Degenerate`]); status `SM_ERR`. + PlaneCurveTouches { + /// The station's surface parameter u. u: f64, - /// The surface parameter v. + /// The station's surface parameter v. v: f64, }, - /// The intersection of the two fillet surfaces a support edge joins failed: the - /// intersection's error is the failure's cause ([`ErrorKind::Failed`]). - SupportIntersectionFailed, - /// The two fillet surfaces a support edge joins do not meet in a curve: an empty search - /// ([`ErrorKind::NotFound`]). - SupportSurfacesDoNotMeet, - /// The support edge's curve does not meet the fillet surface that ends it: an empty - /// search ([`ErrorKind::NotFound`]). - SupportCurveMissesSurface, - /// The support edge's start (or end, where `at_end`) does not drop onto its curve: an - /// empty search ([`ErrorKind::NotFound`]). - SupportEndOffCurve { - /// True for the end, false for the start. - at_end: bool, + /// The radius law of a round is not positive at `s`, where the section is built on it: + /// a check on the caller's law ([`ErrorKind::InvalidInput`]), status `SM_ERR`. + RadiusLawNotPositive { + /// The law's parameter. + s: f64, + /// The radius the law gives there. + radius: f64, }, - /// The solver was given no edge use `index` of the edge to fillet: the caller's solver - /// ([`ErrorKind::InvalidInput`]); status `SM_ERR_NULL_POINTER`. - SolverEdgeUseMissing { - /// The edge use's index, 0 or 1. + /// The radius type of the edge at `index` is not one an edge's fillet is set up with + /// (a constant radius, a constant distance or a variable radius). A check of the + /// caller's arguments ([`ErrorKind::InvalidInput`]); status `SM_ERR_INVALID_INPUT`. + RadiusTypeNotForEdges { + /// The edge's index in the edges given. index: usize, + /// The radius type given. + kind: crate::blend::fillet_solver::p1::FilletSolverType, }, - /// The caller's fillet geometry has no rail on side `side`: the caller's solver set-up - /// ([`ErrorKind::InvalidInput`]); status `SM_ERR_NULL_POINTER`. - FilletGeomWithoutRail { - /// The fillet geometry. - fillet_geom: crate::blend::fillet_geom::p1::FilletGeomId, - /// The rail side, 0 or 1. - side: usize, - }, - /// The caller's fillet geometry has no fillet surface: the caller's solver set-up - /// ([`ErrorKind::InvalidInput`]); status `SM_ERR_NULL_POINTER`. - FilletGeomWithoutSurface { - /// The fillet geometry. - fillet_geom: crate::blend::fillet_geom::p1::FilletGeomId, - }, - /// The caller's fillet geometry names no fillet solver: the caller's solver set-up - /// ([`ErrorKind::InvalidInput`]); status `SM_ERR_NULL_POINTER`. - FilletGeomWithoutSolver { - /// The fillet geometry. - fillet_geom: crate::blend::fillet_geom::p1::FilletGeomId, - }, - /// Rail `side` of the caller's fillet geometry has a curve not of a B-spline class (a - /// rail edge with no curve is [`FilletSetUp::RailCurve`]): a kind the routine cannot - /// handle ([`ErrorKind::Unsupported`]); status `SM_ERR_NULL_POINTER`. - RailNotBSpline { - /// The fillet geometry. - fillet_geom: crate::blend::fillet_geom::p1::FilletGeomId, - /// The rail side, 0 or 1. - side: usize, - /// The curve's kind (its type string). + /// A fillet removal refuses the face it is asked to remove, for the reason named + /// (classes 130 and 131; [`removal_class`]). A refusal that no size decides. + /// Status `SM_ERR`. + RemovalRefused(RemovalRefusal), + /// A G^n section, its system or its stations degenerate where they are built (the + /// section's area does not fall with its thumbweight, a weight or a length is zero, an + /// arc is a half turn or more, a normal or tangent vanishes, the faces' normals agree, the + /// rails or stations have no length, ...): [`ErrorKind::Degenerate`], status `SM_ERR`. + SectionDegenerate(SectionDegeneracy), + /// A G^n section's inputs do not fit together (a range past the round's stations, rails + /// and a centre line over different intervals, a span past the definition's last + /// station): a check on the caller's input ([`ErrorKind::InvalidInput`]), status + /// `SM_ERR`. + SectionInputInvalid(SectionInput), + /// A G^n section's certificate could not prove what it must (a weight or the radius + /// positive over a box, an enclosure, a bound finite): its + /// interval enclosures were too wide. Not a fact of the geometry, which a narrower box + /// may prove, nor the kernel's fault: [`ErrorKind::NotWithinTolerance`], neither defect + /// nor refusal, like [`BlendFailure::NotCertified`]. Status `SM_ERR`; a certificate + /// that reads it (with its operation) subdivides the box. + SectionNotProved(SectionProof), + /// A G^n section's construction or certificate does not handle its input (a face that + /// is not a NURBS surface, a weight that is not positive, a blend face whose definition + /// it does not enclose, an order past the series it holds): [`ErrorKind::Unsupported`], + /// status `SM_ERR`. + SectionUnsupported(SectionLimit), + /// An edge's curve of kind `kind`, in a smooth sequence of filleted edges, has no + /// B-spline form to join; the failure is at the edge. Unsupported + /// ([`ErrorKind::Unsupported`]); status `SM_ERR_NULL_POINTER` (upstream `NER` of the + /// cast). + SequenceCurveNotBSpline { + /// The curve's kind. kind: &'static str, }, - /// The fillet is not of the analytic shape the routine builds (its cross-section, - /// its edge's curve or its faces are of another kind): a kind the routine cannot - /// handle ([`ErrorKind::Unsupported`]). - AnalyticShapeDoesNotApply { - /// The shape the routine builds. - shape: AnalyticShape, - }, - /// The fillet's radius is `start` at its first section and `end` at its last: the - /// analytic surfaces are built for a constant radius only, a kind the routine cannot - /// handle ([`ErrorKind::Unsupported`]). - RadiusNotConstant { - /// The radius at the first section. - start: f64, - /// The radius at the last section. - end: f64, - }, - /// The fillet's radius `radius` is below the zero tolerance, so its section has no - /// arc ([`ErrorKind::Degenerate`]). - RadiusVanishes { - /// The radius. - radius: f64, - }, - /// The fillet's section turns through `angle` radians, too little for an arc - /// ([`ErrorKind::Degenerate`]). - SweepAngleTooSmall { - /// The turn, in radians. - angle: f64, - }, - /// The fillet's section turns through `angle` radians, within the tolerance of half a - /// turn or past it: the analytic surfaces are built for less, a kind the routine - /// cannot handle ([`ErrorKind::Unsupported`]). - SweepAngleNearHalfTurn { - /// The turn, in radians. - angle: f64, - }, - /// The ball's centre has no foot on face `side`'s quadric: an empty search - /// ([`ErrorKind::NotFound`]). - FootNotFound { - /// The face, 0 or 1. - side: usize, - }, - /// The circular spine has no station in the half-plane through the point (the point is - /// on the axis, or the offsets' meridians do not cross there): an empty search - /// ([`ErrorKind::NotFound`]). - SpineStationNotFound, - /// The nearest-point search on a curve found `count` nearest points where one is - /// needed: an empty or ambiguous search ([`ErrorKind::NotFound`]). - NoSingleCurveFoot { - /// The number of nearest points found. - count: usize, - }, - /// An end of the filleted edge lies on cylinder `side`'s axis, so the ball's contact - /// there has no direction from the axis ([`ErrorKind::Degenerate`]). - EdgeEndOnAxis { - /// The cylinder, 0 or 1. - side: usize, + /// A fillet size (a radius, a chamfer's distance, or a setback a chamfer's angle or + /// chord gives at its edge's wedge) is below eight times the body's + /// tolerance, the smallest the fillet builds. A check of the caller's arguments + /// ([`ErrorKind::InvalidInput`]); status `SM_ERR_INVALID_INPUT`. + SizeBelowResolution { + /// The size given. + size: f64, + /// The body's tolerance. + tolerance: f64, }, - /// An end of the trace lies `deviation` off the ball, farther than `tol`: not within - /// tolerance ([`ErrorKind::NotWithinTolerance`]). - TraceEndOffBall { - /// The distance of the trace's end from the ball. - deviation: f64, - /// The tolerance. - tol: f64, + /// A quantity a variable round's skin check computes (a distance from the skin to its + /// balls, or the balls' radius rate and centre speed at a section) was still not a finite + /// number, last at the section at `s` along the trace, when the refinement reached its + /// most rounds or stations (#15256): a defect ([`ErrorKind::StageFailed`]). A value that + /// is not finite before the cap splits its span instead. + /// Status `SM_ERR`. + SkinMeasureNotFinite { + /// The section's parameter along the trace. + s: f64, }, - /// The solver solves for more further values than a fillet point holds (`limit`): the - /// caller's solver ([`ErrorKind::InvalidInput`]). - TooManySolverValues { - /// The values a fillet point holds. - limit: usize, + /// A variable round's skin of balls' touch circles was still measured farther than + /// `asked` from its balls when its refinement reached its most rounds or stations + /// (#15256): the worst distance measured was `reached` (infinite where a span's section + /// could not be placed on the skin to be measured), with `stations` stations after + /// `rounds` rounds. Not within the tolerance ([`ErrorKind::NotWithinTolerance`]): no + /// tolerance is loosened and the skin is not kept. + /// Status `SM_ERR`. + SkinPastStationCap { + /// The tolerance asked: the solver's approximation tolerance. + asked: f64, + /// The largest distance measured from the skin to its balls at the cap. + reached: f64, + /// The stations the skin had at the cap. + stations: usize, + /// The refinement rounds run. + rounds: usize, }, - /// The solver has not got both offset surfaces set: the caller's solver state - /// ([`ErrorKind::InvalidInput`]). - OffsetSurfaceMissing, - /// The corner's cross section does not meet the extended side surface: an empty search - /// ([`ErrorKind::NotFound`]). - CrossSectionMissesSideSurface, - /// The corner point does not drop onto the side edge's curve: an empty search - /// ([`ErrorKind::NotFound`]). - CornerDoesNotDropOnSideCurve, - /// The side surface and the plane through the side curve's end point do not meet in a - /// curve: an empty search ([`ErrorKind::NotFound`]); status `SM_ERR_NULL_POINTER`. - SideSurfaceMissesEndPlane, - /// Interval `index` of the roll-over rail's classification does not end (or, the last, - /// start) at an edge: a case the roll-over does not handle ([`ErrorKind::Unsupported`]). - RolloverIntervalNotAtEdge { - /// The interval's index. + /// A failure of the fillet solver (`crate::blend::fillet_solver`): its class and status + /// are the cause's ([`SolverFailure::class`], status `SM_ERR` unless the cause says + /// otherwise). Typed, so not a phrase cause ([`BlendFailure::is_phrase`]). + Solver(SolverFailure), + /// The face a ball is asked to touch is named by an index past a fillet solver's two + /// faces, first (0) and second (1). A check of the caller's arguments + /// ([`ErrorKind::InvalidInput`]); status `SM_ERR_INVALID_INPUT`. + SolverFaceIndexInvalid { + /// The face index given. index: usize, }, - /// An edge use of the caller's body has no mate: the caller's input - /// ([`ErrorKind::InvalidInput`]); status `SM_ERR_NULL_POINTER`. - EdgeUseWithoutMate, - /// An edge use of the caller's body has no face: the caller's input - /// ([`ErrorKind::InvalidInput`]); status `SM_ERR_NULL_POINTER`. - EdgeUseWithoutFace, - /// The fillet geometry's centre line is of a curve kind with no B-spline form: a kind - /// the routine cannot handle ([`ErrorKind::Unsupported`]); status `SM_ERR_NULL_POINTER`. - CenterLineNotBSpline { - /// The fillet geometry. - fillet_geom: crate::blend::fillet_geom::p1::FilletGeomId, - }, - /// The surface's cache could not be built: the cache's error is the failure's cause - /// ([`ErrorKind::Failed`]); status `SM_ERR_NULL_POINTER`. - SurfaceCacheNotBuilt, - /// The point does not drop onto offset surface `side`: an empty search - /// ([`ErrorKind::NotFound`]). - PointDoesNotDropOnSurface { - /// The surface, 0 or 1. - side: usize, + /// A stage of the blend failed with no reason the kernel names: a defect. The failure + /// holds the operation, the status (for the goldens only) and where in solidcore's source + /// it was built ([`Failure::origin`]). The form not yet reviewed: new code builds + /// [`BlendFailure::Defect`], a named cause or a refusal instead. + /// Its class is [`ErrorKind::StageFailed`] (127); status `SM_ERR` unless its site says otherwise. + StageFailed, + /// The solve of the ball's position at a station of the blend did not converge: a defect, + /// never "no root" (a solve that stops proves nothing about the root). + /// Its class is [`ErrorKind::StationDidNotConverge`] (125); status `SM_ERR`. + StationDidNotConverge { + /// The station: the blend's parameter along its spine. + s: f64, + /// The residual the solve stopped at (`None` where the solve does not report it). + residual: Option, + /// The tolerance it had to reach. + tolerance: f64, + /// The last step it took (`None` where the solve does not report it). + step: Option, + /// The iterations it took (`None` where the solve does not report them). + iterations: Option, }, - /// The solve for the fillet's cross section on the plane through the failure's site - /// found no section: an empty search ([`ErrorKind::NotFound`]). - CrossSectionNotFound, - /// `count` short intervals of the rail's classification could not be squeezed out (no - /// single side edge at both ends, no edge use on the rail's face, no guess on the edge, - /// or wider than the edge's tolerance): a case the refinement does not handle - /// ([`ErrorKind::Unsupported`]). - ShortIntervalsNotRemoved { - /// The number of intervals left. - count: usize, + /// The fillet executive is given no target body, or is run before one is set. A check + /// of the caller's arguments ([`ErrorKind::InvalidInput`]); status + /// `SM_ERR_INVALID_INPUT` (`SM_ERR_NULL_POINTER` where a stage finds it unset). + TargetNotGiven, + /// The fillet trace failed, for the reason the [`TraceFailure`] names: the standard and + /// custom fillet solvers, the fillet intersector and the law corners. Its class and + /// status are the cause's ([`TraceFailure::class`]; the status as each [`TraceFailure`] + /// variant says). + Trace(TraceFailure), + /// The collection of the faces the rails enclose reached past a rail (the trim leaks): + /// the failure's site face, where the check names it, is the face it reached. A defect + /// ([`ErrorKind::TrimLeaks`]). + /// Status `SM_ERR`. + TrimLoopDoesNotSeparate, + /// The boundary loop of the faces the rails enclose is open: the failure's site vertex + /// is where. A defect ([`ErrorKind::TrimLeaks`]). + /// Status `SM_ERR`. + TrimLoopOpen, + /// The edge at `index` of the edges given has a variable radius and no radius law. A + /// check of the caller's arguments ([`ErrorKind::InvalidInput`]); status + /// `SM_ERR_INVALID_INPUT`. + VariableRadiusLawMissing { + /// The edge's index in the edges given. + index: usize, }, - /// The side edge has no edge use on the rail's face: an empty search - /// ([`ErrorKind::NotFound`]); status `SM_ERR_NULL_POINTER`. - SideEdgeNotOnRailFace, - /// The guess point does not drop onto the side edge: an empty search - /// ([`ErrorKind::NotFound`]). - GuessDoesNotDropOnSideEdge, - /// The rail does not cross the side edge from any guess: an empty search - /// ([`ErrorKind::NotFound`]). - RailMissesSideEdge, - /// The roll-over meets a side edge that rolls over tangentially, which the full - /// roll-over does not handle ([`ErrorKind::Unsupported`]). - TangentRolloverUnhandled, -} - -/// The analytic shape a fillet solver routine builds -/// ([`SolverFailure::AnalyticShapeDoesNotApply`]). -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[non_exhaustive] -pub enum AnalyticShape { - /// A cylinder: a circular section along a line. - Cylinder, - /// A cone: a circular section along a line between faces that open. - Cone, - /// A torus: a circular (or linear) section along a circular arc. - Torus, - /// A sphere: the ball where two cylinders' axes meet. - Sphere, - /// The ball's triangle where one face's offset collapses. - BallTriangle, -} - -/// A method of the base fillet solver ([`SolverFailure::BaseSolverMethod`]). -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[non_exhaustive] -pub enum BaseSolverMethod { - /// `SetupOffsetValues`. - SetupOffsetValues, - /// `LoadJacobian`. - LoadJacobian, - /// `LoadInitialValues`. - LoadInitialValues, + /// A variable radius is asked and no list of radius laws is given. A check of the + /// caller's arguments ([`ErrorKind::InvalidInput`]); status `SM_ERR_NULL_POINTER` + /// (upstream dereferences the list). + VariableRadiusLawsNotGiven, + /// A weld bead the kernel does not build yet (#15129, [`crate::blend::weld_bead`]), for + /// the gap named: not a fact of the geometry and not a defect, so no size is named. Its + /// class is [`ErrorKind::Unsupported`]. Not upstream. + /// Status `SM_ERR`. + WeldNotBuilt(WeldGap), } -impl SolverFailure { - /// The failure's class ([`ErrorKind`]): see each variant. - #[must_use] - pub const fn class(&self) -> ErrorKind { - match self { - Self::CrossSectionPointNotFound { .. } - | Self::ClippedIsoMissesSurface { .. } - | Self::SupportSurfacesDoNotMeet - | Self::SupportCurveMissesSurface - | Self::SupportEndOffCurve { .. } - | Self::FootNotFound { .. } - | Self::SpineStationNotFound - | Self::NoSingleCurveFoot { .. } - | Self::CrossSectionMissesSideSurface - | Self::CornerDoesNotDropOnSideCurve - | Self::SideSurfaceMissesEndPlane - | Self::PointDoesNotDropOnSurface { .. } - | Self::CrossSectionNotFound - | Self::SideEdgeNotOnRailFace - | Self::GuessDoesNotDropOnSideEdge - | Self::RailMissesSideEdge => ErrorKind::NotFound, - Self::RailTangentZero { .. } - | Self::OffsetNormalVanishes { .. } - | Self::RadiusVanishes { .. } - | Self::SweepAngleTooSmall { .. } - | Self::EdgeEndOnAxis { .. } => ErrorKind::Degenerate, - Self::PiecesTooFarApart { .. } | Self::TraceEndOffBall { .. } => { - ErrorKind::NotWithinTolerance - } - Self::GeneratorBuildsNoSurface - | Self::BaseSolverMethod(_) - | Self::AnalyticShapeDoesNotApply { .. } - | Self::RadiusNotConstant { .. } - | Self::SweepAngleNearHalfTurn { .. } - | Self::RolloverIntervalNotAtEdge { .. } - | Self::CenterLineNotBSpline { .. } - | Self::ShortIntervalsNotRemoved { .. } - | Self::TangentRolloverUnhandled - | Self::RailNotBSpline { .. } => ErrorKind::Unsupported, - Self::GnSideInputMissing { .. } - | Self::ExtensionCornerMissing - | Self::TooManySolverValues { .. } - | Self::OffsetSurfaceMissing - | Self::EdgeUseWithoutMate - | Self::EdgeUseWithoutFace - | Self::SolverEdgeUseMissing { .. } - | Self::FilletGeomWithoutRail { .. } - | Self::FilletGeomWithoutSurface { .. } - | Self::FilletGeomWithoutSolver { .. } => ErrorKind::InvalidInput, - Self::JacobianNotLoaded - | Self::SupportIntersectionFailed - | Self::SurfaceCacheNotBuilt => ErrorKind::Failed, - } - } - - /// The status the C++ reports unless the site says otherwise (a comparison detail). +impl BlendFailure { + /// The status the C++ reports for the failure unless its site says otherwise (a + /// comparison detail). + #[allow( + clippy::match_same_arms, + reason = "one arm per variant, sorted by name, so causes added in parallel touch disjoint lines" + )] pub(crate) const fn comparison_status(&self) -> i32 { match self { - Self::GnSideInputMissing { .. } - | Self::ExtensionCornerMissing - | Self::EdgeUseWithoutMate - | Self::EdgeUseWithoutFace - | Self::CenterLineNotBSpline { .. } - | Self::SurfaceCacheNotBuilt - | Self::SideSurfaceMissesEndPlane - | Self::SideEdgeNotOnRailFace - | Self::SolverEdgeUseMissing { .. } - | Self::FilletGeomWithoutRail { .. } - | Self::FilletGeomWithoutSurface { .. } - | Self::FilletGeomWithoutSolver { .. } - | Self::RailNotBSpline { .. } => SM_ERR_NULL_POINTER, - Self::CrossSectionPointNotFound { .. } - | Self::RailTangentZero { .. } - | Self::PiecesTooFarApart { .. } - | Self::GeneratorBuildsNoSurface - | Self::BaseSolverMethod(_) - | Self::JacobianNotLoaded - | Self::ClippedIsoMissesSurface { .. } - | Self::OffsetNormalVanishes { .. } - | Self::SupportIntersectionFailed - | Self::SupportSurfacesDoNotMeet - | Self::SupportCurveMissesSurface - | Self::SupportEndOffCurve { .. } - | Self::AnalyticShapeDoesNotApply { .. } - | Self::RadiusNotConstant { .. } - | Self::RadiusVanishes { .. } - | Self::SweepAngleTooSmall { .. } - | Self::SweepAngleNearHalfTurn { .. } - | Self::FootNotFound { .. } - | Self::SpineStationNotFound - | Self::NoSingleCurveFoot { .. } - | Self::EdgeEndOnAxis { .. } - | Self::TraceEndOffBall { .. } - | Self::TooManySolverValues { .. } - | Self::OffsetSurfaceMissing - | Self::CrossSectionMissesSideSurface - | Self::CornerDoesNotDropOnSideCurve - | Self::RolloverIntervalNotAtEdge { .. } - | Self::PointDoesNotDropOnSurface { .. } - | Self::CrossSectionNotFound - | Self::ShortIntervalsNotRemoved { .. } - | Self::GuessDoesNotDropOnSideEdge - | Self::RailMissesSideEdge - | Self::TangentRolloverUnhandled => SM_ERR, - } - } -} - -impl core::fmt::Display for SolverFailure { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let end = |at_end: bool| if at_end { "end" } else { "start" }; - match self { - Self::CrossSectionPointNotFound { t } => write!( - f, - "no cross-section point of the fillet was found on the plane at t = {t}" - ), - Self::RailTangentZero { t } => { - write!(f, "the rail's tangent has no length at t = {t}") - } - Self::PiecesTooFarApart { distance, limit } => write!( - f, - "the pieces to blend are {distance} apart, farther than {limit}" - ), - Self::GeneratorBuildsNoSurface => { - f.write_str("the base surface generator builds no surface") - } - Self::GnSideInputMissing { side, uv_curve } => write!( - f, - "the G^n section generator was given no {} for rail side {side}", - if *uv_curve { "uv curve" } else { "surface" } - ), - Self::BaseSolverMethod(method) => { - write!(f, "the base fillet solver does not implement {method:?}") - } - Self::ExtensionCornerMissing => { - f.write_str("the extension flags need a vertex's corner and no corners were given") - } - Self::JacobianNotLoaded => f.write_str("the solver's equations could not be loaded"), - Self::ClippedIsoMissesSurface { radius } => write!( - f, - "at radius {radius} the iso curve does not meet the other offset surface" - ), - Self::OffsetNormalVanishes { side, u, v } => write!( - f, - "offset surface {side} has no normal at (u, v) = ({u}, {v})" - ), - Self::SupportIntersectionFailed => { - f.write_str("the intersection of the support edge's fillet surfaces failed") - } - Self::SupportSurfacesDoNotMeet => { - f.write_str("the support edge's fillet surfaces do not meet") - } - Self::SupportCurveMissesSurface => { - f.write_str("the support edge's curve does not meet the fillet surface ending it") - } - Self::SupportEndOffCurve { at_end } => write!( - f, - "the support edge's {} does not drop onto its curve", - end(*at_end) - ), - Self::AnalyticShapeDoesNotApply { shape } => { - write!(f, "the fillet is not of the analytic shape {shape:?}") - } - Self::RadiusNotConstant { start, end } => write!( - f, - "the fillet's radius is {start} at its start and {end} at its end, not constant" - ), - Self::RadiusVanishes { radius } => { - write!( - f, - "the fillet's radius {radius} is below the zero tolerance" - ) - } - Self::SweepAngleTooSmall { angle } => { - write!(f, "the fillet's section turns through only {angle} radians") - } - Self::SweepAngleNearHalfTurn { angle } => write!( - f, - "the fillet's section turns through {angle} radians, about half a turn or more" - ), - Self::FootNotFound { side } => { - write!(f, "the ball's centre has no foot on face {side}'s quadric") - } - Self::SpineStationNotFound => { - f.write_str("the circular spine has no station in the point's half-plane") - } - Self::NoSingleCurveFoot { count } => write!( - f, - "the nearest-point search on the curve found {count} points where one is needed" - ), - Self::EdgeEndOnAxis { side } => { - write!( - f, - "an end of the filleted edge lies on cylinder {side}'s axis" - ) - } - Self::TraceEndOffBall { deviation, tol } => write!( - f, - "an end of the trace lies {deviation} off the ball, farther than {tol}" - ), - Self::TooManySolverValues { limit } => write!( - f, - "the solver solves for more further values than a fillet point holds ({limit})" - ), - Self::OffsetSurfaceMissing => { - f.write_str("the solver has not got both offset surfaces set") - } - Self::CrossSectionMissesSideSurface => { - f.write_str("the corner's cross section does not meet the extended side surface") - } - Self::CornerDoesNotDropOnSideCurve => { - f.write_str("the corner point does not drop onto the side edge's curve") - } - Self::SideSurfaceMissesEndPlane => f.write_str( - "the side surface and the plane through the side curve's end do not meet", - ), - Self::RolloverIntervalNotAtEdge { index } => write!( - f, - "interval {index} of the roll-over rail's classification is not bounded by an edge" - ), - Self::EdgeUseWithoutMate => f.write_str("an edge use of the body has no mate"), - Self::EdgeUseWithoutFace => f.write_str("an edge use of the body has no face"), - Self::CenterLineNotBSpline { fillet_geom } => write!( - f, - "the centre line of fillet geometry {} has no B-spline form", - fillet_geom.0 - ), - Self::SurfaceCacheNotBuilt => f.write_str("the surface's cache could not be built"), - Self::PointDoesNotDropOnSurface { side } => { - write!(f, "the point does not drop onto offset surface {side}") - } - Self::CrossSectionNotFound => { - f.write_str("no cross section of the fillet was found on the plane") - } - Self::ShortIntervalsNotRemoved { count } => write!( - f, - "{count} short intervals of the rail's classification could not be removed" - ), - Self::SideEdgeNotOnRailFace => { - f.write_str("the side edge has no edge use on the rail's face") - } - Self::GuessDoesNotDropOnSideEdge => { - f.write_str("the guess point does not drop onto the side edge") - } - Self::RailMissesSideEdge => f.write_str("the rail does not cross the side edge"), - Self::TangentRolloverUnhandled => { - f.write_str("a side edge rolls over tangentially, which is not handled") - } - Self::SolverEdgeUseMissing { index } => { - write!( - f, - "the solver has no edge use {index} of the edge to fillet" - ) - } - Self::FilletGeomWithoutRail { fillet_geom, side } => { - write!( - f, - "fillet geometry {fillet_geom:?} has no rail on side {side}" - ) - } - Self::FilletGeomWithoutSurface { fillet_geom } => { - write!(f, "fillet geometry {fillet_geom:?} has no fillet surface") - } - Self::FilletGeomWithoutSolver { fillet_geom } => { - write!(f, "fillet geometry {fillet_geom:?} names no fillet solver") - } - Self::RailNotBSpline { - fillet_geom, - side, - kind, - } => write!( - f, - "rail {side} of fillet geometry {fillet_geom:?} has a {kind} curve, not of a \ - B-spline class" - ), - } - } -} - -/// What the exact round at a radius law's corner looked for and did not find -/// ([`BlendFailure::LawCornerNotFound`]). -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[non_exhaustive] -pub enum LawCornerSearch { - /// The edge the faces on either side of the corner share. - SharedEdge, - /// The edge of a side's face between the corner's rail points. - CornerEdge, - /// The curve where the sides of a peak cross, from rail point to rail point. - Crossing, - /// A side's corner curve, oriented from its edge's start vertex to its end vertex. - CurveBetweenEnds, -} - -impl LawCornerSearch { - const fn what(self) -> &'static str { - match self { - Self::SharedEdge => "edge shared by the faces on either side", - Self::CornerEdge => "edge between the rail points on a side's face", - Self::Crossing => "crossing of the sides between the rail points", - Self::CurveBetweenEnds => "corner curve between its edge's end vertices", - } - } -} - -/// Which input of a rail crossing's judgement is missing ([`BlendFailure::CrossingInputMissing`]). -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[non_exhaustive] -pub enum CrossingInput { - /// The tangency budget of the round a sheet face belongs to. - SheetFaceTangencyBudget, - /// The radial edge use of the edge use that bounds material. - MaterialEdgeUseRadial, - /// The curve of the side edge a rail crosses. - SideEdgeCurve, - /// The place on the side edge where the rail crosses it. - CrossingOnSideEdge, -} - -impl CrossingInput { - /// What is missing, as a phrase ("the side edge's curve"). - #[must_use] - pub const fn what(self) -> &'static str { - match self { - Self::SheetFaceTangencyBudget => "the sheet face's tangency budget", - Self::MaterialEdgeUseRadial => "the material edge use's radial", - Self::SideEdgeCurve => "the side edge's curve", - Self::CrossingOnSideEdge => "the rollover event on the side edge", - } - } -} - -/// What a G^n section's certificate could not prove ([`BlendFailure::SectionNotProved`]). -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[non_exhaustive] -pub enum SectionProof { - /// A face's weights positive over a box. - FaceWeightPositive, - /// A curve's weight positive over a span. - CurveWeightPositive, - /// The section's weight positive over an extension. - SectionWeightPositive, - /// The ball's radius positive over a box. - RadiusPositive, - /// The definition's enclosure over a box. - Enclosure, - /// A bound or a box the certificate computes finite. - BoundFinite, -} - -impl SectionProof { - /// What was not proved, as a phrase. - #[must_use] - pub const fn what(self) -> &'static str { - match self { - Self::FaceWeightPositive => "a face's weights positive over the box", - Self::CurveWeightPositive => "the curve's weight positive over the span", - Self::SectionWeightPositive => "the section's weight positive over the extension", - Self::RadiusPositive => "the ball's radius positive over the box", - Self::Enclosure => "the definition's enclosure over the box", - Self::BoundFinite => "a bound of the certificate finite", - } - } -} - -/// How a G^n section degenerates ([`BlendFailure::SectionDegenerate`]). -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[non_exhaustive] -pub enum SectionDegeneracy { - /// The section's area does not fall as its thumbweight grows, so no thumbweight is the - /// equal area one. - AreaDoesNotFall, - /// A weight or a length of the section is zero at the point. - WeightOrLengthZero, - /// A section of the ball's circle is a half turn or more. - ArcHalfTurn, - /// The varying balls' centres stand still. - CentresStandStill, - /// A vector the section normalises vanishes (a face's normal at a foot, the leader's - /// tangent). - VectorVanishes, - /// The blend's system is singular at a station: its faces' normals agree there. - NormalsAgree, - /// The rails, or the round's stations, have no length. - NoLength, - /// The ball has no radius at the rails' start. - BallHasNoRadius, - /// A span to be halved has no parameter strictly inside it. - SpanCannotSplit, - /// The parameter interval lies in no span of the curve (a curve whose knots are all - /// one value). - NoSpanCoversInterval, -} - -impl SectionDegeneracy { - /// How it degenerates, as a phrase. - #[must_use] - pub const fn what(self) -> &'static str { - match self { - Self::AreaDoesNotFall => "the section's area does not fall with its thumbweight", - Self::WeightOrLengthZero => "a weight or a length of the section is zero", - Self::ArcHalfTurn => "a section of the ball's circle is a half turn or more", - Self::CentresStandStill => "the balls' centres stand still", - Self::VectorVanishes => { - "a vector the section normalises vanishes (a face's normal at a foot, or the leader's tangent)" - } - Self::NormalsAgree => { - "the blend's system is singular at a station (its faces' normals agree there)" - } - Self::NoLength => "the rails or the round's stations have no length", - Self::BallHasNoRadius => "the ball has no radius at the rails' start", - Self::SpanCannotSplit => "a span has no midpoint inside it to be split at", - Self::NoSpanCoversInterval => "no span of the curve covers the parameter", - } - } -} - -/// What a G^n section does not handle ([`BlendFailure::SectionUnsupported`]). -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[non_exhaustive] -pub enum SectionLimit { - /// A face that is not a NURBS surface: its section of order 2 and up, and its - /// certificate, need one. - FaceNotNurbs, - /// A curve or face of degree 0 in a direction. - DegreeBelowOne, - /// A face's weight that is not positive. - FaceWeightNotPositive, - /// A curve's weight that is not positive. - CurveWeightNotPositive, - /// A face that is a blend by its definition, enclosed only for a round of one radius on - /// a round of one radius between NURBS faces. - DefinitionFaceNotOneRadius, - /// A derivative order past the most the series hold. - OrderPastSeries { - /// The order asked. - order: usize, - /// The most the series hold. - most: usize, - }, -} - -/// Which inputs of a G^n section do not fit together ([`BlendFailure::SectionInputInvalid`]). -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[non_exhaustive] -pub enum SectionInput { - /// The round's range is not within its stations. - RangeOutsideStations, - /// The rails and the centre line run over different intervals. - IntervalsDiffer, - /// The span asked for starts at or past the definition's last station. - SpanPastLastStation, -} - -impl SectionInput { - /// What does not fit, as a phrase. - #[must_use] - pub const fn what(self) -> &'static str { - match self { - Self::RangeOutsideStations => "the round's range is not within its stations", - Self::IntervalsDiffer => "the rails and the centre line run over different intervals", - Self::SpanPastLastStation => "the span asked for is past the definition's last station", - } - } -} - -/// A face input required to trim a blend at a cliff. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[non_exhaustive] -pub enum CliffInput { - /// The face's surface. - Surface, - /// The planar support extending the wall. - Plane, - /// The face use facing out of the body. - OutwardFaceUse, -} - -impl CliffInput { - const fn what(self) -> &'static str { - match self { - Self::Surface => "surface", - Self::Plane => "plane", - Self::OutwardFaceUse => "outward face use", - } - } -} - -/// What a thing the ease of a round before a setback reads lacks -/// ([`BlendFailure::EaseInputMissing`]). -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[non_exhaustive] -pub enum EaseInput { - /// An eased corner's filleted vertex. - CornerVertex, - /// A face for the point a setback vertex classifies on (it classifies on no face). - SetbackFace, - /// A round's solver. - RoundSolver, - /// A round solver's surface generator. - SurfaceGenerator, - /// A round's rail edge. - RoundRail, - /// A round's fillet surface. - RoundSurface, - /// A round's centre line. - CentreLine, - /// A round solver's offset surface for a rail (made when the solver is loaded). - SolverSurface, - /// An edge's curve (a rail's or the filleted edge's). - EdgeCurve, - /// A face's surface. - FaceSurface, - /// An edge use's face. - EdgeUseFace, -} - -impl EaseInput { - const fn what(self) -> &'static str { - match self { - Self::CornerVertex => "an eased corner has no filleted vertex", - Self::SetbackFace => "a setback vertex of an eased corner classifies on no face", - Self::RoundSolver => "an eased round has no solver", - Self::SurfaceGenerator => "an eased round's solver has no surface generator", - Self::RoundRail => "an eased round has no rail edge on a side", - Self::RoundSurface => "an eased round has no fillet surface", - Self::CentreLine => "an eased round has no centre line", - Self::SolverSurface => "an eased round's solver has no offset surface for a rail", - Self::EdgeCurve => "an edge the ease reads has no curve", - Self::FaceSurface => "a face the ease reads has no surface", - Self::EdgeUseFace => "an edge use the ease reads has no face", - } - } -} - -/// Where the ease of a round before a setback stops ([`BlendFailure::EaseNotBuilt`]), each -/// with its kind ([`EaseStop::class`]). -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[non_exhaustive] -pub enum EaseStop { - /// A setback vertex of the eased corner is not yet placed (not processed): the ease - /// does not place it ([`ErrorKind::Unsupported`]). - SetbackVertexNotPlaced, - /// A setback vertex lies on other than exactly one fillet geometry: the ease eases one - /// round per setback vertex ([`ErrorKind::Unsupported`]). - SetbackNotOnOneRound, - /// The round's sections are neither circular nor curvature-continuous: the ease eases - /// a circular round only ([`ErrorKind::Unsupported`]). - SectionsNotCircular, - /// The face a setback vertex classifies on carries neither of the round's rails - /// ([`ErrorKind::NotFound`]). - SetbackFaceCarriesNoRail, - /// The setback vertex does not drop onto the round's rail ([`ErrorKind::NotFound`]). - SetbackVertexOffRail, - /// The setback plus the ease runs past the far end of the filleted edge - /// ([`ErrorKind::OutsideDomain`]). - EasePastEdgeEnd, - /// The origin of the plane at the eased setback has other than one closest point on an - /// offset surface of the round ([`ErrorKind::NotFound`]). - PlaneOriginNotOneClosest, - /// No section of the round lies in the plane at the eased setback - /// ([`ErrorKind::NotFound`]). - NoSectionInPlane, - /// The start of the ease does not drop onto the rail ([`ErrorKind::NotFound`]). - EaseStartOffRail, - /// The start of the ease drops onto the rail where the setback's section does: the - /// ease has no length ([`ErrorKind::Degenerate`]). - EaseHasNoLength, - /// A rail does not drop onto its face's surface as one UV curve - /// ([`ErrorKind::Unsupported`]). - RailNotOneUvCurve, - /// A rail's UV curve does not run over the rail's own interval - /// ([`ErrorKind::Unsupported`]). - UvCurveOffRailInterval, - /// Neither direction of the round's surface runs along its rails - /// ([`ErrorKind::Unsupported`]). - NoDirectionAlongRails, -} - -impl EaseStop { - /// The stop's kind. - #[must_use] - pub const fn class(self) -> ErrorKind { - match self { - Self::SetbackVertexNotPlaced - | Self::SetbackNotOnOneRound - | Self::SectionsNotCircular - | Self::RailNotOneUvCurve - | Self::UvCurveOffRailInterval - | Self::NoDirectionAlongRails => ErrorKind::Unsupported, - Self::SetbackFaceCarriesNoRail - | Self::SetbackVertexOffRail - | Self::PlaneOriginNotOneClosest - | Self::NoSectionInPlane - | Self::EaseStartOffRail => ErrorKind::NotFound, - Self::EaseHasNoLength => ErrorKind::Degenerate, - Self::EasePastEdgeEnd => ErrorKind::OutsideDomain, - } - } - - const fn what(self) -> &'static str { - match self { - Self::SetbackVertexNotPlaced => "a setback vertex of an eased corner is not placed", - Self::SetbackNotOnOneRound => { - "a setback vertex of an eased corner is not on exactly one round" - } - Self::SectionsNotCircular => { - "an eased round's sections are neither circular nor curvature-continuous" - } - Self::SetbackFaceCarriesNoRail => { - "the face a setback vertex classifies on carries neither rail of the round" - } - Self::SetbackVertexOffRail => "a setback vertex does not drop onto the round's rail", - Self::EasePastEdgeEnd => { - "the setback plus the ease runs past the end of the filleted edge" - } - Self::PlaneOriginNotOneClosest => { - "the plane's origin at the eased setback has no single closest point on an \ - offset surface" - } - Self::NoSectionInPlane => { - "no section of the round lies in the plane at the eased setback" - } - Self::EaseStartOffRail => "the ease's start does not drop onto the rail", - Self::EaseHasNoLength => { - "the ease's start drops onto the rail where the setback's section does" - } - Self::RailNotOneUvCurve => { - "a rail does not drop onto its face's surface as one UV curve" - } - Self::UvCurveOffRailInterval => { - "a rail's UV curve does not run over the rail's own interval" - } - Self::NoDirectionAlongRails => { - "neither direction of the round's surface runs along its rails" - } - } - } -} - -/// Which curve or surface the ease of a round before a setback finds without a B-spline -/// form ([`BlendFailure::EaseGeometryNotBSpline`]). -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[non_exhaustive] -pub enum EaseGeometry { - /// The eased round's fillet surface. - RoundSurface, - /// A rail's curve. - RailCurve, - /// A rail's UV curve as the trace left it. - TracedUvCurve, - /// A rail's UV curve dropped onto its face's surface. - DroppedUvCurve, -} - -impl EaseGeometry { - const fn what(self) -> &'static str { - match self { - Self::RoundSurface => "an eased round's fillet surface has no B-spline form", - Self::RailCurve => "an eased round's rail curve has no B-spline form", - Self::TracedUvCurve => "a rail's traced UV curve has no B-spline form", - Self::DroppedUvCurve => "a rail's UV curve dropped onto its face has no B-spline form", - } - } -} - -/// What a face or edge a blend's overflow reads lacks ([`BlendFailure::OverflowInputMissing`]). -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[non_exhaustive] -pub enum OverflowInput { - /// A face's surface. - FaceSurface, - /// An edge's curve. - EdgeCurve, - /// An edge's start vertex. - EdgeStartVertex, - /// An edge's end vertex. - EdgeEndVertex, - /// An edge's vertex at its other end from a vertex on it. - EdgeOtherVertex, -} - -impl OverflowInput { - const fn what(self) -> &'static str { - match self { - Self::FaceSurface => "a face a blend's overflow reads has no surface", - Self::EdgeCurve => "an edge a blend's overflow reads has no curve", - Self::EdgeStartVertex => "an edge a blend's overflow reads has no start vertex", - Self::EdgeEndVertex => "an edge a blend's overflow reads has no end vertex", - Self::EdgeOtherVertex => { - "an edge a blend's overflow walks has no vertex at its other end" - } - } - } -} - -/// Why a round kept round a feature is not built ([`BlendFailure::KeptFeatureNotBuilt`]), -/// each with its kind ([`KeepStop::class`]). -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[non_exhaustive] -pub enum KeepStop { - /// The walls of a kept boss are not upright to the planar face it stands on: their - /// continuation down is not built ([`ErrorKind::Unsupported`]; noted `NotExact`). - WallsNotUpright, - /// The faces of a boss's walls swept down are not all copied into the sheet - /// ([`ErrorKind::Failed`]). - WallsNotAllCopied, - /// A kept boss's wall continued down meets no round ([`ErrorKind::NotFound`]; noted - /// `BadMerge`). - WallMeetsNoRound, - /// The kept round's rails and creases enclose no part of the body, or all of it - /// ([`ErrorKind::NotFound`]; noted `BadMerge`). - RoundNotClosed, - /// The kept round does not sew into the body as a manifold solid - /// ([`ErrorKind::Failed`]; noted `BadMerge`). - RoundNotSewn, -} - -impl KeepStop { - /// The kind of the failure. - #[must_use] - pub const fn class(self) -> ErrorKind { - match self { - Self::WallsNotUpright => ErrorKind::Unsupported, - Self::WallMeetsNoRound | Self::RoundNotClosed => ErrorKind::NotFound, - Self::WallsNotAllCopied | Self::RoundNotSewn => ErrorKind::Failed, - } - } - - const fn what(self) -> &'static str { - match self { - Self::WallsNotUpright => { - "a kept boss's walls are not upright to the planar face it stands on" - } - Self::WallsNotAllCopied => "not every face of a kept boss's walls continued is copied", - Self::WallMeetsNoRound => "a kept boss's wall continued down meets no round", - Self::RoundNotClosed => "a round kept round a feature does not close on the body", - Self::RoundNotSewn => "a round kept round a feature does not sew into the body", - } - } -} - -/// Why a blend trimmed at its creases is not built ([`BlendFailure::CreaseTrimNotBuilt`]), -/// each with its kind ([`CreaseTrimStop::class`]). -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[non_exhaustive] -pub enum CreaseTrimStop { - /// The filleted edge has no tangent at an open end's vertex, so no section through the - /// vertex ends the round there ([`ErrorKind::Degenerate`]). - NoSectionThroughEndVertex, - /// A piece of a blend past its faces lies on the body's boundary away from its creases - /// ([`ErrorKind::Unsupported`]; noted `BadMerge`). - PieceOnBoundaryAwayFromCreases, - /// A corner's face between blends that add and blends that take off material, past their - /// faces or at an open setback ([`ErrorKind::Unsupported`]; noted `CornerUnsupported`). - CornerBetweenAddingAndTaking, - /// A round's section end lies along an edge of the body its rail does not cut - /// ([`ErrorKind::Unsupported`]; noted `BadMerge`). - SectionEndAlongUncutEdge, - /// The trim takes off nothing round the blended edges ([`ErrorKind::NotFound`]; noted - /// `BadMerge`). - TakesOffNothing, - /// The creases and rails enclose no part of the body: the trim reaches every face - /// ([`ErrorKind::NotFound`]; noted `BadMerge`). - ReachesEveryFace, - /// A body edge moved onto a crease leaves geometry the trim does not take off - /// ([`ErrorKind::Failed`]; noted `BadMerge`). - MovedEdgeLeavesGeometry, - /// The trimmed sheet does not sew into the body as a manifold solid - /// ([`ErrorKind::Failed`]; noted `BadMerge`). - NotSewn, -} - -impl CreaseTrimStop { - /// The kind of the failure. - #[must_use] - pub const fn class(self) -> ErrorKind { - match self { - Self::NoSectionThroughEndVertex => ErrorKind::Degenerate, - Self::PieceOnBoundaryAwayFromCreases - | Self::CornerBetweenAddingAndTaking - | Self::SectionEndAlongUncutEdge => ErrorKind::Unsupported, - Self::TakesOffNothing | Self::ReachesEveryFace => ErrorKind::NotFound, - Self::MovedEdgeLeavesGeometry | Self::NotSewn => ErrorKind::Failed, - } - } - - const fn what(self) -> &'static str { - match self { - Self::NoSectionThroughEndVertex => { - "the filleted edge has no tangent at an open end's vertex, so no section ends \ - the round there" - } - Self::PieceOnBoundaryAwayFromCreases => { - "a blend past its faces lies on the body's boundary away from its creases" - } - Self::CornerBetweenAddingAndTaking => { - "a corner's face between blends that add and blends that take off material is \ - not built" - } - Self::SectionEndAlongUncutEdge => { - "a round's section end lies along an edge of the body that its rail does not cut" - } - Self::TakesOffNothing => "a blend past its faces takes off nothing round its edges", - Self::ReachesEveryFace => { - "a blend past its faces reaches every face of the body (its creases and rails \ - enclose no part of it)" - } - Self::MovedEdgeLeavesGeometry => { - "a body edge moved onto a blend's crease leaves geometry the trim does not take off" - } - Self::NotSewn => { - "a blend past its faces does not sew into the body along its creases and rails" - } - } - } -} - -/// What a point of the cliff overflow does not drop onto -/// ([`BlendFailure::OverflowPointDoesNotDrop`]). -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[non_exhaustive] -pub enum OverflowDrop { - /// An end of a piece of the body's edge an extension runs along, onto the edge's curve - /// (within ten tolerances). - EdgePieceEndOntoEdge, - /// The middle of the filleted edge, onto a fillet face cut at an open end. - EdgeMiddleOntoFilletFace, - /// A sample of a closing face's loop, onto the face's surface. - LoopSampleOntoSurface, -} - -impl OverflowDrop { - const fn what(self) -> &'static str { - match self { - Self::EdgePieceEndOntoEdge => "an end of an edge's piece does not drop onto the edge", - Self::EdgeMiddleOntoFilletFace => { - "the filleted edge's middle does not drop onto a fillet face cut at an open end" - } - Self::LoopSampleOntoSurface => { - "a sample of a closing face's loop does not drop onto its surface" - } - } - } -} - -/// Which input of the planar-band contact query is missing ([`BlendFailure::BandInputMissing`]). -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[non_exhaustive] -pub enum BandInput { - /// The extrusion's control point in its stored net. - ExtrusionControlPoint, - /// The exact product of the extrusion's translation. - ExtrusionTranslationProduct, - /// A solver's edge use. - EdgeUse, - /// The face the two bands share. - SharedFace, - /// The planar support. - PlanarSupport, - /// The support on the other side of the blended edge. - OtherSupport, - /// The chamfer's setback. - ChamferSetback, - /// The other offset of the chamfer. - OtherOffset, - /// The first offset of the chamfer. - FirstOffset, - /// The blended edge. - BlendedEdge, - /// The blended edge's curve. - BlendedEdgeCurve, - /// The selected edge. - SelectedEdge, - /// The foot of a drop on the other support. - FootOnOtherSupport, - /// An endpoint of the blended edge. - BlendedEdgeEndpoint, - /// The closest feet of the two bands. - ClosestBandFeet, - /// An endpoint of the line. - LineEndpoint, -} - -impl BandInput { - /// What is missing, as a phrase ("the shared face"). - #[must_use] - pub const fn what(self) -> &'static str { - match self { - Self::ExtrusionControlPoint => "the extrusion control point", - Self::ExtrusionTranslationProduct => "the exact extrusion translation product", - Self::EdgeUse => "the edge use", - Self::SharedFace => "the shared face", - Self::PlanarSupport => "the planar support", - Self::OtherSupport => "the other support", - Self::ChamferSetback => "the chamfer setback", - Self::OtherOffset => "the other offset", - Self::FirstOffset => "the first offset", - Self::BlendedEdge => "the blended edge", - Self::BlendedEdgeCurve => "the blended edge's curve", - Self::SelectedEdge => "the selected edge", - Self::FootOnOtherSupport => "the foot on the other support", - Self::BlendedEdgeEndpoint => "the blended edge's endpoint", - Self::ClosestBandFeet => "the closest band feet", - Self::LineEndpoint => "the line endpoint", - } - } -} - -/// The step of the Mixed corner's construction that has no construction for the corner's -/// geometry ([`BlendFailure::MixedCornerUnbuildable`]). -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[non_exhaustive] -pub enum MixedStep { - /// A blend's rail on its wall does not meet the other blend's rail on the common face - /// swept along the face's normal (the corner's vertex A or B). Not found. - RailMissesRailWall, - /// A blend's rail on its wall does not cross the seam's line on its side of the vertex - /// (the corner's vertex P or Q). Not found. - WallRailMissesSeamLine, - /// A corner point has no foot on a wall face, inside the face, to take the face's - /// normal at. Not found. - NoFootOnWallFace, - /// The closest-point solve over a rail's interval returned no point for a corner - /// point (the tree solve's own failures are dropped, so it can end empty). Not found. - NoClosestPointOnRail, - /// A blend's surface has no B-spline form for the corner's exact algebra. - /// Unsupported. - BlendSurfaceNotBSpline, - /// A trimline's parameter curve has no B-spline form for the corner's exact algebra. - /// Unsupported. - TrimlineNotBSpline, - /// Three points of the concave blend's edge lie on one line: the edge has no circle - /// to take the corner's axis from. Degenerate. - ConcaveEdgeStraight, - /// A trimline has no speed at the rails' crossing: it has no tangent there. - /// Degenerate. - TrimlineStalls, - /// The first trimline runs along the convex edge at the rails' crossing: the second - /// trimline's direction has no coordinates in them. Degenerate. - TrimlineAlongConvexEdge, - /// The corner's shape at the rails' crossing has no asymptotic direction between the - /// trimlines. Unsupported. - NoAsymptoticDirection, - /// The inflection's end tangents (from the rails' crossing and at the vertex) are - /// parallel. Degenerate. - InflectionTangentsParallel, - /// The inflection's end tangents do not meet between the rails' crossing and the - /// vertex. Unsupported. - InflectionTangentsMiss, - /// The faces' tangent plane would turn the wrong way along the inflection (the twists' - /// rate is not positive). Unsupported. - TangentPlaneTurns, - /// A side's tangent leaves its neighbour's tangent plane at a corner of a face. - /// Unsupported. - SideLeavesTangentPlane, - /// The corner's twists are not compatible. Unsupported. - TwistsIncompatible, - /// A face's patch has a weight that is not positive. Unsupported. - FaceWeightNotPositive, - /// A curve's C1 reparametrization at a break has singular normal equations. - /// Degenerate. - JoinSingular, - /// A curve's C1 reparametrization at a break needs a span that is not positive. - /// Unsupported. - JoinSpanNotPositive, -} - -impl MixedStep { - /// The step's class: [`ErrorKind::NotFound`] for a crossing or foot not found, - /// [`ErrorKind::Degenerate`] for a degenerate shape, [`ErrorKind::Unsupported`] for a - /// shape the construction does not build. - #[must_use] - pub const fn class(self) -> ErrorKind { - match self { - Self::RailMissesRailWall - | Self::WallRailMissesSeamLine - | Self::NoFootOnWallFace - | Self::NoClosestPointOnRail => ErrorKind::NotFound, - Self::ConcaveEdgeStraight - | Self::TrimlineStalls - | Self::TrimlineAlongConvexEdge - | Self::InflectionTangentsParallel - | Self::JoinSingular => ErrorKind::Degenerate, - Self::BlendSurfaceNotBSpline - | Self::TrimlineNotBSpline - | Self::NoAsymptoticDirection - | Self::InflectionTangentsMiss - | Self::TangentPlaneTurns - | Self::SideLeavesTangentPlane - | Self::TwistsIncompatible - | Self::FaceWeightNotPositive - | Self::JoinSpanNotPositive => ErrorKind::Unsupported, - } - } - - /// What has no construction, as a phrase ("a rail does not meet ..."). - #[must_use] - pub const fn what(self) -> &'static str { - match self { - Self::RailMissesRailWall => { - "a rail on its wall does not meet the other blend's rail swept along the common face's normal" - } - Self::WallRailMissesSeamLine => { - "a rail on its wall does not cross the seam's line on its side of the vertex" - } - Self::NoFootOnWallFace => "a corner point has no foot inside a wall face", - Self::NoClosestPointOnRail => { - "the closest-point solve over a rail returned no point for a corner point" - } - Self::BlendSurfaceNotBSpline => "a blend's surface has no B-spline form", - Self::TrimlineNotBSpline => "a trimline's parameter curve has no B-spline form", - Self::ConcaveEdgeStraight => "the concave edge has no circle: its points lie on a line", - Self::TrimlineStalls => "a trimline has no tangent at the rails' crossing", - Self::TrimlineAlongConvexEdge => { - "the first trimline runs along the convex edge at the rails' crossing" - } - Self::NoAsymptoticDirection => { - "the shape at the rails' crossing has no asymptotic direction between the trimlines" - } - Self::InflectionTangentsParallel => "the inflection's end tangents are parallel", - Self::InflectionTangentsMiss => { - "the inflection's end tangents do not meet between the rails' crossing and the vertex" - } - Self::TangentPlaneTurns => { - "the faces' tangent plane would turn the wrong way along the inflection" - } - Self::SideLeavesTangentPlane => { - "a side's tangent leaves its neighbour's tangent plane at a face's corner" - } - Self::TwistsIncompatible => "the corner's twists are not compatible", - Self::FaceWeightNotPositive => "a face's patch has a weight that is not positive", - Self::JoinSingular => "a curve's C1 join at a break has singular equations", - Self::JoinSpanNotPositive => "a curve's C1 join at a break needs a span that is not positive", - } - } -} - -/// The step of a ball or chamfer corner's construction that has no result for the corner's -/// geometry ([`BlendFailure::CornerUnbuildable`]). -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[non_exhaustive] -pub enum CornerStep { - /// The line where two of the ball's offset planes meet does not meet the third face's - /// offset quadric as computed: the rounds' ball lies on all three offsets, so the miss - /// is rounding's (the line tangent to the offset, or in it). Not within tolerance. - BallCentreLineMissesOffset, - /// The Krawczyk test did not prove where the three offsets meet, in a box of rounding - /// of the part's size around the rounds' ball: the faces' normals there are too close - /// to dependent for the proof at that size. Not within tolerance. - BallCentreNotProved, - /// A chamfer's surface does not hold a corner edge's exact line within the corner's - /// tolerance (no foot of an end on it, or the surface is not affine in its parameters - /// along the line). Unsupported. - ChamferSurfaceOffEdgeLine, - /// The ball's first three offset planes do not meet in one point (two parallel, or the - /// third parallel to the first two's line) at the corner's tolerance. Degenerate. - BallOffsetPlanesDegenerate, - /// A round's end section has its two offset points farther apart than the tolerance. - /// Not within tolerance. - RoundSectionOffsetsApart, - /// The offsets' meeting point is farther than the tolerance from round 0's ball. Not - /// within tolerance. - BallCentreOffRound, - /// A ring plane past the third has an offset farther than the tolerance from the - /// ball's centre. Not within tolerance. - BallPlaneOffCentre, - /// A ball contact is farther than the tolerance from its corner vertex. Not within - /// tolerance. - BallContactOffVertex, - /// The point solve found no foot of the ball's centre on a round's offset surface. - /// Not found. - BallContactFootNotFound, - /// A round's offset surface at its point solve's foot is farther than the tolerance - /// from the ball's centre. Not within tolerance. - BallContactOffOffset, - /// A corner of the ball's triangular patch is farther than the tolerance from its - /// vertex. Not within tolerance. - BallPatchOffVertex, - /// Neither turn of the ball's triangular patch has its normal out of the material at - /// the test point: the normal there is along the material's boundary. Degenerate. - BallPatchNormalUndecided, - /// A chamfer corner's solved rail crossing is farther than the corner's tolerance from - /// its exact point. Not within tolerance. - ChamferCrossingOffExact, - /// The chamfer facet's plane does not hold a side's line within rounding. Not within - /// tolerance. - ChamferFacetOffPlane, - /// The Mixed corner's common face is not planar to the corner's tolerance. Not within - /// tolerance. - CommonFaceNotPlanar, -} - -impl CornerStep { - /// The step's class: [`ErrorKind::NotWithinTolerance`] for a solve that ended within - /// rounding without a result (neither a defect nor a refusal), - /// [`ErrorKind::Unsupported`] for geometry the construction does not build. - #[must_use] - pub const fn class(self) -> ErrorKind { - match self { - Self::BallCentreLineMissesOffset - | Self::BallCentreNotProved - | Self::RoundSectionOffsetsApart - | Self::BallCentreOffRound - | Self::BallPlaneOffCentre - | Self::BallContactOffVertex - | Self::BallContactOffOffset - | Self::BallPatchOffVertex - | Self::ChamferCrossingOffExact - | Self::ChamferFacetOffPlane - | Self::CommonFaceNotPlanar => ErrorKind::NotWithinTolerance, - Self::BallOffsetPlanesDegenerate | Self::BallPatchNormalUndecided => { - ErrorKind::Degenerate - } - Self::BallContactFootNotFound => ErrorKind::NotFound, - Self::ChamferSurfaceOffEdgeLine => ErrorKind::Unsupported, - } - } - - /// What has no result, as a phrase. - #[must_use] - pub const fn what(self) -> &'static str { - match self { - Self::BallCentreLineMissesOffset => { - "the line of two of the ball's offset planes misses the third face's offset within rounding" - } - Self::BallCentreNotProved => { - "the ball's centre was not proved where the three offsets meet, within rounding of the part's size" - } - Self::ChamferSurfaceOffEdgeLine => { - "a chamfer's surface does not hold a corner edge's exact line within the corner's tolerance" - } - Self::BallOffsetPlanesDegenerate => { - "the ball's first three offset planes do not meet in one point at the corner's tolerance" - } - Self::RoundSectionOffsetsApart => { - "a round's end section has its offset points farther apart than the tolerance" - } - Self::BallCentreOffRound => { - "the offsets' meeting point is farther than the tolerance from round 0's ball" - } - Self::BallPlaneOffCentre => { - "a ring plane past the third has its offset farther than the tolerance from the ball's centre" - } - Self::BallContactOffVertex => { - "a ball contact is farther than the tolerance from its corner vertex" - } - Self::BallContactFootNotFound => { - "the point solve found no foot of the ball's centre on a round's offset surface" - } - Self::BallContactOffOffset => { - "a round's offset surface at the ball contact's foot is farther than the tolerance from the ball's centre" - } - Self::BallPatchOffVertex => { - "a corner of the ball's triangular patch is farther than the tolerance from its vertex" - } - Self::BallPatchNormalUndecided => { - "neither turn of the ball's triangular patch has its normal out of the material" - } - Self::ChamferCrossingOffExact => { - "a solved rail crossing is farther than the chamfer corner's tolerance from its exact point" - } - Self::ChamferFacetOffPlane => { - "the chamfer facet's plane does not hold a side's line within rounding" - } - Self::CommonFaceNotPlanar => { - "the Mixed corner's common face is not planar to the corner's tolerance" - } - } - } -} - -/// What a fillet corner given to a corner step lacks, or holds otherwise than the corner -/// topology makes it ([`BlendFailure::CornerInputInvalid`]): the conditions only the corner -/// steps check. A missing link of the fillet structures that other routines read too (a -/// fillet edge's primary edge use or its mate, a rail's end vertex use, a fillet vertex's -/// face, a cross-section's fillet geometry, a rail's curve) is -/// [`BlendFailure::FilletSetUpInvalid`] instead, a fillet geometry without its fillet -/// surface the solver's ([`SolverFailure::FilletGeomWithoutSurface`]), and a target-body -/// edge without curve is [`BlendFailure::EdgeWithoutCurve`]. -/// -/// [`CornerInput::upstream_status`] is each kind's default status. A site whose C++ reports -/// the condition otherwise (a failed state check, `SE(SM_ERR)`, where the default is -/// `SM_ERR_NULL_POINTER`) overrides it with that status, so the status is always the site's. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[non_exhaustive] -pub enum CornerInput { - /// An Nx2 corner of kind `kind` with no filleted edge uses. - FilletedEdgeUsesNotGiven { - /// The corner's kind. - kind: crate::blend::fillet_corner::p3::FilletCornerKind, - }, - /// An Nx2 corner of kind `kind` with `given` filleted edge uses, not two. - FilletedEdgeUsesNotTwo { - /// The corner's kind. - kind: crate::blend::fillet_corner::p3::FilletCornerKind, - /// The filleted edge uses it holds. - given: usize, - }, - /// A concave corner with no rail-cross-edge-use vertex between two fillet geometries. - NoRailXEdgeUseVertex, - /// A vertex of a convex `NxN` corner of at most three vertices that is not where two - /// rails cross. - VertexNotRailXRail, - /// A corner edge's or a rail's edge use with no fillet geometry (a cross-section's is - /// [`FilletSetUp::CrossSectionGeom`]). - EdgeUseWithoutFilletGeometry, - /// A corner edge of the pseudo-B-rep with no curve (a rail's is - /// [`FilletSetUp::RailCurve`], a target-body edge's [`BlendFailure::EdgeWithoutCurve`]). - EdgeWithoutCurve, - /// A 3x2 corner of four edges with no on-edge edge. - MixedCornerWithoutOnEdgeEdge, - /// A 3x2 corner of four edges with no on-extended-edge edge. - MixedCornerWithoutOnExtendedEdgeEdge, - /// A 3x2 corner whose on-edge edge does not start at an on-vertex vertex where the - /// on-extended-edge edge ends. - MixedCornerEdgesDoNotMeet, - /// A 3x2 corner whose on-vertex vertex is not among its vertices. - MixedCornerVertexNotInCorner, - /// An edge of the body at a chamfer corner's vertex with no vertex at an end. - EdgeWithoutVertex, - /// A ball corner with no ring of edge uses. - RingNotSet, - /// A ball, chamfer or Mixed corner with no event of its kind (ball members, chamfer or - /// Mixed event). - EventNotSet, - /// A chamfer facet event with no normal. - FacetNormalNotSet, - /// A chamfer or Mixed corner with no faces' geometry for its patch step. - FacesNotBuilt, - /// A corner patch step given no fillet B-rep. - FilletBrepNotGiven, - /// A ball, chamfer or Mixed corner whose vertices or edges are not the count or kind its - /// topology makes. - TopologyMismatch, - /// A vertex of a chamfer or Mixed corner that is not processed. - VertexNotProcessed, - /// A ring face of a ball corner whose kind or offset is not the one the corner's - /// classification took. - FaceNotAsClassified, - /// An edge of a Mixed corner that does not meet the corner's vertex. - EdgeOffVertex, - /// A corner whose event or patches do not hold together: a facet without crossings or a - /// unit normal, a patch order that does not run round its crossings, or patches and - /// loops that do not pair up. - EventMalformed, -} - -impl CornerInput { - /// The kind's default status: `SM_ERR` where the C++ reports a failed state check - /// (`SE(SM_ERR)`), else `SM_ERR_NULL_POINTER` for what it dereferences and does not - /// find (`NER`). A site that reports the condition otherwise overrides it (see - /// [`CornerInput`]). - #[must_use] - pub const fn upstream_status(self) -> i32 { - match self { - Self::FilletedEdgeUsesNotTwo { .. } - | Self::VertexNotRailXRail - | Self::MixedCornerEdgesDoNotMeet - | Self::MixedCornerVertexNotInCorner - | Self::TopologyMismatch - | Self::VertexNotProcessed - | Self::FaceNotAsClassified - | Self::EdgeOffVertex - | Self::EventMalformed => SM_ERR, - Self::FilletedEdgeUsesNotGiven { .. } - | Self::NoRailXEdgeUseVertex - | Self::EdgeUseWithoutFilletGeometry - | Self::EdgeWithoutCurve - | Self::MixedCornerWithoutOnEdgeEdge - | Self::MixedCornerWithoutOnExtendedEdgeEdge - | Self::EdgeWithoutVertex - | Self::RingNotSet - | Self::EventNotSet - | Self::FacetNormalNotSet - | Self::FacesNotBuilt - | Self::FilletBrepNotGiven => SM_ERR_NULL_POINTER, - } - } -} - -/// The link of the fillet structures that is not there or not as the routine needs -/// ([`BlendFailure::FilletSetUpInvalid`]). -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[non_exhaustive] -pub enum FilletSetUp { - /// One of a fillet solver's two offset surfaces. - SolverOffsetSurface, - /// The offset surface of a fillet geometry's rail, its own or its solver's. - RailOffsetSurface, - /// The vertex use an edge use of the body starts at. - EdgeUseVertexUse, - /// The face use of a vertex use of a face's loop. - VertexUseFaceUse, - /// The body vertex a fillet corner rounds. - CornerVertex, - /// The face a fillet vertex (or its mate) is classified to. - PointClassFace, - /// The side edge use a fillet vertex on a side edge is classified to. - PointClassEdgeUse, - /// The vertex use of a rail's edge at a fillet vertex at the rail's end. - RailEndVertexUse, - /// The fillet geometries a fillet vertex's kind joins. - VertexGeoms, - /// A Join's fillet vertex's mate. - Mate, - /// The radial edge use of a side edge's edge use. - RadialEdgeUse, - /// A rail/rail interpolation edge among its corner's fillet edges. - InterpolationEdgeAtCorner, - /// The cross-section opposite a rail/rail interpolation edge at its corner. - OppositeCrossSection, - /// The fillet geometry a cross-section's primary edge use spans. - CrossSectionGeom, - /// A fillet solver's surface generator. - SurfaceGenerator, - /// A fillet edge's primary edge use. - PrimaryEdgeUse, - /// The mate of a fillet edge's primary edge use. - PrimaryEdgeUseMate, - /// The two fillet vertices a fillet edge joins. - EdgeVertices, - /// The original face a fillet edge records, of any fillet edge type (a rail/rail - /// interpolation edge's face it lies on included). - OriginalFace, - /// The rail ending at an end of a rail/rail interpolation edge. - InterpolationEndRail, - /// A rail edge's 3D curve, or the UV trim curve the 2D path reads. - RailCurve, - /// A rail's end vertex on the rail's curve. - RailEndOffRail, - /// The B-spline UV trim curve of a rail's edge use. - UvTrimCurve, -} - -impl FilletSetUp { - /// What is wrong, as a clause. - const fn what(self) -> &'static str { - match self { - Self::SolverOffsetSurface => "a fillet solver lacks one of its two offset surfaces", - Self::RailOffsetSurface => { - "a rail of a fillet geometry has no offset surface, of its own or its solver's" - } - Self::EdgeUseVertexUse => "an edge use of the body starts at no vertex use", - Self::VertexUseFaceUse => "a vertex use of a face's loop is in no face use", - Self::CornerVertex => "the fillet corner records no body vertex it rounds", - Self::PointClassFace => "a fillet vertex is not classified to a face", - Self::PointClassEdgeUse => { - "a fillet vertex on a side edge is not classified to that edge's edge use" - } - Self::RailEndVertexUse => { - "a fillet vertex at a rail's end has no vertex use of the rail's edge" - } - Self::VertexGeoms => "a fillet vertex lacks the fillet geometries its kind joins", - Self::Mate => "a Join's fillet vertex has no mate", - Self::RadialEdgeUse => "an edge use of a side edge has no radial edge use", - Self::InterpolationEdgeAtCorner => { - "the rail/rail interpolation edge is not one of its corner's fillet edges" - } - Self::OppositeCrossSection => { - "the fillet edge opposite the rail/rail interpolation edge is not a cross-section" - } - Self::CrossSectionGeom => "a cross-section's primary edge use spans no fillet geometry", - Self::SurfaceGenerator => "a fillet solver has no surface generator", - Self::PrimaryEdgeUse => "a fillet edge has no primary edge use", - Self::PrimaryEdgeUseMate => "a fillet edge's primary edge use has no mate", - Self::EdgeVertices => "a fillet edge does not join two fillet vertices", - Self::OriginalFace => "a fillet edge records no original face", - Self::InterpolationEndRail => { - "an end of the rail/rail interpolation edge is no rail's end" - } - Self::RailCurve => { - "a rail edge lacks its 3D curve or the UV trim curve the 2D path reads" - } - Self::RailEndOffRail => { - "the fillet vertex at the rail's end does not lie on the rail's curve" - } - Self::UvTrimCurve => "the rail's edge use has no B-spline UV trim curve", - } - } -} - -/// What a weld bead the kernel does not build yet needs ([`BlendFailure::WeldNotBuilt`]). -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[non_exhaustive] -pub enum WeldGap { - /// Beads that meet at a vertex need a corner piece (#17916); the failure's site names the - /// vertex. - BeadsMeetAtVertex, - /// A joint that is not a straight edge between two planes: only the exact planar bead is - /// built so far; the bead on any joint (the foot blend) comes with its certificate - /// (#18028). The failure's site names the edge. - CurvedJoint, - /// A bead whose toe on one face is obtuse (its second leg at most its first times the - /// cosine of the angle between the faces, or the other way round): the exact planar - /// bead's surface is read through the chamfer's ball, which such legs fold. The failure's - /// site names the edge. - ObtuseToe, -} - -/// The class of a blend larger than its faces allow, for `reason`: one of the blend's -/// refusal classes 101 to 124 (the cliff overflow's own refusals grouped by what decides -/// them), [`ErrorKind::TangentContinuationEnd`] (128) or [`ErrorKind::OverflowKeepsNothing`] -/// (129). -/// [`ErrorKind::CliffSubtractionLeavesNoSolid`] is the one defect among them. -#[must_use] -pub const fn no_room_class(reason: NoRoomReason) -> ErrorKind { - use NoRoomReason as R; - match reason { - // a Join's: the round's ball does not fit its face where its contact line must cross - // the edge between the rounds' faces - R::BallDoesNotFit | R::JoinRailMissesSideEdge => ErrorKind::BallDoesNotFit, - R::RailLeavesFace | R::ConcaveOverflow => ErrorKind::RailLeavesFace, - R::FaceConsumed => ErrorKind::FaceConsumed, - R::BandsOverlap => ErrorKind::BandsOverlap, - R::BallsFold => ErrorKind::BallsFold, - R::OffsetFolds => ErrorKind::ChamferOffsetFolds, - R::CutsThePart => ErrorKind::CutsThePart, - R::BreaksThrough => ErrorKind::BreaksThrough, - R::OffsetCollapses => ErrorKind::BallOffsetCollapses, - R::CornersTakeWholeEdge => ErrorKind::CornersTakeWholeEdge, - R::RoundIntoMaterial | R::RailRunsPastFaceIntoMaterial => ErrorKind::RunsIntoMaterial, - R::OverflowWithConcaveBlend | R::OverflowWithRollover | R::OverflowWithGlobalMerge => { - ErrorKind::CliffOverflowRefused - } - R::CliffEndFaceNotPlanar => ErrorKind::CliffEndFaceNotPlanar, - R::CliffLawNotHeld - | R::CliffEndNotCut - | R::CliffBoundaryOnTwoFaces - | R::CliffBoundaryBranches - | R::CliffBoundaryClosed - | R::CliffBoundaryLeavesAlongNoSideEdge - | R::CliffClosingFaceUnbounded => ErrorKind::CliffOverflowShape, - R::CliffSubtractionLeavesNoSolid => ErrorKind::CliffSubtractionLeavesNoSolid, - R::CreaseAcrossTangentEdge => ErrorKind::CreaseAcrossTangentEdge, - R::RailBelowResolution => ErrorKind::RailBelowResolution, - R::RailPastAxis => ErrorKind::RailPastAxis, - R::JoinOffsetsDiffer => ErrorKind::JoinOffsetsDiffer, - R::StripBelowResolution => ErrorKind::StripBelowResolution, - R::EndPastSideEdge => ErrorKind::EndPastSideEdge, - // an End the round overflows: past its side edge, or over its end face whole - R::EndOverflowsSideEdge | R::EndPassesOverEndFace => ErrorKind::EndOverflowsSideEdge, - R::EndRollsIntoSmoothEnd => ErrorKind::EndRollsIntoSmoothEnd, - R::EndAtSeamVertex => ErrorKind::EndAtSeamVertex, - R::TangentContinuationEndUnsupported => ErrorKind::TangentContinuationEnd, - R::OverflowKeepsNothing => ErrorKind::OverflowKeepsNothing, - // a weld bead larger than its faces take: the error names the size that builds - R::LegPastFace | R::NoToeAtLeg | R::BeadCutsFace => ErrorKind::FilletTooLarge, - } -} - -/// Why a fillet removal (`crate::blend::fillet_removal`, its ring removal included) refuses -/// the face it is asked to remove. Each is a fact of the face and its neighbours, not a -/// defect; the class is [`removal_class`]. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[non_exhaustive] -pub enum RemovalRefusal { - /// A face the removal extends would grow past its surface's domain, which only a plane - /// continues exactly. - FaceGrowsPastDomain, - /// A corner of more than three edges keeps its end edge, which would need a fitted - /// intersection to run on to the new corner. - CornerNeedsFittedIntersection, - /// The side edge that would run on to the new corner is not a straight B-spline curve, - /// so it cannot run on exactly. - SideEdgeNotStraight, - /// The new corner is off the line of the side edge that would run on to it. - CornerOffSideLine, - /// The tangent surfaces of a ring fillet do not meet in a closed curve near its rails - /// within their domains: the sharp edge would lie on a continuation of one of them. - TangentSurfacesDoNotMeet, - /// The support intersection has a shape the removal cannot rebuild as a sharp edge. - UnsupportedSharpSpine(BlendSpine), - /// The new sharp edge's UV trim could not be certified within the original rail tolerance. - RailTrimOutsideTolerance, - /// A seam's UV trim, run on, does not reach the new vertex on its face's surface. - SeamTrimMissesNewVertex, - /// The fillet face does not have four edges. - NotFourEdges, - /// Two adjacent edges of the fillet face are both tangent. - AdjacentEdgesTangent, - /// The selected faces do not form one connected strip with two rails. - NotOneTangentChain, - /// The edge opposite the fillet face's tangent edge is not tangent. - OppositeEdgeNotTangent, - /// Neither of the fillet face's first two edges is tangent. - NoTangentEdge, - /// A tangent or end edge of the fillet face does not have two vertices. - EdgeWithoutTwoVertices, - /// An edge of the fillet face does not border exactly two faces. - EdgeNotBetweenTwoFaces, - /// A tangent face's surface is not a B-spline surface. - TangentFaceNotBSpline, - /// An end face's surface is not a B-spline surface. - EndFaceNotBSpline, - /// The face is not a ring fillet. - NotARing, - /// The ring fillet has more than two rails. - MoreThanTwoRails, - /// The ring fillet does not have two rails between two other faces. - RailsNotBetweenTwoFaces, - /// The ring fillet's seam does not join the two rails' vertices. - SeamDoesNotJoinRails, - /// A rail's vertex has an edge other than one open seam of its tangent face. - RailVertexHasOtherEdges, - /// A tangent face's seam crosses the sharp edge at more than one place. - SeamCrossesSharpEdgeTwice, - /// The two tangent faces' seams cross the sharp edge at different places. - SeamsCrossApart, - /// A seam has more than two edge uses with their own UV trim curves. - SeamHasMoreThanTwoTrims, - /// A seam has no edge use with its own UV trim curve. - SeamHasNoOwnTrim, -} - -/// The class of a fillet removal's refusal, for `reason`: [`ErrorKind::RemovalNotExact`] (130) -/// where the removal would continue a face or an edge past its geometry, and -/// [`ErrorKind::NotARemovableFillet`] (131) where the face and its neighbours are not a fillet -/// the removal recognises. Both are refusals no size decides. -#[must_use] -pub const fn removal_class(reason: RemovalRefusal) -> ErrorKind { - use RemovalRefusal as R; - match reason { - R::FaceGrowsPastDomain - | R::CornerNeedsFittedIntersection - | R::SideEdgeNotStraight - | R::CornerOffSideLine - | R::TangentSurfacesDoNotMeet - | R::UnsupportedSharpSpine(_) - | R::RailTrimOutsideTolerance - | R::SeamTrimMissesNewVertex => ErrorKind::RemovalNotExact, - R::NotFourEdges - | R::AdjacentEdgesTangent - | R::NotOneTangentChain - | R::OppositeEdgeNotTangent - | R::NoTangentEdge - | R::EdgeWithoutTwoVertices - | R::EdgeNotBetweenTwoFaces - | R::TangentFaceNotBSpline - | R::EndFaceNotBSpline - | R::NotARing - | R::MoreThanTwoRails - | R::RailsNotBetweenTwoFaces - | R::SeamDoesNotJoinRails - | R::RailVertexHasOtherEdges - | R::SeamCrossesSharpEdgeTwice - | R::SeamsCrossApart - | R::SeamHasMoreThanTwoTrims - | R::SeamHasNoOwnTrim => ErrorKind::NotARemovableFillet, - } -} - -impl BlendFailure { - /// The status the C++ reports for the failure unless its site says otherwise (a - /// comparison detail). - pub(crate) const fn comparison_status(&self) -> i32 { - match self { - Self::NoRoom(_) - | Self::RemovalRefused(_) - | Self::StationDidNotConverge { .. } - | Self::TrimLoopOpen - | Self::TrimLoopDoesNotSeparate - | Self::ClosedCliffWouldNotSplit { .. } - | Self::StageFailed - | Self::Defect { .. } - | Self::SkinPastStationCap { .. } - | Self::SkinMeasureNotFinite { .. } - | Self::BallsNest { .. } - | Self::CreasePieceEndUnbuildable { .. } - | Self::BallTriangleNotOnePatch { .. } - | Self::MixedCornerUnbuildable(_) - | Self::CornerUnbuildable(_) - | Self::CrossingNotFinite - | Self::PlaneCurveTouches { .. } - | Self::PlaneCurveEndOff { .. } - | Self::PlaneCurveLeavesDomain { .. } - | Self::PlaneCurveStepVanished { .. } - | Self::PlaneCurveFitCap { .. } - | Self::NotCertified { .. } - | Self::CornerPointDropUnresolved { .. } - | Self::WeldNotBuilt(_) - | Self::LawIntervalEmpty - | Self::ExactBlendAxisCannotPlaceEdge { .. } - | Self::LawHasNoValue - | Self::FilletCrossesItself { .. } - | Self::CornerRefused - | Self::ExecutiveStepFailed - | Self::EdgeSplitDeclined { .. } - | Self::EaseNotBuilt(_) - | Self::SectionNotProved(_) - | Self::SectionDegenerate(_) - | Self::SectionUnsupported(_) - | Self::RadiusLawNotPositive { .. } - | Self::SectionInputInvalid(_) - | Self::OverflowPointDoesNotDrop(_) - | Self::ExtensionEndOnTwoSideLines - | Self::NoBlendedEdgeNearExtension - | Self::KeptFeatureNotBuilt(_) - | Self::CreaseTrimNotBuilt(_) - | Self::Failed(_) => SM_ERR, - Self::Trace(t) => t.comparison_status(), - Self::Missing(_) - | Self::BandInputMissing(_) - | Self::CliffInputMissing { .. } - | Self::CrossingInputMissing(_) - | Self::EaseInputMissing(_) - | Self::EaseGeometryNotBSpline(_) - | Self::OverflowInputMissing(_) - | Self::VariableRadiusLawsNotGiven - | Self::BevelVertexNotFilleted - | Self::EdgeWithoutCurve - | Self::FilletSetUpInvalid(_) - | Self::SequenceCurveNotBSpline { .. } - | Self::LawCornerNotFound { .. } - | Self::EdgeUseWithoutEdge - | Self::BoundSurfaceRemoved - | Self::CornerPatchFaceNotFound { .. } => SM_ERR_NULL_POINTER, + Self::ArcLengthNotConverged { .. } => SM_ERR_NOT_CONVERGING, + Self::BadIntersections(_) => SM_ERR_BAD_INTERSECTIONS, + Self::BallTriangleNotOnePatch { .. } => SM_ERR, + Self::BallsNest { .. } => SM_ERR, + Self::BandInputMissing(_) => SM_ERR_NULL_POINTER, + Self::BevelVertexNotFilleted => SM_ERR_NULL_POINTER, + Self::BoundSurfaceRemoved => SM_ERR_NULL_POINTER, + Self::ChamferFaceNotOfEdge => SM_ERR_INVALID_INPUT, + Self::ChamferSizeInvalid => SM_ERR_INVALID_INPUT, + Self::CliffInputMissing { .. } => SM_ERR_NULL_POINTER, + Self::ClosedCliffWouldNotSplit { .. } => SM_ERR, + Self::CornerInputInvalid { input, .. } => input.upstream_status(), + Self::CornerPatchFaceNotFound { .. } => SM_ERR_NULL_POINTER, + Self::CornerPointDropUnresolved { .. } => SM_ERR, + Self::CornerRefused => SM_ERR, Self::CornerShapeNotBuilt(shape) => shape.upstream_status(), - Self::NoEdgesGiven - | Self::SizeBelowResolution { .. } - | Self::PerEdgeListLength { .. } - | Self::ParameterListSizes { .. } - | Self::FaceHasNoSurface - | Self::NoFirstBody - | Self::TargetNotGiven - | Self::EdgeNotInTarget { .. } - | Self::EdgeNotFilletable { .. } - | Self::ChamferSizeInvalid - | Self::ChamferFaceNotOfEdge - | Self::SolverFaceIndexInvalid { .. } - | Self::GnSectionInvalid { .. } - | Self::CrossSectionTypeUnknown - | Self::RadiusTypeNotForEdges { .. } - | Self::VariableRadiusLawMissing { .. } - | Self::InvalidValue(_) => SM_ERR_INVALID_INPUT, - Self::Solver(s) => s.comparison_status(), + Self::CornerUnbuildable(_) => SM_ERR, + Self::CreasePieceEndUnbuildable { .. } => SM_ERR, + Self::CreaseTrimNotBuilt(_) => SM_ERR, + Self::CrossSectionTypeUnknown => SM_ERR_INVALID_INPUT, + Self::CrossingInputMissing(_) => SM_ERR_NULL_POINTER, + Self::CrossingNotFinite => SM_ERR, + Self::Defect { .. } => SM_ERR, + Self::EaseGeometryNotBSpline(_) => SM_ERR_NULL_POINTER, + Self::EaseInputMissing(_) => SM_ERR_NULL_POINTER, + Self::EaseNotBuilt(_) => SM_ERR, + Self::EdgeNotFilletable { .. } => SM_ERR_INVALID_INPUT, + Self::EdgeNotInTarget { .. } => SM_ERR_INVALID_INPUT, + Self::EdgeSplitDeclined { .. } => SM_ERR, + Self::EdgeUseWithoutEdge => SM_ERR_NULL_POINTER, + Self::EdgeWithoutCurve => SM_ERR_NULL_POINTER, + Self::ExactBlendAxisCannotPlaceEdge { .. } => SM_ERR, + Self::ExecutiveStepFailed => SM_ERR, + Self::ExtensionEndOnTwoSideLines => SM_ERR, + Self::FaceHasNoSurface => SM_ERR_INVALID_INPUT, + Self::Failed(_) => SM_ERR, + Self::FilletCrossesItself { .. } => SM_ERR, + Self::FilletSetUpInvalid(_) => SM_ERR_NULL_POINTER, + Self::GnSectionInvalid { .. } => SM_ERR_INVALID_INPUT, Self::Inconsistent(_) => SM_ERR_ASSERT_FAILURE, - Self::BadIntersections(_) => SM_ERR_BAD_INTERSECTIONS, - Self::ArcLengthNotConverged { .. } | Self::NotConverged(_) => SM_ERR_NOT_CONVERGING, - Self::OutsideDomain(_) => SM_ERR_OUTSIDE_OF_DOMAIN, + Self::InvalidValue(_) => SM_ERR_INVALID_INPUT, + Self::KeptFeatureNotBuilt(_) => SM_ERR, + Self::LawCornerNotFound { .. } => SM_ERR_NULL_POINTER, + Self::LawHasNoValue => SM_ERR, + Self::LawIntervalEmpty => SM_ERR, + Self::Missing(_) => SM_ERR_NULL_POINTER, + Self::MixedCornerUnbuildable(_) => SM_ERR, + Self::NoBlendedEdgeNearExtension => SM_ERR, + Self::NoEdgesGiven => SM_ERR_INVALID_INPUT, + Self::NoFirstBody => SM_ERR_INVALID_INPUT, + Self::NoRoom(_) => SM_ERR, + Self::NotCertified { .. } => SM_ERR, + Self::NotConverged(_) => SM_ERR_NOT_CONVERGING, Self::NotWithinTolerance(_) => SM_ERR_NOT_WITHIN_TOLERANCE, - Self::CornerInputInvalid { input, .. } => input.upstream_status(), + Self::OutsideDomain(_) => SM_ERR_OUTSIDE_OF_DOMAIN, + Self::OverflowInputMissing(_) => SM_ERR_NULL_POINTER, + Self::OverflowPointDoesNotDrop(_) => SM_ERR, + Self::ParameterListSizes { .. } => SM_ERR_INVALID_INPUT, Self::PassedOn { status, .. } => *status, + Self::PerEdgeListLength { .. } => SM_ERR_INVALID_INPUT, + Self::PlaneCurveEndOff { .. } => SM_ERR, + Self::PlaneCurveFitCap { .. } => SM_ERR, + Self::PlaneCurveLeavesDomain { .. } => SM_ERR, + Self::PlaneCurveStepVanished { .. } => SM_ERR, + Self::PlaneCurveTouches { .. } => SM_ERR, + Self::RadiusLawNotPositive { .. } => SM_ERR, + Self::RadiusTypeNotForEdges { .. } => SM_ERR_INVALID_INPUT, + Self::RemovalRefused(_) => SM_ERR, + Self::SectionDegenerate(_) => SM_ERR, + Self::SectionInputInvalid(_) => SM_ERR, + Self::SectionNotProved(_) => SM_ERR, + Self::SectionUnsupported(_) => SM_ERR, + Self::SequenceCurveNotBSpline { .. } => SM_ERR_NULL_POINTER, + Self::SizeBelowResolution { .. } => SM_ERR_INVALID_INPUT, + Self::SkinMeasureNotFinite { .. } => SM_ERR, + Self::SkinPastStationCap { .. } => SM_ERR, + Self::Solver(s) => s.comparison_status(), + Self::SolverFaceIndexInvalid { .. } => SM_ERR_INVALID_INPUT, + Self::StageFailed => SM_ERR, + Self::StationDidNotConverge { .. } => SM_ERR, + Self::TargetNotGiven => SM_ERR_INVALID_INPUT, + Self::Trace(t) => t.comparison_status(), + Self::TrimLoopDoesNotSeparate => SM_ERR, + Self::TrimLoopOpen => SM_ERR, + Self::VariableRadiusLawMissing { .. } => SM_ERR_INVALID_INPUT, + Self::VariableRadiusLawsNotGiven => SM_ERR_NULL_POINTER, + Self::WeldNotBuilt(_) => SM_ERR, } } - /// The failure's class, its stable [`ErrorKind`], derived from the cause: the reason's - /// class for [`BlendFailure::NoRoom`] ([`no_room_class`]) and - /// [`BlendFailure::RemovalRefused`] ([`removal_class`]), - /// [`ErrorKind::StationDidNotConverge`], [`ErrorKind::TrimLeaks`] for an open or leaking - /// trim loop, [`ErrorKind::StageFailed`] for [`BlendFailure::StageFailed`], - /// [`BlendFailure::Defect`], [`BlendFailure::SkinMeasureNotFinite`] and - /// [`BlendFailure::PlaneCurveStepVanished`], [`ErrorKind::NotWithinTolerance`] for - /// [`BlendFailure::SkinPastStationCap`], [`BlendFailure::PlaneCurveFitCap`] and for a - /// surface not certified within its tolerance in its work budget - /// ([`BlendFailure::NotCertified`]), [`ErrorKind::Degenerate`] for - /// [`BlendFailure::PlaneCurveTouches`], [`ErrorKind::NotFound`] for - /// [`BlendFailure::PlaneCurveEndOff`], [`ErrorKind::OutsideDomain`] for - /// [`BlendFailure::PlaneCurveLeavesDomain`], [`ErrorKind::BallsFold`] for - /// [`BlendFailure::BallsNest`], and - /// [`ErrorKind::Unsupported`] for [`BlendFailure::CreasePieceEndUnbuildable`] and - /// [`BlendFailure::BallTriangleNotOnePatch`], [`ErrorKind::Unsupported`] for - /// [`BlendFailure::CornerShapeNotBuilt`], [`ErrorKind::NotFound`] for - /// [`BlendFailure::CornerPointDropUnresolved`], and the step's class - /// ([`MixedStep::class`], [`CornerStep::class`]) for [`BlendFailure::MixedCornerUnbuildable`] - /// and [`BlendFailure::CornerUnbuildable`]. A phrase - /// cause keeps the kind of its status ([`ErrorKind::Failed`], [`ErrorKind::Missing`], - /// [`ErrorKind::InvalidInput`], ...), as before the record ([`BlendFailure::is_phrase`]). + /// The failure's class, its stable [`ErrorKind`], derived from the cause: see each + /// variant. A phrase cause keeps the kind of its status ([`ErrorKind::Failed`], + /// [`ErrorKind::Missing`], [`ErrorKind::InvalidInput`], ...), as before the record + /// ([`BlendFailure::is_phrase`]). #[must_use] + #[allow( + clippy::match_same_arms, + reason = "one arm per variant, sorted by name, so causes added in parallel touch disjoint lines" + )] pub const fn class(&self) -> ErrorKind { match self { - Self::NoRoom(reason) => no_room_class(*reason), - Self::Trace(t) => t.class(), - Self::RemovalRefused(reason) => removal_class(*reason), - Self::StationDidNotConverge { .. } => ErrorKind::StationDidNotConverge, - Self::TrimLoopOpen | Self::TrimLoopDoesNotSeparate => ErrorKind::TrimLeaks, - Self::StageFailed - | Self::Defect { .. } - | Self::SkinMeasureNotFinite { .. } - | Self::PlaneCurveStepVanished { .. } - | Self::CrossingNotFinite => ErrorKind::StageFailed, - Self::SkinPastStationCap { .. } - | Self::NotCertified { .. } - | Self::SectionNotProved(_) - | Self::PlaneCurveFitCap { .. } => ErrorKind::NotWithinTolerance, - Self::PlaneCurveTouches { .. } | Self::SectionDegenerate(_) => ErrorKind::Degenerate, - Self::RadiusLawNotPositive { .. } | Self::SectionInputInvalid(_) => { - ErrorKind::InvalidInput - } - Self::PlaneCurveEndOff { .. } - | Self::LawCornerNotFound { .. } - | Self::CornerPatchFaceNotFound { .. } - | Self::CornerPointDropUnresolved { .. } => ErrorKind::NotFound, - Self::PlaneCurveLeavesDomain { .. } => ErrorKind::OutsideDomain, + Self::ArcLengthNotConverged { .. } => ErrorKind::NotConverged, + Self::BadIntersections(_) => ErrorKind::of_status(self.comparison_status()), + Self::BallTriangleNotOnePatch { .. } => ErrorKind::Unsupported, Self::BallsNest { .. } => ErrorKind::BallsFold, - Self::CreasePieceEndUnbuildable { .. } - | Self::BallTriangleNotOnePatch { .. } - | Self::CornerShapeNotBuilt(_) - | Self::LawHasNoValue - | Self::SequenceCurveNotBSpline { .. } - | Self::FilletCrossesItself { .. } - | Self::SectionUnsupported(_) - | Self::EaseGeometryNotBSpline(_) - | Self::WeldNotBuilt(_) - | Self::ExtensionEndOnTwoSideLines => ErrorKind::Unsupported, - Self::MixedCornerUnbuildable(step) => step.class(), + Self::BandInputMissing(_) => ErrorKind::Missing, + Self::BevelVertexNotFilleted => ErrorKind::InvalidInput, + Self::BoundSurfaceRemoved => ErrorKind::InvalidInput, + Self::ChamferFaceNotOfEdge => ErrorKind::InvalidInput, + Self::ChamferSizeInvalid => ErrorKind::InvalidInput, + Self::CliffInputMissing { .. } => ErrorKind::Missing, + Self::ClosedCliffWouldNotSplit { .. } => ErrorKind::Failed, + Self::CornerInputInvalid { .. } => ErrorKind::InvalidInput, + Self::CornerPatchFaceNotFound { .. } => ErrorKind::NotFound, + Self::CornerPointDropUnresolved { .. } => ErrorKind::NotFound, + Self::CornerRefused => ErrorKind::Failed, + Self::CornerShapeNotBuilt(_) => ErrorKind::Unsupported, Self::CornerUnbuildable(step) => step.class(), - Self::ArcLengthNotConverged { .. } => ErrorKind::NotConverged, - Self::BandInputMissing(_) - | Self::CliffInputMissing { .. } - | Self::EaseInputMissing(_) - | Self::OverflowInputMissing(_) - | Self::CrossingInputMissing(_) => ErrorKind::Missing, + Self::CreasePieceEndUnbuildable { .. } => ErrorKind::Unsupported, + Self::CreaseTrimNotBuilt(stop) => stop.class(), + Self::CrossSectionTypeUnknown => ErrorKind::InvalidInput, + Self::CrossingInputMissing(_) => ErrorKind::Missing, + Self::CrossingNotFinite => ErrorKind::StageFailed, + Self::Defect { .. } => ErrorKind::StageFailed, + Self::EaseGeometryNotBSpline(_) => ErrorKind::Unsupported, + Self::EaseInputMissing(_) => ErrorKind::Missing, Self::EaseNotBuilt(stop) => stop.class(), - Self::OverflowPointDoesNotDrop(_) | Self::NoBlendedEdgeNearExtension => { - ErrorKind::NotFound - } - Self::Solver(s) => s.class(), + Self::EdgeNotFilletable { .. } => ErrorKind::InvalidInput, + Self::EdgeNotInTarget { .. } => ErrorKind::InvalidInput, + Self::EdgeSplitDeclined { .. } => ErrorKind::Failed, + Self::EdgeUseWithoutEdge => ErrorKind::InvalidInput, + Self::EdgeWithoutCurve => ErrorKind::InvalidInput, + Self::ExactBlendAxisCannotPlaceEdge { .. } => ErrorKind::InvalidInput, + Self::ExecutiveStepFailed => ErrorKind::Failed, + Self::ExtensionEndOnTwoSideLines => ErrorKind::Unsupported, + Self::FaceHasNoSurface => ErrorKind::InvalidInput, + Self::Failed(_) => ErrorKind::of_status(self.comparison_status()), + Self::FilletCrossesItself { .. } => ErrorKind::Unsupported, + Self::FilletSetUpInvalid(_) => ErrorKind::InvalidInput, + Self::GnSectionInvalid { .. } => ErrorKind::InvalidInput, + Self::Inconsistent(_) => ErrorKind::of_status(self.comparison_status()), + Self::InvalidValue(_) => ErrorKind::of_status(self.comparison_status()), Self::KeptFeatureNotBuilt(stop) => stop.class(), - Self::CreaseTrimNotBuilt(stop) => stop.class(), - Self::NoEdgesGiven - | Self::SizeBelowResolution { .. } - | Self::PerEdgeListLength { .. } - | Self::ParameterListSizes { .. } - | Self::FaceHasNoSurface - | Self::NoFirstBody - | Self::TargetNotGiven - | Self::EdgeNotInTarget { .. } - | Self::EdgeNotFilletable { .. } - | Self::ChamferSizeInvalid - | Self::ChamferFaceNotOfEdge - | Self::SolverFaceIndexInvalid { .. } - | Self::GnSectionInvalid { .. } - | Self::CrossSectionTypeUnknown - | Self::RadiusTypeNotForEdges { .. } - | Self::VariableRadiusLawsNotGiven - | Self::VariableRadiusLawMissing { .. } - | Self::BevelVertexNotFilleted - | Self::LawIntervalEmpty - | Self::ExactBlendAxisCannotPlaceEdge { .. } - | Self::EdgeWithoutCurve - | Self::EdgeUseWithoutEdge - | Self::BoundSurfaceRemoved - | Self::CornerInputInvalid { .. } - | Self::FilletSetUpInvalid(_) => ErrorKind::InvalidInput, - Self::ClosedCliffWouldNotSplit { .. } - | Self::CornerRefused - | Self::ExecutiveStepFailed - | Self::EdgeSplitDeclined { .. } => ErrorKind::Failed, - Self::Failed(_) - | Self::Missing(_) - | Self::InvalidValue(_) - | Self::Inconsistent(_) - | Self::BadIntersections(_) - | Self::NotConverged(_) - | Self::OutsideDomain(_) - | Self::NotWithinTolerance(_) - | Self::PassedOn { .. } => ErrorKind::of_status(self.comparison_status()), + Self::LawCornerNotFound { .. } => ErrorKind::NotFound, + Self::LawHasNoValue => ErrorKind::Unsupported, + Self::LawIntervalEmpty => ErrorKind::InvalidInput, + Self::Missing(_) => ErrorKind::of_status(self.comparison_status()), + Self::MixedCornerUnbuildable(step) => step.class(), + Self::NoBlendedEdgeNearExtension => ErrorKind::NotFound, + Self::NoEdgesGiven => ErrorKind::InvalidInput, + Self::NoFirstBody => ErrorKind::InvalidInput, + Self::NoRoom(reason) => no_room_class(*reason), + Self::NotCertified { .. } => ErrorKind::NotWithinTolerance, + Self::NotConverged(_) => ErrorKind::of_status(self.comparison_status()), + Self::NotWithinTolerance(_) => ErrorKind::of_status(self.comparison_status()), + Self::OutsideDomain(_) => ErrorKind::of_status(self.comparison_status()), + Self::OverflowInputMissing(_) => ErrorKind::Missing, + Self::OverflowPointDoesNotDrop(_) => ErrorKind::NotFound, + Self::ParameterListSizes { .. } => ErrorKind::InvalidInput, + Self::PassedOn { .. } => ErrorKind::of_status(self.comparison_status()), + Self::PerEdgeListLength { .. } => ErrorKind::InvalidInput, + Self::PlaneCurveEndOff { .. } => ErrorKind::NotFound, + Self::PlaneCurveFitCap { .. } => ErrorKind::NotWithinTolerance, + Self::PlaneCurveLeavesDomain { .. } => ErrorKind::OutsideDomain, + Self::PlaneCurveStepVanished { .. } => ErrorKind::StageFailed, + Self::PlaneCurveTouches { .. } => ErrorKind::Degenerate, + Self::RadiusLawNotPositive { .. } => ErrorKind::InvalidInput, + Self::RadiusTypeNotForEdges { .. } => ErrorKind::InvalidInput, + Self::RemovalRefused(reason) => removal_class(*reason), + Self::SectionDegenerate(_) => ErrorKind::Degenerate, + Self::SectionInputInvalid(_) => ErrorKind::InvalidInput, + Self::SectionNotProved(_) => ErrorKind::NotWithinTolerance, + Self::SectionUnsupported(_) => ErrorKind::Unsupported, + Self::SequenceCurveNotBSpline { .. } => ErrorKind::Unsupported, + Self::SizeBelowResolution { .. } => ErrorKind::InvalidInput, + Self::SkinMeasureNotFinite { .. } => ErrorKind::StageFailed, + Self::SkinPastStationCap { .. } => ErrorKind::NotWithinTolerance, + Self::Solver(s) => s.class(), + Self::SolverFaceIndexInvalid { .. } => ErrorKind::InvalidInput, + Self::StageFailed => ErrorKind::StageFailed, + Self::StationDidNotConverge { .. } => ErrorKind::StationDidNotConverge, + Self::TargetNotGiven => ErrorKind::InvalidInput, + Self::Trace(t) => t.class(), + Self::TrimLoopDoesNotSeparate => ErrorKind::TrimLeaks, + Self::TrimLoopOpen => ErrorKind::TrimLeaks, + Self::VariableRadiusLawMissing { .. } => ErrorKind::InvalidInput, + Self::VariableRadiusLawsNotGiven => ErrorKind::InvalidInput, + Self::WeldNotBuilt(_) => ErrorKind::Unsupported, } } @@ -2857,310 +958,228 @@ impl BlendFailure { /// stands for the fork's `SM_ERR` at its certificate's stop (and, past the work budget /// solidcore adds, for the same stop reached sooner). #[must_use] + #[allow( + clippy::match_same_arms, + reason = "one arm per variant, sorted by name, so causes added in parallel touch disjoint lines" + )] pub const fn replaces_upstream_status(&self) -> bool { match self { - Self::NoRoom(_) - | Self::RemovalRefused(_) - | Self::StationDidNotConverge { .. } - | Self::TrimLoopOpen - | Self::TrimLoopDoesNotSeparate - | Self::ClosedCliffWouldNotSplit { .. } - | Self::StageFailed - | Self::Defect { .. } - | Self::SkinPastStationCap { .. } - | Self::SkinMeasureNotFinite { .. } - | Self::BallsNest { .. } - | Self::CreasePieceEndUnbuildable { .. } - | Self::BallTriangleNotOnePatch { .. } - | Self::MixedCornerUnbuildable(_) - | Self::CornerUnbuildable(_) - | Self::CornerInputInvalid { .. } - | Self::FilletSetUpInvalid(_) - | Self::Solver(_) - | Self::PlaneCurveTouches { .. } - | Self::PlaneCurveEndOff { .. } - | Self::PlaneCurveLeavesDomain { .. } - | Self::PlaneCurveStepVanished { .. } - | Self::PlaneCurveFitCap { .. } - | Self::BandInputMissing(_) - | Self::CliffInputMissing { .. } - | Self::CrossingInputMissing(_) - | Self::CrossingNotFinite - | Self::CornerShapeNotBuilt(_) - | Self::CornerPointDropUnresolved { .. } - | Self::NoEdgesGiven - | Self::SizeBelowResolution { .. } - | Self::PerEdgeListLength { .. } - | Self::ParameterListSizes { .. } - | Self::FaceHasNoSurface - | Self::NoFirstBody - | Self::TargetNotGiven - | Self::EdgeNotInTarget { .. } - | Self::EdgeNotFilletable { .. } - | Self::ChamferSizeInvalid - | Self::ChamferFaceNotOfEdge - | Self::SolverFaceIndexInvalid { .. } - | Self::GnSectionInvalid { .. } - | Self::CrossSectionTypeUnknown - | Self::RadiusTypeNotForEdges { .. } - | Self::VariableRadiusLawsNotGiven - | Self::VariableRadiusLawMissing { .. } - | Self::BevelVertexNotFilleted - | Self::LawIntervalEmpty - | Self::ExactBlendAxisCannotPlaceEdge { .. } - | Self::EdgeWithoutCurve - | Self::LawHasNoValue - | Self::SequenceCurveNotBSpline { .. } - | Self::FilletCrossesItself { .. } - | Self::CornerRefused - | Self::ExecutiveStepFailed - | Self::EaseInputMissing(_) - | Self::EaseNotBuilt(_) - | Self::EaseGeometryNotBSpline(_) - | Self::ArcLengthNotConverged { .. } - | Self::Trace(_) - | Self::OverflowInputMissing(_) - | Self::OverflowPointDoesNotDrop(_) - | Self::ExtensionEndOnTwoSideLines - | Self::NoBlendedEdgeNearExtension - | Self::KeptFeatureNotBuilt(_) - | Self::CreaseTrimNotBuilt(_) - | Self::Failed(_) - | Self::Missing(_) - | Self::InvalidValue(_) - | Self::Inconsistent(_) - | Self::BadIntersections(_) - | Self::NotConverged(_) - | Self::OutsideDomain(_) - | Self::NotWithinTolerance(_) - | Self::PassedOn { .. } - | Self::EdgeSplitDeclined { .. } - | Self::LawCornerNotFound { .. } - | Self::EdgeUseWithoutEdge - | Self::BoundSurfaceRemoved - | Self::CornerPatchFaceNotFound { .. } - | Self::SectionNotProved(_) - | Self::SectionDegenerate(_) - | Self::SectionUnsupported(_) - | Self::RadiusLawNotPositive { .. } - | Self::SectionInputInvalid(_) - | Self::NotCertified { .. } - | Self::WeldNotBuilt(_) => true, + Self::ArcLengthNotConverged { .. } => true, + Self::BadIntersections(_) => true, + Self::BallTriangleNotOnePatch { .. } => true, + Self::BallsNest { .. } => true, + Self::BandInputMissing(_) => true, + Self::BevelVertexNotFilleted => true, + Self::BoundSurfaceRemoved => true, + Self::ChamferFaceNotOfEdge => true, + Self::ChamferSizeInvalid => true, + Self::CliffInputMissing { .. } => true, + Self::ClosedCliffWouldNotSplit { .. } => true, + Self::CornerInputInvalid { .. } => true, + Self::CornerPatchFaceNotFound { .. } => true, + Self::CornerPointDropUnresolved { .. } => true, + Self::CornerRefused => true, + Self::CornerShapeNotBuilt(_) => true, + Self::CornerUnbuildable(_) => true, + Self::CreasePieceEndUnbuildable { .. } => true, + Self::CreaseTrimNotBuilt(_) => true, + Self::CrossSectionTypeUnknown => true, + Self::CrossingInputMissing(_) => true, + Self::CrossingNotFinite => true, + Self::Defect { .. } => true, + Self::EaseGeometryNotBSpline(_) => true, + Self::EaseInputMissing(_) => true, + Self::EaseNotBuilt(_) => true, + Self::EdgeNotFilletable { .. } => true, + Self::EdgeNotInTarget { .. } => true, + Self::EdgeSplitDeclined { .. } => true, + Self::EdgeUseWithoutEdge => true, + Self::EdgeWithoutCurve => true, + Self::ExactBlendAxisCannotPlaceEdge { .. } => true, + Self::ExecutiveStepFailed => true, + Self::ExtensionEndOnTwoSideLines => true, + Self::FaceHasNoSurface => true, + Self::Failed(_) => true, + Self::FilletCrossesItself { .. } => true, + Self::FilletSetUpInvalid(_) => true, + Self::GnSectionInvalid { .. } => true, + Self::Inconsistent(_) => true, + Self::InvalidValue(_) => true, + Self::KeptFeatureNotBuilt(_) => true, + Self::LawCornerNotFound { .. } => true, + Self::LawHasNoValue => true, + Self::LawIntervalEmpty => true, + Self::Missing(_) => true, + Self::MixedCornerUnbuildable(_) => true, + Self::NoBlendedEdgeNearExtension => true, + Self::NoEdgesGiven => true, + Self::NoFirstBody => true, + Self::NoRoom(_) => true, + Self::NotCertified { .. } => true, + Self::NotConverged(_) => true, + Self::NotWithinTolerance(_) => true, + Self::OutsideDomain(_) => true, + Self::OverflowInputMissing(_) => true, + Self::OverflowPointDoesNotDrop(_) => true, + Self::ParameterListSizes { .. } => true, + Self::PassedOn { .. } => true, + Self::PerEdgeListLength { .. } => true, + Self::PlaneCurveEndOff { .. } => true, + Self::PlaneCurveFitCap { .. } => true, + Self::PlaneCurveLeavesDomain { .. } => true, + Self::PlaneCurveStepVanished { .. } => true, + Self::PlaneCurveTouches { .. } => true, + Self::RadiusLawNotPositive { .. } => true, + Self::RadiusTypeNotForEdges { .. } => true, + Self::RemovalRefused(_) => true, + Self::SectionDegenerate(_) => true, + Self::SectionInputInvalid(_) => true, + Self::SectionNotProved(_) => true, + Self::SectionUnsupported(_) => true, + Self::SequenceCurveNotBSpline { .. } => true, + Self::SizeBelowResolution { .. } => true, + Self::SkinMeasureNotFinite { .. } => true, + Self::SkinPastStationCap { .. } => true, + Self::Solver(_) => true, + Self::SolverFaceIndexInvalid { .. } => true, + Self::StageFailed => true, + Self::StationDidNotConverge { .. } => true, + Self::TargetNotGiven => true, + Self::Trace(_) => true, + Self::TrimLoopDoesNotSeparate => true, + Self::TrimLoopOpen => true, + Self::VariableRadiusLawMissing { .. } => true, + Self::VariableRadiusLawsNotGiven => true, + Self::WeldNotBuilt(_) => true, } } } impl core::fmt::Display for BlendFailure { /// A typed cause is worded from its class and its numbers; a phrase cause by its phrase. + #[allow( + clippy::match_same_arms, + reason = "one arm per variant, sorted by name, so causes added in parallel touch disjoint lines" + )] fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { match self { - Self::NoRoom(reason) => write!(f, "{}: {reason:?}", self.class()), - Self::ClosedCliffWouldNotSplit { face } => write!( - f, - "the closed cliff blend face {face:?} does not divide at its interior section" - ), - Self::RemovalRefused(reason) => write!(f, "{}: {reason:?}", self.class()), - Self::StationDidNotConverge { - s, - residual, - tolerance, - step, - iterations, - } => { - let shown = |x: Option| x.unwrap_or_else(|| "unreported".into()); - write!( - f, - "{}: the station at s = {s} did not converge: residual {} > {tolerance} after {} iterations (last step {})", - self.class(), - shown(residual.map(|r| r.to_string())), - shown(iterations.map(|n| n.to_string())), - shown(step.map(|d| d.to_string())), - ) - } - Self::TrimLoopOpen => write!(f, "{}: the trim loop is open", self.class()), - Self::TrimLoopDoesNotSeparate => { - write!( - f, - "{}: the faces the rails enclose reach past the rails (the trim loop does not separate)", - self.class() - ) - } - Self::StageFailed => write!(f, "{}", self.class()), - Self::Defect { why } => write!(f, "{}: {why}", self.class()), - Self::SkinPastStationCap { - asked, - reached, - stations, - rounds, + Self::ArcLengthNotConverged { + start, + length, + stopped_at, } => write!( f, - "{}: the round's skin is {reached} from its balls, past {asked}, with {stations} stations after {rounds} rounds", - self.class() - ), - Self::SkinMeasureNotFinite { s } => write!( - f, - "{}: the skin check computed a value that is not finite at s = {s}", - self.class() - ), - Self::BallsNest { s, rate, speed } => write!( - f, - "{}: at s = {s} the balls' radius changes at {rate}, as fast as their centres move ({speed}): no rolling-ball surface exists there", + "{}: the search for the parameter {length} along the curve from {start} stopped at {stopped_at}", self.class() ), - Self::CreasePieceEndUnbuildable { kind, at_end, t } => write!( - f, - "{}: the crease piece's {} at t = {t} cannot be ended on its meet: no construction for a {kind} curve there", - self.class(), - if *at_end { "end" } else { "start" }, - ), + Self::BadIntersections(what) => f.write_str(what), Self::BallTriangleNotOnePatch { pole } => write!( f, "{}: the ball corner's triangle is not one rational patch from the pole at contact {pole}", self.class() ), - Self::CornerUnbuildable(step) => write!( - f, - "{}: the corner has no construction: {}", - self.class(), - step.what() - ), - // (the entity is the failure's site, which the failure prints) - Self::CornerInputInvalid { input, .. } => { - write!(f, "{}: the fillet corner given: {input:?}", self.class()) - } - Self::FilletSetUpInvalid(part) => write!(f, "{}: {}", self.class(), part.what()), - Self::Solver(cause) => cause.fmt(f), - Self::MixedCornerUnbuildable(step) => write!( - f, - "{}: the mixed corner has no construction: {}", - self.class(), - step.what() - ), - Self::PlaneCurveTouches { u, v } => write!( - f, - "{}: the surface touches the plane at (u, v) = ({u}, {v}): the crossing has no direction", - self.class() - ), - Self::PlaneCurveEndOff { at_end, distance } => { - write!( - f, - "{}: the crossing's {} is off the surface or the plane", - self.class(), - if *at_end { "end" } else { "start" }, - )?; - match distance { - Some(distance) => write!(f, " by {distance}"), - None => f.write_str(": the drop or projection found no point"), - } - } - Self::PlaneCurveLeavesDomain { u, v } => write!( - f, - "{}: the crossing leaves the surface's domain at (u, v) = ({u}, {v}) before its end", - self.class() - ), - Self::PlaneCurveStepVanished { - u, - v, - step, - minimum, - } => write!( + Self::BallsNest { s, rate, speed } => write!( f, - "{}: the crossing's step at (u, v) = ({u}, {v}) was halved to {step}, below its minimum {minimum}, without an accepted step", + "{}: at s = {s} the balls' radius changes at {rate}, as fast as their centres move ({speed}): no rolling-ball surface exists there", self.class() ), - Self::PlaneCurveFitCap { stations, passes } => write!( + Self::BandInputMissing(input) => write!(f, "{} is missing", input.what()), + Self::BevelVertexNotFilleted => write!( f, - "{}: the crossing's Hermite fit is still off the exact curve by more than a tenth of the tolerance with {stations} stations after {passes} passes", + "{}: a vertex given to bevel is not a vertex of the filleted edges", self.class() ), - Self::NoEdgesGiven => write!(f, "{}: no edges are given to fillet", self.class()), - Self::SizeBelowResolution { size, tolerance } => write!( + Self::BoundSurfaceRemoved => write!( f, - "{}: the size {size} is below eight times the body's tolerance {tolerance}, the smallest a fillet builds", + "{}: the face's surface was removed after its binding was captured", self.class() ), - Self::PerEdgeListLength { edges, given } => write!( + Self::ChamferFaceNotOfEdge => write!( f, - "{}: a list of one entry per edge holds {given} entries for {edges} edges", + "{}: the face named for the chamfer's first size is neither of its edge's faces", self.class() ), - Self::ParameterListSizes { - edges, - cross_sections, - radius_types, - radii, - } => write!( + Self::ChamferSizeInvalid => write!( f, - "{}: the fillet's parameter lists ({cross_sections} cross-section types, {radius_types} radius types, {radii} radii) each take one entry or one per edge, for {edges} edges", + "{}: the chamfer size is not one the edge can take (sizes and setbacks finite and positive, distances that do not fold, faces that make a wedge, on a knife edge two equal distances)", self.class() ), - Self::FaceHasNoSurface => { - write!(f, "{}: a face given to the fillet has no surface", self.class()) + Self::CliffInputMissing { face, input } => { + write!(f, "cliff face {face:?} is missing its {}", input.what()) } - Self::NoFirstBody => write!( + Self::ClosedCliffWouldNotSplit { face } => write!( f, - "{}: a face of the first surface's body is given where the first surface has no body", - self.class() + "the closed cliff blend face {face:?} does not divide at its interior section" ), - Self::TargetNotGiven => { - write!(f, "{}: the fillet has no target body", self.class()) + // (the entity is the failure's site, which the failure prints) + Self::CornerInputInvalid { input, .. } => { + write!(f, "{}: the fillet corner given: {input:?}", self.class()) } - Self::EdgeNotInTarget { index } => write!( - f, - "{}: edge {index} of the edges given is not an edge of the target body", - self.class() - ), - Self::EdgeNotFilletable { index } => write!( + Self::CornerPatchFaceNotFound { surface } => write!( f, - "{}: edge {index} of the edges given has no edge use the fillet can roll on", + "{}: corner patch surface {surface} has no face in the intermediate body", self.class() ), - Self::ChamferSizeInvalid => write!( + Self::CornerPointDropUnresolved { solutions } => write!( f, - "{}: the chamfer size is not one the edge can take (sizes and setbacks finite and positive, distances that do not fold, faces that make a wedge, on a knife edge two equal distances)", + "{}: the corner's vertex drops onto the surface at {solutions} points, not one", self.class() ), - Self::ChamferFaceNotOfEdge => write!( + Self::CornerRefused => write!( f, - "{}: the face named for the chamfer's first size is neither of its edge's faces", + "{}: a corner was refused at its vertex (the error info says why)", self.class() ), - Self::SolverFaceIndexInvalid { index } => write!( + Self::CornerShapeNotBuilt(shape) => write!(f, "{}: {shape:?}", self.class()), + Self::CornerUnbuildable(step) => write!( f, - "{}: a fillet solver's faces are its first (0) and second (1), not face {index}", - self.class() + "{}: the corner has no construction: {}", + self.class(), + step.what() ), - Self::GnSectionInvalid { order, thumbweight } => write!( + Self::CreasePieceEndUnbuildable { kind, at_end, t } => write!( f, - "{}: a G^n cross-section takes an order of 2 to 4 and a thumbweight below 1, not order {order} and thumbweight {thumbweight}", - self.class() + "{}: the crease piece's {} at t = {t} cannot be ended on its meet: no construction for a {kind} curve there", + self.class(), + if *at_end { "end" } else { "start" }, ), + Self::CreaseTrimNotBuilt(stop) => write!(f, "{}: {}", self.class(), stop.what()), Self::CrossSectionTypeUnknown => { write!(f, "{}: a cross-section type is unknown", self.class()) } - Self::RadiusTypeNotForEdges { index, kind } => write!( + Self::CrossingInputMissing(input) => write!(f, "{} is missing", input.what()), + Self::CrossingNotFinite => write!( f, - "{}: edge {index}'s radius type {kind:?} is not one an edge's fillet is set up with", + "{}: the rail's crossing of an edge is not judged from finite values", self.class() ), - Self::VariableRadiusLawsNotGiven => write!( + Self::Defect { why } => write!(f, "{}: {why}", self.class()), + Self::EaseGeometryNotBSpline(geometry) => { + write!(f, "{}: {}", self.class(), geometry.what()) + } + Self::EaseInputMissing(input) => write!(f, "{}: {}", self.class(), input.what()), + Self::EaseNotBuilt(stop) => write!(f, "{}: {}", self.class(), stop.what()), + Self::EdgeNotFilletable { index } => write!( f, - "{}: a variable radius is asked and no radius laws are given", + "{}: edge {index} of the edges given has no edge use the fillet can roll on", self.class() ), - Self::VariableRadiusLawMissing { index } => write!( + Self::EdgeNotInTarget { index } => write!( f, - "{}: edge {index} of the edges given has a variable radius and no radius law", + "{}: edge {index} of the edges given is not an edge of the target body", self.class() ), - Self::BevelVertexNotFilleted => write!( + Self::EdgeSplitDeclined { parameter } => write!( f, - "{}: a vertex given to bevel is not a vertex of the filleted edges", + "{}: the edge is not split at parameter {parameter} (outside the edge or at an end)", self.class() ), - Self::LawIntervalEmpty => write!( + Self::EdgeUseWithoutEdge => { + write!(f, "{}: an edge use of the body has no edge", self.class()) + } + Self::EdgeWithoutCurve => write!( f, - "{}: the radius law is evaluated over an interval of zero length", + "{}: an edge of the body the fillet reads has no curve", self.class() ), Self::ExactBlendAxisCannotPlaceEdge { @@ -3179,174 +1198,264 @@ impl core::fmt::Display for BlendFailure { } write!(f, "), so the blend given does not match this edge") } - Self::EdgeWithoutCurve => write!( - f, - "{}: an edge of the body the fillet reads has no curve", - self.class() - ), - Self::LawHasNoValue => { - write!(f, "{}: a base radius law has no value of its own", self.class()) - } - Self::SequenceCurveNotBSpline { kind } => write!( - f, - "{}: a {kind} curve of a smooth sequence of filleted edges has no B-spline form to join", - self.class() - ), - Self::FilletCrossesItself { first, second } => write!( + Self::ExecutiveStepFailed => write!( f, - "{}: the offset surfaces' intersection curves {first} and {second} cross, so the fillet would cross itself", + "{}: a step of the fillet executive failed (the error info says which)", self.class() ), - Self::CornerRefused => write!( + Self::ExtensionEndOnTwoSideLines => write!( f, - "{}: a corner was refused at its vertex (the error info says why)", + "{}: the end of a rail's run past a face's boundary lies on the lines of two of \ + the face's side edges", self.class() ), - Self::ExecutiveStepFailed => write!( + Self::FaceHasNoSurface => { + write!(f, "{}: a face given to the fillet has no surface", self.class()) + } + Self::Failed(what) => f.write_str(what), + Self::FilletCrossesItself { first, second } => write!( f, - "{}: a step of the fillet executive failed (the error info says which)", + "{}: the offset surfaces' intersection curves {first} and {second} cross, so the fillet would cross itself", self.class() ), - Self::EdgeSplitDeclined { parameter } => write!( + Self::FilletSetUpInvalid(part) => write!(f, "{}: {}", self.class(), part.what()), + Self::GnSectionInvalid { order, thumbweight } => write!( f, - "{}: the edge is not split at parameter {parameter} (outside the edge or at an end)", + "{}: a G^n cross-section takes an order of 2 to 4 and a thumbweight below 1, not order {order} and thumbweight {thumbweight}", self.class() ), + Self::Inconsistent(what) => write!(f, "a consistency check failed: {what}"), + Self::InvalidValue(what) => f.write_str(what), + Self::KeptFeatureNotBuilt(stop) => write!(f, "{}: {}", self.class(), stop.what()), Self::LawCornerNotFound { corner, what } => write!( f, "{}: law corner {corner} has no {}", self.class(), what.what() ), - Self::EdgeUseWithoutEdge => { - write!(f, "{}: an edge use of the body has no edge", self.class()) + Self::LawHasNoValue => { + write!(f, "{}: a base radius law has no value of its own", self.class()) } - Self::BoundSurfaceRemoved => write!( + Self::LawIntervalEmpty => write!( f, - "{}: the face's surface was removed after its binding was captured", + "{}: the radius law is evaluated over an interval of zero length", self.class() ), - Self::CornerPatchFaceNotFound { surface } => write!( + Self::Missing(what) => write!(f, "{what} is missing"), + Self::MixedCornerUnbuildable(step) => write!( f, - "{}: corner patch surface {surface} has no face in the intermediate body", + "{}: the mixed corner has no construction: {}", + self.class(), + step.what() + ), + Self::NoBlendedEdgeNearExtension => write!( + f, + "{}: no blended edge takes the drop of the middle of an extension's chain", self.class() ), - Self::EaseInputMissing(input) => write!(f, "{}: {}", self.class(), input.what()), - Self::EaseNotBuilt(stop) => write!(f, "{}: {}", self.class(), stop.what()), - Self::EaseGeometryNotBSpline(geometry) => { - write!(f, "{}: {}", self.class(), geometry.what()) - } - Self::ArcLengthNotConverged { - start, - length, - stopped_at, - } => write!( + Self::NoEdgesGiven => write!(f, "{}: no edges are given to fillet", self.class()), + Self::NoFirstBody => write!( f, - "{}: the search for the parameter {length} along the curve from {start} stopped at {stopped_at}", + "{}: a face of the first surface's body is given where the first surface has no body", self.class() ), - Self::Trace(t) => write!(f, "{}: {t}", t.class()), + Self::NoRoom(reason) => write!(f, "{}: {reason:?}", self.class()), + Self::NotCertified { halvings, stations } => write!( + f, + "the blend could not be certified within its tolerance in the work allowed \ + ({halvings} spans halved, {stations} stations)" + ), + Self::NotConverged(what) => f.write_str(what), + Self::NotWithinTolerance(what) => f.write_str(what), + Self::OutsideDomain(what) => f.write_str(what), Self::OverflowInputMissing(input) => write!(f, "{}: {}", self.class(), input.what()), Self::OverflowPointDoesNotDrop(drop) => { write!(f, "{}: {}", self.class(), drop.what()) } - Self::ExtensionEndOnTwoSideLines => write!( + Self::ParameterListSizes { + edges, + cross_sections, + radius_types, + radii, + } => write!( f, - "{}: the end of a rail's run past a face's boundary lies on the lines of two of \ - the face's side edges", + "{}: the fillet's parameter lists ({cross_sections} cross-section types, {radius_types} radius types, {radii} radii) each take one entry or one per edge, for {edges} edges", self.class() ), - Self::NoBlendedEdgeNearExtension => write!( + Self::PassedOn { what, .. } => f.write_str(what), + Self::PerEdgeListLength { edges, given } => write!( f, - "{}: no blended edge takes the drop of the middle of an extension's chain", + "{}: a list of one entry per edge holds {given} entries for {edges} edges", self.class() ), - Self::KeptFeatureNotBuilt(stop) => write!(f, "{}: {}", self.class(), stop.what()), - Self::CreaseTrimNotBuilt(stop) => write!(f, "{}: {}", self.class(), stop.what()), - Self::Failed(what) - | Self::InvalidValue(what) - | Self::BadIntersections(what) - | Self::NotConverged(what) - | Self::OutsideDomain(what) - | Self::NotWithinTolerance(what) - | Self::PassedOn { what, .. } => f.write_str(what), - Self::Missing(what) => write!(f, "{what} is missing"), - Self::WeldNotBuilt(WeldGap::BeadsMeetAtVertex) => write!( + Self::PlaneCurveEndOff { at_end, distance } => { + write!( + f, + "{}: the crossing's {} is off the surface or the plane", + self.class(), + if *at_end { "end" } else { "start" }, + )?; + match distance { + Some(distance) => write!(f, " by {distance}"), + None => f.write_str(": the drop or projection found no point"), + } + } + Self::PlaneCurveFitCap { stations, passes } => write!( f, - "{}: weld beads that meet at a vertex are not built yet (their corner, #17916)", + "{}: the crossing's Hermite fit is still off the exact curve by more than a tenth of the tolerance with {stations} stations after {passes} passes", self.class() ), - Self::WeldNotBuilt(WeldGap::CurvedJoint) => write!( + Self::PlaneCurveLeavesDomain { u, v } => write!( f, - "{}: a weld bead is built only along a straight edge between two planes so far", + "{}: the crossing leaves the surface's domain at (u, v) = ({u}, {v}) before its end", self.class() ), - Self::WeldNotBuilt(WeldGap::ObtuseToe) => write!( + Self::PlaneCurveStepVanished { + u, + v, + step, + minimum, + } => write!( f, - "{}: a weld bead with an obtuse toe (one leg at most the other's cosine of the angle between the faces) is not built yet", + "{}: the crossing's step at (u, v) = ({u}, {v}) was halved to {step}, below its minimum {minimum}, without an accepted step", self.class() ), - Self::BandInputMissing(input) => write!(f, "{} is missing", input.what()), - Self::CliffInputMissing { face, input } => { - write!(f, "cliff face {face:?} is missing its {}", input.what()) - } - Self::CrossingInputMissing(input) => write!(f, "{} is missing", input.what()), - Self::CrossingNotFinite => write!( + Self::PlaneCurveTouches { u, v } => write!( f, - "{}: the rail's crossing of an edge is not judged from finite values", + "{}: the surface touches the plane at (u, v) = ({u}, {v}): the crossing has no direction", self.class() ), - Self::Inconsistent(what) => write!(f, "a consistency check failed: {what}"), - Self::CornerShapeNotBuilt(shape) => write!(f, "{}: {shape:?}", self.class()), - Self::CornerPointDropUnresolved { solutions } => write!( + Self::RadiusLawNotPositive { s, radius } => write!( f, - "{}: the corner's vertex drops onto the surface at {solutions} points, not one", + "{}: the radius law is {radius} at s = {s}, not positive", self.class() ), - Self::NotCertified { halvings, stations } => write!( + Self::RadiusTypeNotForEdges { index, kind } => write!( f, - "the blend could not be certified within its tolerance in the work allowed \ - ({halvings} spans halved, {stations} stations)" + "{}: edge {index}'s radius type {kind:?} is not one an edge's fillet is set up with", + self.class() ), + Self::RemovalRefused(reason) => write!(f, "{}: {reason:?}", self.class()), + Self::SectionDegenerate(what) => write!(f, "{}: {}", self.class(), what.what()), + Self::SectionInputInvalid(what) => write!(f, "{}: {}", self.class(), what.what()), Self::SectionNotProved(what) => write!( f, "{}: the section's certificate did not prove {}", self.class(), what.what() ), - Self::SectionDegenerate(what) => write!(f, "{}: {}", self.class(), what.what()), Self::SectionUnsupported(limit) => match limit { - SectionLimit::FaceNotNurbs => write!( + SectionLimit::CurveWeightNotPositive => { + write!(f, "{}: a curve's weights are not positive", self.class()) + } + SectionLimit::DefinitionFaceNotOneRadius => write!( f, - "{}: a face is not a NURBS surface: its section of order 2 and up cannot be built or certified", + "{}: only a round of one radius between NURBS faces is certified by its definition", self.class() ), SectionLimit::DegreeBelowOne => { write!(f, "{}: a curve or face is of degree 0", self.class()) } - SectionLimit::FaceWeightNotPositive => { - write!(f, "{}: a face's weights are not positive", self.class()) - } - SectionLimit::CurveWeightNotPositive => { - write!(f, "{}: a curve's weights are not positive", self.class()) - } - SectionLimit::DefinitionFaceNotOneRadius => write!( + SectionLimit::FaceNotNurbs => write!( f, - "{}: only a round of one radius between NURBS faces is certified by its definition", + "{}: a face is not a NURBS surface: its section of order 2 and up cannot be built or certified", self.class() ), + SectionLimit::FaceWeightNotPositive => { + write!(f, "{}: a face's weights are not positive", self.class()) + } SectionLimit::OrderPastSeries { order, most } => write!( f, "{}: the order {order} is past the most the series hold ({most})", self.class() ), }, - Self::RadiusLawNotPositive { s, radius } => write!( + Self::SequenceCurveNotBSpline { kind } => write!( f, - "{}: the radius law is {radius} at s = {s}, not positive", + "{}: a {kind} curve of a smooth sequence of filleted edges has no B-spline form to join", + self.class() + ), + Self::SizeBelowResolution { size, tolerance } => write!( + f, + "{}: the size {size} is below eight times the body's tolerance {tolerance}, the smallest a fillet builds", + self.class() + ), + Self::SkinMeasureNotFinite { s } => write!( + f, + "{}: the skin check computed a value that is not finite at s = {s}", + self.class() + ), + Self::SkinPastStationCap { + asked, + reached, + stations, + rounds, + } => write!( + f, + "{}: the round's skin is {reached} from its balls, past {asked}, with {stations} stations after {rounds} rounds", + self.class() + ), + Self::Solver(cause) => cause.fmt(f), + Self::SolverFaceIndexInvalid { index } => write!( + f, + "{}: a fillet solver's faces are its first (0) and second (1), not face {index}", + self.class() + ), + Self::StageFailed => write!(f, "{}", self.class()), + Self::StationDidNotConverge { + s, + residual, + tolerance, + step, + iterations, + } => { + let shown = |x: Option| x.unwrap_or_else(|| "unreported".into()); + write!( + f, + "{}: the station at s = {s} did not converge: residual {} > {tolerance} after {} iterations (last step {})", + self.class(), + shown(residual.map(|r| r.to_string())), + shown(iterations.map(|n| n.to_string())), + shown(step.map(|d| d.to_string())), + ) + } + Self::TargetNotGiven => { + write!(f, "{}: the fillet has no target body", self.class()) + } + Self::Trace(t) => write!(f, "{}: {t}", t.class()), + Self::TrimLoopDoesNotSeparate => { + write!( + f, + "{}: the faces the rails enclose reach past the rails (the trim loop does not separate)", + self.class() + ) + } + Self::TrimLoopOpen => write!(f, "{}: the trim loop is open", self.class()), + Self::VariableRadiusLawMissing { index } => write!( + f, + "{}: edge {index} of the edges given has a variable radius and no radius law", + self.class() + ), + Self::VariableRadiusLawsNotGiven => write!( + f, + "{}: a variable radius is asked and no radius laws are given", + self.class() + ), + Self::WeldNotBuilt(WeldGap::BeadsMeetAtVertex) => write!( + f, + "{}: weld beads that meet at a vertex are not built yet (their corner, #17916)", + self.class() + ), + Self::WeldNotBuilt(WeldGap::CurvedJoint) => write!( + f, + "{}: a weld bead is built only along a straight edge between two planes so far", + self.class() + ), + Self::WeldNotBuilt(WeldGap::ObtuseToe) => write!( + f, + "{}: a weld bead with an obtuse toe (one leg at most the other's cosine of the angle between the faces) is not built yet", self.class() ), - Self::SectionInputInvalid(what) => write!(f, "{}: {}", self.class(), what.what()), } } } @@ -3453,6 +1562,7 @@ impl crate::SolidError { #[cfg(test)] mod tests { use super::*; + use crate::blend::fillet_exact::BlendSpine; use crate::SolidError; #[test] @@ -4837,4 +2947,142 @@ mod tests { "phrase_sites::BLEND must list exactly the phrase variants of BlendFailure" ); } + + /// The causes (every enum of this module and of `error/blend/`) and every match on their + /// variants (but for one with a `_` arm) are kept in name order, one arm per pattern, so changes that each add a cause or its arms touch + /// different lines. Names compare as bytes. + #[test] + fn the_causes_and_the_arms_of_their_matches_stay_sorted_by_name() { + /// The identifier `text` starts with. + fn ident(text: &str) -> &str { + let end = text + .find(|c: char| !(c.is_ascii_alphanumeric() || c == '_')) + .unwrap_or(text.len()); + &text[..end] + } + /// The variant `Path::Name` that `text` starts with, and the text after it; `""` and + /// `text` where it starts with none. + fn variant(text: &str) -> (&str, &str) { + let path = ident(text); + match text[path.len()..].strip_prefix("::") { + Some(after) if !path.is_empty() => { + let name = ident(after); + (name, &after[name.len()..]) + } + _ => ("", text), + } + } + let blend = include_str!("blend.rs"); + let modules: Vec = blend + .lines() + .filter_map(|l| { + Some(format!( + "blend/{}.rs", + l.strip_prefix("pub mod ") + .or_else(|| l.strip_prefix("mod "))? + .strip_suffix(';')? + )) + }) + .collect(); + let files = [ + ("blend.rs", blend), + ("blend/band.rs", include_str!("blend/band.rs")), + ("blend/cliff.rs", include_str!("blend/cliff.rs")), + ("blend/corner.rs", include_str!("blend/corner.rs")), + ("blend/crease_trim.rs", include_str!("blend/crease_trim.rs")), + ("blend/crossing.rs", include_str!("blend/crossing.rs")), + ("blend/ease.rs", include_str!("blend/ease.rs")), + ("blend/keep.rs", include_str!("blend/keep.rs")), + ("blend/law_corner.rs", include_str!("blend/law_corner.rs")), + ("blend/no_room.rs", include_str!("blend/no_room.rs")), + ("blend/overflow.rs", include_str!("blend/overflow.rs")), + ("blend/removal.rs", include_str!("blend/removal.rs")), + ("blend/section.rs", include_str!("blend/section.rs")), + ("blend/set_up.rs", include_str!("blend/set_up.rs")), + ("blend/solver.rs", include_str!("blend/solver.rs")), + ("blend/trace.rs", include_str!("blend/trace.rs")), + ("blend/weld.rs", include_str!("blend/weld.rs")), + ]; + let listed: Vec<&str> = files.iter().skip(1).map(|(file, _)| *file).collect(); + assert_eq!( + listed, modules, + "every `error/blend/` module is listed here, in order" + ); + let mut enums = 0; + let mut matches = 0; + for (file, src) in files { + // the library code: the tests' own matches are not causes + let lines: Vec<&str> = src.lines().take_while(|l| *l != "mod tests {").collect(); + for (i, line) in lines.iter().enumerate() { + let t = line.trim_start(); + let indent = line.len() - t.len(); + let is_enum = t.starts_with("pub enum ") && t.ends_with(" {"); + let is_match = + t.ends_with(" {") && (t.starts_with("match ") || t.contains("=> match ")); + if !is_enum && !is_match { + continue; + } + let pad = " ".repeat(indent + 4); + let close = format!("{}}}", " ".repeat(indent)); + let close_arm = format!("{close},"); + let mut names = Vec::new(); + let mut wildcard = false; + for l in lines[i + 1..] + .iter() + .take_while(|l| **l != close && **l != close_arm) + { + let Some(rest) = l.strip_prefix(pad.as_str()) else { + continue; + }; + assert!( + !(is_match && rest.starts_with("| ")), + "{file}:{}: one arm per pattern, not `|` groups: {l}", + i + 1 + ); + let pattern = rest.split("=>").next().unwrap_or_default(); + assert!( + !(is_match + && rest.starts_with(char::is_alphabetic) + && pattern.contains(" | ")), + "{file}:{}: one arm per pattern, not `|` groups: {l}", + i + 1 + ); + wildcard |= rest.starts_with("_ "); + // a match arm's variant, and the variant nested in its payload + // (`Self::WeldNotBuilt(WeldGap::CurvedJoint)`), each `Path::Name` + let name = if is_enum { + (ident(rest), "") + } else { + let (outer, after) = variant(rest); + let inner = after.strip_prefix('(').map_or("", |p| variant(p).0); + (outer, inner) + }; + if name.0.starts_with(|c: char| c.is_ascii_uppercase()) { + names.push(name); + } + } + if wildcard || names.is_empty() { + continue; + } + for w in names.windows(2) { + assert!( + w[0] < w[1] || (is_match && w[0] == w[1]), + "{file}:{}: `{:?}` is before `{:?}`: keep them sorted by name", + i + 1, + w[0], + w[1] + ); + } + if is_enum { + enums += 1; + } else { + matches += 1; + } + } + } + assert!( + enums >= 20 && matches >= 24, + "{enums} enums and {matches} matches checked" + ); + } } diff --git a/solidcore/crates/solidcore/src/error/blend/band.rs b/solidcore/crates/solidcore/src/error/blend/band.rs new file mode 100644 index 00000000000..e0d1dbf7280 --- /dev/null +++ b/solidcore/crates/solidcore/src/error/blend/band.rs @@ -0,0 +1,70 @@ +//! The inputs of the planar-band contact query a blend failure names missing. +//! +//! Upstream: none. One of the modules of the blend failure causes, re-exported from +//! [`super`]. + +#[cfg(doc)] +use super::BlendFailure; + +/// Which input of the planar-band contact query is missing ([`BlendFailure::BandInputMissing`]). +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[non_exhaustive] +pub enum BandInput { + /// The blended edge. + BlendedEdge, + /// The blended edge's curve. + BlendedEdgeCurve, + /// An endpoint of the blended edge. + BlendedEdgeEndpoint, + /// The chamfer's setback. + ChamferSetback, + /// The closest feet of the two bands. + ClosestBandFeet, + /// A solver's edge use. + EdgeUse, + /// The extrusion's control point in its stored net. + ExtrusionControlPoint, + /// The exact product of the extrusion's translation. + ExtrusionTranslationProduct, + /// The first offset of the chamfer. + FirstOffset, + /// The foot of a drop on the other support. + FootOnOtherSupport, + /// An endpoint of the line. + LineEndpoint, + /// The other offset of the chamfer. + OtherOffset, + /// The support on the other side of the blended edge. + OtherSupport, + /// The planar support. + PlanarSupport, + /// The selected edge. + SelectedEdge, + /// The face the two bands share. + SharedFace, +} + +impl BandInput { + /// What is missing, as a phrase ("the shared face"). + #[must_use] + pub const fn what(self) -> &'static str { + match self { + Self::BlendedEdge => "the blended edge", + Self::BlendedEdgeCurve => "the blended edge's curve", + Self::BlendedEdgeEndpoint => "the blended edge's endpoint", + Self::ChamferSetback => "the chamfer setback", + Self::ClosestBandFeet => "the closest band feet", + Self::EdgeUse => "the edge use", + Self::ExtrusionControlPoint => "the extrusion control point", + Self::ExtrusionTranslationProduct => "the exact extrusion translation product", + Self::FirstOffset => "the first offset", + Self::FootOnOtherSupport => "the foot on the other support", + Self::LineEndpoint => "the line endpoint", + Self::OtherOffset => "the other offset", + Self::OtherSupport => "the other support", + Self::PlanarSupport => "the planar support", + Self::SelectedEdge => "the selected edge", + Self::SharedFace => "the shared face", + } + } +} diff --git a/solidcore/crates/solidcore/src/error/blend/cliff.rs b/solidcore/crates/solidcore/src/error/blend/cliff.rs new file mode 100644 index 00000000000..634856a0b8a --- /dev/null +++ b/solidcore/crates/solidcore/src/error/blend/cliff.rs @@ -0,0 +1,26 @@ +//! The inputs of a blend's trim at a cliff a blend failure names missing. +//! +//! Upstream: none. One of the modules of the blend failure causes, re-exported from +//! [`super`]. + +/// A face input required to trim a blend at a cliff. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[non_exhaustive] +pub enum CliffInput { + /// The face use facing out of the body. + OutwardFaceUse, + /// The planar support extending the wall. + Plane, + /// The face's surface. + Surface, +} + +impl CliffInput { + pub(super) const fn what(self) -> &'static str { + match self { + Self::OutwardFaceUse => "outward face use", + Self::Plane => "plane", + Self::Surface => "surface", + } + } +} diff --git a/solidcore/crates/solidcore/src/error/blend/corner.rs b/solidcore/crates/solidcore/src/error/blend/corner.rs new file mode 100644 index 00000000000..1452f36c171 --- /dev/null +++ b/solidcore/crates/solidcore/src/error/blend/corner.rs @@ -0,0 +1,409 @@ +//! Why a fillet corner fails: the shapes of a filleted vertex's edges the fillet corner +//! topology does not build, the corner input a corner step is given otherwise than the +//! topology makes it, and the ball, chamfer and Mixed corner steps with no construction. +//! +//! Upstream: none. One of the modules of the blend failure causes, re-exported from +//! [`super`]. + +#[cfg(doc)] +use super::{BlendFailure, FilletSetUp, SolverFailure}; +use crate::error::{ErrorKind, SM_ERR, SM_ERR_NULL_POINTER}; + +/// A shape of the edges at a filleted vertex that the fillet corner topology +/// (`crate::blend::fillet_corner::topology`) does not build +/// ([`BlendFailure::CornerShapeNotBuilt`]). Each is a fact of the body's edges at the vertex; +/// none is a defect. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[non_exhaustive] +pub enum CornerShape { + /// A corner of four edges whose two blended edges are next to each other round the vertex. + AdjacentBlendedEdges, + /// A bevel corner (every edge blended, the blends not blending) of other than three edges. + BevelNotOfThreeEdges, + /// A blended edge use the walk round the vertex left out of the ring of the corner's + /// edges: the walk keeps one use of each edge, so an edge that meets the vertex twice (a + /// closed edge) is in the ring by its other use. + BlendedEdgeOffRing, + /// A corner of two edges alone at the vertex whose first blended edge does not lie + /// between exactly two faces: the blends' crossing has an end on each of its faces. + EdgeNotBetweenTwoFaces, + /// An end corner (one blended edge) of at most three edges whose two side edges share + /// no face. + EndSideEdgesShareNoFace, + /// A corner of two blended edges among more than four edges. + MoreThanFourEdges, + /// A concave corner of four edges, two blended, whose side edges are both on the concave + /// side of the blends: no side edge is convex. + NoConvexSideEdge, + /// A Join at one closed blended edge where another edge lies on neither of the blend's + /// faces. + RingEdgeOffClosedBlendFaces, + /// Two edges next to each other in the ring of the corner's edges that share no face: + /// the ring keeps one use of each edge, so an edge that meets the vertex twice stands + /// between edges that are not on one face. + RingEdgesShareNoFace, + /// A Join whose one edge between the blends on a side does not meet the first blended + /// edge in a loop of either of its faces. + SideEdgeNotBesideBlend, +} + +impl CornerShape { + /// The status the site the shape replaces returned: `SM_ERR_NULL_POINTER` where the C++ + /// dereferences the face or edge use it did not find (`NER`), else `SM_ERR`. + #[must_use] + #[allow( + clippy::match_same_arms, + reason = "one arm per variant, sorted by name, so causes added in parallel touch disjoint lines" + )] + pub const fn upstream_status(self) -> i32 { + match self { + Self::AdjacentBlendedEdges => SM_ERR, + Self::BevelNotOfThreeEdges => SM_ERR, + Self::BlendedEdgeOffRing => SM_ERR, + Self::EdgeNotBetweenTwoFaces => SM_ERR, + Self::EndSideEdgesShareNoFace => SM_ERR, + Self::MoreThanFourEdges => SM_ERR, + Self::NoConvexSideEdge => SM_ERR_NULL_POINTER, + Self::RingEdgeOffClosedBlendFaces => SM_ERR, + Self::RingEdgesShareNoFace => SM_ERR_NULL_POINTER, + Self::SideEdgeNotBesideBlend => SM_ERR_NULL_POINTER, + } + } +} + +/// What a fillet corner given to a corner step lacks, or holds otherwise than the corner +/// topology makes it ([`BlendFailure::CornerInputInvalid`]): the conditions only the corner +/// steps check. A missing link of the fillet structures that other routines read too (a +/// fillet edge's primary edge use or its mate, a rail's end vertex use, a fillet vertex's +/// face, a cross-section's fillet geometry, a rail's curve) is +/// [`BlendFailure::FilletSetUpInvalid`] instead, a fillet geometry without its fillet +/// surface the solver's ([`SolverFailure::FilletGeomWithoutSurface`]), and a target-body +/// edge without curve is [`BlendFailure::EdgeWithoutCurve`]. +/// +/// [`CornerInput::upstream_status`] is each kind's default status. A site whose C++ reports +/// the condition otherwise (a failed state check, `SE(SM_ERR)`, where the default is +/// `SM_ERR_NULL_POINTER`) overrides it with that status, so the status is always the site's. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[non_exhaustive] +pub enum CornerInput { + /// An edge of a Mixed corner that does not meet the corner's vertex. + EdgeOffVertex, + /// A corner edge's or a rail's edge use with no fillet geometry (a cross-section's is + /// [`FilletSetUp::CrossSectionGeom`]). + EdgeUseWithoutFilletGeometry, + /// A corner edge of the pseudo-B-rep with no curve (a rail's is + /// [`FilletSetUp::RailCurve`], a target-body edge's [`BlendFailure::EdgeWithoutCurve`]). + EdgeWithoutCurve, + /// An edge of the body at a chamfer corner's vertex with no vertex at an end. + EdgeWithoutVertex, + /// A corner whose event or patches do not hold together: a facet without crossings or a + /// unit normal, a patch order that does not run round its crossings, or patches and + /// loops that do not pair up. + EventMalformed, + /// A ball, chamfer or Mixed corner with no event of its kind (ball members, chamfer or + /// Mixed event). + EventNotSet, + /// A ring face of a ball corner whose kind or offset is not the one the corner's + /// classification took. + FaceNotAsClassified, + /// A chamfer or Mixed corner with no faces' geometry for its patch step. + FacesNotBuilt, + /// A chamfer facet event with no normal. + FacetNormalNotSet, + /// A corner patch step given no fillet B-rep. + FilletBrepNotGiven, + /// An Nx2 corner of kind `kind` with no filleted edge uses. + FilletedEdgeUsesNotGiven { + /// The corner's kind. + kind: crate::blend::fillet_corner::p3::FilletCornerKind, + }, + /// An Nx2 corner of kind `kind` with `given` filleted edge uses, not two. + FilletedEdgeUsesNotTwo { + /// The corner's kind. + kind: crate::blend::fillet_corner::p3::FilletCornerKind, + /// The filleted edge uses it holds. + given: usize, + }, + /// A 3x2 corner whose on-edge edge does not start at an on-vertex vertex where the + /// on-extended-edge edge ends. + MixedCornerEdgesDoNotMeet, + /// A 3x2 corner whose on-vertex vertex is not among its vertices. + MixedCornerVertexNotInCorner, + /// A 3x2 corner of four edges with no on-edge edge. + MixedCornerWithoutOnEdgeEdge, + /// A 3x2 corner of four edges with no on-extended-edge edge. + MixedCornerWithoutOnExtendedEdgeEdge, + /// A concave corner with no rail-cross-edge-use vertex between two fillet geometries. + NoRailXEdgeUseVertex, + /// A ball corner with no ring of edge uses. + RingNotSet, + /// A ball, chamfer or Mixed corner whose vertices or edges are not the count or kind its + /// topology makes. + TopologyMismatch, + /// A vertex of a chamfer or Mixed corner that is not processed. + VertexNotProcessed, + /// A vertex of a convex `NxN` corner of at most three vertices that is not where two + /// rails cross. + VertexNotRailXRail, +} + +impl CornerInput { + /// The kind's default status: `SM_ERR` where the C++ reports a failed state check + /// (`SE(SM_ERR)`), else `SM_ERR_NULL_POINTER` for what it dereferences and does not + /// find (`NER`). A site that reports the condition otherwise overrides it (see + /// [`CornerInput`]). + #[must_use] + #[allow( + clippy::match_same_arms, + reason = "one arm per variant, sorted by name, so causes added in parallel touch disjoint lines" + )] + pub const fn upstream_status(self) -> i32 { + match self { + Self::EdgeOffVertex => SM_ERR, + Self::EdgeUseWithoutFilletGeometry => SM_ERR_NULL_POINTER, + Self::EdgeWithoutCurve => SM_ERR_NULL_POINTER, + Self::EdgeWithoutVertex => SM_ERR_NULL_POINTER, + Self::EventMalformed => SM_ERR, + Self::EventNotSet => SM_ERR_NULL_POINTER, + Self::FaceNotAsClassified => SM_ERR, + Self::FacesNotBuilt => SM_ERR_NULL_POINTER, + Self::FacetNormalNotSet => SM_ERR_NULL_POINTER, + Self::FilletBrepNotGiven => SM_ERR_NULL_POINTER, + Self::FilletedEdgeUsesNotGiven { .. } => SM_ERR_NULL_POINTER, + Self::FilletedEdgeUsesNotTwo { .. } => SM_ERR, + Self::MixedCornerEdgesDoNotMeet => SM_ERR, + Self::MixedCornerVertexNotInCorner => SM_ERR, + Self::MixedCornerWithoutOnEdgeEdge => SM_ERR_NULL_POINTER, + Self::MixedCornerWithoutOnExtendedEdgeEdge => SM_ERR_NULL_POINTER, + Self::NoRailXEdgeUseVertex => SM_ERR_NULL_POINTER, + Self::RingNotSet => SM_ERR_NULL_POINTER, + Self::TopologyMismatch => SM_ERR, + Self::VertexNotProcessed => SM_ERR, + Self::VertexNotRailXRail => SM_ERR, + } + } +} + +/// The step of a ball or chamfer corner's construction that has no result for the corner's +/// geometry ([`BlendFailure::CornerUnbuildable`]). +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[non_exhaustive] +pub enum CornerStep { + /// The line where two of the ball's offset planes meet does not meet the third face's + /// offset quadric as computed: the rounds' ball lies on all three offsets, so the miss + /// is rounding's (the line tangent to the offset, or in it). Not within tolerance. + BallCentreLineMissesOffset, + /// The Krawczyk test did not prove where the three offsets meet, in a box of rounding + /// of the part's size around the rounds' ball: the faces' normals there are too close + /// to dependent for the proof at that size. Not within tolerance. + BallCentreNotProved, + /// The offsets' meeting point is farther than the tolerance from round 0's ball. Not + /// within tolerance. + BallCentreOffRound, + /// The point solve found no foot of the ball's centre on a round's offset surface. + /// Not found. + BallContactFootNotFound, + /// A round's offset surface at its point solve's foot is farther than the tolerance + /// from the ball's centre. Not within tolerance. + BallContactOffOffset, + /// A ball contact is farther than the tolerance from its corner vertex. Not within + /// tolerance. + BallContactOffVertex, + /// The ball's first three offset planes do not meet in one point (two parallel, or the + /// third parallel to the first two's line) at the corner's tolerance. Degenerate. + BallOffsetPlanesDegenerate, + /// Neither turn of the ball's triangular patch has its normal out of the material at + /// the test point: the normal there is along the material's boundary. Degenerate. + BallPatchNormalUndecided, + /// A corner of the ball's triangular patch is farther than the tolerance from its + /// vertex. Not within tolerance. + BallPatchOffVertex, + /// A ring plane past the third has an offset farther than the tolerance from the + /// ball's centre. Not within tolerance. + BallPlaneOffCentre, + /// A chamfer corner's solved rail crossing is farther than the corner's tolerance from + /// its exact point. Not within tolerance. + ChamferCrossingOffExact, + /// The chamfer facet's plane does not hold a side's line within rounding. Not within + /// tolerance. + ChamferFacetOffPlane, + /// A chamfer's surface does not hold a corner edge's exact line within the corner's + /// tolerance (no foot of an end on it, or the surface is not affine in its parameters + /// along the line). Unsupported. + ChamferSurfaceOffEdgeLine, + /// The Mixed corner's common face is not planar to the corner's tolerance. Not within + /// tolerance. + CommonFaceNotPlanar, + /// A round's end section has its two offset points farther apart than the tolerance. + /// Not within tolerance. + RoundSectionOffsetsApart, +} + +impl CornerStep { + /// The step's class: [`ErrorKind::NotWithinTolerance`] for a solve that ended within + /// rounding without a result (neither a defect nor a refusal), + /// [`ErrorKind::Unsupported`] for geometry the construction does not build. + #[must_use] + #[allow( + clippy::match_same_arms, + reason = "one arm per variant, sorted by name, so causes added in parallel touch disjoint lines" + )] + pub const fn class(self) -> ErrorKind { + match self { + Self::BallCentreLineMissesOffset => ErrorKind::NotWithinTolerance, + Self::BallCentreNotProved => ErrorKind::NotWithinTolerance, + Self::BallCentreOffRound => ErrorKind::NotWithinTolerance, + Self::BallContactFootNotFound => ErrorKind::NotFound, + Self::BallContactOffOffset => ErrorKind::NotWithinTolerance, + Self::BallContactOffVertex => ErrorKind::NotWithinTolerance, + Self::BallOffsetPlanesDegenerate => ErrorKind::Degenerate, + Self::BallPatchNormalUndecided => ErrorKind::Degenerate, + Self::BallPatchOffVertex => ErrorKind::NotWithinTolerance, + Self::BallPlaneOffCentre => ErrorKind::NotWithinTolerance, + Self::ChamferCrossingOffExact => ErrorKind::NotWithinTolerance, + Self::ChamferFacetOffPlane => ErrorKind::NotWithinTolerance, + Self::ChamferSurfaceOffEdgeLine => ErrorKind::Unsupported, + Self::CommonFaceNotPlanar => ErrorKind::NotWithinTolerance, + Self::RoundSectionOffsetsApart => ErrorKind::NotWithinTolerance, + } + } + + /// What has no result, as a phrase. + #[must_use] + pub const fn what(self) -> &'static str { + match self { + Self::BallCentreLineMissesOffset => "the line of two of the ball's offset planes misses the third face's offset within rounding", + Self::BallCentreNotProved => "the ball's centre was not proved where the three offsets meet, within rounding of the part's size", + Self::BallCentreOffRound => "the offsets' meeting point is farther than the tolerance from round 0's ball", + Self::BallContactFootNotFound => "the point solve found no foot of the ball's centre on a round's offset surface", + Self::BallContactOffOffset => "a round's offset surface at the ball contact's foot is farther than the tolerance from the ball's centre", + Self::BallContactOffVertex => "a ball contact is farther than the tolerance from its corner vertex", + Self::BallOffsetPlanesDegenerate => "the ball's first three offset planes do not meet in one point at the corner's tolerance", + Self::BallPatchNormalUndecided => "neither turn of the ball's triangular patch has its normal out of the material", + Self::BallPatchOffVertex => "a corner of the ball's triangular patch is farther than the tolerance from its vertex", + Self::BallPlaneOffCentre => "a ring plane past the third has its offset farther than the tolerance from the ball's centre", + Self::ChamferCrossingOffExact => "a solved rail crossing is farther than the chamfer corner's tolerance from its exact point", + Self::ChamferFacetOffPlane => "the chamfer facet's plane does not hold a side's line within rounding", + Self::ChamferSurfaceOffEdgeLine => "a chamfer's surface does not hold a corner edge's exact line within the corner's tolerance", + Self::CommonFaceNotPlanar => "the Mixed corner's common face is not planar to the corner's tolerance", + Self::RoundSectionOffsetsApart => "a round's end section has its offset points farther apart than the tolerance", + } + } +} + +/// The step of the Mixed corner's construction that has no construction for the corner's +/// geometry ([`BlendFailure::MixedCornerUnbuildable`]). +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[non_exhaustive] +pub enum MixedStep { + /// A blend's surface has no B-spline form for the corner's exact algebra. + /// Unsupported. + BlendSurfaceNotBSpline, + /// Three points of the concave blend's edge lie on one line: the edge has no circle + /// to take the corner's axis from. Degenerate. + ConcaveEdgeStraight, + /// A face's patch has a weight that is not positive. Unsupported. + FaceWeightNotPositive, + /// The inflection's end tangents do not meet between the rails' crossing and the + /// vertex. Unsupported. + InflectionTangentsMiss, + /// The inflection's end tangents (from the rails' crossing and at the vertex) are + /// parallel. Degenerate. + InflectionTangentsParallel, + /// A curve's C1 reparametrization at a break has singular normal equations. + /// Degenerate. + JoinSingular, + /// A curve's C1 reparametrization at a break needs a span that is not positive. + /// Unsupported. + JoinSpanNotPositive, + /// The corner's shape at the rails' crossing has no asymptotic direction between the + /// trimlines. Unsupported. + NoAsymptoticDirection, + /// The closest-point solve over a rail's interval returned no point for a corner + /// point (the tree solve's own failures are dropped, so it can end empty). Not found. + NoClosestPointOnRail, + /// A corner point has no foot on a wall face, inside the face, to take the face's + /// normal at. Not found. + NoFootOnWallFace, + /// A blend's rail on its wall does not meet the other blend's rail on the common face + /// swept along the face's normal (the corner's vertex A or B). Not found. + RailMissesRailWall, + /// A side's tangent leaves its neighbour's tangent plane at a corner of a face. + /// Unsupported. + SideLeavesTangentPlane, + /// The faces' tangent plane would turn the wrong way along the inflection (the twists' + /// rate is not positive). Unsupported. + TangentPlaneTurns, + /// The first trimline runs along the convex edge at the rails' crossing: the second + /// trimline's direction has no coordinates in them. Degenerate. + TrimlineAlongConvexEdge, + /// A trimline's parameter curve has no B-spline form for the corner's exact algebra. + /// Unsupported. + TrimlineNotBSpline, + /// A trimline has no speed at the rails' crossing: it has no tangent there. + /// Degenerate. + TrimlineStalls, + /// The corner's twists are not compatible. Unsupported. + TwistsIncompatible, + /// A blend's rail on its wall does not cross the seam's line on its side of the vertex + /// (the corner's vertex P or Q). Not found. + WallRailMissesSeamLine, +} + +impl MixedStep { + /// The step's class: [`ErrorKind::NotFound`] for a crossing or foot not found, + /// [`ErrorKind::Degenerate`] for a degenerate shape, [`ErrorKind::Unsupported`] for a + /// shape the construction does not build. + #[must_use] + #[allow( + clippy::match_same_arms, + reason = "one arm per variant, sorted by name, so causes added in parallel touch disjoint lines" + )] + pub const fn class(self) -> ErrorKind { + match self { + Self::BlendSurfaceNotBSpline => ErrorKind::Unsupported, + Self::ConcaveEdgeStraight => ErrorKind::Degenerate, + Self::FaceWeightNotPositive => ErrorKind::Unsupported, + Self::InflectionTangentsMiss => ErrorKind::Unsupported, + Self::InflectionTangentsParallel => ErrorKind::Degenerate, + Self::JoinSingular => ErrorKind::Degenerate, + Self::JoinSpanNotPositive => ErrorKind::Unsupported, + Self::NoAsymptoticDirection => ErrorKind::Unsupported, + Self::NoClosestPointOnRail => ErrorKind::NotFound, + Self::NoFootOnWallFace => ErrorKind::NotFound, + Self::RailMissesRailWall => ErrorKind::NotFound, + Self::SideLeavesTangentPlane => ErrorKind::Unsupported, + Self::TangentPlaneTurns => ErrorKind::Unsupported, + Self::TrimlineAlongConvexEdge => ErrorKind::Degenerate, + Self::TrimlineNotBSpline => ErrorKind::Unsupported, + Self::TrimlineStalls => ErrorKind::Degenerate, + Self::TwistsIncompatible => ErrorKind::Unsupported, + Self::WallRailMissesSeamLine => ErrorKind::NotFound, + } + } + + /// What has no construction, as a phrase ("a rail does not meet ..."). + #[must_use] + pub const fn what(self) -> &'static str { + match self { + Self::BlendSurfaceNotBSpline => "a blend's surface has no B-spline form", + Self::ConcaveEdgeStraight => "the concave edge has no circle: its points lie on a line", + Self::FaceWeightNotPositive => "a face's patch has a weight that is not positive", + Self::InflectionTangentsMiss => "the inflection's end tangents do not meet between the rails' crossing and the vertex", + Self::InflectionTangentsParallel => "the inflection's end tangents are parallel", + Self::JoinSingular => "a curve's C1 join at a break has singular equations", + Self::JoinSpanNotPositive => "a curve's C1 join at a break needs a span that is not positive", + Self::NoAsymptoticDirection => "the shape at the rails' crossing has no asymptotic direction between the trimlines", + Self::NoClosestPointOnRail => "the closest-point solve over a rail returned no point for a corner point", + Self::NoFootOnWallFace => "a corner point has no foot inside a wall face", + Self::RailMissesRailWall => "a rail on its wall does not meet the other blend's rail swept along the common face's normal", + Self::SideLeavesTangentPlane => "a side's tangent leaves its neighbour's tangent plane at a face's corner", + Self::TangentPlaneTurns => "the faces' tangent plane would turn the wrong way along the inflection", + Self::TrimlineAlongConvexEdge => "the first trimline runs along the convex edge at the rails' crossing", + Self::TrimlineNotBSpline => "a trimline's parameter curve has no B-spline form", + Self::TrimlineStalls => "a trimline has no tangent at the rails' crossing", + Self::TwistsIncompatible => "the corner's twists are not compatible", + Self::WallRailMissesSeamLine => "a rail on its wall does not cross the seam's line on its side of the vertex", + } + } +} diff --git a/solidcore/crates/solidcore/src/error/blend/crease_trim.rs b/solidcore/crates/solidcore/src/error/blend/crease_trim.rs new file mode 100644 index 00000000000..af9ec5350ab --- /dev/null +++ b/solidcore/crates/solidcore/src/error/blend/crease_trim.rs @@ -0,0 +1,90 @@ +//! Why a blend trimmed at its creases is not built. +//! +//! Upstream: none. One of the modules of the blend failure causes, re-exported from +//! [`super`]. + +#[cfg(doc)] +use super::BlendFailure; +use crate::error::ErrorKind; + +/// Why a blend trimmed at its creases is not built ([`BlendFailure::CreaseTrimNotBuilt`]), +/// each with its kind ([`CreaseTrimStop::class`]). +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[non_exhaustive] +pub enum CreaseTrimStop { + /// A corner's face between blends that add and blends that take off material, past their + /// faces or at an open setback ([`ErrorKind::Unsupported`]; noted `CornerUnsupported`). + CornerBetweenAddingAndTaking, + /// A body edge moved onto a crease leaves geometry the trim does not take off + /// ([`ErrorKind::Failed`]; noted `BadMerge`). + MovedEdgeLeavesGeometry, + /// The filleted edge has no tangent at an open end's vertex, so no section through the + /// vertex ends the round there ([`ErrorKind::Degenerate`]). + NoSectionThroughEndVertex, + /// The trimmed sheet does not sew into the body as a manifold solid + /// ([`ErrorKind::Failed`]; noted `BadMerge`). + NotSewn, + /// A piece of a blend past its faces lies on the body's boundary away from its creases + /// ([`ErrorKind::Unsupported`]; noted `BadMerge`). + PieceOnBoundaryAwayFromCreases, + /// The creases and rails enclose no part of the body: the trim reaches every face + /// ([`ErrorKind::NotFound`]; noted `BadMerge`). + ReachesEveryFace, + /// A round's section end lies along an edge of the body its rail does not cut + /// ([`ErrorKind::Unsupported`]; noted `BadMerge`). + SectionEndAlongUncutEdge, + /// The trim takes off nothing round the blended edges ([`ErrorKind::NotFound`]; noted + /// `BadMerge`). + TakesOffNothing, +} + +impl CreaseTrimStop { + /// The kind of the failure. + #[must_use] + #[allow( + clippy::match_same_arms, + reason = "one arm per variant, sorted by name, so causes added in parallel touch disjoint lines" + )] + pub const fn class(self) -> ErrorKind { + match self { + Self::CornerBetweenAddingAndTaking => ErrorKind::Unsupported, + Self::MovedEdgeLeavesGeometry => ErrorKind::Failed, + Self::NoSectionThroughEndVertex => ErrorKind::Degenerate, + Self::NotSewn => ErrorKind::Failed, + Self::PieceOnBoundaryAwayFromCreases => ErrorKind::Unsupported, + Self::ReachesEveryFace => ErrorKind::NotFound, + Self::SectionEndAlongUncutEdge => ErrorKind::Unsupported, + Self::TakesOffNothing => ErrorKind::NotFound, + } + } + + pub(super) const fn what(self) -> &'static str { + match self { + Self::CornerBetweenAddingAndTaking => { + "a corner's face between blends that add and blends that take off material is \ + not built" + } + Self::MovedEdgeLeavesGeometry => { + "a body edge moved onto a blend's crease leaves geometry the trim does not take off" + } + Self::NoSectionThroughEndVertex => { + "the filleted edge has no tangent at an open end's vertex, so no section ends \ + the round there" + } + Self::NotSewn => { + "a blend past its faces does not sew into the body along its creases and rails" + } + Self::PieceOnBoundaryAwayFromCreases => { + "a blend past its faces lies on the body's boundary away from its creases" + } + Self::ReachesEveryFace => { + "a blend past its faces reaches every face of the body (its creases and rails \ + enclose no part of it)" + } + Self::SectionEndAlongUncutEdge => { + "a round's section end lies along an edge of the body that its rail does not cut" + } + Self::TakesOffNothing => "a blend past its faces takes off nothing round its edges", + } + } +} diff --git a/solidcore/crates/solidcore/src/error/blend/crossing.rs b/solidcore/crates/solidcore/src/error/blend/crossing.rs new file mode 100644 index 00000000000..308eb2baafd --- /dev/null +++ b/solidcore/crates/solidcore/src/error/blend/crossing.rs @@ -0,0 +1,34 @@ +//! The inputs of a rail crossing's judgement a blend failure names missing. +//! +//! Upstream: none. One of the modules of the blend failure causes, re-exported from +//! [`super`]. + +#[cfg(doc)] +use super::BlendFailure; + +/// Which input of a rail crossing's judgement is missing ([`BlendFailure::CrossingInputMissing`]). +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[non_exhaustive] +pub enum CrossingInput { + /// The place on the side edge where the rail crosses it. + CrossingOnSideEdge, + /// The radial edge use of the edge use that bounds material. + MaterialEdgeUseRadial, + /// The tangency budget of the round a sheet face belongs to. + SheetFaceTangencyBudget, + /// The curve of the side edge a rail crosses. + SideEdgeCurve, +} + +impl CrossingInput { + /// What is missing, as a phrase ("the side edge's curve"). + #[must_use] + pub const fn what(self) -> &'static str { + match self { + Self::CrossingOnSideEdge => "the rollover event on the side edge", + Self::MaterialEdgeUseRadial => "the material edge use's radial", + Self::SheetFaceTangencyBudget => "the sheet face's tangency budget", + Self::SideEdgeCurve => "the side edge's curve", + } + } +} diff --git a/solidcore/crates/solidcore/src/error/blend/ease.rs b/solidcore/crates/solidcore/src/error/blend/ease.rs new file mode 100644 index 00000000000..1cdd9d92db2 --- /dev/null +++ b/solidcore/crates/solidcore/src/error/blend/ease.rs @@ -0,0 +1,190 @@ +//! Why the ease of a round before a setback fails: its missing inputs, stops and geometry. +//! +//! Upstream: none. One of the modules of the blend failure causes, re-exported from +//! [`super`]. + +#[cfg(doc)] +use super::BlendFailure; +use crate::error::ErrorKind; + +/// What a thing the ease of a round before a setback reads lacks +/// ([`BlendFailure::EaseInputMissing`]). +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[non_exhaustive] +pub enum EaseInput { + /// A round's centre line. + CentreLine, + /// An eased corner's filleted vertex. + CornerVertex, + /// An edge's curve (a rail's or the filleted edge's). + EdgeCurve, + /// An edge use's face. + EdgeUseFace, + /// A face's surface. + FaceSurface, + /// A round's rail edge. + RoundRail, + /// A round's solver. + RoundSolver, + /// A round's fillet surface. + RoundSurface, + /// A face for the point a setback vertex classifies on (it classifies on no face). + SetbackFace, + /// A round solver's offset surface for a rail (made when the solver is loaded). + SolverSurface, + /// A round solver's surface generator. + SurfaceGenerator, +} + +impl EaseInput { + pub(super) const fn what(self) -> &'static str { + match self { + Self::CentreLine => "an eased round has no centre line", + Self::CornerVertex => "an eased corner has no filleted vertex", + Self::EdgeCurve => "an edge the ease reads has no curve", + Self::EdgeUseFace => "an edge use the ease reads has no face", + Self::FaceSurface => "a face the ease reads has no surface", + Self::RoundRail => "an eased round has no rail edge on a side", + Self::RoundSolver => "an eased round has no solver", + Self::RoundSurface => "an eased round has no fillet surface", + Self::SetbackFace => "a setback vertex of an eased corner classifies on no face", + Self::SolverSurface => "an eased round's solver has no offset surface for a rail", + Self::SurfaceGenerator => "an eased round's solver has no surface generator", + } + } +} + +/// Where the ease of a round before a setback stops ([`BlendFailure::EaseNotBuilt`]), each +/// with its kind ([`EaseStop::class`]). +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[non_exhaustive] +pub enum EaseStop { + /// The start of the ease drops onto the rail where the setback's section does: the + /// ease has no length ([`ErrorKind::Degenerate`]). + EaseHasNoLength, + /// The setback plus the ease runs past the far end of the filleted edge + /// ([`ErrorKind::OutsideDomain`]). + EasePastEdgeEnd, + /// The start of the ease does not drop onto the rail ([`ErrorKind::NotFound`]). + EaseStartOffRail, + /// Neither direction of the round's surface runs along its rails + /// ([`ErrorKind::Unsupported`]). + NoDirectionAlongRails, + /// No section of the round lies in the plane at the eased setback + /// ([`ErrorKind::NotFound`]). + NoSectionInPlane, + /// The origin of the plane at the eased setback has other than one closest point on an + /// offset surface of the round ([`ErrorKind::NotFound`]). + PlaneOriginNotOneClosest, + /// A rail does not drop onto its face's surface as one UV curve + /// ([`ErrorKind::Unsupported`]). + RailNotOneUvCurve, + /// The round's sections are neither circular nor curvature-continuous: the ease eases + /// a circular round only ([`ErrorKind::Unsupported`]). + SectionsNotCircular, + /// The face a setback vertex classifies on carries neither of the round's rails + /// ([`ErrorKind::NotFound`]). + SetbackFaceCarriesNoRail, + /// A setback vertex lies on other than exactly one fillet geometry: the ease eases one + /// round per setback vertex ([`ErrorKind::Unsupported`]). + SetbackNotOnOneRound, + /// A setback vertex of the eased corner is not yet placed (not processed): the ease + /// does not place it ([`ErrorKind::Unsupported`]). + SetbackVertexNotPlaced, + /// The setback vertex does not drop onto the round's rail ([`ErrorKind::NotFound`]). + SetbackVertexOffRail, + /// A rail's UV curve does not run over the rail's own interval + /// ([`ErrorKind::Unsupported`]). + UvCurveOffRailInterval, +} + +impl EaseStop { + /// The stop's kind. + #[must_use] + #[allow( + clippy::match_same_arms, + reason = "one arm per variant, sorted by name, so causes added in parallel touch disjoint lines" + )] + pub const fn class(self) -> ErrorKind { + match self { + Self::EaseHasNoLength => ErrorKind::Degenerate, + Self::EasePastEdgeEnd => ErrorKind::OutsideDomain, + Self::EaseStartOffRail => ErrorKind::NotFound, + Self::NoDirectionAlongRails => ErrorKind::Unsupported, + Self::NoSectionInPlane => ErrorKind::NotFound, + Self::PlaneOriginNotOneClosest => ErrorKind::NotFound, + Self::RailNotOneUvCurve => ErrorKind::Unsupported, + Self::SectionsNotCircular => ErrorKind::Unsupported, + Self::SetbackFaceCarriesNoRail => ErrorKind::NotFound, + Self::SetbackNotOnOneRound => ErrorKind::Unsupported, + Self::SetbackVertexNotPlaced => ErrorKind::Unsupported, + Self::SetbackVertexOffRail => ErrorKind::NotFound, + Self::UvCurveOffRailInterval => ErrorKind::Unsupported, + } + } + + pub(super) const fn what(self) -> &'static str { + match self { + Self::EaseHasNoLength => { + "the ease's start drops onto the rail where the setback's section does" + } + Self::EasePastEdgeEnd => { + "the setback plus the ease runs past the end of the filleted edge" + } + Self::EaseStartOffRail => "the ease's start does not drop onto the rail", + Self::NoDirectionAlongRails => { + "neither direction of the round's surface runs along its rails" + } + Self::NoSectionInPlane => { + "no section of the round lies in the plane at the eased setback" + } + Self::PlaneOriginNotOneClosest => { + "the plane's origin at the eased setback has no single closest point on an \ + offset surface" + } + Self::RailNotOneUvCurve => { + "a rail does not drop onto its face's surface as one UV curve" + } + Self::SectionsNotCircular => { + "an eased round's sections are neither circular nor curvature-continuous" + } + Self::SetbackFaceCarriesNoRail => { + "the face a setback vertex classifies on carries neither rail of the round" + } + Self::SetbackNotOnOneRound => { + "a setback vertex of an eased corner is not on exactly one round" + } + Self::SetbackVertexNotPlaced => "a setback vertex of an eased corner is not placed", + Self::SetbackVertexOffRail => "a setback vertex does not drop onto the round's rail", + Self::UvCurveOffRailInterval => { + "a rail's UV curve does not run over the rail's own interval" + } + } + } +} + +/// Which curve or surface the ease of a round before a setback finds without a B-spline +/// form ([`BlendFailure::EaseGeometryNotBSpline`]). +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[non_exhaustive] +pub enum EaseGeometry { + /// A rail's UV curve dropped onto its face's surface. + DroppedUvCurve, + /// A rail's curve. + RailCurve, + /// The eased round's fillet surface. + RoundSurface, + /// A rail's UV curve as the trace left it. + TracedUvCurve, +} + +impl EaseGeometry { + pub(super) const fn what(self) -> &'static str { + match self { + Self::DroppedUvCurve => "a rail's UV curve dropped onto its face has no B-spline form", + Self::RailCurve => "an eased round's rail curve has no B-spline form", + Self::RoundSurface => "an eased round's fillet surface has no B-spline form", + Self::TracedUvCurve => "a rail's traced UV curve has no B-spline form", + } + } +} diff --git a/solidcore/crates/solidcore/src/error/blend/keep.rs b/solidcore/crates/solidcore/src/error/blend/keep.rs new file mode 100644 index 00000000000..8ef8b13851d --- /dev/null +++ b/solidcore/crates/solidcore/src/error/blend/keep.rs @@ -0,0 +1,60 @@ +//! Why a round kept round a feature standing in its band is not built. +//! +//! Upstream: none. One of the modules of the blend failure causes, re-exported from +//! [`super`]. + +#[cfg(doc)] +use super::BlendFailure; +use crate::error::ErrorKind; + +/// Why a round kept round a feature is not built ([`BlendFailure::KeptFeatureNotBuilt`]), +/// each with its kind ([`KeepStop::class`]). +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[non_exhaustive] +pub enum KeepStop { + /// The kept round's rails and creases enclose no part of the body, or all of it + /// ([`ErrorKind::NotFound`]; noted `BadMerge`). + RoundNotClosed, + /// The kept round does not sew into the body as a manifold solid + /// ([`ErrorKind::Failed`]; noted `BadMerge`). + RoundNotSewn, + /// A kept boss's wall continued down meets no round ([`ErrorKind::NotFound`]; noted + /// `BadMerge`). + WallMeetsNoRound, + /// The faces of a boss's walls swept down are not all copied into the sheet + /// ([`ErrorKind::Failed`]). + WallsNotAllCopied, + /// The walls of a kept boss are not upright to the planar face it stands on: their + /// continuation down is not built ([`ErrorKind::Unsupported`]; noted `NotExact`). + WallsNotUpright, +} + +impl KeepStop { + /// The kind of the failure. + #[must_use] + #[allow( + clippy::match_same_arms, + reason = "one arm per variant, sorted by name, so causes added in parallel touch disjoint lines" + )] + pub const fn class(self) -> ErrorKind { + match self { + Self::RoundNotClosed => ErrorKind::NotFound, + Self::RoundNotSewn => ErrorKind::Failed, + Self::WallMeetsNoRound => ErrorKind::NotFound, + Self::WallsNotAllCopied => ErrorKind::Failed, + Self::WallsNotUpright => ErrorKind::Unsupported, + } + } + + pub(super) const fn what(self) -> &'static str { + match self { + Self::RoundNotClosed => "a round kept round a feature does not close on the body", + Self::RoundNotSewn => "a round kept round a feature does not sew into the body", + Self::WallMeetsNoRound => "a kept boss's wall continued down meets no round", + Self::WallsNotAllCopied => "not every face of a kept boss's walls continued is copied", + Self::WallsNotUpright => { + "a kept boss's walls are not upright to the planar face it stands on" + } + } + } +} diff --git a/solidcore/crates/solidcore/src/error/blend/law_corner.rs b/solidcore/crates/solidcore/src/error/blend/law_corner.rs new file mode 100644 index 00000000000..9cbb5c1472f --- /dev/null +++ b/solidcore/crates/solidcore/src/error/blend/law_corner.rs @@ -0,0 +1,33 @@ +//! What the exact round at a radius law's corner looks for and does not find. +//! +//! Upstream: none. One of the modules of the blend failure causes, re-exported from +//! [`super`]. + +#[cfg(doc)] +use super::BlendFailure; + +/// What the exact round at a radius law's corner looked for and did not find +/// ([`BlendFailure::LawCornerNotFound`]). +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[non_exhaustive] +pub enum LawCornerSearch { + /// The edge of a side's face between the corner's rail points. + CornerEdge, + /// The curve where the sides of a peak cross, from rail point to rail point. + Crossing, + /// A side's corner curve, oriented from its edge's start vertex to its end vertex. + CurveBetweenEnds, + /// The edge the faces on either side of the corner share. + SharedEdge, +} + +impl LawCornerSearch { + pub(super) const fn what(self) -> &'static str { + match self { + Self::CornerEdge => "edge between the rail points on a side's face", + Self::Crossing => "crossing of the sides between the rail points", + Self::CurveBetweenEnds => "corner curve between its edge's end vertices", + Self::SharedEdge => "edge shared by the faces on either side", + } + } +} diff --git a/solidcore/crates/solidcore/src/error/blend/no_room.rs b/solidcore/crates/solidcore/src/error/blend/no_room.rs new file mode 100644 index 00000000000..5213108c1ec --- /dev/null +++ b/solidcore/crates/solidcore/src/error/blend/no_room.rs @@ -0,0 +1,74 @@ +//! The class of a blend larger than its faces allow, by its reason. +//! +//! Upstream: none. One of the modules of the blend failure causes, re-exported from +//! [`super`]. + +use crate::blend::fillet_executive::NoRoomReason; +use crate::error::ErrorKind; + +/// The class of a blend larger than its faces allow, for `reason`: +/// [`ErrorKind::FilletTooLarge`] (100) for a weld bead larger than its faces take, one of +/// the blend's refusal classes 101 to 124 (the cliff overflow's own refusals grouped by +/// what decides them), [`ErrorKind::TangentContinuationEnd`] (128) or +/// [`ErrorKind::OverflowKeepsNothing`] (129). +/// [`ErrorKind::CliffSubtractionLeavesNoSolid`] is the one defect among them. +#[must_use] +#[allow( + clippy::match_same_arms, + reason = "one arm per variant, sorted by name, so causes added in parallel touch disjoint lines" +)] +pub const fn no_room_class(reason: NoRoomReason) -> ErrorKind { + use NoRoomReason as R; + match reason { + // a Join's: the round's ball does not fit its face where its contact line must cross + // the edge between the rounds' faces + R::BallDoesNotFit => ErrorKind::BallDoesNotFit, + R::BallsFold => ErrorKind::BallsFold, + R::BandsOverlap => ErrorKind::BandsOverlap, + // a weld bead larger than its faces take: the error names the size that builds + R::BeadCutsFace => ErrorKind::FilletTooLarge, + R::BreaksThrough => ErrorKind::BreaksThrough, + R::CliffBoundaryBranches => ErrorKind::CliffOverflowShape, + R::CliffBoundaryClosed => ErrorKind::CliffOverflowShape, + R::CliffBoundaryLeavesAlongNoSideEdge => ErrorKind::CliffOverflowShape, + R::CliffBoundaryOnTwoFaces => ErrorKind::CliffOverflowShape, + R::CliffClosingFaceUnbounded => ErrorKind::CliffOverflowShape, + R::CliffEndFaceNotPlanar => ErrorKind::CliffEndFaceNotPlanar, + R::CliffEndNotCut => ErrorKind::CliffOverflowShape, + R::CliffLawNotHeld => ErrorKind::CliffOverflowShape, + R::CliffSubtractionLeavesNoSolid => ErrorKind::CliffSubtractionLeavesNoSolid, + R::ConcaveOverflow => ErrorKind::RailLeavesFace, + R::CornersTakeWholeEdge => ErrorKind::CornersTakeWholeEdge, + R::CreaseAcrossTangentEdge => ErrorKind::CreaseAcrossTangentEdge, + R::CutsThePart => ErrorKind::CutsThePart, + R::EndAtSeamVertex => ErrorKind::EndAtSeamVertex, + // an End the round overflows: past its side edge, or over its end face whole + R::EndOverflowsSideEdge => ErrorKind::EndOverflowsSideEdge, + // an End the round overflows: past its side edge, or over its end face whole + R::EndPassesOverEndFace => ErrorKind::EndOverflowsSideEdge, + R::EndPastSideEdge => ErrorKind::EndPastSideEdge, + R::EndRollsIntoSmoothEnd => ErrorKind::EndRollsIntoSmoothEnd, + R::FaceConsumed => ErrorKind::FaceConsumed, + R::JoinOffsetsDiffer => ErrorKind::JoinOffsetsDiffer, + // a Join's: the round's ball does not fit its face where its contact line must cross + // the edge between the rounds' faces + R::JoinRailMissesSideEdge => ErrorKind::BallDoesNotFit, + // a weld bead larger than its faces take: the error names the size that builds + R::LegPastFace => ErrorKind::FilletTooLarge, + // a weld bead larger than its faces take: the error names the size that builds + R::NoToeAtLeg => ErrorKind::FilletTooLarge, + R::OffsetCollapses => ErrorKind::BallOffsetCollapses, + R::OffsetFolds => ErrorKind::ChamferOffsetFolds, + R::OverflowKeepsNothing => ErrorKind::OverflowKeepsNothing, + R::OverflowWithConcaveBlend => ErrorKind::CliffOverflowRefused, + R::OverflowWithGlobalMerge => ErrorKind::CliffOverflowRefused, + R::OverflowWithRollover => ErrorKind::CliffOverflowRefused, + R::RailBelowResolution => ErrorKind::RailBelowResolution, + R::RailLeavesFace => ErrorKind::RailLeavesFace, + R::RailPastAxis => ErrorKind::RailPastAxis, + R::RailRunsPastFaceIntoMaterial => ErrorKind::RunsIntoMaterial, + R::RoundIntoMaterial => ErrorKind::RunsIntoMaterial, + R::StripBelowResolution => ErrorKind::StripBelowResolution, + R::TangentContinuationEndUnsupported => ErrorKind::TangentContinuationEnd, + } +} diff --git a/solidcore/crates/solidcore/src/error/blend/overflow.rs b/solidcore/crates/solidcore/src/error/blend/overflow.rs new file mode 100644 index 00000000000..dea32ef9829 --- /dev/null +++ b/solidcore/crates/solidcore/src/error/blend/overflow.rs @@ -0,0 +1,65 @@ +//! Why a blend's overflow fails: its missing inputs and the drops that find no foot. +//! +//! Upstream: none. One of the modules of the blend failure causes, re-exported from +//! [`super`]. + +#[cfg(doc)] +use super::BlendFailure; + +/// What a face or edge a blend's overflow reads lacks ([`BlendFailure::OverflowInputMissing`]). +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[non_exhaustive] +pub enum OverflowInput { + /// An edge's curve. + EdgeCurve, + /// An edge's end vertex. + EdgeEndVertex, + /// An edge's vertex at its other end from a vertex on it. + EdgeOtherVertex, + /// An edge's start vertex. + EdgeStartVertex, + /// A face's surface. + FaceSurface, +} + +impl OverflowInput { + pub(super) const fn what(self) -> &'static str { + match self { + Self::EdgeCurve => "an edge a blend's overflow reads has no curve", + Self::EdgeEndVertex => "an edge a blend's overflow reads has no end vertex", + Self::EdgeOtherVertex => { + "an edge a blend's overflow walks has no vertex at its other end" + } + Self::EdgeStartVertex => "an edge a blend's overflow reads has no start vertex", + Self::FaceSurface => "a face a blend's overflow reads has no surface", + } + } +} + +/// What a point of the cliff overflow does not drop onto +/// ([`BlendFailure::OverflowPointDoesNotDrop`]). +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[non_exhaustive] +pub enum OverflowDrop { + /// The middle of the filleted edge, onto a fillet face cut at an open end. + EdgeMiddleOntoFilletFace, + /// An end of a piece of the body's edge an extension runs along, onto the edge's curve + /// (within ten tolerances). + EdgePieceEndOntoEdge, + /// A sample of a closing face's loop, onto the face's surface. + LoopSampleOntoSurface, +} + +impl OverflowDrop { + pub(super) const fn what(self) -> &'static str { + match self { + Self::EdgeMiddleOntoFilletFace => { + "the filleted edge's middle does not drop onto a fillet face cut at an open end" + } + Self::EdgePieceEndOntoEdge => "an end of an edge's piece does not drop onto the edge", + Self::LoopSampleOntoSurface => { + "a sample of a closing face's loop does not drop onto its surface" + } + } + } +} diff --git a/solidcore/crates/solidcore/src/error/blend/removal.rs b/solidcore/crates/solidcore/src/error/blend/removal.rs new file mode 100644 index 00000000000..b79be1dd0f0 --- /dev/null +++ b/solidcore/crates/solidcore/src/error/blend/removal.rs @@ -0,0 +1,112 @@ +//! Why a fillet removal refuses, and the class of each refusal. +//! +//! Upstream: none. One of the modules of the blend failure causes, re-exported from +//! [`super`]. + +use crate::blend::fillet_exact::BlendSpine; +use crate::error::ErrorKind; + +/// Why a fillet removal (`crate::blend::fillet_removal`, its ring removal included) refuses +/// the face it is asked to remove. Each is a fact of the face and its neighbours, not a +/// defect; the class is [`removal_class`]. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[non_exhaustive] +pub enum RemovalRefusal { + /// Two adjacent edges of the fillet face are both tangent. + AdjacentEdgesTangent, + /// A corner of more than three edges keeps its end edge, which would need a fitted + /// intersection to run on to the new corner. + CornerNeedsFittedIntersection, + /// The new corner is off the line of the side edge that would run on to it. + CornerOffSideLine, + /// An edge of the fillet face does not border exactly two faces. + EdgeNotBetweenTwoFaces, + /// A tangent or end edge of the fillet face does not have two vertices. + EdgeWithoutTwoVertices, + /// An end face's surface is not a B-spline surface. + EndFaceNotBSpline, + /// A face the removal extends would grow past its surface's domain, which only a plane + /// continues exactly. + FaceGrowsPastDomain, + /// The ring fillet has more than two rails. + MoreThanTwoRails, + /// Neither of the fillet face's first two edges is tangent. + NoTangentEdge, + /// The face is not a ring fillet. + NotARing, + /// The fillet face does not have four edges. + NotFourEdges, + /// The selected faces do not form one connected strip with two rails. + NotOneTangentChain, + /// The edge opposite the fillet face's tangent edge is not tangent. + OppositeEdgeNotTangent, + /// The new sharp edge's UV trim could not be certified within the original rail tolerance. + RailTrimOutsideTolerance, + /// A rail's vertex has an edge other than one open seam of its tangent face. + RailVertexHasOtherEdges, + /// The ring fillet does not have two rails between two other faces. + RailsNotBetweenTwoFaces, + /// A tangent face's seam crosses the sharp edge at more than one place. + SeamCrossesSharpEdgeTwice, + /// The ring fillet's seam does not join the two rails' vertices. + SeamDoesNotJoinRails, + /// A seam has more than two edge uses with their own UV trim curves. + SeamHasMoreThanTwoTrims, + /// A seam has no edge use with its own UV trim curve. + SeamHasNoOwnTrim, + /// A seam's UV trim, run on, does not reach the new vertex on its face's surface. + SeamTrimMissesNewVertex, + /// The two tangent faces' seams cross the sharp edge at different places. + SeamsCrossApart, + /// The side edge that would run on to the new corner is not a straight B-spline curve, + /// so it cannot run on exactly. + SideEdgeNotStraight, + /// A tangent face's surface is not a B-spline surface. + TangentFaceNotBSpline, + /// The tangent surfaces of a ring fillet do not meet in a closed curve near its rails + /// within their domains: the sharp edge would lie on a continuation of one of them. + TangentSurfacesDoNotMeet, + /// The support intersection has a shape the removal cannot rebuild as a sharp edge. + UnsupportedSharpSpine(BlendSpine), +} + +/// The class of a fillet removal's refusal, for `reason`: [`ErrorKind::RemovalNotExact`] (130) +/// where the removal would continue a face or an edge past its geometry, and +/// [`ErrorKind::NotARemovableFillet`] (131) where the face and its neighbours are not a fillet +/// the removal recognises. Both are refusals no size decides. +#[must_use] +#[allow( + clippy::match_same_arms, + reason = "one arm per variant, sorted by name, so causes added in parallel touch disjoint lines" +)] +pub const fn removal_class(reason: RemovalRefusal) -> ErrorKind { + use RemovalRefusal as R; + match reason { + R::AdjacentEdgesTangent => ErrorKind::NotARemovableFillet, + R::CornerNeedsFittedIntersection => ErrorKind::RemovalNotExact, + R::CornerOffSideLine => ErrorKind::RemovalNotExact, + R::EdgeNotBetweenTwoFaces => ErrorKind::NotARemovableFillet, + R::EdgeWithoutTwoVertices => ErrorKind::NotARemovableFillet, + R::EndFaceNotBSpline => ErrorKind::NotARemovableFillet, + R::FaceGrowsPastDomain => ErrorKind::RemovalNotExact, + R::MoreThanTwoRails => ErrorKind::NotARemovableFillet, + R::NoTangentEdge => ErrorKind::NotARemovableFillet, + R::NotARing => ErrorKind::NotARemovableFillet, + R::NotFourEdges => ErrorKind::NotARemovableFillet, + R::NotOneTangentChain => ErrorKind::NotARemovableFillet, + R::OppositeEdgeNotTangent => ErrorKind::NotARemovableFillet, + R::RailTrimOutsideTolerance => ErrorKind::RemovalNotExact, + R::RailVertexHasOtherEdges => ErrorKind::NotARemovableFillet, + R::RailsNotBetweenTwoFaces => ErrorKind::NotARemovableFillet, + R::SeamCrossesSharpEdgeTwice => ErrorKind::NotARemovableFillet, + R::SeamDoesNotJoinRails => ErrorKind::NotARemovableFillet, + R::SeamHasMoreThanTwoTrims => ErrorKind::NotARemovableFillet, + R::SeamHasNoOwnTrim => ErrorKind::NotARemovableFillet, + R::SeamTrimMissesNewVertex => ErrorKind::RemovalNotExact, + R::SeamsCrossApart => ErrorKind::NotARemovableFillet, + R::SideEdgeNotStraight => ErrorKind::RemovalNotExact, + R::TangentFaceNotBSpline => ErrorKind::NotARemovableFillet, + R::TangentSurfacesDoNotMeet => ErrorKind::RemovalNotExact, + R::UnsupportedSharpSpine(_) => ErrorKind::RemovalNotExact, + } +} diff --git a/solidcore/crates/solidcore/src/error/blend/section.rs b/solidcore/crates/solidcore/src/error/blend/section.rs new file mode 100644 index 00000000000..4c1aba57bad --- /dev/null +++ b/solidcore/crates/solidcore/src/error/blend/section.rs @@ -0,0 +1,141 @@ +//! Why a G^n section fails: what its certificate cannot prove, its degeneracies, limits and inputs. +//! +//! Upstream: none. One of the modules of the blend failure causes, re-exported from +//! [`super`]. + +#[cfg(doc)] +use super::BlendFailure; + +/// What a G^n section's certificate could not prove ([`BlendFailure::SectionNotProved`]). +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[non_exhaustive] +pub enum SectionProof { + /// A bound or a box the certificate computes finite. + BoundFinite, + /// A curve's weight positive over a span. + CurveWeightPositive, + /// The definition's enclosure over a box. + Enclosure, + /// A face's weights positive over a box. + FaceWeightPositive, + /// The ball's radius positive over a box. + RadiusPositive, + /// The section's weight positive over an extension. + SectionWeightPositive, +} + +impl SectionProof { + /// What was not proved, as a phrase. + #[must_use] + pub const fn what(self) -> &'static str { + match self { + Self::BoundFinite => "a bound of the certificate finite", + Self::CurveWeightPositive => "the curve's weight positive over the span", + Self::Enclosure => "the definition's enclosure over the box", + Self::FaceWeightPositive => "a face's weights positive over the box", + Self::RadiusPositive => "the ball's radius positive over the box", + Self::SectionWeightPositive => "the section's weight positive over the extension", + } + } +} + +/// How a G^n section degenerates ([`BlendFailure::SectionDegenerate`]). +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[non_exhaustive] +pub enum SectionDegeneracy { + /// A section of the ball's circle is a half turn or more. + ArcHalfTurn, + /// The section's area does not fall as its thumbweight grows, so no thumbweight is the + /// equal area one. + AreaDoesNotFall, + /// The ball has no radius at the rails' start. + BallHasNoRadius, + /// The varying balls' centres stand still. + CentresStandStill, + /// The rails, or the round's stations, have no length. + NoLength, + /// The parameter interval lies in no span of the curve (a curve whose knots are all + /// one value). + NoSpanCoversInterval, + /// The blend's system is singular at a station: its faces' normals agree there. + NormalsAgree, + /// A span to be halved has no parameter strictly inside it. + SpanCannotSplit, + /// A vector the section normalises vanishes (a face's normal at a foot, the leader's + /// tangent). + VectorVanishes, + /// A weight or a length of the section is zero at the point. + WeightOrLengthZero, +} + +impl SectionDegeneracy { + /// How it degenerates, as a phrase. + #[must_use] + pub const fn what(self) -> &'static str { + match self { + Self::ArcHalfTurn => "a section of the ball's circle is a half turn or more", + Self::AreaDoesNotFall => "the section's area does not fall with its thumbweight", + Self::BallHasNoRadius => "the ball has no radius at the rails' start", + Self::CentresStandStill => "the balls' centres stand still", + Self::NoLength => "the rails or the round's stations have no length", + Self::NoSpanCoversInterval => "no span of the curve covers the parameter", + Self::NormalsAgree => { + "the blend's system is singular at a station (its faces' normals agree there)" + } + Self::SpanCannotSplit => "a span has no midpoint inside it to be split at", + Self::VectorVanishes => { + "a vector the section normalises vanishes (a face's normal at a foot, or the leader's tangent)" + } + Self::WeightOrLengthZero => "a weight or a length of the section is zero", + } + } +} + +/// What a G^n section does not handle ([`BlendFailure::SectionUnsupported`]). +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[non_exhaustive] +pub enum SectionLimit { + /// A curve's weight that is not positive. + CurveWeightNotPositive, + /// A face that is a blend by its definition, enclosed only for a round of one radius on + /// a round of one radius between NURBS faces. + DefinitionFaceNotOneRadius, + /// A curve or face of degree 0 in a direction. + DegreeBelowOne, + /// A face that is not a NURBS surface: its section of order 2 and up, and its + /// certificate, need one. + FaceNotNurbs, + /// A face's weight that is not positive. + FaceWeightNotPositive, + /// A derivative order past the most the series hold. + OrderPastSeries { + /// The order asked. + order: usize, + /// The most the series hold. + most: usize, + }, +} + +/// Which inputs of a G^n section do not fit together ([`BlendFailure::SectionInputInvalid`]). +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[non_exhaustive] +pub enum SectionInput { + /// The rails and the centre line run over different intervals. + IntervalsDiffer, + /// The round's range is not within its stations. + RangeOutsideStations, + /// The span asked for starts at or past the definition's last station. + SpanPastLastStation, +} + +impl SectionInput { + /// What does not fit, as a phrase. + #[must_use] + pub const fn what(self) -> &'static str { + match self { + Self::IntervalsDiffer => "the rails and the centre line run over different intervals", + Self::RangeOutsideStations => "the round's range is not within its stations", + Self::SpanPastLastStation => "the span asked for is past the definition's last station", + } + } +} diff --git a/solidcore/crates/solidcore/src/error/blend/set_up.rs b/solidcore/crates/solidcore/src/error/blend/set_up.rs new file mode 100644 index 00000000000..7d0405fc8b2 --- /dev/null +++ b/solidcore/crates/solidcore/src/error/blend/set_up.rs @@ -0,0 +1,108 @@ +//! Which link of the fillet structures a routine is given is not there or not as it needs. +//! +//! Upstream: none. One of the modules of the blend failure causes, re-exported from +//! [`super`]. + +#[cfg(doc)] +use super::BlendFailure; + +/// The link of the fillet structures that is not there or not as the routine needs +/// ([`BlendFailure::FilletSetUpInvalid`]). +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[non_exhaustive] +pub enum FilletSetUp { + /// The body vertex a fillet corner rounds. + CornerVertex, + /// The fillet geometry a cross-section's primary edge use spans. + CrossSectionGeom, + /// The vertex use an edge use of the body starts at. + EdgeUseVertexUse, + /// The two fillet vertices a fillet edge joins. + EdgeVertices, + /// A rail/rail interpolation edge among its corner's fillet edges. + InterpolationEdgeAtCorner, + /// The rail ending at an end of a rail/rail interpolation edge. + InterpolationEndRail, + /// A Join's fillet vertex's mate. + Mate, + /// The cross-section opposite a rail/rail interpolation edge at its corner. + OppositeCrossSection, + /// The original face a fillet edge records, of any fillet edge type (a rail/rail + /// interpolation edge's face it lies on included). + OriginalFace, + /// The side edge use a fillet vertex on a side edge is classified to. + PointClassEdgeUse, + /// The face a fillet vertex (or its mate) is classified to. + PointClassFace, + /// A fillet edge's primary edge use. + PrimaryEdgeUse, + /// The mate of a fillet edge's primary edge use. + PrimaryEdgeUseMate, + /// The radial edge use of a side edge's edge use. + RadialEdgeUse, + /// A rail edge's 3D curve, or the UV trim curve the 2D path reads. + RailCurve, + /// A rail's end vertex on the rail's curve. + RailEndOffRail, + /// The vertex use of a rail's edge at a fillet vertex at the rail's end. + RailEndVertexUse, + /// The offset surface of a fillet geometry's rail, its own or its solver's. + RailOffsetSurface, + /// One of a fillet solver's two offset surfaces. + SolverOffsetSurface, + /// A fillet solver's surface generator. + SurfaceGenerator, + /// The B-spline UV trim curve of a rail's edge use. + UvTrimCurve, + /// The fillet geometries a fillet vertex's kind joins. + VertexGeoms, + /// The face use of a vertex use of a face's loop. + VertexUseFaceUse, +} + +impl FilletSetUp { + /// What is wrong, as a clause. + pub(super) const fn what(self) -> &'static str { + match self { + Self::CornerVertex => "the fillet corner records no body vertex it rounds", + Self::CrossSectionGeom => "a cross-section's primary edge use spans no fillet geometry", + Self::EdgeUseVertexUse => "an edge use of the body starts at no vertex use", + Self::EdgeVertices => "a fillet edge does not join two fillet vertices", + Self::InterpolationEdgeAtCorner => { + "the rail/rail interpolation edge is not one of its corner's fillet edges" + } + Self::InterpolationEndRail => { + "an end of the rail/rail interpolation edge is no rail's end" + } + Self::Mate => "a Join's fillet vertex has no mate", + Self::OppositeCrossSection => { + "the fillet edge opposite the rail/rail interpolation edge is not a cross-section" + } + Self::OriginalFace => "a fillet edge records no original face", + Self::PointClassEdgeUse => { + "a fillet vertex on a side edge is not classified to that edge's edge use" + } + Self::PointClassFace => "a fillet vertex is not classified to a face", + Self::PrimaryEdgeUse => "a fillet edge has no primary edge use", + Self::PrimaryEdgeUseMate => "a fillet edge's primary edge use has no mate", + Self::RadialEdgeUse => "an edge use of a side edge has no radial edge use", + Self::RailCurve => { + "a rail edge lacks its 3D curve or the UV trim curve the 2D path reads" + } + Self::RailEndOffRail => { + "the fillet vertex at the rail's end does not lie on the rail's curve" + } + Self::RailEndVertexUse => { + "a fillet vertex at a rail's end has no vertex use of the rail's edge" + } + Self::RailOffsetSurface => { + "a rail of a fillet geometry has no offset surface, of its own or its solver's" + } + Self::SolverOffsetSurface => "a fillet solver lacks one of its two offset surfaces", + Self::SurfaceGenerator => "a fillet solver has no surface generator", + Self::UvTrimCurve => "the rail's edge use has no B-spline UV trim curve", + Self::VertexGeoms => "a fillet vertex lacks the fillet geometries its kind joins", + Self::VertexUseFaceUse => "a vertex use of a face's loop is in no face use", + } + } +} diff --git a/solidcore/crates/solidcore/src/error/blend/solver.rs b/solidcore/crates/solidcore/src/error/blend/solver.rs new file mode 100644 index 00000000000..0d63eecde1c --- /dev/null +++ b/solidcore/crates/solidcore/src/error/blend/solver.rs @@ -0,0 +1,578 @@ +//! Why the fillet solver fails, with its class and status. +//! +//! Upstream: none. One of the modules of the blend failure causes, re-exported from +//! [`super`]. + +#[cfg(doc)] +use super::BlendFailure; +use crate::error::{ErrorKind, SM_ERR, SM_ERR_NULL_POINTER}; + +/// Why the fillet solver (`crate::blend::fillet_solver`) fails ([`BlendFailure::Solver`]). +/// Each names its class ([`SolverFailure::class`]); none is a defect: the solver's defects +/// are [`BlendFailure::Defect`], with their reason. +#[derive(Debug, Clone, Copy, PartialEq)] +#[non_exhaustive] +pub enum SolverFailure { + /// The fillet is not of the analytic shape the routine builds (its cross-section, + /// its edge's curve or its faces are of another kind): a kind the routine cannot + /// handle ([`ErrorKind::Unsupported`]). + AnalyticShapeDoesNotApply { + /// The shape the routine builds. + shape: AnalyticShape, + }, + /// A method the base fillet solver (`SmFilletSolver` itself) does not implement was + /// called on a solver that does not override it: a kind the routine cannot handle + /// ([`ErrorKind::Unsupported`]). + BaseSolverMethod(BaseSolverMethod), + /// The fillet geometry's centre line is of a curve kind with no B-spline form: a kind + /// the routine cannot handle ([`ErrorKind::Unsupported`]); status `SM_ERR_NULL_POINTER`. + CenterLineNotBSpline { + /// The fillet geometry. + fillet_geom: crate::blend::fillet_geom::p1::FilletGeomId, + }, + /// The clipped-radius search's iso curve at radius `radius` does not meet the other + /// offset surface: an empty search ([`ErrorKind::NotFound`]). + ClippedIsoMissesSurface { + /// The radius the offsets were set to. + radius: f64, + }, + /// The corner point does not drop onto the side edge's curve: an empty search + /// ([`ErrorKind::NotFound`]). + CornerDoesNotDropOnSideCurve, + /// The corner's cross section does not meet the extended side surface: an empty search + /// ([`ErrorKind::NotFound`]). + CrossSectionMissesSideSurface, + /// The solve for the fillet's cross section on the plane through the failure's site + /// found no section: an empty search ([`ErrorKind::NotFound`]). + CrossSectionNotFound, + /// The solve for the fillet's cross-section point on the plane through a rail's point + /// at parameter `t` found no point: an empty search ([`ErrorKind::NotFound`]). + CrossSectionPointNotFound { + /// The parameter of the curve the plane is taken on. + t: f64, + }, + /// An end of the filleted edge lies on cylinder `side`'s axis, so the ball's contact + /// there has no direction from the axis ([`ErrorKind::Degenerate`]). + EdgeEndOnAxis { + /// The cylinder, 0 or 1. + side: usize, + }, + /// An edge use of the caller's body has no face: the caller's input + /// ([`ErrorKind::InvalidInput`]); status `SM_ERR_NULL_POINTER`. + EdgeUseWithoutFace, + /// An edge use of the caller's body has no mate: the caller's input + /// ([`ErrorKind::InvalidInput`]); status `SM_ERR_NULL_POINTER`. + EdgeUseWithoutMate, + /// The extension flags need a vertex's corner and the caller gave no corners (a + /// standalone entry point): the caller's input ([`ErrorKind::InvalidInput`]); status + /// `SM_ERR_NULL_POINTER`. + ExtensionCornerMissing, + /// The caller's fillet geometry has no rail on side `side`: the caller's solver set-up + /// ([`ErrorKind::InvalidInput`]); status `SM_ERR_NULL_POINTER`. + FilletGeomWithoutRail { + /// The fillet geometry. + fillet_geom: crate::blend::fillet_geom::p1::FilletGeomId, + /// The rail side, 0 or 1. + side: usize, + }, + /// The caller's fillet geometry names no fillet solver: the caller's solver set-up + /// ([`ErrorKind::InvalidInput`]); status `SM_ERR_NULL_POINTER`. + FilletGeomWithoutSolver { + /// The fillet geometry. + fillet_geom: crate::blend::fillet_geom::p1::FilletGeomId, + }, + /// The caller's fillet geometry has no fillet surface: the caller's solver set-up + /// ([`ErrorKind::InvalidInput`]); status `SM_ERR_NULL_POINTER`. + FilletGeomWithoutSurface { + /// The fillet geometry. + fillet_geom: crate::blend::fillet_geom::p1::FilletGeomId, + }, + /// The ball's centre has no foot on face `side`'s quadric: an empty search + /// ([`ErrorKind::NotFound`]). + FootNotFound { + /// The face, 0 or 1. + side: usize, + }, + /// A surface was asked of the base surface generator (`SmFilletSurfaceGenerator` + /// itself), which builds none: a kind the routine cannot handle + /// ([`ErrorKind::Unsupported`]). + GeneratorBuildsNoSurface, + /// The G^n section generator was not given rail side `side`'s surface (or its uv curve, + /// where `uv_curve`): the caller's input ([`ErrorKind::InvalidInput`]); status + /// `SM_ERR_NULL_POINTER`. + GnSideInputMissing { + /// The rail side, 0 or 1. + side: usize, + /// True for the side's uv curve, false for its surface. + uv_curve: bool, + }, + /// The guess point does not drop onto the side edge: an empty search + /// ([`ErrorKind::NotFound`]). + GuessDoesNotDropOnSideEdge, + /// A solver's equations could not be loaded for the solve: the solver's error is the + /// failure's cause, and decides whether it is a defect or a refusal + /// ([`ErrorKind::Failed`]). + JacobianNotLoaded, + /// The nearest-point search on a curve found `count` nearest points where one is + /// needed: an empty or ambiguous search ([`ErrorKind::NotFound`]). + NoSingleCurveFoot { + /// The number of nearest points found. + count: usize, + }, + /// Offset surface `side` has no normal at `(u, v)`: its partial derivatives and its + /// evaluated normal both vanish there ([`ErrorKind::Degenerate`]). + OffsetNormalVanishes { + /// The offset surface, 0 or 1. + side: usize, + /// The surface parameter u. + u: f64, + /// The surface parameter v. + v: f64, + }, + /// The solver has not got both offset surfaces set: the caller's solver state + /// ([`ErrorKind::InvalidInput`]). + OffsetSurfaceMissing, + /// The curve-blending self-intersection handler's previous and next pieces are + /// `distance` apart where they come closest, farther than the `limit` it blends across + /// (three step-back distances): not within tolerance ([`ErrorKind::NotWithinTolerance`]). + PiecesTooFarApart { + /// The closest distance between the pieces' rails. + distance: f64, + /// The largest distance blended across. + limit: f64, + }, + /// The point does not drop onto offset surface `side`: an empty search + /// ([`ErrorKind::NotFound`]). + PointDoesNotDropOnSurface { + /// The surface, 0 or 1. + side: usize, + }, + /// The fillet's radius is `start` at its first section and `end` at its last: the + /// analytic surfaces are built for a constant radius only, a kind the routine cannot + /// handle ([`ErrorKind::Unsupported`]). + RadiusNotConstant { + /// The radius at the first section. + start: f64, + /// The radius at the last section. + end: f64, + }, + /// The fillet's radius `radius` is below the zero tolerance, so its section has no + /// arc ([`ErrorKind::Degenerate`]). + RadiusVanishes { + /// The radius. + radius: f64, + }, + /// The rail does not cross the side edge from any guess: an empty search + /// ([`ErrorKind::NotFound`]). + RailMissesSideEdge, + /// Rail `side` of the caller's fillet geometry has a curve not of a B-spline class (a + /// rail edge with no curve is [`FilletSetUp::RailCurve`]): a kind the routine cannot + /// handle ([`ErrorKind::Unsupported`]); status `SM_ERR_NULL_POINTER`. + RailNotBSpline { + /// The fillet geometry. + fillet_geom: crate::blend::fillet_geom::p1::FilletGeomId, + /// The rail side, 0 or 1. + side: usize, + /// The curve's kind (its type string). + kind: &'static str, + }, + /// A rail curve's tangent has no length at parameter `t`, so no step along it is + /// defined there ([`ErrorKind::Degenerate`]). + RailTangentZero { + /// The rail curve's parameter. + t: f64, + }, + /// Interval `index` of the roll-over rail's classification does not end (or, the last, + /// start) at an edge: a case the roll-over does not handle ([`ErrorKind::Unsupported`]). + RolloverIntervalNotAtEdge { + /// The interval's index. + index: usize, + }, + /// `count` short intervals of the rail's classification could not be squeezed out (no + /// single side edge at both ends, no edge use on the rail's face, no guess on the edge, + /// or wider than the edge's tolerance): a case the refinement does not handle + /// ([`ErrorKind::Unsupported`]). + ShortIntervalsNotRemoved { + /// The number of intervals left. + count: usize, + }, + /// The side edge has no edge use on the rail's face: an empty search + /// ([`ErrorKind::NotFound`]); status `SM_ERR_NULL_POINTER`. + SideEdgeNotOnRailFace, + /// The side surface and the plane through the side curve's end point do not meet in a + /// curve: an empty search ([`ErrorKind::NotFound`]); status `SM_ERR_NULL_POINTER`. + SideSurfaceMissesEndPlane, + /// The solver was given no edge use `index` of the edge to fillet: the caller's solver + /// ([`ErrorKind::InvalidInput`]); status `SM_ERR_NULL_POINTER`. + SolverEdgeUseMissing { + /// The edge use's index, 0 or 1. + index: usize, + }, + /// The circular spine has no station in the half-plane through the point (the point is + /// on the axis, or the offsets' meridians do not cross there): an empty search + /// ([`ErrorKind::NotFound`]). + SpineStationNotFound, + /// The support edge's curve does not meet the fillet surface that ends it: an empty + /// search ([`ErrorKind::NotFound`]). + SupportCurveMissesSurface, + /// The support edge's start (or end, where `at_end`) does not drop onto its curve: an + /// empty search ([`ErrorKind::NotFound`]). + SupportEndOffCurve { + /// True for the end, false for the start. + at_end: bool, + }, + /// The intersection of the two fillet surfaces a support edge joins failed: the + /// intersection's error is the failure's cause ([`ErrorKind::Failed`]). + SupportIntersectionFailed, + /// The two fillet surfaces a support edge joins do not meet in a curve: an empty search + /// ([`ErrorKind::NotFound`]). + SupportSurfacesDoNotMeet, + /// The surface's cache could not be built: the cache's error is the failure's cause + /// ([`ErrorKind::Failed`]); status `SM_ERR_NULL_POINTER`. + SurfaceCacheNotBuilt, + /// The fillet's section turns through `angle` radians, within the tolerance of half a + /// turn or past it: the analytic surfaces are built for less, a kind the routine + /// cannot handle ([`ErrorKind::Unsupported`]). + SweepAngleNearHalfTurn { + /// The turn, in radians. + angle: f64, + }, + /// The fillet's section turns through `angle` radians, too little for an arc + /// ([`ErrorKind::Degenerate`]). + SweepAngleTooSmall { + /// The turn, in radians. + angle: f64, + }, + /// The roll-over meets a side edge that rolls over tangentially, which the full + /// roll-over does not handle ([`ErrorKind::Unsupported`]). + TangentRolloverUnhandled, + /// The solver solves for more further values than a fillet point holds (`limit`): the + /// caller's solver ([`ErrorKind::InvalidInput`]). + TooManySolverValues { + /// The values a fillet point holds. + limit: usize, + }, + /// An end of the trace lies `deviation` off the ball, farther than `tol`: not within + /// tolerance ([`ErrorKind::NotWithinTolerance`]). + TraceEndOffBall { + /// The distance of the trace's end from the ball. + deviation: f64, + /// The tolerance. + tol: f64, + }, +} + +/// The analytic shape a fillet solver routine builds +/// ([`SolverFailure::AnalyticShapeDoesNotApply`]). +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[non_exhaustive] +pub enum AnalyticShape { + /// The ball's triangle where one face's offset collapses. + BallTriangle, + /// A cone: a circular section along a line between faces that open. + Cone, + /// A cylinder: a circular section along a line. + Cylinder, + /// A sphere: the ball where two cylinders' axes meet. + Sphere, + /// A torus: a circular (or linear) section along a circular arc. + Torus, +} + +/// A method of the base fillet solver ([`SolverFailure::BaseSolverMethod`]). +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[non_exhaustive] +pub enum BaseSolverMethod { + /// `LoadInitialValues`. + LoadInitialValues, + /// `LoadJacobian`. + LoadJacobian, + /// `SetupOffsetValues`. + SetupOffsetValues, +} + +impl SolverFailure { + /// The failure's class ([`ErrorKind`]): see each variant. + #[must_use] + #[allow( + clippy::match_same_arms, + reason = "one arm per variant, sorted by name, so causes added in parallel touch disjoint lines" + )] + pub const fn class(&self) -> ErrorKind { + match self { + Self::AnalyticShapeDoesNotApply { .. } => ErrorKind::Unsupported, + Self::BaseSolverMethod(_) => ErrorKind::Unsupported, + Self::CenterLineNotBSpline { .. } => ErrorKind::Unsupported, + Self::ClippedIsoMissesSurface { .. } => ErrorKind::NotFound, + Self::CornerDoesNotDropOnSideCurve => ErrorKind::NotFound, + Self::CrossSectionMissesSideSurface => ErrorKind::NotFound, + Self::CrossSectionNotFound => ErrorKind::NotFound, + Self::CrossSectionPointNotFound { .. } => ErrorKind::NotFound, + Self::EdgeEndOnAxis { .. } => ErrorKind::Degenerate, + Self::EdgeUseWithoutFace => ErrorKind::InvalidInput, + Self::EdgeUseWithoutMate => ErrorKind::InvalidInput, + Self::ExtensionCornerMissing => ErrorKind::InvalidInput, + Self::FilletGeomWithoutRail { .. } => ErrorKind::InvalidInput, + Self::FilletGeomWithoutSolver { .. } => ErrorKind::InvalidInput, + Self::FilletGeomWithoutSurface { .. } => ErrorKind::InvalidInput, + Self::FootNotFound { .. } => ErrorKind::NotFound, + Self::GeneratorBuildsNoSurface => ErrorKind::Unsupported, + Self::GnSideInputMissing { .. } => ErrorKind::InvalidInput, + Self::GuessDoesNotDropOnSideEdge => ErrorKind::NotFound, + Self::JacobianNotLoaded => ErrorKind::Failed, + Self::NoSingleCurveFoot { .. } => ErrorKind::NotFound, + Self::OffsetNormalVanishes { .. } => ErrorKind::Degenerate, + Self::OffsetSurfaceMissing => ErrorKind::InvalidInput, + Self::PiecesTooFarApart { .. } => ErrorKind::NotWithinTolerance, + Self::PointDoesNotDropOnSurface { .. } => ErrorKind::NotFound, + Self::RadiusNotConstant { .. } => ErrorKind::Unsupported, + Self::RadiusVanishes { .. } => ErrorKind::Degenerate, + Self::RailMissesSideEdge => ErrorKind::NotFound, + Self::RailNotBSpline { .. } => ErrorKind::Unsupported, + Self::RailTangentZero { .. } => ErrorKind::Degenerate, + Self::RolloverIntervalNotAtEdge { .. } => ErrorKind::Unsupported, + Self::ShortIntervalsNotRemoved { .. } => ErrorKind::Unsupported, + Self::SideEdgeNotOnRailFace => ErrorKind::NotFound, + Self::SideSurfaceMissesEndPlane => ErrorKind::NotFound, + Self::SolverEdgeUseMissing { .. } => ErrorKind::InvalidInput, + Self::SpineStationNotFound => ErrorKind::NotFound, + Self::SupportCurveMissesSurface => ErrorKind::NotFound, + Self::SupportEndOffCurve { .. } => ErrorKind::NotFound, + Self::SupportIntersectionFailed => ErrorKind::Failed, + Self::SupportSurfacesDoNotMeet => ErrorKind::NotFound, + Self::SurfaceCacheNotBuilt => ErrorKind::Failed, + Self::SweepAngleNearHalfTurn { .. } => ErrorKind::Unsupported, + Self::SweepAngleTooSmall { .. } => ErrorKind::Degenerate, + Self::TangentRolloverUnhandled => ErrorKind::Unsupported, + Self::TooManySolverValues { .. } => ErrorKind::InvalidInput, + Self::TraceEndOffBall { .. } => ErrorKind::NotWithinTolerance, + } + } + + /// The status the C++ reports unless the site says otherwise (a comparison detail). + #[allow( + clippy::match_same_arms, + reason = "one arm per variant, sorted by name, so causes added in parallel touch disjoint lines" + )] + pub(crate) const fn comparison_status(&self) -> i32 { + match self { + Self::AnalyticShapeDoesNotApply { .. } => SM_ERR, + Self::BaseSolverMethod(_) => SM_ERR, + Self::CenterLineNotBSpline { .. } => SM_ERR_NULL_POINTER, + Self::ClippedIsoMissesSurface { .. } => SM_ERR, + Self::CornerDoesNotDropOnSideCurve => SM_ERR, + Self::CrossSectionMissesSideSurface => SM_ERR, + Self::CrossSectionNotFound => SM_ERR, + Self::CrossSectionPointNotFound { .. } => SM_ERR, + Self::EdgeEndOnAxis { .. } => SM_ERR, + Self::EdgeUseWithoutFace => SM_ERR_NULL_POINTER, + Self::EdgeUseWithoutMate => SM_ERR_NULL_POINTER, + Self::ExtensionCornerMissing => SM_ERR_NULL_POINTER, + Self::FilletGeomWithoutRail { .. } => SM_ERR_NULL_POINTER, + Self::FilletGeomWithoutSolver { .. } => SM_ERR_NULL_POINTER, + Self::FilletGeomWithoutSurface { .. } => SM_ERR_NULL_POINTER, + Self::FootNotFound { .. } => SM_ERR, + Self::GeneratorBuildsNoSurface => SM_ERR, + Self::GnSideInputMissing { .. } => SM_ERR_NULL_POINTER, + Self::GuessDoesNotDropOnSideEdge => SM_ERR, + Self::JacobianNotLoaded => SM_ERR, + Self::NoSingleCurveFoot { .. } => SM_ERR, + Self::OffsetNormalVanishes { .. } => SM_ERR, + Self::OffsetSurfaceMissing => SM_ERR, + Self::PiecesTooFarApart { .. } => SM_ERR, + Self::PointDoesNotDropOnSurface { .. } => SM_ERR, + Self::RadiusNotConstant { .. } => SM_ERR, + Self::RadiusVanishes { .. } => SM_ERR, + Self::RailMissesSideEdge => SM_ERR, + Self::RailNotBSpline { .. } => SM_ERR_NULL_POINTER, + Self::RailTangentZero { .. } => SM_ERR, + Self::RolloverIntervalNotAtEdge { .. } => SM_ERR, + Self::ShortIntervalsNotRemoved { .. } => SM_ERR, + Self::SideEdgeNotOnRailFace => SM_ERR_NULL_POINTER, + Self::SideSurfaceMissesEndPlane => SM_ERR_NULL_POINTER, + Self::SolverEdgeUseMissing { .. } => SM_ERR_NULL_POINTER, + Self::SpineStationNotFound => SM_ERR, + Self::SupportCurveMissesSurface => SM_ERR, + Self::SupportEndOffCurve { .. } => SM_ERR, + Self::SupportIntersectionFailed => SM_ERR, + Self::SupportSurfacesDoNotMeet => SM_ERR, + Self::SurfaceCacheNotBuilt => SM_ERR_NULL_POINTER, + Self::SweepAngleNearHalfTurn { .. } => SM_ERR, + Self::SweepAngleTooSmall { .. } => SM_ERR, + Self::TangentRolloverUnhandled => SM_ERR, + Self::TooManySolverValues { .. } => SM_ERR, + Self::TraceEndOffBall { .. } => SM_ERR, + } + } +} + +impl core::fmt::Display for SolverFailure { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let end = |at_end: bool| if at_end { "end" } else { "start" }; + match self { + Self::AnalyticShapeDoesNotApply { shape } => { + write!(f, "the fillet is not of the analytic shape {shape:?}") + } + Self::BaseSolverMethod(method) => { + write!(f, "the base fillet solver does not implement {method:?}") + } + Self::CenterLineNotBSpline { fillet_geom } => write!( + f, + "the centre line of fillet geometry {} has no B-spline form", + fillet_geom.0 + ), + Self::ClippedIsoMissesSurface { radius } => write!( + f, + "at radius {radius} the iso curve does not meet the other offset surface" + ), + Self::CornerDoesNotDropOnSideCurve => { + f.write_str("the corner point does not drop onto the side edge's curve") + } + Self::CrossSectionMissesSideSurface => { + f.write_str("the corner's cross section does not meet the extended side surface") + } + Self::CrossSectionNotFound => { + f.write_str("no cross section of the fillet was found on the plane") + } + Self::CrossSectionPointNotFound { t } => write!( + f, + "no cross-section point of the fillet was found on the plane at t = {t}" + ), + Self::EdgeEndOnAxis { side } => { + write!( + f, + "an end of the filleted edge lies on cylinder {side}'s axis" + ) + } + Self::EdgeUseWithoutFace => f.write_str("an edge use of the body has no face"), + Self::EdgeUseWithoutMate => f.write_str("an edge use of the body has no mate"), + Self::ExtensionCornerMissing => { + f.write_str("the extension flags need a vertex's corner and no corners were given") + } + Self::FilletGeomWithoutRail { fillet_geom, side } => { + write!( + f, + "fillet geometry {fillet_geom:?} has no rail on side {side}" + ) + } + Self::FilletGeomWithoutSolver { fillet_geom } => { + write!(f, "fillet geometry {fillet_geom:?} names no fillet solver") + } + Self::FilletGeomWithoutSurface { fillet_geom } => { + write!(f, "fillet geometry {fillet_geom:?} has no fillet surface") + } + Self::FootNotFound { side } => { + write!(f, "the ball's centre has no foot on face {side}'s quadric") + } + Self::GeneratorBuildsNoSurface => { + f.write_str("the base surface generator builds no surface") + } + Self::GnSideInputMissing { side, uv_curve } => write!( + f, + "the G^n section generator was given no {} for rail side {side}", + if *uv_curve { "uv curve" } else { "surface" } + ), + Self::GuessDoesNotDropOnSideEdge => { + f.write_str("the guess point does not drop onto the side edge") + } + Self::JacobianNotLoaded => f.write_str("the solver's equations could not be loaded"), + Self::NoSingleCurveFoot { count } => write!( + f, + "the nearest-point search on the curve found {count} points where one is needed" + ), + Self::OffsetNormalVanishes { side, u, v } => write!( + f, + "offset surface {side} has no normal at (u, v) = ({u}, {v})" + ), + Self::OffsetSurfaceMissing => { + f.write_str("the solver has not got both offset surfaces set") + } + Self::PiecesTooFarApart { distance, limit } => write!( + f, + "the pieces to blend are {distance} apart, farther than {limit}" + ), + Self::PointDoesNotDropOnSurface { side } => { + write!(f, "the point does not drop onto offset surface {side}") + } + Self::RadiusNotConstant { start, end } => write!( + f, + "the fillet's radius is {start} at its start and {end} at its end, not constant" + ), + Self::RadiusVanishes { radius } => { + write!( + f, + "the fillet's radius {radius} is below the zero tolerance" + ) + } + Self::RailMissesSideEdge => f.write_str("the rail does not cross the side edge"), + Self::RailNotBSpline { + fillet_geom, + side, + kind, + } => write!( + f, + "rail {side} of fillet geometry {fillet_geom:?} has a {kind} curve, not of a \ + B-spline class" + ), + Self::RailTangentZero { t } => { + write!(f, "the rail's tangent has no length at t = {t}") + } + Self::RolloverIntervalNotAtEdge { index } => write!( + f, + "interval {index} of the roll-over rail's classification is not bounded by an edge" + ), + Self::ShortIntervalsNotRemoved { count } => write!( + f, + "{count} short intervals of the rail's classification could not be removed" + ), + Self::SideEdgeNotOnRailFace => { + f.write_str("the side edge has no edge use on the rail's face") + } + Self::SideSurfaceMissesEndPlane => f.write_str( + "the side surface and the plane through the side curve's end do not meet", + ), + Self::SolverEdgeUseMissing { index } => { + write!( + f, + "the solver has no edge use {index} of the edge to fillet" + ) + } + Self::SpineStationNotFound => { + f.write_str("the circular spine has no station in the point's half-plane") + } + Self::SupportCurveMissesSurface => { + f.write_str("the support edge's curve does not meet the fillet surface ending it") + } + Self::SupportEndOffCurve { at_end } => write!( + f, + "the support edge's {} does not drop onto its curve", + end(*at_end) + ), + Self::SupportIntersectionFailed => { + f.write_str("the intersection of the support edge's fillet surfaces failed") + } + Self::SupportSurfacesDoNotMeet => { + f.write_str("the support edge's fillet surfaces do not meet") + } + Self::SurfaceCacheNotBuilt => f.write_str("the surface's cache could not be built"), + Self::SweepAngleNearHalfTurn { angle } => write!( + f, + "the fillet's section turns through {angle} radians, about half a turn or more" + ), + Self::SweepAngleTooSmall { angle } => { + write!(f, "the fillet's section turns through only {angle} radians") + } + Self::TangentRolloverUnhandled => { + f.write_str("a side edge rolls over tangentially, which is not handled") + } + Self::TooManySolverValues { limit } => write!( + f, + "the solver solves for more further values than a fillet point holds ({limit})" + ), + Self::TraceEndOffBall { deviation, tol } => write!( + f, + "an end of the trace lies {deviation} off the ball, farther than {tol}" + ), + } + } +} diff --git a/solidcore/crates/solidcore/src/error/blend/trace.rs b/solidcore/crates/solidcore/src/error/blend/trace.rs index 23cb65e690a..de2eb3d9650 100644 --- a/solidcore/crates/solidcore/src/error/blend/trace.rs +++ b/solidcore/crates/solidcore/src/error/blend/trace.rs @@ -18,91 +18,6 @@ use crate::SolidError; #[derive(Debug, Clone, Copy, PartialEq)] #[non_exhaustive] pub enum TraceFailure { - /// The law corners' classification was given no end parameter for the corner after - /// piece `piece`: its `ends` hold fewer parameters than there are pieces. The - /// caller's input ([`ErrorKind::InvalidInput`]); status `SM_ERR`. - LawCornerEndMissing { - /// The piece before the corner. - piece: usize, - }, - /// The two points a law dip's sphere zone runs between are `distance` apart, within - /// the effective zero: the zone has no circles to run between - /// ([`ErrorKind::Degenerate`]). - ZoneEndsCoincide { - /// The distance between the two points. - distance: f64, - }, - /// A point on one of a law dip's two circles inverts onto the image of the zone's other - /// end, so the circle's ray in the inverted plane has no direction - /// ([`ErrorKind::Degenerate`]). - ZoneFootAtPole, - /// A law dip's two circles open a wedge whose cosine `cos` is within the square root of - /// the effective zero of a half turn, past what the zone's one rational quadratic patch - /// represents to its accuracy ([`ErrorKind::Unsupported`]). - ZoneWedgeNearHalfTurn { - /// The cosine of the wedge's angle. - cos: f64, - }, - /// A weight of a law dip's sphere zone patch, `weight`, is not positive: the patch does - /// not represent that zone ([`ErrorKind::Unsupported`]). - ZoneWeightNotPositive { - /// The weight. - weight: f64, - }, - /// The surface/surface solver's base surface `side` is not a face's surface, and the - /// trace in a live executive puts each rail on its base surface's face. The caller's - /// input ([`ErrorKind::InvalidInput`]); status `SM_ERR_NULL_POINTER`. - BaseSurfaceNotOnFace { - /// The base surface, 0 or 1. - side: usize, - }, - /// The surface/surface solver's trace of its offset surfaces' intersection succeeded - /// but left its fillet geometry with no fillet surface: the trace found no curve to skin - /// ([`ErrorKind::NotFound`]); status `SM_ERR_NULL_POINTER`. - TraceBuiltNoSurface, - /// The constant-radius solver was asked for the fillet surface but holds no fillet - /// surface generator (one built with `ConstantRadiusAssistedFs::from_parts` has none): - /// the caller's solver ([`ErrorKind::InvalidInput`]); status `SM_ERR_NULL_POINTER`. - SurfaceGeneratorMissing, - /// The solver's smoothing of a self-intersecting fillet - /// (`FilletSolverOps::smooth_out_intersection`) handed back fewer curves than the - /// fillet needs (its centre line, both rails and a uv curve on each side). The kernel's - /// handler writes back every curve it takes, so this is a caller's own solver breaking - /// the trait's contract ([`ErrorKind::InvalidInput`]); status `SM_ERR_NULL_POINTER`. - SmoothedCurveMissing, - /// The solver could not compute a section's values: the solver's error is the - /// failure's cause, and decides whether it is a defect or a refusal - /// ([`ErrorKind::Failed`]). - SectionValuesFailed, - /// The chord between a section and its neighbour along the trace, which stands for the - /// section's tangent, is `length` long, under the effective zero - /// ([`ErrorKind::Degenerate`]). - ChordTooShort { - /// The chord's length. - length: f64, - }, - /// The next section of the trace, at curve parameter `t`, has no tangent, so the span - /// to it cannot be tested ([`ErrorKind::Degenerate`]). - SectionTangentZero { - /// The section's curve parameter. - t: f64, - }, - /// The trace's curve has no points to flush into a curve: the trace found none - /// ([`ErrorKind::NotFound`]); status `SM_ERR_NULL_POINTER`. - TraceHasNoPoints, - /// The self-intersecting fillet's curves could not be smoothed: the smoothing - /// handler's error is the failure's cause ([`ErrorKind::Failed`]). - SmoothingFailed, - /// The fillet surface could not be skinned from the traced curves: the surface - /// generator's error is the failure's cause ([`ErrorKind::Failed`]). - SkinningFailed, - /// The nearest-point search on a surface found `count` nearest points where one is - /// needed: an empty or ambiguous search ([`ErrorKind::NotFound`]). The curve's case is - /// `SolverFailure::NoSingleCurveFoot`. - NoSingleSurfaceFoot { - /// The number of nearest points found. - count: usize, - }, /// A base surface's first partial derivative has no length at the custom solver's /// current solution, so its equations have no Jacobian there /// ([`ErrorKind::Degenerate`]). @@ -114,6 +29,13 @@ pub enum TraceFailure { /// The base surface, 0 or 1, where the check names one. side: Option, }, + /// The surface/surface solver's base surface `side` is not a face's surface, and the + /// trace in a live executive puts each rail on its base surface's face. The caller's + /// input ([`ErrorKind::InvalidInput`]); status `SM_ERR_NULL_POINTER`. + BaseSurfaceNotOnFace { + /// The base surface, 0 or 1. + side: usize, + }, /// The Eiffel tower cross section's bisector meets the segment it must cross in /// `solutions` points, not one, so the second arc's centre is not found /// ([`ErrorKind::NotFound`]). @@ -121,6 +43,13 @@ pub enum TraceFailure { /// The intersection points found. solutions: usize, }, + /// The chord between a section and its neighbour along the trace, which stands for the + /// section's tangent, is `length` long, under the effective zero + /// ([`ErrorKind::Degenerate`]). + ChordTooShort { + /// The chord's length. + length: f64, + }, /// The Eiffel tower surface generator was given rails with `rail1_knots` and /// `rail2_knots` distinct knots and `sections` fillet points, which must all be equal /// (one cross section at each knot). The caller's input ([`ErrorKind::InvalidInput`]); @@ -133,6 +62,9 @@ pub enum TraceFailure { /// The fillet points given. sections: usize, }, + /// The curve-based solver's base curve is not B-spline based, and only a B-spline + /// based curve is extended past its interval ([`ErrorKind::Unsupported`]). + CurveNotExtendable, /// The faces of the edge the caller asked to fillet meet tangentially (the cosine /// `dot` between one face's binormal and the other's normal is within the square root /// of the effective zero, where the check measures one), or the edge has no sector to @@ -142,6 +74,27 @@ pub enum TraceFailure { /// The cosine measured, where the check measures one. dot: Option, }, + /// The law corners' classification was given no end parameter for the corner after + /// piece `piece`: its `ends` hold fewer parameters than there are pieces. The + /// caller's input ([`ErrorKind::InvalidInput`]); status `SM_ERR`. + LawCornerEndMissing { + /// The piece before the corner. + piece: usize, + }, + /// The nearest-point search on a surface found `count` nearest points where one is + /// needed: an empty or ambiguous search ([`ErrorKind::NotFound`]). The curve's case is + /// `SolverFailure::NoSingleCurveFoot`. + NoSingleSurfaceFoot { + /// The number of nearest points found. + count: usize, + }, + /// A knot inserted in the middle of the largest span of the rails, which have + /// `knots` distinct knots, added none, so the rails cannot be refined to four cross + /// sections. The caller's rails ([`ErrorKind::InvalidInput`]); status `SM_ERR`. + RailKnotsNotRefinable { + /// The rails' distinct knots. + knots: usize, + }, /// The chamfer solver's rail points are `gap` apart, more than ten times its distance /// `distance` (the check measures `sqrt(|gap^2 - distance^2|)` against `10 distance`): /// the Newton step has run away from the solution. A solve that stops with its numbers, @@ -152,16 +105,32 @@ pub enum TraceFailure { /// The chamfer's distance. distance: f64, }, - /// The curve-based solver's base curve is not B-spline based, and only a B-spline - /// based curve is extended past its interval ([`ErrorKind::Unsupported`]). - CurveNotExtendable, - /// A knot inserted in the middle of the largest span of the rails, which have - /// `knots` distinct knots, added none, so the rails cannot be refined to four cross - /// sections. The caller's rails ([`ErrorKind::InvalidInput`]); status `SM_ERR`. - RailKnotsNotRefinable { - /// The rails' distinct knots. - knots: usize, + /// The next section of the trace, at curve parameter `t`, has no tangent, so the span + /// to it cannot be tested ([`ErrorKind::Degenerate`]). + SectionTangentZero { + /// The section's curve parameter. + t: f64, }, + /// The solver could not compute a section's values: the solver's error is the + /// failure's cause, and decides whether it is a defect or a refusal + /// ([`ErrorKind::Failed`]). + SectionValuesFailed, + /// The fillet surface could not be skinned from the traced curves: the surface + /// generator's error is the failure's cause ([`ErrorKind::Failed`]). + SkinningFailed, + /// The solver's smoothing of a self-intersecting fillet + /// (`FilletSolverOps::smooth_out_intersection`) handed back fewer curves than the + /// fillet needs (its centre line, both rails and a uv curve on each side). The kernel's + /// handler writes back every curve it takes, so this is a caller's own solver breaking + /// the trait's contract ([`ErrorKind::InvalidInput`]); status `SM_ERR_NULL_POINTER`. + SmoothedCurveMissing, + /// The self-intersecting fillet's curves could not be smoothed: the smoothing + /// handler's error is the failure's cause ([`ErrorKind::Failed`]). + SmoothingFailed, + /// The constant-radius solver was asked for the fillet surface but holds no fillet + /// surface generator (one built with `ConstantRadiusAssistedFs::from_parts` has none): + /// the caller's solver ([`ErrorKind::InvalidInput`]); status `SM_ERR_NULL_POINTER`. + SurfaceGeneratorMissing, /// The circular cross section surface generator kept `sections` cross sections (it /// skips those whose rails are at radii more than a tenth apart), fewer than the /// surface it builds needs ([`ErrorKind::NotFound`]). @@ -169,69 +138,108 @@ pub enum TraceFailure { /// The cross sections kept. sections: usize, }, + /// The surface/surface solver's trace of its offset surfaces' intersection succeeded + /// but left its fillet geometry with no fillet surface: the trace found no curve to skin + /// ([`ErrorKind::NotFound`]); status `SM_ERR_NULL_POINTER`. + TraceBuiltNoSurface, + /// The trace's curve has no points to flush into a curve: the trace found none + /// ([`ErrorKind::NotFound`]); status `SM_ERR_NULL_POINTER`. + TraceHasNoPoints, + /// The two points a law dip's sphere zone runs between are `distance` apart, within + /// the effective zero: the zone has no circles to run between + /// ([`ErrorKind::Degenerate`]). + ZoneEndsCoincide { + /// The distance between the two points. + distance: f64, + }, + /// A point on one of a law dip's two circles inverts onto the image of the zone's other + /// end, so the circle's ray in the inverted plane has no direction + /// ([`ErrorKind::Degenerate`]). + ZoneFootAtPole, + /// A law dip's two circles open a wedge whose cosine `cos` is within the square root of + /// the effective zero of a half turn, past what the zone's one rational quadratic patch + /// represents to its accuracy ([`ErrorKind::Unsupported`]). + ZoneWedgeNearHalfTurn { + /// The cosine of the wedge's angle. + cos: f64, + }, + /// A weight of a law dip's sphere zone patch, `weight`, is not positive: the patch does + /// not represent that zone ([`ErrorKind::Unsupported`]). + ZoneWeightNotPositive { + /// The weight. + weight: f64, + }, } impl TraceFailure { /// The failure's class ([`ErrorKind`]): see each variant. #[must_use] + #[allow( + clippy::match_same_arms, + reason = "one arm per variant, sorted by name, so causes added in parallel touch disjoint lines" + )] pub const fn class(&self) -> ErrorKind { match self { - Self::LawCornerEndMissing { .. } - | Self::BaseSurfaceNotOnFace { .. } - | Self::CrossSectionsIncompatible { .. } - | Self::SurfaceGeneratorMissing - | Self::SmoothedCurveMissing - | Self::EdgeFacesTangent { .. } - | Self::RailKnotsNotRefinable { .. } => ErrorKind::InvalidInput, + Self::BaseDerivativeZero => ErrorKind::Degenerate, + Self::BaseNormalZero { .. } => ErrorKind::Degenerate, + Self::BaseSurfaceNotOnFace { .. } => ErrorKind::InvalidInput, + Self::BisectorMissesSegment { .. } => ErrorKind::NotFound, + Self::ChordTooShort { .. } => ErrorKind::Degenerate, + Self::CrossSectionsIncompatible { .. } => ErrorKind::InvalidInput, + Self::CurveNotExtendable => ErrorKind::Unsupported, + Self::EdgeFacesTangent { .. } => ErrorKind::InvalidInput, + Self::LawCornerEndMissing { .. } => ErrorKind::InvalidInput, + Self::NoSingleSurfaceFoot { .. } => ErrorKind::NotFound, + Self::RailKnotsNotRefinable { .. } => ErrorKind::InvalidInput, Self::RailPointsDiverged { .. } => ErrorKind::StationDidNotConverge, - Self::ZoneEndsCoincide { .. } - | Self::ZoneFootAtPole - | Self::ChordTooShort { .. } - | Self::SectionTangentZero { .. } - | Self::BaseDerivativeZero - | Self::BaseNormalZero { .. } => ErrorKind::Degenerate, - Self::ZoneWedgeNearHalfTurn { .. } - | Self::ZoneWeightNotPositive { .. } - | Self::CurveNotExtendable => ErrorKind::Unsupported, - Self::TraceBuiltNoSurface - | Self::TraceHasNoPoints - | Self::NoSingleSurfaceFoot { .. } - | Self::BisectorMissesSegment { .. } - | Self::TooFewCrossSections { .. } => ErrorKind::NotFound, - Self::SectionValuesFailed | Self::SmoothingFailed | Self::SkinningFailed => { - ErrorKind::Failed - } + Self::SectionTangentZero { .. } => ErrorKind::Degenerate, + Self::SectionValuesFailed => ErrorKind::Failed, + Self::SkinningFailed => ErrorKind::Failed, + Self::SmoothedCurveMissing => ErrorKind::InvalidInput, + Self::SmoothingFailed => ErrorKind::Failed, + Self::SurfaceGeneratorMissing => ErrorKind::InvalidInput, + Self::TooFewCrossSections { .. } => ErrorKind::NotFound, + Self::TraceBuiltNoSurface => ErrorKind::NotFound, + Self::TraceHasNoPoints => ErrorKind::NotFound, + Self::ZoneEndsCoincide { .. } => ErrorKind::Degenerate, + Self::ZoneFootAtPole => ErrorKind::Degenerate, + Self::ZoneWedgeNearHalfTurn { .. } => ErrorKind::Unsupported, + Self::ZoneWeightNotPositive { .. } => ErrorKind::Unsupported, } } /// The status the C++ reports unless the site says otherwise (a comparison detail). + #[allow( + clippy::match_same_arms, + reason = "one arm per variant, sorted by name, so causes added in parallel touch disjoint lines" + )] pub(crate) const fn comparison_status(&self) -> i32 { match self { - Self::BaseSurfaceNotOnFace { .. } - | Self::TraceBuiltNoSurface - | Self::SurfaceGeneratorMissing - | Self::SmoothedCurveMissing - | Self::TraceHasNoPoints => SM_ERR_NULL_POINTER, - Self::LawCornerEndMissing { .. } - | Self::ZoneEndsCoincide { .. } - | Self::ZoneFootAtPole - | Self::ZoneWedgeNearHalfTurn { .. } - | Self::ZoneWeightNotPositive { .. } - | Self::SectionValuesFailed - | Self::ChordTooShort { .. } - | Self::SectionTangentZero { .. } - | Self::SmoothingFailed - | Self::SkinningFailed - | Self::NoSingleSurfaceFoot { .. } - | Self::BaseDerivativeZero - | Self::BaseNormalZero { .. } - | Self::BisectorMissesSegment { .. } - | Self::CrossSectionsIncompatible { .. } - | Self::EdgeFacesTangent { .. } - | Self::RailPointsDiverged { .. } - | Self::CurveNotExtendable - | Self::RailKnotsNotRefinable { .. } - | Self::TooFewCrossSections { .. } => SM_ERR, + Self::BaseDerivativeZero => SM_ERR, + Self::BaseNormalZero { .. } => SM_ERR, + Self::BaseSurfaceNotOnFace { .. } => SM_ERR_NULL_POINTER, + Self::BisectorMissesSegment { .. } => SM_ERR, + Self::ChordTooShort { .. } => SM_ERR, + Self::CrossSectionsIncompatible { .. } => SM_ERR, + Self::CurveNotExtendable => SM_ERR, + Self::EdgeFacesTangent { .. } => SM_ERR, + Self::LawCornerEndMissing { .. } => SM_ERR, + Self::NoSingleSurfaceFoot { .. } => SM_ERR, + Self::RailKnotsNotRefinable { .. } => SM_ERR, + Self::RailPointsDiverged { .. } => SM_ERR, + Self::SectionTangentZero { .. } => SM_ERR, + Self::SectionValuesFailed => SM_ERR, + Self::SkinningFailed => SM_ERR, + Self::SmoothedCurveMissing => SM_ERR_NULL_POINTER, + Self::SmoothingFailed => SM_ERR, + Self::SurfaceGeneratorMissing => SM_ERR_NULL_POINTER, + Self::TooFewCrossSections { .. } => SM_ERR, + Self::TraceBuiltNoSurface => SM_ERR_NULL_POINTER, + Self::TraceHasNoPoints => SM_ERR_NULL_POINTER, + Self::ZoneEndsCoincide { .. } => SM_ERR, + Self::ZoneFootAtPole => SM_ERR, + Self::ZoneWedgeNearHalfTurn { .. } => SM_ERR, + Self::ZoneWeightNotPositive { .. } => SM_ERR, } } } @@ -239,62 +247,22 @@ impl TraceFailure { impl core::fmt::Display for TraceFailure { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { match self { - Self::LawCornerEndMissing { piece } => { - write!(f, "the law corner after piece {piece} has no end parameter") - } - Self::ZoneEndsCoincide { distance } => write!( - f, - "the sphere zone's two ends are {distance} apart, within the effective zero" - ), - Self::ZoneFootAtPole => { - f.write_str("a point of the sphere zone's circles inverts onto its other end") - } - Self::ZoneWedgeNearHalfTurn { cos } => write!( - f, - "the sphere zone's wedge (cosine {cos}) is too near a half turn for one patch" - ), - Self::ZoneWeightNotPositive { weight } => { - write!( - f, - "a weight of the sphere zone's patch is {weight}, not positive" - ) - } - Self::BaseSurfaceNotOnFace { side } => { - write!(f, "base surface {side} is not a face's surface") - } - Self::TraceBuiltNoSurface => f.write_str("the trace built no fillet surface"), - Self::SurfaceGeneratorMissing => { - f.write_str("the solver has no fillet surface generator") - } - Self::SmoothedCurveMissing => { - f.write_str("the solver's smoothing handed back fewer curves than it took") - } - Self::SectionValuesFailed => f.write_str("the section's values could not be computed"), - Self::ChordTooShort { length } => write!( - f, - "the chord standing for the section's tangent is {length} long" - ), - Self::SectionTangentZero { t } => { - write!(f, "the next section's tangent has no length at t = {t}") - } - Self::TraceHasNoPoints => f.write_str("the trace has no points to flush"), - Self::SmoothingFailed => { - f.write_str("the self-intersecting fillet could not be smoothed") - } - Self::SkinningFailed => f.write_str("the fillet surface could not be skinned"), - Self::NoSingleSurfaceFoot { count } => write!( - f, - "the nearest-point search on the surface found {count} points, not one" - ), Self::BaseDerivativeZero => f.write_str("a base surface has a zero derivative"), Self::BaseNormalZero { side: Some(side) } => { write!(f, "base surface {side}'s normal is zero") } Self::BaseNormalZero { side: None } => f.write_str("a base surface normal is zero"), + Self::BaseSurfaceNotOnFace { side } => { + write!(f, "base surface {side} is not a face's surface") + } Self::BisectorMissesSegment { solutions } => write!( f, "the bisector meets the segment at {solutions} points, not one" ), + Self::ChordTooShort { length } => write!( + f, + "the chord standing for the section's tangent is {length} long" + ), Self::CrossSectionsIncompatible { rail1_knots, rail2_knots, @@ -303,25 +271,65 @@ impl core::fmt::Display for TraceFailure { f, "the rails have {rail1_knots} and {rail2_knots} knots for {sections} cross sections" ), + Self::CurveNotExtendable => { + f.write_str("a curve that is not B-spline based cannot be extended") + } Self::EdgeFacesTangent { dot: Some(dot) } => { write!(f, "the edge's faces meet tangentially (cosine {dot})") } Self::EdgeFacesTangent { dot: None } => { f.write_str("the edge is smooth or has no sector to fillet") } + Self::LawCornerEndMissing { piece } => { + write!(f, "the law corner after piece {piece} has no end parameter") + } + Self::NoSingleSurfaceFoot { count } => write!( + f, + "the nearest-point search on the surface found {count} points, not one" + ), + Self::RailKnotsNotRefinable { knots } => { + write!(f, "a knot inserted into rails of {knots} knots added none") + } Self::RailPointsDiverged { gap, distance } => write!( f, "the rail points are {gap} apart, more than ten times the distance {distance}" ), - Self::CurveNotExtendable => { - f.write_str("a curve that is not B-spline based cannot be extended") + Self::SectionTangentZero { t } => { + write!(f, "the next section's tangent has no length at t = {t}") } - Self::RailKnotsNotRefinable { knots } => { - write!(f, "a knot inserted into rails of {knots} knots added none") + Self::SectionValuesFailed => f.write_str("the section's values could not be computed"), + Self::SkinningFailed => f.write_str("the fillet surface could not be skinned"), + Self::SmoothedCurveMissing => { + f.write_str("the solver's smoothing handed back fewer curves than it took") + } + Self::SmoothingFailed => { + f.write_str("the self-intersecting fillet could not be smoothed") + } + Self::SurfaceGeneratorMissing => { + f.write_str("the solver has no fillet surface generator") } Self::TooFewCrossSections { sections } => { write!(f, "only {sections} cross sections were kept") } + Self::TraceBuiltNoSurface => f.write_str("the trace built no fillet surface"), + Self::TraceHasNoPoints => f.write_str("the trace has no points to flush"), + Self::ZoneEndsCoincide { distance } => write!( + f, + "the sphere zone's two ends are {distance} apart, within the effective zero" + ), + Self::ZoneFootAtPole => { + f.write_str("a point of the sphere zone's circles inverts onto its other end") + } + Self::ZoneWedgeNearHalfTurn { cos } => write!( + f, + "the sphere zone's wedge (cosine {cos}) is too near a half turn for one patch" + ), + Self::ZoneWeightNotPositive { weight } => { + write!( + f, + "a weight of the sphere zone's patch is {weight}, not positive" + ) + } } } } diff --git a/solidcore/crates/solidcore/src/error/blend/weld.rs b/solidcore/crates/solidcore/src/error/blend/weld.rs new file mode 100644 index 00000000000..3b7cd4e0560 --- /dev/null +++ b/solidcore/crates/solidcore/src/error/blend/weld.rs @@ -0,0 +1,25 @@ +//! The weld bead gaps a blend failure names not built yet. +//! +//! Upstream: none. One of the modules of the blend failure causes, re-exported from +//! [`super`]. + +#[cfg(doc)] +use super::BlendFailure; + +/// What a weld bead the kernel does not build yet needs ([`BlendFailure::WeldNotBuilt`]). +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[non_exhaustive] +pub enum WeldGap { + /// Beads that meet at a vertex need a corner piece (#17916); the failure's site names the + /// vertex. + BeadsMeetAtVertex, + /// A joint that is not a straight edge between two planes: only the exact planar bead is + /// built so far; the bead on any joint (the foot blend) comes with its certificate + /// (#18028). The failure's site names the edge. + CurvedJoint, + /// A bead whose toe on one face is obtuse (its second leg at most its first times the + /// cosine of the angle between the faces, or the other way round): the exact planar + /// bead's surface is read through the chamfer's ball, which such legs fold. The failure's + /// site names the edge. + ObtuseToe, +}