From ab1df5e5a4f2a68455b7c74ecb746f53860beb99 Mon Sep 17 00:00:00 2001 From: azv Date: Fri, 17 Jun 2016 10:55:24 +0300 Subject: [PATCH] Projection should not use edges from the same plane --- src/SketchPlugin/SketchPlugin_Validators.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/SketchPlugin/SketchPlugin_Validators.cpp b/src/SketchPlugin/SketchPlugin_Validators.cpp index a2f1f27ca..c2f1badd6 100755 --- a/src/SketchPlugin/SketchPlugin_Validators.cpp +++ b/src/SketchPlugin/SketchPlugin_Validators.cpp @@ -860,16 +860,24 @@ bool SketchPlugin_ProjectionValidator::isValid(const AttributePtr& theAttribute, std::shared_ptr aPlane = aSketch->plane(); std::shared_ptr aNormal = aPlane->direction(); + std::shared_ptr anOrigin = aPlane->location(); if (anEdge->isLine()) { - std::shared_ptr aLineDir = anEdge->line()->direction(); + std::shared_ptr aLine = anEdge->line(); + std::shared_ptr aLineDir = aLine->direction(); + std::shared_ptr aLineLoc = aLine->location(); double aDot = aNormal->dot(aLineDir); - return aDot > -1.0 + tolerance && aDot < 1.0 - tolerance; + double aDist = aLineLoc->xyz()->decreased(anOrigin->xyz())->dot(aNormal->xyz()); + return (fabs(aDot) >= tolerance && fabs(aDot) < 1.0 - tolerance) || + (fabs(aDot) < tolerance && fabs(aDist) > tolerance); } else if (anEdge->isCircle() || anEdge->isArc()) { - std::shared_ptr aCircNormal = anEdge->circle()->normal(); + std::shared_ptr aCircle = anEdge->circle(); + std::shared_ptr aCircNormal = aCircle->normal(); + std::shared_ptr aCircCenter = aCircle->center(); double aDot = fabs(aNormal->dot(aCircNormal)); - return fabs(aDot - 1.0) < tolerance * tolerance; + double aDist = aCircCenter->xyz()->decreased(anOrigin->xyz())->dot(aNormal->xyz()); + return fabs(aDot - 1.0) < tolerance * tolerance && fabs(aDist) > tolerance; } return false; -- 2.39.2