1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: PlaneGCSSolver_EntityDestroyer.cpp
4 // Created: 10 Feb 2017
5 // Author: Artem ZHIDKOV
7 #include <PlaneGCSSolver_EntityDestroyer.h>
9 #include <PlaneGCSSolver_PointWrapper.h>
10 #include <PlaneGCSSolver_ScalarWrapper.h>
11 #include <PlaneGCSSolver_EdgeWrapper.h>
13 static void destroyScalar(const EntityWrapperPtr& theEntity, GCS::SET_pD& theParams)
15 ScalarWrapperPtr aScalar = std::dynamic_pointer_cast<PlaneGCSSolver_ScalarWrapper>(theEntity);
16 theParams.insert(aScalar->scalar());
19 static void destroyPoint(const EntityWrapperPtr& theEntity, GCS::SET_pD& theParams)
21 std::shared_ptr<PlaneGCSSolver_PointWrapper> aPoint =
22 std::dynamic_pointer_cast<PlaneGCSSolver_PointWrapper>(theEntity);
23 theParams.insert(aPoint->point()->x);
24 theParams.insert(aPoint->point()->y);
27 static void destroyLine(const EntityWrapperPtr& theEntity, GCS::SET_pD& theParams)
29 std::shared_ptr<PlaneGCSSolver_EdgeWrapper> anEntity =
30 std::dynamic_pointer_cast<PlaneGCSSolver_EdgeWrapper>(theEntity);
31 std::shared_ptr<GCS::Line> aLine = std::dynamic_pointer_cast<GCS::Line>(anEntity->entity());
32 theParams.insert(aLine->p1.x);
33 theParams.insert(aLine->p1.y);
34 theParams.insert(aLine->p2.x);
35 theParams.insert(aLine->p2.y);
38 static void destroyCircle(const EntityWrapperPtr& theEntity, GCS::SET_pD& theParams)
40 std::shared_ptr<PlaneGCSSolver_EdgeWrapper> anEntity =
41 std::dynamic_pointer_cast<PlaneGCSSolver_EdgeWrapper>(theEntity);
42 std::shared_ptr<GCS::Circle> aCirc = std::dynamic_pointer_cast<GCS::Circle>(anEntity->entity());
43 theParams.insert(aCirc->center.x);
44 theParams.insert(aCirc->center.y);
45 theParams.insert(aCirc->rad);
48 static void destroyArc(const EntityWrapperPtr& theEntity, GCS::SET_pD& theParams)
50 std::shared_ptr<PlaneGCSSolver_EdgeWrapper> anEntity =
51 std::dynamic_pointer_cast<PlaneGCSSolver_EdgeWrapper>(theEntity);
52 std::shared_ptr<GCS::Arc> anArc = std::dynamic_pointer_cast<GCS::Arc>(anEntity->entity());
53 theParams.insert(anArc->center.x);
54 theParams.insert(anArc->center.y);
55 theParams.insert(anArc->start.x);
56 theParams.insert(anArc->start.y);
57 theParams.insert(anArc->end.x);
58 theParams.insert(anArc->end.y);
59 theParams.insert(anArc->startAngle);
60 theParams.insert(anArc->endAngle);
61 theParams.insert(anArc->rad);
64 void PlaneGCSSolver_EntityDestroyer::remove(const EntityWrapperPtr& theEntity)
66 GCS::SET_pD& aParamSet = theEntity->isExternal() ? myParamsOutOfStorage : myParams;
68 switch (theEntity->type()) {
71 destroyScalar(theEntity, aParamSet);
74 destroyPoint(theEntity, aParamSet);
77 destroyLine(theEntity, aParamSet);
80 destroyCircle(theEntity, aParamSet);
83 destroyArc(theEntity, aParamSet);