]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_ConstraintWrapper.cpp
Salome HOME
SketchSolver Refactoring: Eliminate SolveSpace as a sketch solver.
[modules/shaper.git] / src / SketchSolver / PlaneGCSSolver / PlaneGCSSolver_ConstraintWrapper.cpp
index a2be38efe0ea444771532bb37d0e1069005be4e9..a9924a77343c99319d5956e31f59eab17ec38eb5 100644 (file)
@@ -6,30 +6,22 @@
 
 #include <PlaneGCSSolver_ConstraintWrapper.h>
 
-#include <math.h>
-
 PlaneGCSSolver_ConstraintWrapper::PlaneGCSSolver_ConstraintWrapper(
-    const ConstraintPtr& theOriginal,
     const GCSConstraintPtr& theConstraint,
     const SketchSolver_ConstraintType& theType)
   : myGCSConstraints(1, theConstraint),
-    myType(theType),
-    myID(CID_UNKNOWN)
+    myType(theType)
 {
-  myBaseConstraint = theOriginal;
-  myValue = 0.0;
+  myID = CID_UNKNOWN;
 }
 
 PlaneGCSSolver_ConstraintWrapper::PlaneGCSSolver_ConstraintWrapper(
-    const ConstraintPtr& theOriginal,
     const std::list<GCSConstraintPtr>& theConstraints,
     const SketchSolver_ConstraintType& theType)
   : myGCSConstraints(theConstraints),
-    myType(theType),
-    myID(CID_UNKNOWN)
+    myType(theType)
 {
-  myBaseConstraint = theOriginal;
-  myValue = 0.0;
+  myID = CID_UNKNOWN;
 }
 
 void PlaneGCSSolver_ConstraintWrapper::setId(const ConstraintID& theID)
@@ -40,81 +32,17 @@ void PlaneGCSSolver_ConstraintWrapper::setId(const ConstraintID& theID)
     (*anIt)->setTag((int)theID);
 }
 
-void PlaneGCSSolver_ConstraintWrapper::setValueParameter(const ParameterWrapperPtr& theValue)
+void PlaneGCSSolver_ConstraintWrapper::setValueParameter(const ScalarWrapperPtr& theValue)
 {
   myValueParam = theValue;
-  myValue = myValueParam->value();
 }
 
 void PlaneGCSSolver_ConstraintWrapper::setValue(const double& theValue)
 {
-  myValue = theValue;
   myValueParam->setValue(theValue);
 }
 
-
-void PlaneGCSSolver_ConstraintWrapper::setGroup(const GroupID& theGroup)
-{
-  myGroup = theGroup;
-  std::list<EntityWrapperPtr>::iterator aSubsIt = myConstrained.begin();
-  for (; aSubsIt != myConstrained.end(); ++aSubsIt)
-    (*aSubsIt)->setGroup(theGroup);
-}
-
-bool PlaneGCSSolver_ConstraintWrapper::isUsed(FeaturePtr theFeature) const
-{
-  std::list<EntityWrapperPtr>::const_iterator anIt = myConstrained.begin();
-  for (; anIt != myConstrained.end(); ++anIt)
-    if ((*anIt)->isUsed(theFeature))
-      return true;
-  return false;
-}
-
-bool PlaneGCSSolver_ConstraintWrapper::isUsed(AttributePtr theAttribute) const
-{
-  std::list<EntityWrapperPtr>::const_iterator anIt = myConstrained.begin();
-  for (; anIt != myConstrained.end(); ++anIt)
-    if ((*anIt)->isUsed(theAttribute))
-      return true;
-  return false;
-}
-
-bool PlaneGCSSolver_ConstraintWrapper::isEqual(const ConstraintWrapperPtr& theOther)
+double PlaneGCSSolver_ConstraintWrapper::value() const
 {
-  if (type() != theOther->type())
-    return false;
-
-  // Verify equality of values
-  if (fabs(myValue - theOther->value()) > tolerance)
-    return false;
-
-  // Verify equality of entities
-  const std::list<EntityWrapperPtr>& anOtherSubs = theOther->entities();
-  if (myConstrained.size() != anOtherSubs.size())
-    return false;
-  std::list<EntityWrapperPtr>::const_iterator aMySubsIt = myConstrained.begin();
-  std::list<EntityWrapperPtr>::const_iterator anOtherSubsIt = anOtherSubs.begin();
-  for (; aMySubsIt != myConstrained.end(); ++aMySubsIt, ++anOtherSubsIt)
-    if (!(*aMySubsIt)->isEqual(*anOtherSubsIt))
-      return false;
-  return true;
-}
-
-bool PlaneGCSSolver_ConstraintWrapper::update(const ConstraintWrapperPtr& theOther)
-{
-  bool isUpdated = false;
-
-  std::list<EntityWrapperPtr> aMySubs = entities();
-  std::list<EntityWrapperPtr> anOtherSubs = theOther->entities();
-  std::list<EntityWrapperPtr>::const_iterator aMySubsIt = aMySubs.begin();
-  std::list<EntityWrapperPtr>::const_iterator anOtherSubsIt = anOtherSubs.begin();
-  for (; aMySubsIt != aMySubs.end() && anOtherSubsIt != anOtherSubs.end();
-       ++aMySubsIt, ++anOtherSubsIt)
-     isUpdated = (*aMySubsIt)->update(*anOtherSubsIt) || isUpdated;
-
-  if (fabs(value() - theOther->value()) > tolerance) {
-    myValue = theOther->value();
-    isUpdated = true;
-  }
-  return isUpdated;
+  return myValueParam->value();
 }