solidcore

Units / heal

heal.stitch_p1 green

Layer
49
Upstream lines
2,037
Functions
19
Rust module
heal::stitch::p1

Status history

Oct 12Nov 25
  1. todo 2,037 lines
  2. partial 2,037 lines
  3. green 2,037 lines

Source: crates/solidcore/src/heal/stitch/p1.rs

Upstream: source/SMLib/inc/SmStitch.h, source/SMLib/src/SmStitch.cpp, source/SM_API/src/SmApiBrep.cpp

Port-plan notes

These notes preserve historical port measurements and limitations, not current CI results.

2026-10-30 (#1462 P5): the default stitch edge split lends the B-rep attributes (both pieces keep them); tagged ops (op + 100, fixtures/heal.stitch_p1/attributed.json, 218 cases): cases=674 passed=674. Owner-tolerance follow-up (PR #1355, 2026-10-29): test_and_split_edge_with records the actual live edge tolerance on its curve before DropPoint, independently of the stitch tolerance, reusing one arena lookup without a geometry copy. Five independent native/Rust Hermite-wire cases compare drop/refusal output and cache geometry exactly; the scaled off-center regression and perturbation detect the change. These cases do not establish successful nonlinear edge splitting. The published #1306 cleanup is adopted without restoring its obsolete C++-export-based Rust construction: main's independent builders remain. Exact-head CI6203d4178 compared all22 former nesting cases with values and zero numerical mismatches, but failed solely on stale known-mismatch entries; the two obsolete registries are removed by this dependency merge. Historical unit evidence follows. 19 fns; largest: SmStitch::StitchVertexPairs, SmStitch::DoSimpleFaceStitch, SmStitchCallback::SelectTopologyToKeep, SmStitch::StitchEdgesOfVertices; entry points: SmApiSimpleFaceStitch, SmApiStitch, SmApiStitchAdvanced, SmApiStitchIntoShell, SmApiStitchIntoSolid, SmApiUnifyNormals; cycle back-edges (call into later units; stub or co-port): heal.stitch_p2(3), boolean.merge_p2(2), sweep.topology_sweep(1); unit-SCC #22 (220 units); 179 upstream test entry points reach this unit; PARTIAL (PR #196, builds on #145 topology.brep_p1): all 19 fns ported in heal::stitch::p1 (the Stitch struct, StitchCallback/DefaultStitchCallback, the file-statics sm_CheckInteriorEdge / sm_TestAndSplitEdge, and the SM_API entry points); difftest 300 cases (284 fixtures: the SM_API_test box tests TestSmStitchIntoSolid/IntoShell/UnifyNormals/AdvancedStitch, SmApiStitch(NULL), every entry point's null guard, two-square sheets with gaps 0/1e-4/5e-3, and boundary cases for the SelectTopologyToKeep vertex branch, sm_TestAndSplitEdge's tolerance and sm_CheckInteriorEdge's parametric band; 16 generated): 206 pass, all comparing values, 0 failed, 94 deferred (topology.face_p2 49 = surface code's SmTol::GetZoneTol3d -> SmFace::GetTolerance stub on face-owned surfaces, topology.brep_p9 26 = MakeVertexSplitEdge, query.brep 7 = UnifyNormals' first call, 6 through topology.brep_p5's GlueVertices / StitchAndOrient (wired in PR #194; now topology.brep_p2 5, topology.brep_p4 1), heal.stitch_p2 3, topology.face_p4 2, harness:analytic-geometry-export 1); 1000 seeds: 1284 cases, 868 pass, 6 rejected (no entity of the op's kind), 0 failed, 410 deferred; --perturb 333/333 (200 seeds); --fuzz 2000 FUZZ-PASS (crashes=0 panics=0 timeouts=0 differs=0; HANG-30 bounded in the FFI); valgrind 0 errors (127 generated programs earlier, the simple/unify/select/split families this round). Mutation probe (review S3): SelectTopologyToKeep's tol*10 -> 5 and sm_TestAndSplitEdge's max(tol, edge tol) -> tol are detected; sm_CheckInteriorEdge's param_tol*20 -> *10 cannot change a result while vertices sit at their curve ends, and StitchVertexPairs' dist < tol -> <= turns a pass into a glue deferral (now inside topology.brep_p5's GlueVertices) until the glue lands. Real comparisons: SelectTopologyToKeep (vertex and edge branches), StitchVertexPairs / StitchEdgesOfVertices up to their first glue, sm_CheckInteriorEdge, sm_TestAndSplitEdge up to MakeVertexSplitEdge, DoSimpleFaceStitch's validation statuses (SM_ERR) once the exact UB-177 guard runs only on inputs that reach RemoveFaces, and the API null guards; UnifyNormals defers at query.brep. Upstream defects: UB-167 (SmApiStitch(brep, face) always crashes in SmMerge's constructor), UB-176 (two-list StitchVertexPairs double free on repeated vertices), UB-177 [PSIRT] (DoSimpleFaceStitch glues vertices RemoveFaces or an earlier glue freed), HANG-30 (SmApiStitch -> StitchAndOrient never returns on a 1e300 coordinate); the FFI and shim refuse exactly those inputs. Round 3 (merged #145 at 5b1b28ae, main through e1ae2640): UnifyNormals' SmEdgeuse::NormalizedEvaluate (status ignored, 3d with the first derivative, bOKToMakeUVTrimCurve TRUE) and both EvaluateBinormal calls (bUse3DOnly FALSE, SER as upstream) call topology::edgeuse::p3; on a failed NormalizedEvaluate sPnt / sDir keep SmVector3d's default SM_UNDEF_DOUBLE (defined; the port's UNDEF), the header no longer calls it uninitialised. Latent for the difftest: no case deferred first at topology.edgeuse_p3, so 300/206/0/94, the 1000-seed 1284/868/0/410, perturb 333/333 and fuzz 2000 are unchanged (0 flips); valgrind with harness/valgrind/ub11.supp 0 errors on the simple/unify/select/split samples. Round 4 (delta review of 4ad4e504, MF1): the UB-177 guard also refuses a vertex in more than one entry of the two vertex lists (upstream builds them with plain Add across face pairs, so a vertex shared by two keep or two delete faces, or a repeated keep face, is freed by its first glue and read at the next), in the shim and the port alike; a repeated vertex whose first entry would glue nothing is over-refused, deliberately. UB-177 is now [PSIRT]: well-formed face lists over file-read geometry reach the cross-pair repeat. HANG-30 is file-reachable (hang only). PR #183 wires sm_TestAndSplitEdge's SmBrep::MakeVertexSplitEdge (topology.brep_p9; call-local notification records as SetPoint; a refusal is SM_ERR, the only distinction the caller makes; test_and_split_edge takes &mut Kernel). Rerun on 7da151aa: 300 cases, 232 passed, 68 deferred, 0 failed; the 26 former topology.brep_p9 deferrals pass as matching refusals (the fixture B-rep keeps editing disabled, as native), so no split mutation is compared. PR #205 (heal.stitch_p2): query.brep 8 = UnifyNormals' first call and the API StitchIntoSolid's CalculateBoundingBox, topology.brep_p2 2 = the API StitchIntoShell / StitchAdvanced reaching DoStitching's first Notify (heal.stitch_p2 is wired since #205 merged #196). UPDATE after topology.brep_p2 (PR #149 follow-up): brep_notify_pre_edit (SmBrep::Notify(SM_NO_PRE_EDIT)) calls topology::brep::p2::notify on an empty notify state: no Rust caller holds the B-rep cache and the heal path carries no attribute state (plan/findings.md); PRE_EDIT reads no topology record. Report unchanged (300 cases, 206 pass, 94 deferred). Re-run in PR #149 (review 5578349117 round, merged with main through fb58ea76; topology.brep_p2's UNPORTED stubs wired): 300 cases, 232 pass, 0 fail, 68 deferred; brep_notify_pre_edit wired, the 7 Notify deferrals relabel (topology.brep_p1 5, query.brep 2). topology.face_p4 (PR #239) wired SmFace::GetBrep / GetVertices / GetEdges (default arguments): after the batch merge 300 cases, 234 pass, 0 failed, 66 deferred (was 232/68).; boolean.merge_p2 (PR #229) wired api_stitch_face: SmMerge::with_breps(.., None, 0.0, ..) fails on the null other B-rep where upstream crashes (UB-167), so MergeAddedFace is never reached UPDATE (GlueEdgesGeneral wiring follow-up, after #257): the SmBrep::GlueEdgesGeneral wrapper now calls topology::brep::p7::glue_edges_general on a default record per arena object (brep_p2::ArenaNotifyState) and the kernel's notification context (Context::with_notification_context), so SmTopology propagation finds both edges and installed callbacks see PreEdit / MergeInBrep; since #149 its notifies are live, so a wire edge to delete stops at SmBrep::DeleteEdge (topology.brep_p4) and face-bounded edges run the glue up to part 7's own stubs. No current case reaches it (both call sites sit behind face_p2 GetTolerance / face_p4 / query.brep deferrals), so the report is unchanged. UPDATE (PR #204, topology.brep_p3): the UNPORTED(topology.brep_p3) SmBrep::SqueezeEdge stub (squeeze_edge_to) is wired to topology::brep::p3::squeeze_edge, notifying through the kernel context's callbacks (brep::p3::with_kernel_callbacks: seeded SmTopology records, no attribute store) under brep::p3::default_key_of identities; squeeze_edge_to takes the kernel; a null edge is InvalidInput (upstream dereferences it). UPDATE (PR #204, Codex re-check of d61f8d48): squeeze_edge_to notifies under the kernel's identities (brep::p3::with_kernel_callbacks; default_key_of is removed). CORRECTION to 'a null edge is InvalidInput' above: it is SM_ERR_NULL_POINTER (SolidError::null_pointer), as the code always returned; the doc said InvalidInput. Report unchanged. UPDATE (PR #204, overseer ruling on the 9129d9f2 reviews): brep::p3::with_kernel_callbacks (squeeze_edge_to) refuses a nested call before anything changes; behaviour otherwise unchanged. Report unchanged. UPDATE (PR #204, topology.brep_p3): stitch_and_orient passes the kernel to topology::brep::p5::stitch_and_orient (which now takes it). Report unchang Owner zone-tol cache (surface/owner-zone-tol): 300 cases, 283 pass, 0 fail, 17 deferred. UPDATE (PR #526, FindAndSetInfiniteRegion wired): 300 cases, 287 pass, 0 fail, 13 deferred; 2 FindInfiniteRegion deferrals now stop at geom.tol SmTol::GetZoneTol3d(const SmObject) (topology solver point-face ray solve). GREEN (2026-10-23, PR #600): difftest PASS heal.stitch_p1 cases=300 passed=300 failed=0 deferred=0 max_rel_err=0e0 with_values=299 no_values=1 vacuous=0; the former 13 heal.stitch_p1 deferrals (PR #526 count, incl. 2 at geom.tol SmTol::GetZoneTol3d(const SmObject*)) no longer occur on main 38b0745b3 (the GetZoneTol3d ones likely by #541, topology solver zone tol); 1 both-errored case (no_values=1) counts as agreement; local rerun and CI run 39935703236 agree. PARTIAL (2026-10-27, PR #1297): the runner now compares the stitched B-rep's digest (counts, vertex points and tolerances, shell count, per-edge end vertices/tolerance/interval/use count, per-face loops as edge/orientation sequences) after every mutating op, including the SmApi* entry points; fixtures/heal.stitch_p1/coverage.json adds 151 cases (T-junction sheets with slivers, unstitched cubes with a split face, 31 Solids/*.smb files under SmApiStitchAdvanced; file B-reps run their C++ op in a fresh process). difftest heal.stitch_p1 cases=451 passed=442 failed=0 deferred=0 known_mismatch=9: the 9 are cov_cube2/4/5 SmApiStitch/SmApiStitchAdvanced, whose region nesting (FindAndSetInfiniteRegion's ray fire) raises different tolerances (plan/findings/heal.stitch_p2--region-nesting-ray-fire-raises-other-edge-tolerances.md). GREEN (2026-10-27, PR #1306, stacked on #1297): the runner records the import's arena naming on the B-rep (Brep::use_arena_naming), so the nested glue's region split (SplitClosed -> FindAndSetInfiniteRegion -> SmShell::RayFire), which names geometry under the stitch's notification identities, resolves the curve owners instead of failing every shell ray with an internal owner-lookup error; the former known mismatches now pass and are removed. difftest heal.stitch_p1 cases=451 passed=451 failed=0 deferred=0 (plan/findings/heal.stitch_p2--region-nesting-ray-fire-raises-other-edge-tolerances--addendum-2026-10-27-resolved.md).

Goldens

This is committed inventory, not a runtime result or a correctness proof. A golden records what solidcore produced when blessed. Current results require the canonical CI gate, not these counts.

Golden records
674
Stored error outcomes
2
Stored deferrals
0
Stored harness rejections
0
Known-failure entries
0

Metadata counts describe fields in the stored records; they are not passes or live failures.

Source at f9704ee3b: golden JSONL · known-failure list.

Dependencies

Depends on: curve.curve_p2 green curve.curve_p6 green geom.context green geom.extent1d green geom.extent3d green geom.object green geom.tree green geom.vector3d green topology.brep_p1 green topology.brep_p5 green topology.edge green topology.edgeuse_p1 green topology.face_p2 partial topology.face_p4 green topology.topology green topology.vertex green

Soft dependencies: geom.tol green query.brep green topology.brep_p2 green topology.brep_p7 green topology.brep_p9 green topology.edgeuse_p3 green topology.face_p1 green

Dependents: blend.fillet_executive_p3 partial boolean.merge_p2 green heal.stitch_p2 green sweep.topology_sweep green topology.brep_constructor green

Soft dependents: primitive.primitive_creation_p3 green

Upstream functions

Upstream functionDefined atLinesRust (from the file header)
SmStitchCallback::SmStitchCallbackSmStitch.h:341[StitchCallback], [DefaultStitchCallback]
SmStitchCallback::~SmStitchCallbackSmStitch.h:361
SmStitch::SmStitchSmStitch.h:9918[Stitch], [Stitch::new]
SmStitch::~SmStitchSmStitch.h:1181Drop (implicit)
SmStitch::SetStitchTol3dSmStitch.h:1201[Stitch::set_stitch_tol_3d], [Stitch::stitch_tol_3d]
SmStitchCallback::SelectTopologyToKeepSmStitch.cpp:54394[StitchCallback::select_topology_to_keep], [select_topology_to_keep]
sm_CheckInteriorEdgeSmStitch.cpp:45350[check_interior_edge]
sm_TestAndSplitEdgeSmStitch.cpp:51879[test_and_split_edge], [SplitReason], [EdgeSplitTest]
SmStitch::DoSimpleFaceStitchSmStitch.cpp:617413[Stitch::do_simple_face_stitch], [SimpleFaceStitch]
SmStitch::UnifyNormalsSmStitch.cpp:2512138[Stitch::unify_normals]
SmStitch::StitchVertexPairsSmStitch.cpp:3242508[Stitch::stitch_vertex_pairs], [VertexPairs]
SmStitch::StitchEdgesOfVerticesSmStitch.cpp:3925266[Stitch::stitch_edges_of_vertices], [EdgesOfVertices]
SmApiStitchSmApiBrep.cpp:112823[api_stitch]
SmApiStitchSmApiBrep.cpp:115732[api_stitch]
SmApiStitchIntoSolidSmApiBrep.cpp:248418[api_stitch_into_solid]
SmApiStitchIntoShellSmApiBrep.cpp:250819[api_stitch_into_shell]
SmApiUnifyNormalsSmApiBrep.cpp:253320[api_unify_normals]
SmApiSimpleFaceStitchSmApiBrep.cpp:255923[api_simple_face_stitch]
SmApiStitchAdvancedSmApiBrep.cpp:258932[api_stitch_advanced], [AdvancedStitch], [AdvancedStitchOptions]
Module file-header table (19 rows)
RustUpstream
[StitchCallback], [DefaultStitchCallback]SmStitchCallback (constructor, destructor)
[StitchCallback::select_topology_to_keep], [select_topology_to_keep]SmStitchCallback::SelectTopologyToKeep
[KeepChoice]SelectTopologyToKeep's out-params
[Stitch], [Stitch::new]SmStitch, SmStitch::SmStitch
Drop (implicit)SmStitch::~SmStitch
[Stitch::set_stitch_tol_3d], [Stitch::stitch_tol_3d]SmStitch::SetStitchTol3d, m_dStitchTol3d
[check_interior_edge]sm_CheckInteriorEdge (file-static)
[test_and_split_edge], [SplitReason], [EdgeSplitTest]sm_TestAndSplitEdge, sReasonType (file-static)
[Stitch::do_simple_face_stitch], [SimpleFaceStitch]SmStitch::DoSimpleFaceStitch
[Stitch::unify_normals]SmStitch::UnifyNormals
[Stitch::stitch_vertex_pairs], [VertexPairs]SmStitch::StitchVertexPairs (two-list overload)
[Stitch::stitch_edges_of_vertices], [EdgesOfVertices]SmStitch::StitchEdgesOfVertices
[api_stitch]SmApiStitch(SmBrep*)
[api_stitch_face]SmApiStitch(SmBrep*, SmFace*)
[api_stitch_into_solid]SmApiStitchIntoSolid
[api_stitch_into_shell]SmApiStitchIntoShell
[api_unify_normals]SmApiUnifyNormals
[api_simple_face_stitch]SmApiSimpleFaceStitch
[api_stitch_advanced], [AdvancedStitch], [AdvancedStitchOptions]SmApiStitchAdvanced

Upstream tests reaching this unit

prog_test:my_test_single_periodic_vertexuse, SM_API_test:TestSmAdvancedStitch, SM_API_test:TestSmEdgeCurveOwnership, SM_API_test:TestSmGetClosestPoint, SM_API_test:TestSmGetEdges, SM_API_test:TestSmGetFaces