1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: SketchSolver_Storage.cpp
4 // Created: 30 Nov 2015
5 // Author: Artem ZHIDKOV
7 #include <SketchSolver_Storage.h>
8 #include <SketchSolver_Manager.h>
10 #include <GeomDataAPI_Point2D.h>
11 #include <ModelAPI_AttributeRefAttr.h>
12 #include <ModelAPI_AttributeRefList.h>
13 #include <SketchPlugin_Arc.h>
14 #include <SketchPlugin_Circle.h>
17 /// \brief Verify two vectors of constraints are equal.
18 /// Vectors differ by the order of elements are equal.
19 static bool isEqual(const std::list<ConstraintWrapperPtr>& theCVec1,
20 const std::list<ConstraintWrapperPtr>& theCVec2);
23 void SketchSolver_Storage::addConstraint(ConstraintPtr theConstraint,
24 ConstraintWrapperPtr theSolverConstraint)
26 if (theSolverConstraint) {
27 std::list<ConstraintWrapperPtr> aConstrList(1, theSolverConstraint);
28 addConstraint(theConstraint, aConstrList);
30 addConstraint(theConstraint, std::list<ConstraintWrapperPtr>());
33 void SketchSolver_Storage::addConstraint(
34 ConstraintPtr theConstraint,
35 std::list<ConstraintWrapperPtr> theSolverConstraints)
37 std::map<ConstraintPtr, std::list<ConstraintWrapperPtr> >::const_iterator
38 aFound = myConstraintMap.find(theConstraint);
39 if (aFound == myConstraintMap.end() || !isEqual(aFound->second, theSolverConstraints))
40 setNeedToResolve(true);
42 if (theSolverConstraints.empty()) {
43 // constraint links to the empty list, add its attributes linked to the empty entities
44 std::list<AttributePtr> aRefAttrs =
45 theConstraint->data()->attributes(ModelAPI_AttributeRefAttr::typeId());
46 std::list<AttributePtr>::const_iterator anAttrIt = aRefAttrs.begin();
47 for (; anAttrIt != aRefAttrs.end(); ++anAttrIt) {
48 AttributeRefAttrPtr aRef = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(*anAttrIt);
49 if (aRef->isObject()) {
50 FeaturePtr aFeature = ModelAPI_Feature::feature(aRef->object());
51 if (aFeature) addEntity(aFeature, EntityWrapperPtr());
53 addEntity(aRef->attr(), EntityWrapperPtr());
55 std::list<AttributePtr> aRefLists =
56 theConstraint->data()->attributes(ModelAPI_AttributeRefList::typeId());
57 for (anAttrIt = aRefLists.begin(); anAttrIt != aRefLists.end(); ++anAttrIt) {
58 AttributeRefListPtr aRef = std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(*anAttrIt);
59 std::list<ObjectPtr> anObj = aRef->list();
60 std::list<ObjectPtr>::iterator anIt = anObj.begin();
61 for (; anIt != anObj.end(); ++anIt) {
62 FeaturePtr aFeature = ModelAPI_Feature::feature(*anIt);
63 if (aFeature) addEntity(aFeature, EntityWrapperPtr());
67 else if (theSolverConstraints.front()->type() != CONSTRAINT_PT_PT_COINCIDENT) {
68 // Do not add point-point coincidence, because it is already made by setting
69 // the same parameters for both points
70 std::list<ConstraintWrapperPtr>::iterator aCIt = theSolverConstraints.begin();
71 for (; aCIt != theSolverConstraints.end(); ++aCIt)
74 myConstraintMap[theConstraint] = theSolverConstraints;
75 // block events if necessary
76 if (myEventsBlocked && theConstraint->data() && theConstraint->data()->isValid())
77 theConstraint->data()->blockSendAttributeUpdated(myEventsBlocked);
80 void SketchSolver_Storage::addEntity(FeaturePtr theFeature,
81 EntityWrapperPtr theSolverEntity)
83 std::map<FeaturePtr, EntityWrapperPtr>::const_iterator aFound = myFeatureMap.find(theFeature);
84 if (aFound == myFeatureMap.end() || !aFound->second ||
85 (theSolverEntity && !aFound->second->isEqual(theSolverEntity)))
86 setNeedToResolve(true); // the entity is new or modified
88 myFeatureMap[theFeature] = theSolverEntity;
89 // block events if necessary
90 if (myEventsBlocked && theFeature->data() && theFeature->data()->isValid())
91 theFeature->data()->blockSendAttributeUpdated(myEventsBlocked);
94 void SketchSolver_Storage::addEntity(AttributePtr theAttribute,
95 EntityWrapperPtr theSolverEntity)
97 std::map<AttributePtr, EntityWrapperPtr>::const_iterator aFound = myAttributeMap.find(theAttribute);
98 if (aFound == myAttributeMap.end() || !aFound->second ||
99 (theSolverEntity && !aFound->second->isEqual(theSolverEntity)))
100 setNeedToResolve(true); // the entity is new or modified
102 myAttributeMap[theAttribute] = theSolverEntity;
103 // block events if necessary
104 if (myEventsBlocked && theAttribute->owner() &&
105 theAttribute->owner()->data() && theAttribute->owner()->data()->isValid())
106 theAttribute->owner()->data()->blockSendAttributeUpdated(myEventsBlocked);
110 bool SketchSolver_Storage::update(FeaturePtr theFeature, const GroupID& theGroup)
112 bool isUpdated = false;
113 EntityWrapperPtr aRelated = entity(theFeature);
114 if (!aRelated) { // Feature is not exist, create it
115 std::list<EntityWrapperPtr> aSubs;
116 // Reserve the feature in the map of features (do not want to add several copies of it)
117 myFeatureMap[theFeature] = aRelated;
118 // Firstly, create/update its attributes
119 std::list<AttributePtr> anAttrs =
120 theFeature->data()->attributes(GeomDataAPI_Point2D::typeId());
121 std::list<AttributePtr>::const_iterator anIt = anAttrs.begin();
122 for (; anIt != anAttrs.end(); ++anIt) {
123 isUpdated = update(*anIt, theGroup) || isUpdated;
124 aSubs.push_back(entity(*anIt));
126 // If the feature is a circle, add its radius as a sub
127 if (theFeature->getKind() == SketchPlugin_Circle::ID()) {
128 AttributePtr aRadius = theFeature->attribute(SketchPlugin_Circle::RADIUS_ID());
129 isUpdated = update(aRadius, theGroup) || isUpdated;
130 aSubs.push_back(entity(aRadius));
132 // If the feature if circle or arc, we need to add normal of the sketch to the list of subs
133 if (theFeature->getKind() == SketchPlugin_Arc::ID() ||
134 theFeature->getKind() == SketchPlugin_Circle::ID()) {
135 EntityWrapperPtr aNormal = getNormal();
136 if (aNormal) aSubs.push_back(aNormal);
138 // Secondly, convert feature
139 BuilderPtr aBuilder = SketchSolver_Manager::instance()->builder();
140 GroupID aGroup = theGroup != GID_UNKNOWN ? theGroup : myGroupID;
141 aRelated = aBuilder->createFeature(theFeature, aSubs, aGroup);
144 addEntity(theFeature, aRelated);
145 } else if (theGroup != GID_UNKNOWN)
146 changeGroup(aRelated, theGroup);
147 return update(aRelated) || isUpdated;
150 bool SketchSolver_Storage::update(AttributePtr theAttribute, const GroupID& theGroup)
152 AttributePtr anAttribute = theAttribute;
153 AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(anAttribute);
155 if (aRefAttr->isObject()) {
156 FeaturePtr aFeature = ModelAPI_Feature::feature(aRefAttr->object());
157 return update(aFeature, theGroup);
159 anAttribute = aRefAttr->attr();
162 EntityWrapperPtr aRelated = entity(anAttribute);
163 if (!aRelated) { // Attribute is not exist, create it
164 // verify the attribute is a point of arc and add whole arc
165 if (anAttribute->owner()) {
166 FeaturePtr aFeature = ModelAPI_Feature::feature(anAttribute->owner());
167 if (aFeature->getKind() == SketchPlugin_Arc::ID() &&
168 myFeatureMap.find(aFeature) == myFeatureMap.end()) {
169 // Additional checking that all attributes are initialized
170 if (aFeature->attribute(SketchPlugin_Arc::CENTER_ID())->isInitialized() &&
171 aFeature->attribute(SketchPlugin_Arc::START_ID())->isInitialized() &&
172 aFeature->attribute(SketchPlugin_Arc::END_ID())->isInitialized()) {
173 //// myFeatureMap[aFeature] = EntityWrapperPtr();
174 return SketchSolver_Storage::update(aFeature);
178 BuilderPtr aBuilder = SketchSolver_Manager::instance()->builder();
179 GroupID aGroup = theGroup != GID_UNKNOWN ? theGroup : myGroupID;
180 aRelated = aBuilder->createAttribute(anAttribute, aGroup);
183 addEntity(anAttribute, aRelated);
184 } else if (theGroup != GID_UNKNOWN)
185 changeGroup(aRelated, theGroup);
186 return update(aRelated);
191 const std::list<ConstraintWrapperPtr>& SketchSolver_Storage::constraint(
192 const ConstraintPtr& theConstraint) const
194 static std::list<ConstraintWrapperPtr> aDummy;
196 std::map<ConstraintPtr, std::list<ConstraintWrapperPtr>>::const_iterator
197 aFound = myConstraintMap.find(theConstraint);
198 if (aFound != myConstraintMap.end())
199 return aFound->second;
203 const EntityWrapperPtr& SketchSolver_Storage::entity(const FeaturePtr& theFeature) const
205 static EntityWrapperPtr aDummy;
207 std::map<FeaturePtr, EntityWrapperPtr>::const_iterator aFound = myFeatureMap.find(theFeature);
208 if (aFound != myFeatureMap.end())
209 return aFound->second;
213 const EntityWrapperPtr& SketchSolver_Storage::entity(const AttributePtr& theAttribute) const
215 static EntityWrapperPtr aDummy;
217 std::map<AttributePtr, EntityWrapperPtr>::const_iterator
218 aFound = myAttributeMap.find(theAttribute);
219 if (aFound != myAttributeMap.end())
220 return aFound->second;
222 AttributeRefAttrPtr aRefAttr =
223 std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
225 if (aRefAttr->isObject()) {
226 FeaturePtr aFeature = ModelAPI_Feature::feature(aRefAttr->object());
227 return entity(aFeature);
229 return entity(aRefAttr->attr());
234 bool SketchSolver_Storage::removeConstraint(ConstraintPtr theConstraint)
236 std::map<ConstraintPtr, std::list<ConstraintWrapperPtr> >::iterator
237 aFound = myConstraintMap.find(theConstraint);
238 if (aFound == myConstraintMap.end())
239 return true; // no constraint, already deleted
242 std::list<ConstraintWrapperPtr> aConstrList = aFound->second;
243 myConstraintMap.erase(aFound);
244 // Remove SolveSpace constraints
245 bool isFullyRemoved = true;
246 std::list<ConstraintWrapperPtr>::iterator anIt = aConstrList.begin();
247 while (anIt != aConstrList.end()) {
249 std::list<ConstraintWrapperPtr>::iterator aRemoveIt = anIt++;
250 aConstrList.erase(aRemoveIt);
252 isFullyRemoved = false;
256 return isFullyRemoved;
259 template <class ENT_TYPE>
260 static bool isUsed(ConstraintWrapperPtr theConstraint, ENT_TYPE theEntity)
262 std::list<EntityWrapperPtr>::const_iterator anEntIt = theConstraint->entities().begin();
263 for (; anEntIt != theConstraint->entities().end(); ++anEntIt)
264 if ((*anEntIt)->isBase(theEntity))
269 static bool isUsed(EntityWrapperPtr theFeature, AttributePtr theSubEntity)
271 std::list<EntityWrapperPtr>::const_iterator aSubIt = theFeature->subEntities().begin();
272 for (; aSubIt != theFeature->subEntities().end(); ++aSubIt)
273 if ((*aSubIt)->isBase(theSubEntity))
278 bool SketchSolver_Storage::isUsed(FeaturePtr theFeature) const
280 if (myFeatureMap.find(theFeature) != myFeatureMap.end())
283 std::map<ConstraintPtr, std::list<ConstraintWrapperPtr> >::const_iterator
284 aCIt = myConstraintMap.begin();
285 std::list<ConstraintWrapperPtr>::const_iterator aCWIt;
286 for (; aCIt != myConstraintMap.end(); ++aCIt)
287 for (aCWIt = aCIt->second.begin(); aCWIt != aCIt->second.end(); ++aCWIt)
288 if (::isUsed(*aCWIt, theFeature))
291 std::list<AttributePtr> anAttrList = theFeature->data()->attributes(GeomDataAPI_Point2D::typeId());
292 std::list<AttributePtr>::const_iterator anIt = anAttrList.begin();
293 for (; anIt != anAttrList.end(); ++anIt)
299 bool SketchSolver_Storage::isUsed(AttributePtr theAttribute) const
301 AttributePtr anAttribute = theAttribute;
302 AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(anAttribute);
304 if (aRefAttr->isObject())
305 return isUsed(ModelAPI_Feature::feature(aRefAttr->object()));
307 anAttribute = aRefAttr->attr();
310 if (myAttributeMap.find(theAttribute) != myAttributeMap.end())
312 // check in constraints
313 std::map<ConstraintPtr, std::list<ConstraintWrapperPtr> >::const_iterator
314 aCIt = myConstraintMap.begin();
315 std::list<ConstraintWrapperPtr>::const_iterator aCWIt;
316 for (; aCIt != myConstraintMap.end(); ++aCIt)
317 for (aCWIt = aCIt->second.begin(); aCWIt != aCIt->second.end(); ++aCWIt)
318 if (::isUsed(*aCWIt, anAttribute))
321 std::map<FeaturePtr, EntityWrapperPtr>::const_iterator aFIt = myFeatureMap.begin();
322 for (; aFIt != myFeatureMap.end(); ++aFIt)
323 if (::isUsed(aFIt->second, anAttribute))
329 bool SketchSolver_Storage::removeEntity(FeaturePtr theFeature)
331 std::map<FeaturePtr, EntityWrapperPtr>::iterator aFound = myFeatureMap.find(theFeature);
332 if (aFound == myFeatureMap.end())
333 return false; // feature not found, nothing to delete
335 EntityWrapperPtr anEntity = aFound->second;
336 myFeatureMap.erase(aFound);
338 // Check if the feature is not used by constraints, remove it
339 if (!isUsed(theFeature) && remove(anEntity))
342 // feature is not removed, revert operation
343 myFeatureMap[theFeature] = anEntity;
348 bool SketchSolver_Storage::removeEntity(AttributePtr theAttribute)
350 std::map<AttributePtr, EntityWrapperPtr>::iterator aFound = myAttributeMap.find(theAttribute);
351 if (aFound == myAttributeMap.end())
352 return false; // attribute not found, nothing to delete
354 EntityWrapperPtr anEntity = aFound->second;
355 myAttributeMap.erase(aFound);
357 // Check if the attribute is not used by constraints and features, remove it
358 if (!isUsed(theAttribute) && remove(anEntity))
361 // attribute is not removed, revert operation
362 myAttributeMap[theAttribute] = anEntity;
368 bool SketchSolver_Storage::remove(ConstraintWrapperPtr theConstraint)
370 bool isFullyRemoved = true;
371 std::list<EntityWrapperPtr>::const_iterator anIt = theConstraint->entities().begin();
372 for (; anIt != theConstraint->entities().end(); ++anIt) {
373 FeaturePtr aBaseFeature = (*anIt)->baseFeature();
375 isFullyRemoved = SketchSolver_Storage::removeEntity(aBaseFeature) && isFullyRemoved;
377 isFullyRemoved = SketchSolver_Storage::removeEntity((*anIt)->baseAttribute()) && isFullyRemoved;
379 return isFullyRemoved;
382 bool SketchSolver_Storage::remove(EntityWrapperPtr theEntity)
384 bool isFullyRemoved = true;
385 std::list<EntityWrapperPtr>::const_iterator anEntIt = theEntity->subEntities().begin();
386 for (; anEntIt != theEntity->subEntities().end(); ++anEntIt) {
387 FeaturePtr aBaseFeature = (*anEntIt)->baseFeature();
389 isFullyRemoved = SketchSolver_Storage::removeEntity(aBaseFeature) && isFullyRemoved;
391 isFullyRemoved = SketchSolver_Storage::removeEntity((*anEntIt)->baseAttribute()) && isFullyRemoved;
394 std::list<ParameterWrapperPtr>::const_iterator aParIt = theEntity->parameters().begin();
395 for (; aParIt != theEntity->parameters().end(); ++aParIt)
396 isFullyRemoved = remove(*aParIt) && isFullyRemoved;
397 return isFullyRemoved;
401 bool SketchSolver_Storage::isInteract(const FeaturePtr& theFeature) const
405 if (myConstraintMap.empty())
406 return true; // empty storage interacts with each feature
408 ConstraintPtr aConstraint = std::dynamic_pointer_cast<SketchPlugin_Constraint>(theFeature);
410 if (myConstraintMap.find(aConstraint) != myConstraintMap.end())
412 } else if (myFeatureMap.find(theFeature) != myFeatureMap.end())
415 std::list<AttributePtr> anAttrList = theFeature->data()->attributes(std::string());
416 std::list<AttributePtr>::const_iterator anIt = anAttrList.begin();
417 for (; anIt != anAttrList.end(); ++anIt)
418 if (isInteract(*anIt))
424 bool SketchSolver_Storage::isInteract(const AttributePtr& theAttribute) const
429 AttributeRefListPtr aRefList =
430 std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(theAttribute);
432 std::list<ObjectPtr> anObjects = aRefList->list();
433 std::list<ObjectPtr>::iterator anObjIt = anObjects.begin();
434 for (; anObjIt != anObjects.end(); ++anObjIt) {
435 FeaturePtr aFeature = ModelAPI_Feature::feature(*anObjIt);
436 if (isInteract(aFeature))
442 AttributeRefAttrPtr aRefAttr =
443 std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
445 return myAttributeMap.find(theAttribute) != myAttributeMap.end();
446 if (!aRefAttr->isObject())
447 return myAttributeMap.find(aRefAttr->attr()) != myAttributeMap.end();
449 FeaturePtr aFeature = ModelAPI_Feature::feature(aRefAttr->object());
450 return isInteract(aFeature);
453 bool SketchSolver_Storage::isConsistent() const
455 // Check the constraints are valid
456 std::map<ConstraintPtr, std::list<ConstraintWrapperPtr> >::const_iterator
457 aCIter = myConstraintMap.begin();
458 for (; aCIter != myConstraintMap.end(); ++aCIter)
459 if (!aCIter->first->data() || !aCIter->first->data()->isValid())
461 // Check the features are valid
462 std::map<FeaturePtr, EntityWrapperPtr>::const_iterator aFIter = myFeatureMap.begin();
463 for (; aFIter != myFeatureMap.end(); aFIter++)
464 if (!aFIter->first->data() || !aFIter->first->data()->isValid())
469 bool SketchSolver_Storage::isFixed(EntityWrapperPtr theEntity) const
471 if (theEntity->group() != myGroupID)
473 // no need additional checking for entities differ than point
474 if (theEntity->type() != ENTITY_POINT)
477 CoincidentPointsMap::const_iterator anIt = myCoincidentPoints.begin();
478 for (; anIt != myCoincidentPoints.end(); ++anIt)
479 if (anIt->first == theEntity || anIt->second.find(theEntity) != anIt->second.end()) {
480 if (anIt->first->group() != myGroupID)
482 std::set<EntityWrapperPtr>::const_iterator anEntIt = anIt->second.begin();
483 for (; anEntIt != anIt->second.end(); ++anEntIt)
484 if ((*anEntIt)->group() != myGroupID)
488 std::map<ConstraintPtr, std::list<ConstraintWrapperPtr> >::const_iterator aCIt = myConstraintMap.begin();
489 std::list<ConstraintWrapperPtr>::const_iterator aCWIt;
490 for (; aCIt != myConstraintMap.end(); ++aCIt) {
491 if (aCIt->second.empty())
493 aCWIt = aCIt->second.begin();
494 if ((*aCWIt)->type() != CONSTRAINT_FIXED)
496 for (; aCWIt != aCIt->second.end(); ++aCIt)
497 if ((theEntity->baseAttribute() && (*aCWIt)->isUsed(theEntity->baseAttribute())) ||
498 (theEntity->baseFeature() && (*aCWIt)->isUsed(theEntity->baseFeature())))
505 void SketchSolver_Storage::removeInvalidEntities()
507 // Remove invalid constraints
508 std::list<ConstraintPtr> anInvalidConstraints;
509 std::map<ConstraintPtr, std::list<ConstraintWrapperPtr> >::const_iterator
510 aCIter = myConstraintMap.begin();
511 for (; aCIter != myConstraintMap.end(); ++aCIter)
512 if (!aCIter->first->data() || !aCIter->first->data()->isValid())
513 anInvalidConstraints.push_back(aCIter->first);
514 std::list<ConstraintPtr>::const_iterator anInvCIt = anInvalidConstraints.begin();
515 for (; anInvCIt != anInvalidConstraints.end(); ++anInvCIt)
516 removeConstraint(*anInvCIt);
517 // Remove invalid features
518 std::list<FeaturePtr> anInvalidFeatures;
519 std::map<FeaturePtr, EntityWrapperPtr>::const_iterator aFIter = myFeatureMap.begin();
520 for (; aFIter != myFeatureMap.end(); aFIter++)
521 if (!aFIter->first->data() || !aFIter->first->data()->isValid())
522 anInvalidFeatures.push_back(aFIter->first);
523 std::list<FeaturePtr>::const_iterator anInvFIt = anInvalidFeatures.begin();
524 for (; anInvFIt != anInvalidFeatures.end(); ++anInvFIt)
525 removeEntity(*anInvFIt);
528 EntityWrapperPtr SketchSolver_Storage::getNormal() const
530 EntityWrapperPtr aSketch = sketch();
534 // Find normal entity
535 const std::list<EntityWrapperPtr>& aSketchSubs = aSketch->subEntities();
536 std::list<EntityWrapperPtr>::const_iterator aSIt = aSketchSubs.begin();
537 for (; aSIt != aSketchSubs.end(); ++aSIt)
538 if ((*aSIt)->type() == ENTITY_NORMAL)
540 return EntityWrapperPtr();
543 const EntityWrapperPtr& SketchSolver_Storage::sketch() const
545 static EntityWrapperPtr aDummySketch;
547 std::map<FeaturePtr, EntityWrapperPtr>::const_iterator aFIt = myFeatureMap.begin();
548 for (; aFIt != myFeatureMap.end(); ++aFIt)
549 if (aFIt->second && aFIt->second->type() == ENTITY_SKETCH)
551 if (aFIt == myFeatureMap.end())
556 void SketchSolver_Storage::setSketch(const EntityWrapperPtr& theSketch)
560 addEntity(FeaturePtr(), theSketch);
563 void SketchSolver_Storage::blockEvents(bool isBlocked)
565 if (isBlocked == myEventsBlocked)
568 std::map<ConstraintPtr, std::list<ConstraintWrapperPtr> >::const_iterator
569 aCIter = myConstraintMap.begin();
570 for (; aCIter != myConstraintMap.end(); aCIter++)
571 if (aCIter->first->data() && aCIter->first->data()->isValid())
572 aCIter->first->data()->blockSendAttributeUpdated(isBlocked);
574 std::map<FeaturePtr, EntityWrapperPtr>::const_iterator aFIter = myFeatureMap.begin();
575 for (; aFIter != myFeatureMap.end(); aFIter++)
576 if (aFIter->first->data() && aFIter->first->data()->isValid())
577 aFIter->first->data()->blockSendAttributeUpdated(isBlocked);
579 std::map<AttributePtr, EntityWrapperPtr>::const_iterator anAtIter = myAttributeMap.begin();
580 for (; anAtIter != myAttributeMap.end(); anAtIter++)
581 if (anAtIter->first->owner() && anAtIter->first->owner()->data() &&
582 anAtIter->first->owner()->data()->isValid())
583 anAtIter->first->owner()->data()->blockSendAttributeUpdated(isBlocked);
584 myEventsBlocked = isBlocked;
592 // ============== Auxiliary functions ====================================
593 bool isEqual(const std::list<ConstraintWrapperPtr>& theCVec1,
594 const std::list<ConstraintWrapperPtr>& theCVec2)
596 if (theCVec1.size() != theCVec2.size())
599 std::list<bool> aChecked(theCVec2.size(), false);
600 std::list<ConstraintWrapperPtr>::const_iterator anIt1 = theCVec1.begin();
601 for (; anIt1 != theCVec1.end(); ++anIt1) {
602 std::list<ConstraintWrapperPtr>::const_iterator anIt2 = theCVec2.begin();
603 std::list<bool>::iterator aCheckIt = aChecked.begin();
604 while (aCheckIt != aChecked.end() && *aCheckIt) {
608 for (; anIt2 != theCVec2.end(); ++anIt2, ++aCheckIt)
609 if (!(*aCheckIt) && (*anIt1)->isEqual(*anIt2)) {
613 // the same constraint is not found
614 if (anIt2 == theCVec2.end())