]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #2106: Arc transformed in line problem
authorazv <azv@opencascade.com>
Thu, 6 Apr 2017 11:26:38 +0000 (14:26 +0300)
committerazv <azv@opencascade.com>
Thu, 6 Apr 2017 11:26:38 +0000 (14:26 +0300)
src/SketchPlugin/SketchPlugin_Arc.cpp

index ca7579d8664f8f285ba30f85a1d09b63b1c3d0e4..e818241d0859a98687e7829fa6374e6a46703f8a 100644 (file)
@@ -37,7 +37,7 @@
 #include <GeomAlgoAPI_EdgeBuilder.h>
 #include <GeomAlgoAPI_CompoundBuilder.h>
 // for sqrt on Linux
-#include <math.h>
+#include <cmath>
 
 const double tolerance = 1e-7;
 const double paramTolerance = 1.e-4;
@@ -99,16 +99,21 @@ void SketchPlugin_Arc::execute()
       aSketch->data()->attribute(SketchPlugin_Sketch::NORM_ID()));
   std::shared_ptr<GeomAPI_Dir> aNormal(new GeomAPI_Dir(aNDir->x(), aNDir->y(), aNDir->z()));
 
-  GeomShapePtr anArcShape = boolean(REVERSED_ID())->value() ?
-      GeomAlgoAPI_EdgeBuilder::lineCircleArc(aCenter, anEnd, aStart, aNormal)
-    : GeomAlgoAPI_EdgeBuilder::lineCircleArc(aCenter, aStart, anEnd, aNormal);
-
   if (myParamBefore == 0) { // parameter has not been calculate yet
     std::shared_ptr<GeomAPI_Circ2d> aCircleForArc(
         new GeomAPI_Circ2d(aCenterAttr->pnt(), aStartAttr->pnt()));
     aCircleForArc->parameter(anEndAttr->pnt(), paramTolerance, myParamBefore);
   }
 
+  GeomShapePtr anArcShape;
+  if (fabs(myParamBefore - 2.0 * PI) < paramTolerance)
+    anArcShape = GeomAlgoAPI_EdgeBuilder::lineCircle(aCenter, aNormal, aStart->distance(aCenter));
+  else {
+    anArcShape = boolean(REVERSED_ID())->value() ?
+      GeomAlgoAPI_EdgeBuilder::lineCircleArc(aCenter, anEnd, aStart, aNormal)
+    : GeomAlgoAPI_EdgeBuilder::lineCircleArc(aCenter, aStart, anEnd, aNormal);
+  }
+
   std::shared_ptr<ModelAPI_ResultConstruction> aResult = document()->createConstruction(data(), 1);
   aResult->setShape(anArcShape);
   aResult->setIsInHistory(false);
@@ -245,6 +250,9 @@ void SketchPlugin_Arc::attributeChanged(const std::string& theID)
         }
         data()->blockSendAttributeUpdated(aWasBlocked, false);
       }
+      if (fabs(aParameterNew) < paramTolerance ||
+          fabs(aParameterNew - 2.0 * PI) < paramTolerance)
+        aParameterNew = 2.0 * PI;
       myParamBefore = aParameterNew;
     }
   }