]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Task 2.11. Ability to impose a midpoint on an arc (refers issue #3002)
authorazv <azv@opencascade.com>
Mon, 9 Sep 2019 13:38:03 +0000 (16:38 +0300)
committerazv <azv@opencascade.com>
Mon, 9 Sep 2019 13:39:24 +0000 (16:39 +0300)
Revert more code related to arc processing in SketchSolver plugin.

src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp

index 9f23cf6c51a09cabb0946b726e55ad191012e384..6a41efc0d85c2b4daa6efd9f12bf647b61696d2a 100644 (file)
@@ -223,6 +223,30 @@ bool PlaneGCSSolver_Storage::update(FeaturePtr theFeature, bool theForce)
   if (sendNotify && isUpdated)
     notify(theFeature);
 
+  // update arc
+  if (aRelated && aRelated->type() == ENTITY_ARC) {
+    /// TODO: this code should be shared with FeatureBuilder somehow
+
+    std::shared_ptr<PlaneGCSSolver_EdgeWrapper> anEntity =
+      std::dynamic_pointer_cast<PlaneGCSSolver_EdgeWrapper>(aRelated);
+    std::shared_ptr<GCS::Arc> anArc = std::dynamic_pointer_cast<GCS::Arc>(anEntity->entity());
+
+    static std::shared_ptr<GeomAPI_Dir2d> OX(new GeomAPI_Dir2d(1.0, 0.0));
+    std::shared_ptr<GeomAPI_Pnt2d> aCenter(
+      new GeomAPI_Pnt2d(*anArc->center.x, *anArc->center.y));
+    std::shared_ptr<GeomAPI_Pnt2d> aStart(
+      new GeomAPI_Pnt2d(*anArc->start.x, *anArc->start.y));
+
+    *anArc->rad = aStart->distance(aCenter);
+
+    std::shared_ptr<GeomAPI_Dir2d> aDir(new GeomAPI_Dir2d(aStart->xy()->decreased(aCenter->xy())));
+    *anArc->startAngle = OX->angle(aDir);
+
+    aDir = std::shared_ptr<GeomAPI_Dir2d>(
+      new GeomAPI_Dir2d((*anArc->end.x) - aCenter->x(), (*anArc->end.y) - aCenter->y()));
+    *anArc->endAngle = OX->angle(aDir);
+  }
+
   return isUpdated;
 }