Salome HOME
Merge branch 'Dev_1.1.0' of newgeom:newgeom into Dev_1.1.0
[modules/shaper.git] / src / SketchSolver / SketchSolver_Group.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:    SketchSolver_Group.cpp
4 // Created: 27 May 2014
5 // Author:  Artem ZHIDKOV
6
7 #include "SketchSolver_Group.h"
8
9 #include <SketchSolver_Builder.h>
10 #include <SketchSolver_Constraint.h>
11 #include <SketchSolver_ConstraintCoincidence.h>
12 #include <SketchSolver_Error.h>
13
14 #include <Events_Error.h>
15 #include <Events_Loop.h>
16 #include <GeomAPI_XY.h>
17 #include <GeomAPI_Dir2d.h>
18 #include <GeomAPI_Pnt2d.h>
19 #include <GeomDataAPI_Dir.h>
20 #include <GeomDataAPI_Point.h>
21 #include <GeomDataAPI_Point2D.h>
22 #include <ModelAPI_AttributeDouble.h>
23 #include <ModelAPI_Document.h>
24 #include <ModelAPI_Events.h>
25 #include <ModelAPI_ResultConstruction.h>
26
27 #include <SketchPlugin_Constraint.h>
28 #include <SketchPlugin_ConstraintEqual.h>
29 #include <SketchPlugin_ConstraintFillet.h>
30 #include <SketchPlugin_ConstraintLength.h>
31 #include <SketchPlugin_ConstraintCoincidence.h>
32 #include <SketchPlugin_ConstraintMirror.h>
33 #include <SketchPlugin_ConstraintRigid.h>
34 #include <SketchPlugin_ConstraintTangent.h>
35 #include <SketchPlugin_Feature.h>
36
37 #include <SketchPlugin_Arc.h>
38 #include <SketchPlugin_Circle.h>
39 #include <SketchPlugin_Line.h>
40 #include <SketchPlugin_Point.h>
41 #include <SketchPlugin_Sketch.h>
42
43 #include <math.h>
44 #include <assert.h>
45
46
47 /// \brief This class is used to give unique index to the groups
48 class GroupIndexer
49 {
50 public:
51   /// \brief Return vacant index
52   static Slvs_hGroup NEW_GROUP() { return ++myGroupIndex; }
53   /// \brief Removes the index
54   static void REMOVE_GROUP(const Slvs_hGroup& theIndex) {
55     if (myGroupIndex == theIndex)
56       myGroupIndex--;
57   }
58
59 private:
60   GroupIndexer() {};
61
62   static Slvs_hGroup myGroupIndex; ///< index of the group
63 };
64
65 Slvs_hGroup GroupIndexer::myGroupIndex = 0;
66
67
68
69 // ========================================================
70 // =========  SketchSolver_Group  ===============
71 // ========================================================
72
73 SketchSolver_Group::SketchSolver_Group(
74     std::shared_ptr<ModelAPI_CompositeFeature> theWorkplane)
75     : myID(GroupIndexer::NEW_GROUP())
76 {
77   // Initialize workplane
78   myWorkplaneID = SLVS_E_UNKNOWN;
79 #ifndef NDEBUG
80   assert(addWorkplane(theWorkplane));
81 #else
82   addWorkplane(theWorkplane);
83 #endif
84 }
85
86 SketchSolver_Group::~SketchSolver_Group()
87 {
88   myConstraints.clear();
89   GroupIndexer::REMOVE_GROUP(myID);
90 }
91
92 // ============================================================================
93 //  Function: isBaseWorkplane
94 //  Class:    SketchSolver_Group
95 //  Purpose:  verify the group is based on the given workplane
96 // ============================================================================
97 bool SketchSolver_Group::isBaseWorkplane(CompositeFeaturePtr theWorkplane) const
98 {
99   return theWorkplane == mySketch;
100 }
101
102 // ============================================================================
103 //  Function: isInteract
104 //  Class:    SketchSolver_Group
105 //  Purpose:  verify are there any entities in the group used by given constraint
106 // ============================================================================
107 bool SketchSolver_Group::isInteract(
108     std::shared_ptr<SketchPlugin_Feature> theFeature) const
109 {
110   // Empty group interacts with everything
111   if (isEmpty()) return true;
112   ConstraintPtr aConstraint = std::dynamic_pointer_cast<SketchPlugin_Constraint>(theFeature);
113   if (aConstraint)
114     return myFeatureStorage->isInteract(aConstraint);
115   return myFeatureStorage->isInteract(std::dynamic_pointer_cast<ModelAPI_Feature>(theFeature));
116 }
117
118 // ============================================================================
119 //  Function: getFeatureId
120 //  Class:    SketchSolver_Group
121 //  Purpose:  Find the identifier of the feature, if it already exists in the group
122 // ============================================================================
123 Slvs_hEntity SketchSolver_Group::getFeatureId(FeaturePtr theFeature) const
124 {
125   Slvs_hEntity aResult = SLVS_E_UNKNOWN;
126   if (!myFeatureStorage)
127     return aResult;
128   std::set<ConstraintPtr> aConstraints = myFeatureStorage->getConstraints(theFeature);
129   if (aConstraints.empty())
130     return aResult;
131   std::set<ConstraintPtr>::iterator aConstrIter = aConstraints.begin();
132   for (; aConstrIter != aConstraints.end(); aConstrIter++) {
133     ConstraintConstraintMap::const_iterator aCIter = myConstraints.find(*aConstrIter);
134     if (aCIter == myConstraints.end())
135       continue;
136     aResult = aCIter->second->getId(theFeature);
137     if (aResult != SLVS_E_UNKNOWN)
138       return aResult;
139   }
140   return SLVS_E_UNKNOWN;
141 }
142
143 // ============================================================================
144 //  Function: getAttributeId
145 //  Class:    SketchSolver_Group
146 //  Purpose:  Find the identifier of the attribute, if it already exists in the group
147 // ============================================================================
148 Slvs_hEntity SketchSolver_Group::getAttributeId(AttributePtr theAttribute) const
149 {
150   Slvs_hEntity aResult = SLVS_E_UNKNOWN;
151   if (!myFeatureStorage)
152     return aResult;
153   std::set<ConstraintPtr> aConstraints = myFeatureStorage->getConstraints(theAttribute);
154   if (aConstraints.empty())
155     return aResult;
156   std::set<ConstraintPtr>::iterator aConstrIter = aConstraints.begin();
157   for (; aConstrIter != aConstraints.end(); aConstrIter++) {
158     ConstraintConstraintMap::const_iterator aCIter = myConstraints.find(*aConstrIter);
159     if (aCIter == myConstraints.end())
160       continue;
161     aResult = aCIter->second->getId(theAttribute);
162     if (aResult != SLVS_E_UNKNOWN)
163       return aResult;
164   }
165   return SLVS_E_UNKNOWN;
166 }
167
168 // ============================================================================
169 //  Function: changeConstraint
170 //  Class:    SketchSolver_Group
171 //  Purpose:  create/update the constraint in the group
172 // ============================================================================
173 bool SketchSolver_Group::changeConstraint(
174     std::shared_ptr<SketchPlugin_Constraint> theConstraint)
175 {
176   // There is no workplane yet, something wrong
177   if (myWorkplaneID == SLVS_E_UNKNOWN)
178     return false;
179
180   if (!theConstraint)
181     return false;
182
183   if (myConstraints.find(theConstraint) == myConstraints.end()) {
184     // Add constraint to the current group
185     SolverConstraintPtr aConstraint =
186         SketchSolver_Builder::getInstance()->createConstraint(theConstraint);
187     if (!aConstraint)
188       return false;
189     aConstraint->setGroup(this);
190     aConstraint->setStorage(myStorage);
191     if (!aConstraint->error().empty()) {
192       if (aConstraint->error() == SketchSolver_Error::NOT_INITIALIZED())
193         return false; // some attribute are not initialized yet, don't show message
194       Events_Error::send(aConstraint->error(), this);
195     }
196
197     // Additional verification of coincidence of several points
198     if (theConstraint->getKind() == SketchPlugin_ConstraintCoincidence::ID()) {
199       ConstraintConstraintMap::iterator aCIter = myConstraints.begin();
200       for (; aCIter != myConstraints.end(); aCIter++) {
201         std::shared_ptr<SketchSolver_ConstraintCoincidence> aCoincidence =
202           std::dynamic_pointer_cast<SketchSolver_ConstraintCoincidence>(aCIter->second);
203         if (!aCoincidence)
204           continue;
205         std::shared_ptr<SketchSolver_ConstraintCoincidence> aCoinc2 =
206           std::dynamic_pointer_cast<SketchSolver_ConstraintCoincidence>(aConstraint);
207         if (aCoincidence != aCoinc2 && aCoincidence->isCoincide(aCoinc2)) {
208           aCoincidence->attach(aCoinc2);
209           aConstraint = aCoincidence;
210         }
211       }
212     }
213     myConstraints[theConstraint] = aConstraint;
214   }
215   else
216     myConstraints[theConstraint]->update();
217
218   // Fix base features for fillet
219   if (theConstraint->getKind() == SketchPlugin_ConstraintFillet::ID()) {
220     std::list<AttributePtr> anAttrList =
221         theConstraint->data()->attributes(ModelAPI_AttributeRefAttr::typeId());
222     std::list<AttributePtr>::iterator anAttrIter = anAttrList.begin();
223     for (; anAttrIter != anAttrList.end(); anAttrIter++) {
224       AttributeRefAttrPtr aRefAttr =
225           std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(*anAttrIter);
226       if (!aRefAttr || !aRefAttr->isObject())
227         continue;
228       FeaturePtr aFeature = ModelAPI_Feature::feature(aRefAttr->object());
229       SolverConstraintPtr aConstraint =
230           SketchSolver_Builder::getInstance()->createRigidConstraint(aFeature);
231       if (!aConstraint)
232         continue;
233       aConstraint->setGroup(this);
234       aConstraint->setStorage(myStorage);
235       setTemporary(aConstraint);
236     }
237   }
238   //// Fix base features for mirror
239   //if (theConstraint->getKind() == SketchPlugin_ConstraintMirror::ID()) {
240   //  AttributeRefListPtr aRefList = std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(
241   //      theConstraint->attribute(SketchPlugin_ConstraintMirror::ENTITY_B()));
242   //  fixFeaturesList(aRefList);
243   //}
244
245   if (!myFeatureStorage)
246     myFeatureStorage = FeatureStoragePtr(new SketchSolver_FeatureStorage);
247   myFeatureStorage->changeConstraint(theConstraint);
248
249   return true;
250 }
251
252
253 bool SketchSolver_Group::updateFeature(std::shared_ptr<SketchPlugin_Feature> theFeature)
254 {
255   std::set<ConstraintPtr> aConstraints =
256       myFeatureStorage->getConstraints(std::dynamic_pointer_cast<ModelAPI_Feature>(theFeature));
257   if (aConstraints.empty())
258     return false;
259   std::set<ConstraintPtr>::iterator aCIter = aConstraints.begin();
260   for (; aCIter != aConstraints.end(); aCIter++) {
261     ConstraintConstraintMap::iterator aSolConIter = myConstraints.find(*aCIter);
262     if (aSolConIter == myConstraints.end())
263       continue;
264     myFeatureStorage->changeFeature(theFeature, aSolConIter->first);
265     aSolConIter->second->addFeature(theFeature);
266     aSolConIter->second->update();
267   }
268   return true;
269 }
270
271 void SketchSolver_Group::moveFeature(std::shared_ptr<SketchPlugin_Feature> theFeature)
272 {
273   updateFeature(theFeature);
274   // Temporary rigid constraint
275   SolverConstraintPtr aConstraint =
276       SketchSolver_Builder::getInstance()->createRigidConstraint(theFeature);
277   if (!aConstraint)
278     return;
279   aConstraint->setGroup(this);
280   aConstraint->setStorage(myStorage);
281   setTemporary(aConstraint);
282 }
283
284 // ============================================================================
285 //  Function: fixFeaturesList
286 //  Class:    SketchSolver_Group
287 //  Purpose:  Apply temporary rigid constraints for the list of features
288 // ============================================================================
289 void SketchSolver_Group::fixFeaturesList(AttributeRefListPtr theList)
290 {
291   std::list<ObjectPtr> aList = theList->list();
292   std::list<ObjectPtr>::iterator anIt = aList.begin();
293   std::list<FeaturePtr> aFeatures;
294   // Sort features, at begining there are features used by Equal constraint
295   for (; anIt != aList.end(); anIt++) {
296     if (!(*anIt))
297       continue;
298     FeaturePtr aFeature = ModelAPI_Feature::feature(*anIt);
299     std::set<ConstraintPtr> aConstraints = myFeatureStorage->getConstraints(aFeature);
300     std::set<ConstraintPtr>::iterator aCIter = aConstraints.begin();
301     for (; aCIter != aConstraints.end(); aCIter++)
302       if ((*aCIter)->getKind() == SketchPlugin_ConstraintEqual::ID())
303         break;
304     if (aCIter != aConstraints.end())
305       aFeatures.push_front(aFeature);
306     else
307       aFeatures.push_back(aFeature);
308   }
309
310   std::list<FeaturePtr>::iterator aFeatIter = aFeatures.begin();
311   for (; aFeatIter != aFeatures.end(); aFeatIter++) {
312     SolverConstraintPtr aConstraint =
313         SketchSolver_Builder::getInstance()->createRigidConstraint(*aFeatIter);
314     if (!aConstraint)
315       continue;
316     aConstraint->setGroup(this);
317     aConstraint->setStorage(myStorage);
318     setTemporary(aConstraint);
319   }
320 }
321
322 // ============================================================================
323 //  Function: addWorkplane
324 //  Class:    SketchSolver_Group
325 //  Purpose:  create workplane for the group
326 // ============================================================================
327 bool SketchSolver_Group::addWorkplane(CompositeFeaturePtr theSketch)
328 {
329   if (myWorkplaneID != SLVS_E_UNKNOWN || theSketch->getKind() != SketchPlugin_Sketch::ID())
330     return false;  // the workplane already exists or the function parameter is not Sketch
331
332   mySketch = theSketch;
333   updateWorkplane();
334   return true;
335 }
336
337 // ============================================================================
338 //  Function: updateWorkplane
339 //  Class:    SketchSolver_Group
340 //  Purpose:  update parameters of workplane
341 // ============================================================================
342 bool SketchSolver_Group::updateWorkplane()
343 {
344   if (!myStorage) // Create storage if not exists
345     myStorage = StoragePtr(new SketchSolver_Storage);
346   SketchSolver_Builder* aBuilder = SketchSolver_Builder::getInstance();
347
348   std::vector<Slvs_Entity> anEntities;
349   std::vector<Slvs_Param> aParams;
350   if (!aBuilder->createWorkplane(mySketch, anEntities, aParams))
351     return false;
352
353   if (myWorkplaneID == SLVS_E_UNKNOWN) {
354     myWorkplaneID = anEntities.back().h;
355     // Add new workplane elements
356     std::vector<Slvs_Param>::iterator aParIter = aParams.begin();
357     for (; aParIter != aParams.end(); aParIter++) {
358       aParIter->h = SLVS_E_UNKNOWN; // the ID should be generated by storage
359       aParIter->group = myID;
360       aParIter->h = myStorage->addParameter(*aParIter);
361     }
362     std::vector<Slvs_Entity>::iterator anEntIter = anEntities.begin();
363     for (; anEntIter != anEntities.end(); anEntIter++) {
364       anEntIter->h = SLVS_E_UNKNOWN; // the ID should be generated by storage
365       anEntIter->group = myID;
366       anEntIter->wrkpl = myWorkplaneID;
367       for (int i = 0; i < 4; i++)
368         if (anEntIter->param[i] != SLVS_E_UNKNOWN)
369           anEntIter->param[i] = aParams[anEntIter->param[i]-1].h;
370       for (int i = 0; i < 4; i++)
371         if (anEntIter->point[i] != SLVS_E_UNKNOWN)
372           anEntIter->point[i] = anEntities[anEntIter->point[i]-1].h;
373       anEntIter->h = myStorage->addEntity(*anEntIter);
374     }
375   } else {
376     // Update existent workplane
377     const Slvs_Entity& aWP = myStorage->getEntity(myWorkplaneID);
378     const Slvs_Entity& anOrigin = myStorage->getEntity(aWP.point[0]);
379     const Slvs_Entity& aNormal = myStorage->getEntity(aWP.normal);
380     // Get parameters and update them
381     Slvs_hParam aWPParams[7] = {
382         anOrigin.param[0], anOrigin.param[1], anOrigin.param[2],
383         aNormal.param[0], aNormal.param[1], aNormal.param[2], aNormal.param[3]
384       };
385     std::vector<Slvs_Param>::iterator aParIter = aParams.begin();
386     for (int i = 0; aParIter != aParams.end(); aParIter++, i++) {
387       Slvs_Param aParam = myStorage->getParameter(aWPParams[i]);
388       aParam.val = aParIter->val;
389       myStorage->updateParameter(aParam);
390     }
391   }
392   return myWorkplaneID > 0;
393 }
394
395 // ============================================================================
396 //  Function: resolveConstraints
397 //  Class:    SketchSolver_Group
398 //  Purpose:  solve the set of constraints for the current group
399 // ============================================================================
400 bool SketchSolver_Group::resolveConstraints()
401 {
402   bool aResolved = false;
403   if (myStorage->isNeedToResolve() && !isEmpty()) {
404     myConstrSolver.setGroupID(myID);
405     myStorage->initializeSolver(myConstrSolver);
406
407     int aResult = SLVS_RESULT_OKAY;
408     try {
409       aResult = myConstrSolver.solve();
410     } catch (...) {
411       Events_Error::send(SketchSolver_Error::SOLVESPACE_CRASH(), this);
412       return false;
413     }
414     if (aResult == SLVS_RESULT_OKAY) {  // solution succeeded, store results into correspondent attributes
415       myFeatureStorage->blockEvents(true);
416       ConstraintConstraintMap::iterator aConstrIter = myConstraints.begin();
417       for (; aConstrIter != myConstraints.end(); aConstrIter++)
418         aConstrIter->second->refresh();
419       myFeatureStorage->blockEvents(false);
420     } else if (!myConstraints.empty())
421       Events_Error::send(SketchSolver_Error::CONSTRAINTS(), this);
422
423     aResolved = true;
424   }
425   removeTemporaryConstraints();
426   myStorage->setNeedToResolve(false);
427   return aResolved;
428 }
429
430 // ============================================================================
431 //  Function: mergeGroups
432 //  Class:    SketchSolver_Group
433 //  Purpose:  append specified group to the current group
434 // ============================================================================
435 void SketchSolver_Group::mergeGroups(const SketchSolver_Group& theGroup)
436 {
437   // If specified group is empty, no need to merge
438   if (theGroup.isEmpty())
439     return;
440   if (!myFeatureStorage)
441     myFeatureStorage = FeatureStoragePtr(new SketchSolver_FeatureStorage);
442
443   std::vector<ConstraintPtr> aComplexConstraints;
444   ConstraintConstraintMap::const_iterator aConstrIter = theGroup.myConstraints.begin();
445   // append simple constraints
446   for (; aConstrIter != theGroup.myConstraints.end(); aConstrIter++)
447     if (isComplexConstraint(aConstrIter->first))
448       aComplexConstraints.push_back(aConstrIter->first);
449     else
450       changeConstraint(aConstrIter->first);
451   // append complex constraints
452   std::vector<ConstraintPtr>::iterator aComplexIter = aComplexConstraints.begin();
453   for (; aComplexIter != aComplexConstraints.end(); aComplexIter++)
454       changeConstraint(*aComplexIter);
455 }
456
457 // ============================================================================
458 //  Function: splitGroup
459 //  Class:    SketchSolver_Group
460 //  Purpose:  divide the group into several subgroups
461 // ============================================================================
462 void SketchSolver_Group::splitGroup(std::vector<SketchSolver_Group*>& theCuts)
463 {
464   // Obtain constraints, which should be separated
465   FeatureStoragePtr aNewFeatStorage(new SketchSolver_FeatureStorage);
466   std::vector<ConstraintPtr> anUnusedConstraints;
467   ConstraintConstraintMap::iterator aCIter = myConstraints.begin();
468   for ( ; aCIter != myConstraints.end(); aCIter++) {
469     std::list<ConstraintPtr> aBaseConstraints = aCIter->second->constraints();
470     std::list<ConstraintPtr>::iterator anIter = aBaseConstraints.begin();
471     for (; anIter != aBaseConstraints.end(); anIter++)
472       if (aNewFeatStorage->isInteract(*anIter)) {
473         aNewFeatStorage->changeConstraint(*anIter);
474       } else
475         anUnusedConstraints.push_back(*anIter);
476   }
477
478   // Check the unused constraints once again, because they may become interacted with new storage since adding constraints
479   std::vector<ConstraintPtr>::iterator aUnuseIt = anUnusedConstraints.begin();
480   while (aUnuseIt != anUnusedConstraints.end()) {
481     if (aNewFeatStorage->isInteract(*aUnuseIt)) {
482       size_t aShift = aUnuseIt - anUnusedConstraints.begin();
483       anUnusedConstraints.erase(aUnuseIt);
484       aUnuseIt = anUnusedConstraints.begin() + aShift;
485       continue;
486     }
487     aUnuseIt++;
488   }
489
490   std::vector<SketchSolver_Group*>::iterator aCutsIter;
491   aUnuseIt = anUnusedConstraints.begin();
492   for ( ; aUnuseIt != anUnusedConstraints.end(); aUnuseIt++) {
493     // Remove unused constraints
494     removeConstraint(*aUnuseIt);
495     // Try to append constraint to already existent group
496     for (aCutsIter = theCuts.begin(); aCutsIter != theCuts.end(); aCutsIter++)
497       if ((*aCutsIter)->isInteract(*aUnuseIt)) {
498         (*aCutsIter)->changeConstraint(*aUnuseIt);
499         break;
500       }
501     if (aCutsIter == theCuts.end()) {
502       // Add new group
503       SketchSolver_Group* aGroup = new SketchSolver_Group(mySketch);
504       aGroup->changeConstraint(*aUnuseIt);
505       theCuts.push_back(aGroup);
506     }
507   }
508 }
509
510 // ============================================================================
511 //  Function: isConsistent
512 //  Class:    SketchSolver_Group
513 //  Purpose:  search removed entities and constraints
514 // ============================================================================
515 bool SketchSolver_Group::isConsistent()
516 {
517   if (!myFeatureStorage) // no one constraint is initialized yet
518     return true;
519
520   bool aResult = myFeatureStorage->isConsistent();
521   if (!aResult) {
522     // remove invalid entities
523     ConstraintConstraintMap::iterator aCIter = myConstraints.begin();
524     while (aCIter != myConstraints.end()) {
525       std::list<ConstraintPtr> aConstraints = aCIter->second->constraints();
526       std::list<ConstraintPtr>::iterator anIt = aConstraints.begin();
527       for (; anIt != aConstraints.end(); anIt++)
528         if (!(*anIt)->data() || !(*anIt)->data()->isValid())
529           if (aCIter->second->remove(*anIt)) {
530             // the constraint is fully removed, detach it from the list
531             ConstraintConstraintMap::iterator aTmpIt = aCIter++;
532             myFeatureStorage->removeConstraint(aTmpIt->first);
533             myConstraints.erase(aTmpIt);
534             break;
535           }
536       if (anIt == aConstraints.end())
537         aCIter++;
538     }
539   }
540   return aResult;
541 }
542
543 // ============================================================================
544 //  Function: removeTemporaryConstraints
545 //  Class:    SketchSolver_Group
546 //  Purpose:  remove all transient SLVS_C_WHERE_DRAGGED constraints after
547 //            resolving the set of constraints
548 // ============================================================================
549 void SketchSolver_Group::removeTemporaryConstraints()
550 {
551   myTempConstraints.clear();
552   myStorage->removeTemporaryConstraints();
553   // Clean lists of removed entities in the storage
554   std::set<Slvs_hParam> aRemPar;
555   std::set<Slvs_hEntity> aRemEnt;
556   std::set<Slvs_hConstraint> aRemCon;
557   myStorage->getRemoved(aRemPar, aRemEnt, aRemCon);
558   myStorage->setNeedToResolve(false);
559 }
560
561 // ============================================================================
562 //  Function: removeConstraint
563 //  Class:    SketchSolver_Group
564 //  Purpose:  remove constraint and all unused entities
565 // ============================================================================
566 void SketchSolver_Group::removeConstraint(ConstraintPtr theConstraint)
567 {
568   myFeatureStorage->removeConstraint(theConstraint);
569   ConstraintConstraintMap::iterator aCIter = myConstraints.begin();
570   for (; aCIter != myConstraints.end(); aCIter++)
571     if (aCIter->second->hasConstraint(theConstraint)) {
572       if (!aCIter->second->remove(theConstraint)) // the constraint is not fully removed
573         aCIter = myConstraints.end();
574       break;
575     }
576   if (aCIter != myConstraints.end())
577     myConstraints.erase(aCIter);
578 }
579
580 // ============================================================================
581 //  Function: isComplexConstraint
582 //  Class:    SketchSolver_Group
583 //  Purpose:  verifies the constraint is complex, i.e. it needs another constraints to be created before
584 // ============================================================================
585 bool SketchSolver_Group::isComplexConstraint(FeaturePtr theConstraint)
586 {
587   return theConstraint->getKind() == SketchPlugin_ConstraintFillet::ID() ||
588          theConstraint->getKind() == SketchPlugin_ConstraintMirror::ID() ||
589          theConstraint->getKind() == SketchPlugin_ConstraintTangent::ID();
590 }
591
592 // ============================================================================
593 //  Function: setTemporary
594 //  Class:    SketchSolver_Group
595 //  Purpose:  append given constraint to th group of temporary constraints
596 // ============================================================================
597 void SketchSolver_Group::setTemporary(SolverConstraintPtr theConstraint)
598 {
599   theConstraint->makeTemporary();
600   myTempConstraints.insert(theConstraint);
601 }
602