From fa6622903010eb82b07b16adf06d31d5ffcd6bb9 Mon Sep 17 00:00:00 2001 From: whitequark Date: Mon, 22 Apr 2019 11:50:47 +0000 Subject: [PATCH] Fix choice of normal for revolution in some corner cases. Before this commit, if the sketch contain no entities with starting points off of the axis of revolution, the revolution may fail, which manifests as the face normals being inverted. The code at the top of MakeFromRevolutionOf() takes the furthest point from the axis, projects it on that axis to get a vector. In this case that vector is essentially zero length except for rounding errors. After this commit, instead of only considering start points of beziers, all control points are considered. Fix by @phkahler. --- src/srf/surface.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/srf/surface.cpp b/src/srf/surface.cpp index fdd1c50..33f0d4a 100644 --- a/src/srf/surface.cpp +++ b/src/srf/surface.cpp @@ -634,11 +634,13 @@ void SShell::MakeFromRevolutionOf(SBezierLoopSet *sbls, Vector pt, Vector axis, // if we choose a point that lies on the axis, for example. // (And our surface will be self-intersecting if the sketch // spans the axis, so don't worry about that.) - Vector p = sb->Start(); - double d = p.DistanceToLine(pt, axis); - if(d > md) { - md = d; - pto = p; + for(i = 0; i <= sb->deg; i++) { + Vector p = sb->ctrl[i]; + double d = p.DistanceToLine(pt, axis); + if(d > md) { + md = d; + pto = p; + } } } }