From 04b332dfd0d885a45c9bb52d3e76294a3e5eb847 Mon Sep 17 00:00:00 2001 From: phkahler <14852918+phkahler@users.noreply.github.com> Date: Thu, 13 Aug 2020 15:24:53 -0400 Subject: [PATCH] Ratpoly - Less noise in terminal. Comment out expected dbg print and try harder to converge. --- src/srf/ratpoly.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/srf/ratpoly.cpp b/src/srf/ratpoly.cpp index bd878ab1..8e43367d 100644 --- a/src/srf/ratpoly.cpp +++ b/src/srf/ratpoly.cpp @@ -447,11 +447,13 @@ void SSurface::ClosestPointTo(Vector p, double *u, double *v, bool mustConverge) // If we failed to converge, then at least don't return NaN. if(mustConverge) { - Vector p0 = PointAt(*u, *v); - dbp("didn't converge"); - dbp("have %.3f %.3f %.3f", CO(p0)); - dbp("want %.3f %.3f %.3f", CO(p)); - dbp("distance = %g", (p.Minus(p0)).Magnitude()); +// This is expected not to converge when the target point is not on the surface but nearby. +// let's not pollute the output window for normal use. +// Vector p0 = PointAt(*u, *v); +// dbp("didn't converge"); +// dbp("have %.3f %.3f %.3f", CO(p0)); +// dbp("want %.3f %.3f %.3f", CO(p)); +// dbp("distance = %g", (p.Minus(p0)).Magnitude()); } if(IsReasonable(*u) || IsReasonable(*v)) { *u = *v = 0; @@ -500,7 +502,7 @@ bool SSurface::ClosestPointNewton(Vector p, double *u, double *v, bool mustConve bool SSurface::PointIntersectingLine(Vector p0, Vector p1, double *u, double *v) const { int i; - for(i = 0; i < 15; i++) { + for(i = 0; i < 20; i++) { Vector pi, p, tu, tv; p = PointAt(*u, *v); TangentsAt(*u, *v, &tu, &tv); @@ -510,7 +512,10 @@ bool SSurface::PointIntersectingLine(Vector p0, Vector p1, double *u, double *v) bool parallel; pi = Vector::AtIntersectionOfPlaneAndLine(n, d, p0, p1, ¶llel); - if(parallel) break; + if(parallel) { + dbp("parallel (surface intersecting line)"); + break; + } // Check for convergence if(pi.Equals(p, RATPOLY_EPS)) return true; @@ -617,7 +622,10 @@ void SSurface::PointOnSurfaces(SSurface *s1, SSurface *s2, double *up, double *v Vector pi = Vector::AtIntersectionOfPlanes(n[0], d[0], n[1], d[1], n[2], d[2], ¶llel); - if(parallel) break; + + if(parallel) { // lets try something else for parallel planes + pi = p[0].Plus(p[1]).Plus(p[2]).ScaledBy(1.0/3.0); + } for(j = 0; j < 3; j++) { Vector n = tu[j].Cross(tv[j]);