From 221917f4c12b395bbad556d27c791c7d8260bade Mon Sep 17 00:00:00 2001 From: Brett Lawson Date: Mon, 23 Nov 2026 08:14:40 +0100 Subject: [PATCH 1/3] solidcore: error/blend.rs causes sorted, detail enums in their own files The 12 enums that detail a blend failure cause move verbatim into private modules under error/blend/, re-exported item by item so every public path is unchanged. Every enum's variants and every match on them (one arm per pattern) are kept in name order, and a test checks that. The module-doc cause/class and status tables go; each variant's doc now states its class and status (14 docs gain the missing line). Changes that each add a cause then touch different lines instead of all appending at the same points. No behaviour change: no derive or cast depends on variant order, the sorted matches have no guards or `_` arms, and a mechanical comparison finds every enum's variants and every match's (pattern, body) pairs identical to main's. Part of #21121. Co-Authored-By: Claude Opus 5.5 --- solidcore/crates/solidcore/src/error/blend.rs | 3212 ++++++----------- .../crates/solidcore/src/error/blend/band.rs | 70 + .../crates/solidcore/src/error/blend/cliff.rs | 26 + .../solidcore/src/error/blend/corner.rs | 70 + .../solidcore/src/error/blend/crossing.rs | 34 + .../crates/solidcore/src/error/blend/ease.rs | 190 + .../solidcore/src/error/blend/law_corner.rs | 33 + .../solidcore/src/error/blend/no_room.rs | 73 + .../solidcore/src/error/blend/overflow.rs | 65 + .../solidcore/src/error/blend/removal.rs | 112 + .../solidcore/src/error/blend/section.rs | 141 + .../solidcore/src/error/blend/solver.rs | 504 +++ .../crates/solidcore/src/error/blend/weld.rs | 25 + 13 files changed, 2384 insertions(+), 2171 deletions(-) create mode 100644 solidcore/crates/solidcore/src/error/blend/band.rs create mode 100644 solidcore/crates/solidcore/src/error/blend/cliff.rs create mode 100644 solidcore/crates/solidcore/src/error/blend/corner.rs create mode 100644 solidcore/crates/solidcore/src/error/blend/crossing.rs create mode 100644 solidcore/crates/solidcore/src/error/blend/ease.rs create mode 100644 solidcore/crates/solidcore/src/error/blend/law_corner.rs create mode 100644 solidcore/crates/solidcore/src/error/blend/no_room.rs create mode 100644 solidcore/crates/solidcore/src/error/blend/overflow.rs create mode 100644 solidcore/crates/solidcore/src/error/blend/removal.rs create mode 100644 solidcore/crates/solidcore/src/error/blend/section.rs create mode 100644 solidcore/crates/solidcore/src/error/blend/solver.rs create mode 100644 solidcore/crates/solidcore/src/error/blend/weld.rs diff --git a/solidcore/crates/solidcore/src/error/blend.rs b/solidcore/crates/solidcore/src/error/blend.rs index 9675eea80b7..76504a7e8ea 100644 --- a/solidcore/crates/solidcore/src/error/blend.rs +++ b/solidcore/crates/solidcore/src/error/blend.rs @@ -12,68 +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::CreasePieceEndUnbuildable`], [`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 | -//! | 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::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`] | `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`] | `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::Inconsistent`] | `SM_ERR_ASSERT_FAILURE` | -//! | [`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 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 `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 @@ -99,9 +50,43 @@ 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 crossing; +mod ease; +mod law_corner; +mod no_room; +mod overflow; +mod removal; +mod section; +mod solver; +mod weld; + +pub use band::BandInput; +pub use cliff::CliffInput; +pub use corner::CornerShape; +pub use crossing::CrossingInput; +pub use ease::EaseGeometry; +pub use ease::EaseInput; +pub use ease::EaseStop; +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 solver::AnalyticShape; +pub use solver::BaseSolverMethod; +pub use solver::SolverFailure; +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 /// typed causes; a new variant is never a phrase cause, so it needs no line here. @@ -125,88 +110,28 @@ 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, - }, - /// 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, + /// 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, }, + /// 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), /// 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, @@ -215,11 +140,78 @@ pub enum BlendFailure { /// `|c'|`: how fast the balls' centres move along the trace. speed: 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 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, + }, + /// 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 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 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), /// 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, @@ -228,180 +220,72 @@ pub enum BlendFailure { /// The end's parameter on the crease. t: f64, }, - /// 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, + /// A cross-section type is given as unknown. A check of the caller's arguments + /// ([`ErrorKind::InvalidInput`]); status `SM_ERR_INVALID_INPUT`. + 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, }, - /// 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 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`. + EdgeNotFilletable { + /// The edge's index in the edges given. + index: 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 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, }, - /// 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, + /// 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, }, - /// 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, or a chamfer's distance) 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 - /// ([`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, - }, - /// 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`. - EdgeNotFilletable { - /// 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 - /// `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 { - /// 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, - }, - /// 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 @@ -426,132 +310,94 @@ 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, - }, - /// 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 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 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 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), + /// 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 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. + /// 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 @@ -570,73 +416,111 @@ 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`], + /// 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, + }, + /// 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 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`. - SectionUnsupported(SectionLimit), + PlaneCurveLeavesDomain { + /// The station's surface parameter u. + u: f64, + /// The station's surface parameter v. + v: 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, + }, + /// 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, + }, /// 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 { @@ -645,1445 +529,329 @@ pub enum BlendFailure { /// The radius the law gives there. radius: f64, }, + /// 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, + }, + /// 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 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), -} - -/// 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 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, - }, - /// 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, - }, - /// 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, - }, - /// 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 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 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, - }, - /// 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 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, - }, - /// 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. - 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 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 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, + /// A fillet size (a radius, or a chamfer's distance) 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, }, - /// 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, -} - -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 => ErrorKind::Unsupported, - Self::GnSideInputMissing { .. } - | Self::ExtensionCornerMissing - | Self::TooManySolverValues { .. } - | Self::OffsetSurfaceMissing - | Self::EdgeUseWithoutMate - | Self::EdgeUseWithoutFace => ErrorKind::InvalidInput, - Self::JacobianNotLoaded - | Self::SupportIntersectionFailed - | Self::SurfaceCacheNotBuilt => ErrorKind::Failed, - } - } - - /// The status the C++ reports unless the site says otherwise (a comparison detail). - 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 => 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") - } - } - } -} - -/// 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" - } - } - } -} - -/// 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", - } - } -} - -/// 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, - } + /// 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, + }, + /// 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, + }, + /// 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, + }, + /// 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 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 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, + }, + /// 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 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::NoRoom(_) - | Self::RemovalRefused(_) - | Self::StationDidNotConverge { .. } - | Self::TrimLoopOpen - | Self::TrimLoopDoesNotSeparate - | Self::ClosedCliffWouldNotSplit { .. } - | Self::StageFailed - | Self::Defect { .. } - | Self::SkinPastStationCap { .. } - | Self::SkinMeasureNotFinite { .. } - | Self::BallsNest { .. } - | Self::CreasePieceEndUnbuildable { .. } - | 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::Failed(_) => SM_ERR, - Self::Missing(_) - | Self::BandInputMissing(_) - | Self::CliffInputMissing { .. } - | Self::CrossingInputMissing(_) - | Self::EaseInputMissing(_) - | Self::EaseGeometryNotBSpline(_) - | Self::OverflowInputMissing(_) - | Self::VariableRadiusLawsNotGiven - | Self::BevelVertexNotFilleted - | Self::EdgeWithoutCurve - | 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::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::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::CreasePieceEndUnbuildable { .. } => 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::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::LawCornerNotFound { .. } => SM_ERR_NULL_POINTER, + Self::LawHasNoValue => SM_ERR, + Self::LawIntervalEmpty => SM_ERR, + Self::Missing(_) => SM_ERR_NULL_POINTER, + 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::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::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::CornerShapeNotBuilt`], [`ErrorKind::NotFound`] for - /// [`BlendFailure::CornerPointDropUnresolved`]. 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::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::BallsNest { .. } => ErrorKind::BallsFold, - Self::CreasePieceEndUnbuildable { .. } - | Self::CornerShapeNotBuilt(_) - | Self::LawHasNoValue - | Self::SequenceCurveNotBSpline { .. } - | Self::FilletCrossesItself { .. } - | Self::SectionUnsupported(_) - | Self::EaseGeometryNotBSpline(_) - | Self::ExtensionEndOnTwoSideLines - | Self::WeldNotBuilt(_) => ErrorKind::Unsupported, Self::ArcLengthNotConverged { .. } => ErrorKind::NotConverged, - Self::BandInputMissing(_) - | Self::CliffInputMissing { .. } - | Self::EaseInputMissing(_) - | Self::OverflowInputMissing(_) - | Self::CrossingInputMissing(_) => ErrorKind::Missing, + Self::BadIntersections(_) => ErrorKind::of_status(self.comparison_status()), + Self::BallsNest { .. } => ErrorKind::BallsFold, + 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::CornerPatchFaceNotFound { .. } => ErrorKind::NotFound, + Self::CornerPointDropUnresolved { .. } => ErrorKind::NotFound, + Self::CornerRefused => ErrorKind::Failed, + Self::CornerShapeNotBuilt(_) => ErrorKind::Unsupported, + Self::CreasePieceEndUnbuildable { .. } => ErrorKind::Unsupported, + 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::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::GnSectionInvalid { .. } => ErrorKind::InvalidInput, + Self::Inconsistent(_) => ErrorKind::of_status(self.comparison_status()), + Self::InvalidValue(_) => 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::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::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 => 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::SolverFaceIndexInvalid { .. } => ErrorKind::InvalidInput, + Self::StageFailed => ErrorKind::StageFailed, + Self::StationDidNotConverge { .. } => ErrorKind::StationDidNotConverge, + Self::TargetNotGiven => ErrorKind::InvalidInput, + Self::TrimLoopDoesNotSeparate => ErrorKind::TrimLeaks, + Self::TrimLoopOpen => ErrorKind::TrimLeaks, + Self::VariableRadiusLawMissing { .. } => ErrorKind::InvalidInput, + Self::VariableRadiusLawsNotGiven => ErrorKind::InvalidInput, + Self::WeldNotBuilt(_) => ErrorKind::Unsupported, } } @@ -2105,279 +873,204 @@ 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::PlaneCurveTouches { .. } - | Self::PlaneCurveEndOff { .. } - | Self::PlaneCurveLeavesDomain { .. } - | Self::PlaneCurveStepVanished { .. } - | Self::PlaneCurveFitCap { .. } - | Self::BandInputMissing(_) - | Self::CliffInputMissing { .. } - | Self::CrossingInputMissing(_) - | Self::CrossingNotFinite - | Self::Solver(_) - | 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::OverflowInputMissing(_) - | Self::OverflowPointDoesNotDrop(_) - | Self::ExtensionEndOnTwoSideLines - | Self::NoBlendedEdgeNearExtension - | 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::BallsNest { .. } => true, + Self::BandInputMissing(_) => true, + Self::BevelVertexNotFilleted => true, + Self::BoundSurfaceRemoved => true, + Self::ChamferFaceNotOfEdge => true, + Self::ChamferSizeInvalid => true, + Self::CliffInputMissing { .. } => true, + Self::ClosedCliffWouldNotSplit { .. } => true, + Self::CornerPatchFaceNotFound { .. } => true, + Self::CornerPointDropUnresolved { .. } => true, + Self::CornerRefused => true, + Self::CornerShapeNotBuilt(_) => true, + Self::CreasePieceEndUnbuildable { .. } => 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::GnSectionInvalid { .. } => true, + Self::Inconsistent(_) => true, + Self::InvalidValue(_) => true, + Self::LawCornerNotFound { .. } => true, + Self::LawHasNoValue => true, + Self::LawIntervalEmpty => true, + Self::Missing(_) => 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::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}", + "{}: the search for the parameter {length} along the curve from {start} stopped at {stopped_at}", self.class() ), + Self::BadIntersections(what) => f.write_str(what), 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", 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::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!( - f, - "{}: the crossing's step at (u, v) = ({u}, {v}) was halved to {step}, below its minimum {minimum}, without an accepted step", - self.class() - ), - Self::PlaneCurveFitCap { stations, passes } => 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", - self.class() - ), - Self::NoEdgesGiven => write!(f, "{}: no edges are given to fillet", self.class()), - Self::SizeBelowResolution { size, tolerance } => write!( + Self::BandInputMissing(input) => write!(f, "{} is missing", input.what()), + Self::BevelVertexNotFilleted => write!( f, - "{}: the size {size} is below eight times the body's tolerance {tolerance}, the smallest a fillet builds", + "{}: a vertex given to bevel is not a vertex of the filleted edges", self.class() ), - Self::PerEdgeListLength { edges, given } => write!( + Self::BoundSurfaceRemoved => write!( f, - "{}: a list of one entry per edge holds {given} entries for {edges} edges", + "{}: the face's surface was removed after its binding was captured", self.class() ), - Self::ParameterListSizes { - edges, - cross_sections, - radius_types, - radii, - } => write!( + Self::ChamferFaceNotOfEdge => 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 face named for the chamfer's first size is neither of its edge's faces", self.class() ), - Self::FaceHasNoSurface => { - write!(f, "{}: a face given to the fillet has no surface", self.class()) - } - Self::NoFirstBody => write!( + Self::ChamferSizeInvalid => write!( f, - "{}: a face of the first surface's body is given where the first surface has no body", + "{}: 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::TargetNotGiven => { - write!(f, "{}: the fillet has no target body", self.class()) + Self::CliffInputMissing { face, input } => { + write!(f, "cliff face {face:?} is missing its {}", input.what()) } - 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::ClosedCliffWouldNotSplit { face } => write!( f, - "{}: edge {index} of the edges given has no edge use the fillet can roll on", - self.class() + "the closed cliff blend face {face:?} does not divide at its interior section" ), - Self::ChamferSizeInvalid => write!( + Self::CornerPatchFaceNotFound { surface } => 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)", + "{}: corner patch surface {surface} has no face in the intermediate body", self.class() ), - Self::ChamferFaceNotOfEdge => write!( + Self::CornerPointDropUnresolved { solutions } => write!( f, - "{}: the face named for the chamfer's first size is neither of its edge's faces", + "{}: the corner's vertex drops onto the surface at {solutions} points, not one", self.class() ), - Self::SolverFaceIndexInvalid { index } => write!( + Self::CornerRefused => write!( f, - "{}: a fillet solver's faces are its first (0) and second (1), not face {index}", + "{}: a corner was refused at its vertex (the error info says why)", self.class() ), - Self::GnSectionInvalid { order, thumbweight } => write!( + Self::CornerShapeNotBuilt(shape) => write!(f, "{}: {shape:?}", self.class()), + 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::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 { @@ -2396,140 +1089,144 @@ impl core::fmt::Display for BlendFailure { } write!(f, "), so the blend given does not match this edge") } - Self::EdgeWithoutCurve => write!( + Self::ExecutiveStepFailed => write!( f, - "{}: an edge of the body the fillet reads has no curve", + "{}: a step of the fillet executive failed (the error info says which)", self.class() ), - Self::LawHasNoValue => { - write!(f, "{}: a base radius law has no value of its own", self.class()) - } - Self::SequenceCurveNotBSpline { kind } => write!( + Self::ExtensionEndOnTwoSideLines => write!( f, - "{}: a {kind} curve of a smooth sequence of filleted edges has no B-spline form to join", + "{}: 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::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, "{}: the offset surfaces' intersection curves {first} and {second} cross, so the fillet would cross itself", self.class() ), - Self::CornerRefused => write!( - f, - "{}: a corner was refused at its vertex (the error info says why)", - self.class() - ), - Self::ExecutiveStepFailed => write!( - f, - "{}: a step of the fillet executive failed (the error info says which)", - self.class() - ), - Self::EdgeSplitDeclined { parameter } => write!( + 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::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::NoBlendedEdgeNearExtension => write!( f, - "{}: corner patch surface {surface} has no face in the intermediate body", + "{}: 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::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::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::Solver(cause) => cause.fmt(f), - 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!( f, @@ -2556,12 +1253,91 @@ impl core::fmt::Display for BlendFailure { 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::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()), } } } @@ -2668,6 +1444,7 @@ impl crate::SolidError { #[cfg(test)] mod tests { use super::*; + use crate::blend::fillet_exact::BlendSpine; use crate::SolidError; #[test] @@ -3882,4 +2659,97 @@ 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 (`match self` and `match reason`, 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] + } + let files = [ + ("blend.rs", include_str!("blend.rs")), + ("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/crossing.rs", include_str!("blend/crossing.rs")), + ("blend/ease.rs", include_str!("blend/ease.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/solver.rs", include_str!("blend/solver.rs")), + ("blend/weld.rs", include_str!("blend/weld.rs")), + ]; + let mut enums = 0; + let mut matches = 0; + for (file, src) in files { + let lines: Vec<&str> = src.lines().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 == "match self {" || t == "match reason {"; + if !is_enum && !is_match { + continue; + } + let pad = " ".repeat(indent + 4); + let close = format!("{}}}", " ".repeat(indent)); + let mut names = Vec::new(); + let mut wildcard = false; + for l in lines[i + 1..].iter().take_while(|l| **l != close) { + 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 + ); + wildcard |= rest.starts_with("_ "); + let name = if is_enum { + ident(rest) + } else { + let path = ident(rest); + match rest[path.len()..].strip_prefix("::") { + Some(after) if !path.is_empty() => ident(after), + _ => "", + } + }; + if name.starts_with(|c: char| c.is_ascii_uppercase()) { + names.push(name); + } + } + if wildcard { + continue; + } + assert!(!names.is_empty(), "{file}:{}: no variants found", i + 1); + 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 >= 23, + "{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..aef65eaa515 --- /dev/null +++ b/solidcore/crates/solidcore/src/error/blend/corner.rs @@ -0,0 +1,70 @@ +//! The shapes of a filleted vertex's edges the fillet corner topology does not build. +//! +//! Upstream: none. One of the modules of the blend failure causes, re-exported from +//! [`super`]. + +#[cfg(doc)] +use super::BlendFailure; +use crate::error::{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, + } + } +} 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/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..516ac0c58ed --- /dev/null +++ b/solidcore/crates/solidcore/src/error/blend/no_room.rs @@ -0,0 +1,73 @@ +//! 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`: 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/solver.rs b/solidcore/crates/solidcore/src/error/blend/solver.rs new file mode 100644 index 00000000000..f3e71d5ae91 --- /dev/null +++ b/solidcore/crates/solidcore/src/error/blend/solver.rs @@ -0,0 +1,504 @@ +//! 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 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, + /// 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 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::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::RailTangentZero { .. } => ErrorKind::Degenerate, + Self::RolloverIntervalNotAtEdge { .. } => ErrorKind::Unsupported, + Self::ShortIntervalsNotRemoved { .. } => ErrorKind::Unsupported, + Self::SideEdgeNotOnRailFace => ErrorKind::NotFound, + Self::SideSurfaceMissesEndPlane => ErrorKind::NotFound, + 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::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::RailTangentZero { .. } => SM_ERR, + Self::RolloverIntervalNotAtEdge { .. } => SM_ERR, + Self::ShortIntervalsNotRemoved { .. } => SM_ERR, + Self::SideEdgeNotOnRailFace => SM_ERR_NULL_POINTER, + Self::SideSurfaceMissesEndPlane => 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::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::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::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/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, +} From 8703d2b9eec1527d0fc7e9b2d3db2dc921797b99 Mon Sep 17 00:00:00 2001 From: Brett Lawson Date: Mon, 23 Nov 2026 08:25:12 +0100 Subject: [PATCH 2/3] solidcore: blend cause order test covers every module and nested match From the independent review of the split: - The order test now checks that its file list matches the `mod` lines of error/blend.rs, so a new detail-enum file cannot go unchecked. - It checks every match on the causes in library code, nested ones included (`=> match limit {`), and flags a one-line `A | B =>` group. - The nested `SectionLimit` match in BlendFailure's Display is sorted like the others (same arms, same text). - The module doc says "the nine causes `phrase_causes!` lists". Part of #21121. Co-Authored-By: Claude Opus 5.5 --- solidcore/crates/solidcore/src/error/blend.rs | 67 +++++++++++++------ 1 file changed, 47 insertions(+), 20 deletions(-) diff --git a/solidcore/crates/solidcore/src/error/blend.rs b/solidcore/crates/solidcore/src/error/blend.rs index 76504a7e8ea..79b2dbd8daf 100644 --- a/solidcore/crates/solidcore/src/error/blend.rs +++ b/solidcore/crates/solidcore/src/error/blend.rs @@ -24,7 +24,7 @@ //! `upstream_status`); it never decides the type. The status a cause gives unless its //! site says otherwise is named in its doc. //! -//! **The phrase causes** (the nine `phrase_causes!` lists, [`BlendFailure::Failed`] first) 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 @@ -1228,25 +1228,25 @@ impl core::fmt::Display for BlendFailure { 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})", @@ -2661,8 +2661,7 @@ mod tests { } /// The causes (every enum of this module and of `error/blend/`) and every match on their - /// variants (`match self` and `match reason`, 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 + /// 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() { @@ -2673,8 +2672,18 @@ mod tests { .unwrap_or(text.len()); &text[..end] } + let blend = include_str!("blend.rs"); + let modules: Vec = blend + .lines() + .filter_map(|l| { + Some(format!( + "blend/{}.rs", + l.strip_prefix("mod ")?.strip_suffix(';')? + )) + }) + .collect(); let files = [ - ("blend.rs", include_str!("blend.rs")), + ("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")), @@ -2688,23 +2697,34 @@ mod tests { ("blend/solver.rs", include_str!("blend/solver.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 { - let lines: Vec<&str> = src.lines().collect(); + // 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 == "match self {" || t == "match reason {"; + 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) { + 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; }; @@ -2713,6 +2733,14 @@ mod tests { "{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("_ "); let name = if is_enum { ident(rest) @@ -2727,10 +2755,9 @@ mod tests { names.push(name); } } - if wildcard { + if wildcard || names.is_empty() { continue; } - assert!(!names.is_empty(), "{file}:{}: no variants found", i + 1); for w in names.windows(2) { assert!( w[0] < w[1] || (is_match && w[0] == w[1]), @@ -2748,7 +2775,7 @@ mod tests { } } assert!( - enums >= 20 && matches >= 23, + enums >= 20 && matches >= 24, "{enums} enums and {matches} matches checked" ); } From 4aec9ed1cf28631e3e50873b4f55de1c7979107b Mon Sep 17 00:00:00 2001 From: Brett Lawson Date: Mon, 23 Nov 2026 08:52:39 +0100 Subject: [PATCH 3/3] solidcore: NoRoom's doc gives its real classes; the order test checks nested variants From CodeRabbit's review of #21122: - BlendFailure::NoRoom and no_room_class now say that a weld bead larger than its faces (BeadCutsFace, LegPastFace, NoToeAtLeg) is FilletTooLarge (100) and that CliffSubtractionLeavesNoSolid is a defect, as the mapping does. No mapping changes. - The order test compares a match arm's nested variant too (`Self::WeldNotBuilt(WeldGap::CurvedJoint)`), so swapping the WeldGap Display arms fails it. No other match needed reordering. Co-Authored-By: Claude Opus 5.5 --- solidcore/crates/solidcore/src/error/blend.rs | 38 +++++++++++++------ .../solidcore/src/error/blend/no_room.rs | 9 +++-- 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/solidcore/crates/solidcore/src/error/blend.rs b/solidcore/crates/solidcore/src/error/blend.rs index 75aab4d8554..2a1f90edd30 100644 --- a/solidcore/crates/solidcore/src/error/blend.rs +++ b/solidcore/crates/solidcore/src/error/blend.rs @@ -395,9 +395,13 @@ pub enum BlendFailure { /// 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 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. + /// 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 @@ -2683,6 +2687,18 @@ mod tests { .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() @@ -2756,16 +2772,16 @@ mod tests { 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) + (ident(rest), "") } else { - let path = ident(rest); - match rest[path.len()..].strip_prefix("::") { - Some(after) if !path.is_empty() => ident(after), - _ => "", - } + let (outer, after) = variant(rest); + let inner = after.strip_prefix('(').map_or("", |p| variant(p).0); + (outer, inner) }; - if name.starts_with(|c: char| c.is_ascii_uppercase()) { + if name.0.starts_with(|c: char| c.is_ascii_uppercase()) { names.push(name); } } @@ -2775,7 +2791,7 @@ mod tests { 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", + "{file}:{}: `{:?}` is before `{:?}`: keep them sorted by name", i + 1, w[0], w[1] diff --git a/solidcore/crates/solidcore/src/error/blend/no_room.rs b/solidcore/crates/solidcore/src/error/blend/no_room.rs index 516ac0c58ed..5213108c1ec 100644 --- a/solidcore/crates/solidcore/src/error/blend/no_room.rs +++ b/solidcore/crates/solidcore/src/error/blend/no_room.rs @@ -6,10 +6,11 @@ use crate::blend::fillet_executive::NoRoomReason; use crate::error::ErrorKind; -/// 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). +/// 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(