1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: SketchSolver_Group.cpp
4 // Created: 27 May 2014
5 // Author: Artem ZHIDKOV
7 #include "SketchSolver_Group.h"
9 #include <SketchSolver_Builder.h>
10 #include <SketchSolver_Constraint.h>
11 #include <SketchSolver_ConstraintCoincidence.h>
12 #include <SketchSolver_Error.h>
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>
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 #include <SketchPlugin_MultiRotation.h>
37 #include <SketchPlugin_MultiTranslation.h>
39 #include <SketchPlugin_Arc.h>
40 #include <SketchPlugin_Circle.h>
41 #include <SketchPlugin_Line.h>
42 #include <SketchPlugin_Point.h>
43 #include <SketchPlugin_Sketch.h>
49 /// \brief This class is used to give unique index to the groups
53 /// \brief Return vacant index
54 static Slvs_hGroup NEW_GROUP() { return ++myGroupIndex; }
55 /// \brief Removes the index
56 static void REMOVE_GROUP(const Slvs_hGroup& theIndex) {
57 if (myGroupIndex == theIndex)
64 static Slvs_hGroup myGroupIndex; ///< index of the group
67 Slvs_hGroup GroupIndexer::myGroupIndex = 0;
71 // ========================================================
72 // ========= SketchSolver_Group ===============
73 // ========================================================
75 SketchSolver_Group::SketchSolver_Group(
76 std::shared_ptr<ModelAPI_CompositeFeature> theWorkplane)
77 : myID(GroupIndexer::NEW_GROUP())
79 // Initialize workplane
80 myWorkplaneID = SLVS_E_UNKNOWN;
82 assert(addWorkplane(theWorkplane));
84 addWorkplane(theWorkplane);
88 SketchSolver_Group::~SketchSolver_Group()
90 myConstraints.clear();
91 GroupIndexer::REMOVE_GROUP(myID);
94 // ============================================================================
95 // Function: isBaseWorkplane
96 // Class: SketchSolver_Group
97 // Purpose: verify the group is based on the given workplane
98 // ============================================================================
99 bool SketchSolver_Group::isBaseWorkplane(CompositeFeaturePtr theWorkplane) const
101 return theWorkplane == mySketch;
104 // ============================================================================
105 // Function: isInteract
106 // Class: SketchSolver_Group
107 // Purpose: verify are there any entities in the group used by given constraint
108 // ============================================================================
109 bool SketchSolver_Group::isInteract(
110 std::shared_ptr<SketchPlugin_Feature> theFeature) const
112 // Empty group interacts with everything
113 if (isEmpty()) return true;
114 ConstraintPtr aConstraint = std::dynamic_pointer_cast<SketchPlugin_Constraint>(theFeature);
116 return myFeatureStorage->isInteract(aConstraint);
117 return myFeatureStorage->isInteract(std::dynamic_pointer_cast<ModelAPI_Feature>(theFeature));
120 // ============================================================================
121 // Function: getFeatureId
122 // Class: SketchSolver_Group
123 // Purpose: Find the identifier of the feature, if it already exists in the group
124 // ============================================================================
125 Slvs_hEntity SketchSolver_Group::getFeatureId(FeaturePtr theFeature) const
127 Slvs_hEntity aResult = SLVS_E_UNKNOWN;
128 if (!myFeatureStorage)
130 std::set<ConstraintPtr> aConstraints = myFeatureStorage->getConstraints(theFeature);
131 if (aConstraints.empty())
133 std::set<ConstraintPtr>::iterator aConstrIter = aConstraints.begin();
134 for (; aConstrIter != aConstraints.end(); aConstrIter++) {
135 ConstraintConstraintMap::const_iterator aCIter = myConstraints.find(*aConstrIter);
136 if (aCIter == myConstraints.end())
138 aResult = aCIter->second->getId(theFeature);
139 if (aResult != SLVS_E_UNKNOWN)
142 return SLVS_E_UNKNOWN;
145 // ============================================================================
146 // Function: getAttributeId
147 // Class: SketchSolver_Group
148 // Purpose: Find the identifier of the attribute, if it already exists in the group
149 // ============================================================================
150 Slvs_hEntity SketchSolver_Group::getAttributeId(AttributePtr theAttribute) const
152 Slvs_hEntity aResult = SLVS_E_UNKNOWN;
153 if (!myFeatureStorage)
155 std::set<ConstraintPtr> aConstraints = myFeatureStorage->getConstraints(theAttribute);
156 if (aConstraints.empty())
158 std::set<ConstraintPtr>::iterator aConstrIter = aConstraints.begin();
159 for (; aConstrIter != aConstraints.end(); aConstrIter++) {
160 ConstraintConstraintMap::const_iterator aCIter = myConstraints.find(*aConstrIter);
161 if (aCIter == myConstraints.end())
163 aResult = aCIter->second->getId(theAttribute);
164 if (aResult != SLVS_E_UNKNOWN)
167 return SLVS_E_UNKNOWN;
170 // ============================================================================
171 // Function: changeConstraint
172 // Class: SketchSolver_Group
173 // Purpose: create/update the constraint in the group
174 // ============================================================================
175 bool SketchSolver_Group::changeConstraint(
176 std::shared_ptr<SketchPlugin_Constraint> theConstraint)
178 // There is no workplane yet, something wrong
179 if (myWorkplaneID == SLVS_E_UNKNOWN)
185 bool isNewConstraint = myConstraints.find(theConstraint) == myConstraints.end();
186 if (isNewConstraint) {
187 // Add constraint to the current group
188 SolverConstraintPtr aConstraint =
189 SketchSolver_Builder::getInstance()->createConstraint(theConstraint);
192 aConstraint->setGroup(this);
193 aConstraint->setStorage(myStorage);
194 if (!aConstraint->error().empty()) {
195 if (aConstraint->error() == SketchSolver_Error::NOT_INITIALIZED())
196 return false; // some attribute are not initialized yet, don't show message
197 Events_Error::send(aConstraint->error(), this);
200 // Additional verification of coincidence of several points
201 if (theConstraint->getKind() == SketchPlugin_ConstraintCoincidence::ID()) {
202 ConstraintConstraintMap::iterator aCIter = myConstraints.begin();
203 for (; aCIter != myConstraints.end(); aCIter++) {
204 std::shared_ptr<SketchSolver_ConstraintCoincidence> aCoincidence =
205 std::dynamic_pointer_cast<SketchSolver_ConstraintCoincidence>(aCIter->second);
208 std::shared_ptr<SketchSolver_ConstraintCoincidence> aCoinc2 =
209 std::dynamic_pointer_cast<SketchSolver_ConstraintCoincidence>(aConstraint);
210 if (aCoincidence != aCoinc2 && aCoincidence->isCoincide(aCoinc2)) {
211 aCoinc2->attach(aCoincidence);
212 // update other coincidences
213 ConstraintConstraintMap::iterator anIt = aCIter;
214 for (++anIt; anIt != myConstraints.end(); ++anIt)
215 if (anIt->second == aCIter->second)
216 anIt->second = aCoinc2;
217 aCIter->second = aCoinc2;
221 myConstraints[theConstraint] = aConstraint;
224 myConstraints[theConstraint]->update();
226 // Fix base features for fillet
227 if (isNewConstraint && theConstraint->getKind() == SketchPlugin_ConstraintFillet::ID()) {
228 std::list<AttributePtr> anAttrList =
229 theConstraint->data()->attributes(ModelAPI_AttributeRefAttr::typeId());
230 std::list<AttributePtr>::iterator anAttrIter = anAttrList.begin();
231 for (; anAttrIter != anAttrList.end(); anAttrIter++) {
232 AttributeRefAttrPtr aRefAttr =
233 std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(*anAttrIter);
234 if (!aRefAttr || !aRefAttr->isObject())
236 FeaturePtr aFeature = ModelAPI_Feature::feature(aRefAttr->object());
237 SolverConstraintPtr aConstraint =
238 SketchSolver_Builder::getInstance()->createRigidConstraint(aFeature);
241 aConstraint->setGroup(this);
242 aConstraint->setStorage(myStorage);
243 setTemporary(aConstraint);
247 if (theConstraint->getKind() == SketchPlugin_ConstraintMirror::ID()) {
248 AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
249 theConstraint->attribute(SketchPlugin_ConstraintMirror::ENTITY_A()));
250 if (aRefAttr && aRefAttr->isObject()) {
251 FeaturePtr aFeature = ModelAPI_Feature::feature(aRefAttr->object());
253 SolverConstraintPtr aConstraint =
254 SketchSolver_Builder::getInstance()->createRigidConstraint(aFeature);
256 aConstraint->setGroup(this);
257 aConstraint->setStorage(myStorage);
258 setTemporary(aConstraint);
264 if (!myFeatureStorage)
265 myFeatureStorage = FeatureStoragePtr(new SketchSolver_FeatureStorage);
266 myFeatureStorage->changeConstraint(theConstraint);
272 bool SketchSolver_Group::updateFeature(std::shared_ptr<SketchPlugin_Feature> theFeature)
274 std::set<ConstraintPtr> aConstraints =
275 myFeatureStorage->getConstraints(std::dynamic_pointer_cast<ModelAPI_Feature>(theFeature));
276 if (aConstraints.empty())
278 std::set<ConstraintPtr>::iterator aCIter = aConstraints.begin();
279 std::set<SolverConstraintPtr> aPostponed; // postponed constraints Multi-Rotation and Multi-Translation
280 for (; aCIter != aConstraints.end(); aCIter++) {
281 ConstraintConstraintMap::iterator aSolConIter = myConstraints.find(*aCIter);
282 if (aSolConIter == myConstraints.end() || !aSolConIter->first->data() ||
283 !aSolConIter->first->data()->isValid())
285 myFeatureStorage->changeFeature(theFeature, aSolConIter->first);
287 if (aSolConIter->first->getKind() == SketchPlugin_MultiRotation::ID() ||
288 aSolConIter->first->getKind() == SketchPlugin_MultiTranslation::ID()) {
289 aPostponed.insert(aSolConIter->second);
292 aSolConIter->second->addFeature(theFeature);
293 aSolConIter->second->update();
296 // Update postponed constraints
297 std::set<SolverConstraintPtr>::iterator aSCIter = aPostponed.begin();
298 for (; aSCIter != aPostponed.end(); ++aSCIter) {
299 (*aSCIter)->addFeature(theFeature);
300 (*aSCIter)->update();
305 void SketchSolver_Group::moveFeature(std::shared_ptr<SketchPlugin_Feature> theFeature)
307 // Firstly, create temporary rigid constraint
308 SolverConstraintPtr aConstraint =
309 SketchSolver_Builder::getInstance()->createMovementConstraint(theFeature);
312 aConstraint->setGroup(this);
313 aConstraint->setStorage(myStorage);
314 if (aConstraint->error().empty())
315 setTemporary(aConstraint);
316 // Secondly, update the feature
317 updateFeature(theFeature);
320 // ============================================================================
321 // Function: fixFeaturesList
322 // Class: SketchSolver_Group
323 // Purpose: Apply temporary rigid constraints for the list of features
324 // ============================================================================
325 void SketchSolver_Group::fixFeaturesList(AttributeRefListPtr theList)
327 std::list<ObjectPtr> aList = theList->list();
328 std::list<ObjectPtr>::iterator anIt = aList.begin();
329 std::list<FeaturePtr> aFeatures;
330 // Sort features, at begining there are features used by Equal constraint
331 for (; anIt != aList.end(); anIt++) {
334 FeaturePtr aFeature = ModelAPI_Feature::feature(*anIt);
335 std::set<ConstraintPtr> aConstraints = myFeatureStorage->getConstraints(aFeature);
336 std::set<ConstraintPtr>::iterator aCIter = aConstraints.begin();
337 for (; aCIter != aConstraints.end(); aCIter++)
338 if ((*aCIter)->getKind() == SketchPlugin_ConstraintEqual::ID())
340 if (aCIter != aConstraints.end())
341 aFeatures.push_front(aFeature);
343 aFeatures.push_back(aFeature);
346 std::list<FeaturePtr>::iterator aFeatIter = aFeatures.begin();
347 for (; aFeatIter != aFeatures.end(); aFeatIter++) {
348 SolverConstraintPtr aConstraint =
349 SketchSolver_Builder::getInstance()->createRigidConstraint(*aFeatIter);
352 aConstraint->setGroup(this);
353 aConstraint->setStorage(myStorage);
354 setTemporary(aConstraint);
358 // ============================================================================
359 // Function: addWorkplane
360 // Class: SketchSolver_Group
361 // Purpose: create workplane for the group
362 // ============================================================================
363 bool SketchSolver_Group::addWorkplane(CompositeFeaturePtr theSketch)
365 if (myWorkplaneID != SLVS_E_UNKNOWN || theSketch->getKind() != SketchPlugin_Sketch::ID())
366 return false; // the workplane already exists or the function parameter is not Sketch
368 mySketch = theSketch;
373 // ============================================================================
374 // Function: updateWorkplane
375 // Class: SketchSolver_Group
376 // Purpose: update parameters of workplane
377 // ============================================================================
378 bool SketchSolver_Group::updateWorkplane()
380 if (!myStorage) // Create storage if not exists
381 myStorage = StoragePtr(new SketchSolver_Storage);
382 SketchSolver_Builder* aBuilder = SketchSolver_Builder::getInstance();
384 std::vector<Slvs_Entity> anEntities;
385 std::vector<Slvs_Param> aParams;
386 if (!aBuilder->createWorkplane(mySketch, anEntities, aParams))
389 if (myWorkplaneID == SLVS_E_UNKNOWN) {
390 myWorkplaneID = anEntities.back().h;
391 // Add new workplane elements
392 std::vector<Slvs_Param>::iterator aParIter = aParams.begin();
393 for (; aParIter != aParams.end(); aParIter++) {
394 aParIter->h = SLVS_E_UNKNOWN; // the ID should be generated by storage
395 aParIter->group = myID;
396 aParIter->h = myStorage->addParameter(*aParIter);
398 std::vector<Slvs_Entity>::iterator anEntIter = anEntities.begin();
399 for (; anEntIter != anEntities.end(); anEntIter++) {
400 anEntIter->h = SLVS_E_UNKNOWN; // the ID should be generated by storage
401 anEntIter->group = myID;
402 anEntIter->wrkpl = myWorkplaneID;
403 for (int i = 0; i < 4; i++)
404 if (anEntIter->param[i] != SLVS_E_UNKNOWN)
405 anEntIter->param[i] = aParams[anEntIter->param[i]-1].h;
406 for (int i = 0; i < 4; i++)
407 if (anEntIter->point[i] != SLVS_E_UNKNOWN)
408 anEntIter->point[i] = anEntities[anEntIter->point[i]-1].h;
409 anEntIter->h = myStorage->addEntity(*anEntIter);
412 // Update existent workplane
413 const Slvs_Entity& aWP = myStorage->getEntity(myWorkplaneID);
414 const Slvs_Entity& anOrigin = myStorage->getEntity(aWP.point[0]);
415 const Slvs_Entity& aNormal = myStorage->getEntity(aWP.normal);
416 // Get parameters and update them
417 Slvs_hParam aWPParams[7] = {
418 anOrigin.param[0], anOrigin.param[1], anOrigin.param[2],
419 aNormal.param[0], aNormal.param[1], aNormal.param[2], aNormal.param[3]
421 std::vector<Slvs_Param>::iterator aParIter = aParams.begin();
422 for (int i = 0; aParIter != aParams.end(); aParIter++, i++) {
423 Slvs_Param aParam = myStorage->getParameter(aWPParams[i]);
424 aParam.val = aParIter->val;
425 myStorage->updateParameter(aParam);
428 return myWorkplaneID > 0;
431 // ============================================================================
432 // Function: resolveConstraints
433 // Class: SketchSolver_Group
434 // Purpose: solve the set of constraints for the current group
435 // ============================================================================
436 bool SketchSolver_Group::resolveConstraints()
438 bool aResolved = false;
439 if (myStorage->isNeedToResolve() && !isEmpty()) {
440 myConstrSolver.setGroupID(myID);
441 myStorage->initializeSolver(myConstrSolver);
443 int aResult = SLVS_RESULT_OKAY;
445 if (myStorage->hasDuplicatedConstraint())
446 aResult = SLVS_RESULT_INCONSISTENT;
448 // To avoid overconstraint situation, we will remove temporary constraints one-by-one
449 // and try to find the case without overconstraint
450 bool isLastChance = false;
451 int aNbTemp = myStorage->numberTemporary();
453 aResult = myConstrSolver.solve();
454 if (aResult == SLVS_RESULT_OKAY || isLastChance)
457 // try to update parameters and resolve once again
458 ConstraintConstraintMap::iterator aConstrIt = myConstraints.begin();
459 for (; aConstrIt != myConstraints.end(); ++aConstrIt)
460 aConstrIt->second->update();
463 aNbTemp = myStorage->deleteTemporaryConstraint();
464 myStorage->initializeSolver(myConstrSolver);
468 Events_Error::send(SketchSolver_Error::SOLVESPACE_CRASH(), this);
471 if (aResult == SLVS_RESULT_OKAY) { // solution succeeded, store results into correspondent attributes
472 myFeatureStorage->blockEvents(true);
473 ConstraintConstraintMap::iterator aConstrIter = myConstraints.begin();
474 for (; aConstrIter != myConstraints.end(); aConstrIter++)
475 aConstrIter->second->refresh();
476 myFeatureStorage->blockEvents(false);
477 } else if (!myConstraints.empty())
478 Events_Error::send(SketchSolver_Error::CONSTRAINTS(), this);
482 removeTemporaryConstraints();
483 myStorage->setNeedToResolve(false);
487 // ============================================================================
488 // Function: mergeGroups
489 // Class: SketchSolver_Group
490 // Purpose: append specified group to the current group
491 // ============================================================================
492 void SketchSolver_Group::mergeGroups(const SketchSolver_Group& theGroup)
494 // If specified group is empty, no need to merge
495 if (theGroup.isEmpty())
497 if (!myFeatureStorage)
498 myFeatureStorage = FeatureStoragePtr(new SketchSolver_FeatureStorage);
500 std::vector<ConstraintPtr> aComplexConstraints;
501 ConstraintConstraintMap::const_iterator aConstrIter = theGroup.myConstraints.begin();
502 // append simple constraints
503 for (; aConstrIter != theGroup.myConstraints.end(); aConstrIter++)
504 if (isComplexConstraint(aConstrIter->first))
505 aComplexConstraints.push_back(aConstrIter->first);
507 changeConstraint(aConstrIter->first);
508 // append complex constraints
509 std::vector<ConstraintPtr>::iterator aComplexIter = aComplexConstraints.begin();
510 for (; aComplexIter != aComplexConstraints.end(); aComplexIter++)
511 changeConstraint(*aComplexIter);
514 // ============================================================================
515 // Function: splitGroup
516 // Class: SketchSolver_Group
517 // Purpose: divide the group into several subgroups
518 // ============================================================================
519 void SketchSolver_Group::splitGroup(std::vector<SketchSolver_Group*>& theCuts)
521 // Obtain constraints, which should be separated
522 FeatureStoragePtr aNewFeatStorage(new SketchSolver_FeatureStorage);
523 std::vector<ConstraintPtr> anUnusedConstraints;
524 ConstraintConstraintMap::iterator aCIter = myConstraints.begin();
525 for ( ; aCIter != myConstraints.end(); aCIter++) {
526 std::list<ConstraintPtr> aBaseConstraints = aCIter->second->constraints();
527 std::list<ConstraintPtr>::iterator anIter = aBaseConstraints.begin();
528 for (; anIter != aBaseConstraints.end(); anIter++)
529 if (aNewFeatStorage->isInteract(*anIter)) {
530 aNewFeatStorage->changeConstraint(*anIter);
532 anUnusedConstraints.push_back(*anIter);
535 // Check the unused constraints once again, because they may become interacted with new storage since adding constraints
536 std::vector<ConstraintPtr>::iterator aUnuseIt = anUnusedConstraints.begin();
537 while (aUnuseIt != anUnusedConstraints.end()) {
538 if (aNewFeatStorage->isInteract(*aUnuseIt)) {
539 size_t aShift = aUnuseIt - anUnusedConstraints.begin();
540 anUnusedConstraints.erase(aUnuseIt);
541 aUnuseIt = anUnusedConstraints.begin() + aShift;
547 std::vector<SketchSolver_Group*>::iterator aCutsIter;
548 aUnuseIt = anUnusedConstraints.begin();
549 for ( ; aUnuseIt != anUnusedConstraints.end(); aUnuseIt++) {
550 // Remove unused constraints
551 removeConstraint(*aUnuseIt);
552 // Try to append constraint to already existent group
553 for (aCutsIter = theCuts.begin(); aCutsIter != theCuts.end(); aCutsIter++)
554 if ((*aCutsIter)->isInteract(*aUnuseIt)) {
555 (*aCutsIter)->changeConstraint(*aUnuseIt);
558 if (aCutsIter == theCuts.end()) {
560 SketchSolver_Group* aGroup = new SketchSolver_Group(mySketch);
561 aGroup->changeConstraint(*aUnuseIt);
562 theCuts.push_back(aGroup);
567 // ============================================================================
568 // Function: isConsistent
569 // Class: SketchSolver_Group
570 // Purpose: search removed entities and constraints
571 // ============================================================================
572 bool SketchSolver_Group::isConsistent()
574 if (!myFeatureStorage) // no one constraint is initialized yet
577 bool aResult = myFeatureStorage->isConsistent();
579 // remove invalid entities
580 std::set<ConstraintPtr> anInvalidConstraints;
581 ConstraintConstraintMap::iterator aCIter = myConstraints.begin();
582 for (; aCIter != myConstraints.end(); ++aCIter) {
583 if (!aCIter->first->data() || !aCIter->first->data()->isValid())
584 anInvalidConstraints.insert(aCIter->first);
586 std::set<ConstraintPtr>::const_iterator aRemoveIt = anInvalidConstraints.begin();
587 for (; aRemoveIt != anInvalidConstraints.end(); ++aRemoveIt)
588 removeConstraint(*aRemoveIt);
593 // ============================================================================
594 // Function: removeTemporaryConstraints
595 // Class: SketchSolver_Group
596 // Purpose: remove all transient SLVS_C_WHERE_DRAGGED constraints after
597 // resolving the set of constraints
598 // ============================================================================
599 void SketchSolver_Group::removeTemporaryConstraints()
601 myTempConstraints.clear();
602 while (myStorage->numberTemporary())
603 myStorage->deleteTemporaryConstraint();
604 // Clean lists of removed entities in the storage
605 std::set<Slvs_hParam> aRemPar;
606 std::set<Slvs_hEntity> aRemEnt;
607 std::set<Slvs_hConstraint> aRemCon;
608 myStorage->getRemoved(aRemPar, aRemEnt, aRemCon);
609 myStorage->setNeedToResolve(false);
612 // ============================================================================
613 // Function: removeConstraint
614 // Class: SketchSolver_Group
615 // Purpose: remove constraint and all unused entities
616 // ============================================================================
617 void SketchSolver_Group::removeConstraint(ConstraintPtr theConstraint)
619 bool isFullyRemoved = true;
620 myFeatureStorage->removeConstraint(theConstraint);
621 ConstraintConstraintMap::iterator aCIter = myConstraints.begin();
622 for (; aCIter != myConstraints.end(); aCIter++)
623 if (aCIter->second->hasConstraint(theConstraint)) {
624 if (!aCIter->second->remove(theConstraint)) // the constraint is not fully removed
625 isFullyRemoved = false;
629 myConstraints.erase(aCIter);
630 else if (aCIter != myConstraints.end() &&
631 aCIter->first->getKind() == SketchPlugin_ConstraintCoincidence::ID()) {
632 // Update multicoincidence
633 std::list<ConstraintPtr> aMultiCoinc;
634 SolverConstraintPtr aCoincidence = aCIter->second;
635 while (aCIter != myConstraints.end()) {
636 if (aCIter->second != aCoincidence) {
640 if (aCIter->first != theConstraint)
641 aMultiCoinc.push_back(aCIter->first);
642 aCIter->second->remove(aCIter->first);
643 ConstraintConstraintMap::iterator aRemoveIt = aCIter++;
644 myConstraints.erase(aRemoveIt);
647 std::list<ConstraintPtr>::iterator anIt = aMultiCoinc.begin();
648 for (; anIt != aMultiCoinc.end(); ++anIt)
649 changeConstraint(*anIt);
653 // ============================================================================
654 // Function: isComplexConstraint
655 // Class: SketchSolver_Group
656 // Purpose: verifies the constraint is complex, i.e. it needs another constraints to be created before
657 // ============================================================================
658 bool SketchSolver_Group::isComplexConstraint(FeaturePtr theConstraint)
660 return theConstraint->getKind() == SketchPlugin_ConstraintFillet::ID() ||
661 theConstraint->getKind() == SketchPlugin_ConstraintMirror::ID() ||
662 theConstraint->getKind() == SketchPlugin_ConstraintTangent::ID();
665 // ============================================================================
666 // Function: setTemporary
667 // Class: SketchSolver_Group
668 // Purpose: append given constraint to th group of temporary constraints
669 // ============================================================================
670 void SketchSolver_Group::setTemporary(SolverConstraintPtr theConstraint)
672 theConstraint->makeTemporary();
673 myTempConstraints.insert(theConstraint);