]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Projection should not use edges from the same plane
authorazv <azv@opencascade.com>
Fri, 17 Jun 2016 07:55:24 +0000 (10:55 +0300)
committerazv <azv@opencascade.com>
Fri, 17 Jun 2016 07:55:24 +0000 (10:55 +0300)
src/SketchPlugin/SketchPlugin_Validators.cpp

index a2f1f27ca19f965aae074ae9da65c5f2a9f158a6..c2f1badd67199669600053b2a2847481d750fdda 100755 (executable)
@@ -860,16 +860,24 @@ bool SketchPlugin_ProjectionValidator::isValid(const AttributePtr& theAttribute,
 
   std::shared_ptr<GeomAPI_Pln> aPlane = aSketch->plane();
   std::shared_ptr<GeomAPI_Dir> aNormal = aPlane->direction();
+  std::shared_ptr<GeomAPI_Pnt> anOrigin = aPlane->location();
 
   if (anEdge->isLine()) {
-    std::shared_ptr<GeomAPI_Dir> aLineDir = anEdge->line()->direction();
+    std::shared_ptr<GeomAPI_Lin> aLine = anEdge->line();
+    std::shared_ptr<GeomAPI_Dir> aLineDir = aLine->direction();
+    std::shared_ptr<GeomAPI_Pnt> 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<GeomAPI_Dir> aCircNormal = anEdge->circle()->normal();
+    std::shared_ptr<GeomAPI_Circ> aCircle = anEdge->circle();
+    std::shared_ptr<GeomAPI_Dir> aCircNormal = aCircle->normal();
+    std::shared_ptr<GeomAPI_Pnt> 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;