Salome HOME
cosmétique
[modules/shaper.git] / src / SketchSolver / SketchSolver_ConstraintMirror.cpp
index 6381b2bd3dc8f85750cab74f798213a6d37bfb40..b92a37827dae014494ccf8553649bc933091964c 100644 (file)
@@ -1,16 +1,36 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+// Copyright (C) 2014-2022  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
 
 #include <SketchSolver_ConstraintMirror.h>
 #include <SketchSolver_Error.h>
-#include <SketchSolver_Manager.h>
 
+#include <PlaneGCSSolver_Tools.h>
 #include <PlaneGCSSolver_UpdateFeature.h>
 
+#include <GeomAPI_Lin2d.h>
+#include <GeomAPI_Pnt2d.h>
 #include <GeomAPI_XY.h>
 #include <GeomDataAPI_Point2D.h>
 #include <ModelAPI_AttributeRefList.h>
 #include <SketchPlugin_Arc.h>
 #include <SketchPlugin_Circle.h>
+#include <SketchPlugin_EllipticArc.h>
 
 
 static void mirrorPoints(const std::shared_ptr<GeomAPI_Lin2d>& theMirrorLine,
@@ -99,12 +119,10 @@ void SketchSolver_ConstraintMirror::update()
 
 void SketchSolver_ConstraintMirror::adjustConstraint()
 {
-  BuilderPtr aBuilder = SketchSolver_Manager::instance()->builder();
-
   AttributeRefAttrPtr aMirrLineRefAttr =
       myBaseConstraint->refattr(SketchPlugin_Constraint::ENTITY_A());
   std::shared_ptr<GeomAPI_Lin2d> aMirrorLine =
-      aBuilder->line(ModelAPI_Feature::feature(aMirrLineRefAttr->object()));
+      PlaneGCSSolver_Tools::line(ModelAPI_Feature::feature(aMirrLineRefAttr->object()));
 
   AttributeRefListPtr aBaseRefList =
       myBaseConstraint->reflist(SketchPlugin_Constraint::ENTITY_B());
@@ -120,6 +138,10 @@ void SketchSolver_ConstraintMirror::adjustConstraint()
     FeaturePtr aBase = ModelAPI_Feature::feature(*aBIt);
     FeaturePtr aMirrored = ModelAPI_Feature::feature(*aMIt);
     mirrorEntities(aMirrorLine, aBase, aMirrored);
+
+    // update mirrored entity if it exists in the storage
+    if (myStorage->entity(aMirrored))
+      myStorage->update(aMirrored);
   }
 }
 
@@ -166,13 +188,18 @@ void mirrorEntities(const std::shared_ptr<GeomAPI_Lin2d>& theMirrorLine,
   // process specific features
   if (theOriginal->getKind() == SketchPlugin_Arc::ID()) {
     // orientation of arc
-    theMirrored->boolean(SketchPlugin_Arc::INVERSED_ID())->setValue(
-        !theOriginal->boolean(SketchPlugin_Arc::INVERSED_ID())->value());
+    theMirrored->boolean(SketchPlugin_Arc::REVERSED_ID())->setValue(
+        !theOriginal->boolean(SketchPlugin_Arc::REVERSED_ID())->value());
   } else if (theOriginal->getKind() == SketchPlugin_Circle::ID()) {
     // radius of the circle
     theMirrored->real(SketchPlugin_Circle::RADIUS_ID())->setValue(
         theOriginal->real(SketchPlugin_Circle::RADIUS_ID())->value());
   }
+  else if (theOriginal->getKind() == SketchPlugin_EllipticArc::ID()) {
+    // orientation of arc
+    theMirrored->boolean(SketchPlugin_EllipticArc::REVERSED_ID())->setValue(
+        !theOriginal->boolean(SketchPlugin_EllipticArc::REVERSED_ID())->value());
+  }
 
   // mirror all initialized points of features
   std::list<AttributePtr>::iterator anIt0, anIt1;