Salome HOME
Copyright update 2021
[modules/shaper.git] / src / SketchSolver / PlaneGCSSolver / PlaneGCSSolver_EntityDestroyer.cpp
index 697d2db5c0c6f9a9be17bb49cf073ea2c1318955..8d9e7b942eecb586a1ed2bfa18bb5eadccf9d641 100644 (file)
@@ -1,87 +1,34 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File:    PlaneGCSSolver_EntityDestroyer.cpp
-// Created: 10 Feb 2017
-// Author:  Artem ZHIDKOV
+// Copyright (C) 2014-2021  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 <PlaneGCSSolver_EntityDestroyer.h>
 
 #include <PlaneGCSSolver_PointWrapper.h>
 #include <PlaneGCSSolver_ScalarWrapper.h>
-#include <PlaneGCSSolver_EntityWrapper.h>
-
-static void destroyScalar(const EntityWrapperPtr& theEntity, GCS::SET_pD& theParams)
-{
-  ScalarWrapperPtr aScalar = std::dynamic_pointer_cast<PlaneGCSSolver_ScalarWrapper>(theEntity);
-  theParams.insert(aScalar->scalar());
-}
-
-static void destroyPoint(const EntityWrapperPtr& theEntity, GCS::SET_pD& theParams)
-{
-  std::shared_ptr<PlaneGCSSolver_PointWrapper> aPoint =
-      std::dynamic_pointer_cast<PlaneGCSSolver_PointWrapper>(theEntity);
-  theParams.insert(aPoint->point()->x);
-  theParams.insert(aPoint->point()->y);
-}
-
-static void destroyLine(const EntityWrapperPtr& theEntity, GCS::SET_pD& theParams)
-{
-  std::shared_ptr<PlaneGCSSolver_EntityWrapper> anEntity =
-      std::dynamic_pointer_cast<PlaneGCSSolver_EntityWrapper>(theEntity);
-  std::shared_ptr<GCS::Line> aLine = std::dynamic_pointer_cast<GCS::Line>(anEntity->entity());
-  theParams.insert(aLine->p1.x);
-  theParams.insert(aLine->p1.y);
-  theParams.insert(aLine->p2.x);
-  theParams.insert(aLine->p2.y);
-}
-
-static void destroyCircle(const EntityWrapperPtr& theEntity, GCS::SET_pD& theParams)
-{
-  std::shared_ptr<PlaneGCSSolver_EntityWrapper> anEntity =
-      std::dynamic_pointer_cast<PlaneGCSSolver_EntityWrapper>(theEntity);
-  std::shared_ptr<GCS::Circle> aCirc = std::dynamic_pointer_cast<GCS::Circle>(anEntity->entity());
-  theParams.insert(aCirc->center.x);
-  theParams.insert(aCirc->center.y);
-  theParams.insert(aCirc->rad);
-}
-
-static void destroyArc(const EntityWrapperPtr& theEntity, GCS::SET_pD& theParams)
-{
-  std::shared_ptr<PlaneGCSSolver_EntityWrapper> anEntity =
-      std::dynamic_pointer_cast<PlaneGCSSolver_EntityWrapper>(theEntity);
-  std::shared_ptr<GCS::Arc> anArc = std::dynamic_pointer_cast<GCS::Arc>(anEntity->entity());
-  theParams.insert(anArc->center.x);
-  theParams.insert(anArc->center.y);
-  theParams.insert(anArc->start.x);
-  theParams.insert(anArc->start.y);
-  theParams.insert(anArc->end.x);
-  theParams.insert(anArc->end.y);
-  theParams.insert(anArc->startAngle);
-  theParams.insert(anArc->endAngle);
-  theParams.insert(anArc->rad);
-}
+#include <PlaneGCSSolver_EdgeWrapper.h>
+#include <PlaneGCSSolver_Tools.h>
 
 void PlaneGCSSolver_EntityDestroyer::remove(const EntityWrapperPtr& theEntity)
 {
-  GCS::SET_pD& aParamSet = theEntity->isExternal() ? myParamsOutOfStorage : myParams;
-
-  switch (theEntity->type()) {
-  case ENTITY_SCALAR:
-  case ENTITY_ANGLE:
-    destroyScalar(theEntity, aParamSet);
-    break;
-  case ENTITY_POINT:
-    destroyPoint(theEntity, aParamSet);
-    break;
-  case ENTITY_LINE:
-    destroyLine(theEntity, aParamSet);
-    break;
-  case ENTITY_CIRCLE:
-    destroyCircle(theEntity, aParamSet);
-    break;
-  case ENTITY_ARC:
-    destroyArc(theEntity, aParamSet);
-    break;
-  default: break;
-  }
+  GCS::SET_pD aParameters = PlaneGCSSolver_Tools::parameters(theEntity);
+  if (theEntity->isExternal())
+    myParamsOutOfStorage.insert(aParameters.begin(), aParameters.end());
+  else
+    myParams.insert(aParameters.begin(), aParameters.end());
 }