1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: PlaneGCSSolver_ConstraintWrapper.cpp
4 // Created: 14 Dec 2015
5 // Author: Artem ZHIDKOV
7 #include <PlaneGCSSolver_ConstraintWrapper.h>
11 PlaneGCSSolver_ConstraintWrapper::PlaneGCSSolver_ConstraintWrapper(
12 const ConstraintPtr& theOriginal,
13 const GCSConstraintPtr& theConstraint,
14 const SketchSolver_ConstraintType& theType)
15 : myGCSConstraints(1, theConstraint),
19 myBaseConstraint = theOriginal;
23 PlaneGCSSolver_ConstraintWrapper::PlaneGCSSolver_ConstraintWrapper(
24 const ConstraintPtr& theOriginal,
25 const std::list<GCSConstraintPtr>& theConstraints,
26 const SketchSolver_ConstraintType& theType)
27 : myGCSConstraints(theConstraints),
31 myBaseConstraint = theOriginal;
35 void PlaneGCSSolver_ConstraintWrapper::setValueParameter(const ParameterWrapperPtr& theValue)
37 myValueParam = theValue;
38 myValue = myValueParam->value();
41 void PlaneGCSSolver_ConstraintWrapper::setValue(const double& theValue)
44 myValueParam->setValue(theValue);
48 void PlaneGCSSolver_ConstraintWrapper::setGroup(const GroupID& theGroup)
51 std::list<EntityWrapperPtr>::iterator aSubsIt = myConstrained.begin();
52 for (; aSubsIt != myConstrained.end(); ++aSubsIt)
53 (*aSubsIt)->setGroup(theGroup);
56 bool PlaneGCSSolver_ConstraintWrapper::isUsed(FeaturePtr theFeature) const
58 std::list<EntityWrapperPtr>::const_iterator anIt = myConstrained.begin();
59 for (; anIt != myConstrained.end(); ++anIt)
60 if ((*anIt)->isUsed(theFeature))
65 bool PlaneGCSSolver_ConstraintWrapper::isUsed(AttributePtr theAttribute) const
67 std::list<EntityWrapperPtr>::const_iterator anIt = myConstrained.begin();
68 for (; anIt != myConstrained.end(); ++anIt)
69 if ((*anIt)->isUsed(theAttribute))
74 bool PlaneGCSSolver_ConstraintWrapper::isEqual(const ConstraintWrapperPtr& theOther)
76 if (type() != theOther->type())
79 // Verify equality of values
80 if (fabs(myValue - theOther->value()) > tolerance)
83 // Verify equality of entities
84 const std::list<EntityWrapperPtr>& anOtherSubs = theOther->entities();
85 if (myConstrained.size() != anOtherSubs.size())
87 std::list<EntityWrapperPtr>::const_iterator aMySubsIt = myConstrained.begin();
88 std::list<EntityWrapperPtr>::const_iterator anOtherSubsIt = anOtherSubs.begin();
89 for (; aMySubsIt != myConstrained.end(); ++aMySubsIt, ++anOtherSubsIt)
90 if (!(*aMySubsIt)->isEqual(*anOtherSubsIt))
95 bool PlaneGCSSolver_ConstraintWrapper::update(const ConstraintWrapperPtr& theOther)
97 bool isUpdated = false;
99 std::list<EntityWrapperPtr> aMySubs = entities();
100 std::list<EntityWrapperPtr> anOtherSubs = theOther->entities();
101 std::list<EntityWrapperPtr>::const_iterator aMySubsIt = aMySubs.begin();
102 std::list<EntityWrapperPtr>::const_iterator anOtherSubsIt = anOtherSubs.begin();
103 for (; aMySubsIt != aMySubs.end() && anOtherSubsIt != anOtherSubs.end();
104 ++aMySubsIt, ++anOtherSubsIt)
105 isUpdated = (*aMySubsIt)->update(*anOtherSubsIt) || isUpdated;
107 if (fabs(value() - theOther->value()) > tolerance) {
108 myValue = theOther->value();