]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #2374: SIGSEGV when adding a distance constraint on a circle center and another...
authorazv <azv@opencascade.com>
Tue, 19 Dec 2017 07:41:55 +0000 (10:41 +0300)
committerazv <azv@opencascade.com>
Tue, 19 Dec 2017 07:41:55 +0000 (10:41 +0300)
Fix incorrect projecting of circular shape when it is not in plane parallel to the sketch plane.

src/SketchPlugin/SketchPlugin_Projection.cpp

index 4c6dfefc27e9a96a90a55682564c45b52db64f43..0f441f3905ff237d3088cf21717c8dd3046c2803 100644 (file)
@@ -204,6 +204,10 @@ void SketchPlugin_Projection::computeProjection(const std::string& theID)
     std::shared_ptr<GeomAPI_Circ> 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<GeomAPI_Pnt> aCenter = aSketchPlane->project(aCircle->center());
     std::shared_ptr<GeomAPI_Pnt2d> aCenterInSketch = sketch()->to2D(aCenter);
 
@@ -227,7 +231,11 @@ void SketchPlugin_Projection::computeProjection(const std::string& theID)
     std::shared_ptr<GeomAPI_Pnt> aCenter = aSketchPlane->project(aCircle->center());
     std::shared_ptr<GeomAPI_Pnt2d> 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());