From e83e48392e0b65eb6e1b7b6bf7d5d1d4882481d1 Mon Sep 17 00:00:00 2001 From: phkahler <14852918+phkahler@users.noreply.github.com> Date: Thu, 4 Jun 2020 19:03:54 -0400 Subject: [PATCH] Change criteria for short edge removal --- src/srf/curve.cpp | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/srf/curve.cpp b/src/srf/curve.cpp index 9bdcca289..eae0479a8 100644 --- a/src/srf/curve.cpp +++ b/src/srf/curve.cpp @@ -799,20 +799,37 @@ SSurface *SCurve::GetSurfaceB(SShell *a, SShell *b) const { // stuff in the Booleans. So remove them. //----------------------------------------------------------------------------- void SCurve::RemoveShortSegments(SSurface *srfA, SSurface *srfB) { - // Three, not two; curves are pwl'd to at least two edges (three points) - // even if not necessary, to avoid square holes. - if(pts.n <= 3) return; + if(pts.n <= 2) return; pts.ClearTags(); Vector prev = pts[0].p; + double tprev = 0; + double t = 0; + double tnext = 0; + int i, a; for(i = 1; i < pts.n - 1; i++) { SCurvePt *sct = &(pts[i]), *scn = &(pts[i+1]); + if(sct->vertex) { prev = sct->p; continue; } + + // if the curve is exact and points are >0.1 appart wrt t, point is there + // deliberately regardless of chord tolerance (ex: small circles) + tprev = t = tnext = 0; + if (isExact) { + exact.ClosestPointTo(prev, &tprev, /*mustconverge=*/ true); + exact.ClosestPointTo(sct->p, &t, /*mustconverge=*/ true); + exact.ClosestPointTo(scn->p, &tnext, /*mustconverge=*/ true); + } + if ( (t - tprev > 0.1) && (tnext - t > 0.1) ) { + prev = sct->p; + continue; + } + bool mustKeep = false; // We must check against both surfaces; the piecewise linear edge @@ -826,7 +843,7 @@ void SCurve::RemoveShortSegments(SSurface *srfA, SSurface *srfB) { srf->ClosestPointTo(prev, &(puv.x), &(puv.y)); srf->ClosestPointTo(scn->p, &(nuv.x), &(nuv.y)); - if(srf->ChordToleranceForEdge(nuv, puv) > SS.ChordTolMm()) { + if(srf->ChordToleranceForEdge(nuv, puv) > SS.ChordTolMm() ) { mustKeep = true; } }