From 3012077f57fffba56427829c17ff80a428f9a39d Mon Sep 17 00:00:00 2001 From: azv Date: Tue, 19 Dec 2017 10:41:55 +0300 Subject: [PATCH] Issue #2374: SIGSEGV when adding a distance constraint on a circle center and another edge Fix incorrect projecting of circular shape when it is not in plane parallel to the sketch plane. --- src/SketchPlugin/SketchPlugin_Projection.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/SketchPlugin/SketchPlugin_Projection.cpp b/src/SketchPlugin/SketchPlugin_Projection.cpp index 4c6dfefc2..0f441f390 100644 --- a/src/SketchPlugin/SketchPlugin_Projection.cpp +++ b/src/SketchPlugin/SketchPlugin_Projection.cpp @@ -204,6 +204,10 @@ void SketchPlugin_Projection::computeProjection(const std::string& theID) std::shared_ptr aCircle = anEdge->circle(); double aRadius = aCircle->radius(); + double aNormalsDot = aCircle->normal()->dot(aSketchPlane->direction()); + if (fabs(fabs(aNormalsDot) - 1.0) > tolerance) + return; // circle is not in the plane, parallel to the sketch plane + std::shared_ptr aCenter = aSketchPlane->project(aCircle->center()); std::shared_ptr aCenterInSketch = sketch()->to2D(aCenter); @@ -227,7 +231,11 @@ void SketchPlugin_Projection::computeProjection(const std::string& theID) std::shared_ptr aCenter = aSketchPlane->project(aCircle->center()); std::shared_ptr aCenterInSketch = sketch()->to2D(aCenter); - bool isInversed = aCircle->normal()->dot(aSketchPlane->direction()) < 0.; + double aNormalsDot = aCircle->normal()->dot(aSketchPlane->direction()); + if (fabs(fabs(aNormalsDot) - 1.0) > tolerance) + return; // arc is not in the plane, parallel to the sketch plane + + bool isInversed = aNormalsDot < 0.; if (!hasPrevProj) aProjection = sketch()->addFeature(SketchPlugin_Arc::ID()); -- 2.39.2