Salome HOME
a1e66e5871c1e58650a0f87a9b3a7cbc9918023d
[modules/shaper.git] / src / SketchSolver / PlaneGCSSolver / PlaneGCSSolver_PointWrapper.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:    PlaneGCSSolver_PointWrapper.cpp
4 // Created: 14 Dec 2015
5 // Author:  Artem ZHIDKOV
6
7 #include <PlaneGCSSolver_PointWrapper.h>
8
9 PlaneGCSSolver_PointWrapper::PlaneGCSSolver_PointWrapper(
10     const AttributePtr theAttribute, const GCSPointPtr thePoint)
11   : myPoint(thePoint),
12     myID(EID_UNKNOWN)
13 {
14   myBaseAttribute = theAttribute;
15 }
16
17 void PlaneGCSSolver_PointWrapper::setGroup(const GroupID& theGroup)
18 {
19   myGroup = theGroup;
20   std::list<EntityWrapperPtr>::iterator aSubsIt = mySubEntities.begin();
21   for (; aSubsIt != mySubEntities.end(); ++aSubsIt)
22     (*aSubsIt)->setGroup(theGroup);
23   std::list<ParameterWrapperPtr>::iterator aPIt = myParameters.begin();
24   for (; aPIt != myParameters.end(); ++aPIt)
25     (*aPIt)->setGroup(theGroup);
26 }
27
28 bool PlaneGCSSolver_PointWrapper::isUsed(AttributePtr theAttribute) const
29 {
30   return isBase(theAttribute);
31 }
32
33 bool PlaneGCSSolver_PointWrapper::isEqual(const EntityWrapperPtr& theOther)
34 {
35   if (type() != theOther->type())
36     return false;
37
38   // Verify equality of parameters
39   const std::list<ParameterWrapperPtr>& anOtherParams = theOther->parameters();
40   if (myParameters.size() != anOtherParams.size())
41     return false;
42   std::list<ParameterWrapperPtr>::const_iterator aMyIt = myParameters.begin();
43   std::list<ParameterWrapperPtr>::const_iterator anOtherIt = anOtherParams.begin();
44   for (; aMyIt != myParameters.end(); ++aMyIt, ++anOtherIt)
45     if (!(*aMyIt)->isEqual(*anOtherIt))
46       return false;
47   return true;
48 }
49
50 bool PlaneGCSSolver_PointWrapper::update(const EntityWrapperPtr& theOther)
51 {
52   bool isUpdated = false;
53   std::list<ParameterWrapperPtr> aMyParams = parameters();
54   std::list<ParameterWrapperPtr> anOtherParams = theOther->parameters();
55   std::list<ParameterWrapperPtr>::const_iterator aMyParIt = aMyParams.begin();
56   std::list<ParameterWrapperPtr>::const_iterator anOtherParIt = anOtherParams.begin();
57   for (; aMyParIt != aMyParams.end() && anOtherParIt != anOtherParams.end();
58       ++aMyParIt, ++anOtherParIt)
59     isUpdated = (*aMyParIt)->update(*anOtherParIt);
60   return isUpdated;
61 }