From: azv Date: Fri, 17 Jun 2016 07:55:24 +0000 (+0300) Subject: Projection should not use edges from the same plane X-Git-Tag: V_2.4.0~93 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ab1df5e5a4f2a68455b7c74ecb746f53860beb99;p=modules%2Fshaper.git Projection should not use edges from the same plane --- 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;