FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Split Boolean curves at the shell's vertices, not its curves' endpoints. · solvespace/solvespace@b27bcf5 · GitHub

Commit b27bcf5

Browse files
authored andcommitted
Split Boolean curves at the shell's vertices, not its curves' endpoints.
FindVertsOnCurve() used the endpoints of the shell's exact curves as the vertices to split other curves at. But an exact intersection curve can extend past the real geometry on both sides, out to the padded bounds that MergeCoincidentSurfaces() gives the surfaces it merges, so its endpoints may lie at phantom positions on another surface's edge where nothing actually happens. Splitting a curve there--when the trims adjacent across that curve are not split there--creates T-junctions, which triangulate into naked edges, and overlapping duplicate trim edges with mismatched splits, which make the trim polygon fail to assemble and leave a face missing entirely. The real vertices of a shell are the points where its trims begin and end, so use the trims' start and finish points instead. A curve endpoint that the shell actually uses is such a point anyway, and the unused tails past the last vertex no longer contribute. Add a regression test with a model reconstructed from the recipe in issue #1452: cuboids A (extruded down), B (up), C (up on top of B), unioned so that their coplanar side faces merge, then cuboid D sketched on the shared side plane and extruded away from the stack, joining only across that plane and spanning the side faces of A, B and part of C. Before this and the previous commit the resulting shell had a whole side face missing; the test checks that the mesh is watertight and has the expected volume. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UNfXectzZqpvY2c7TpGxe4
1 parent 906cf73 commit b27bcf5

4 files changed

Lines changed: 3533 additions & 20 deletions

File tree

‎src/srf/boolean.cpp‎

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,26 +41,27 @@ static void FindVertsOnCurve(List<SInter> *l, const SCurve *curve, SShell *sh) {
4141
Vector amax, amin;
4242
curve->GetAxisAlignedBounding(&amax, &amin);
4343

44-
for(const auto &sc : sh->curve) {
45-
if(!sc.isExact) continue;
46-
47-
Vector cmax, cmin;
48-
sc.GetAxisAlignedBounding(&cmax, &cmin);
49-
50-
if(Vector::BoundingBoxesDisjoint(amax, amin, cmax, cmin)) {
51-
// They cannot possibly intersect, no curves to generate
52-
continue;
53-
}
54-
55-
for(int i=0; i<2; i++) {
56-
Vector pt = sc.exact.ctrl[ i==0 ? 0 : sc.exact.deg ];
57-
double t;
58-
curve->exact.ClosestPointTo(pt, &t, /*must converge=*/ false);
59-
double d = pt.Minus(curve->exact.PointAt(t)).Magnitude();
60-
if((t>LENGTH_EPS) && (t<(1.0-LENGTH_EPS)) && (d < LENGTH_EPS)) {
61-
SInter inter;
62-
inter.p = pt;
63-
l->Add(&inter);
44+
// The vertices of the shell are the endpoints of its trims, not the
45+
// endpoints of its curves: an exact intersection curve may extend past
46+
// the real geometry on both sides (e.g. out to the padded bounds of a
47+
// surface that got enlarged by SShell::MergeCoincidentSurfaces()), and
48+
// splitting some other curve at such a phantom point--which is not a
49+
// vertex of the trims adjacent across that other curve--produces
50+
// T-junctions and naked edges in the triangulated shell (issue #1452).
51+
for(const SSurface &ss : sh->surface) {
52+
for(const STrimBy &stb : ss.trim) {
53+
for(int i = 0; i < 2; i++) {
54+
Vector pt = (i == 0) ? stb.start : stb.finish;
55+
if(pt.OutsideAndNotOn(amax, amin)) continue;
56+
57+
double t;
58+
curve->exact.ClosestPointTo(pt, &t, /*mustConverge=*/false);
59+
double d = pt.Minus(curve->exact.PointAt(t)).Magnitude();
60+
if((t > LENGTH_EPS) && (t < (1.0 - LENGTH_EPS)) && (d < LENGTH_EPS)) {
61+
SInter inter = {};
62+
inter.p = pt;
63+
l->Add(&inter);
64+
}
6465
}
6566
}
6667
}

‎test/CMakeLists.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ set(testsuite_SOURCES
6363
request/line_segment/test.cpp
6464
request/ttf_text/test.cpp
6565
request/workplane/test.cpp
66+
group/boolean_coplanar_union/test.cpp
6667
group/boolean_knife_edge/test.cpp
6768
group/boolean_tangent_edge/test.cpp
6869
group/boolean_tangent_fillet/test.cpp

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL