- // If specified group is empty, no need to merge
- if (theGroup.isEmpty())
- return;
-
- std::set<ObjectPtr> aConstraints;
- ConstraintConstraintMap::const_iterator aConstrIter = theGroup.myConstraints.begin();
- for (; aConstrIter != theGroup.myConstraints.end(); aConstrIter++)
- aConstraints.insert(aConstrIter->first);
-
- std::list<FeaturePtr> aSortedConstraints = selectApplicableFeatures(aConstraints);
- std::list<FeaturePtr>::iterator aSCIter = aSortedConstraints.begin();
- for (; aSCIter != aSortedConstraints.end(); ++aSCIter) {
- ConstraintPtr aConstr = std::dynamic_pointer_cast<SketchPlugin_Constraint>(*aSCIter);
- if (!aConstr)
- continue;
- changeConstraint(aConstr);
- }
-}
-
-// ============================================================================
-// Function: splitGroup
-// Class: SketchSolver_Group
-// Purpose: divide the group into several subgroups
-// ============================================================================
-void SketchSolver_Group::splitGroup(std::list<SketchSolver_Group*>& theCuts)
-{
- // New storage will be used in trimmed way to store the list of constraint interacted together.
- StoragePtr aNewStorage = SketchSolver_Manager::instance()->builder()->createStorage(getId());
- std::list<ConstraintWrapperPtr> aDummyVec; // empty vector to avoid creation of solver's constraints
-
- // Obtain constraints, which should be separated
- std::list<ConstraintPtr> anUnusedConstraints;
- ConstraintConstraintMap::iterator aCIter = myConstraints.begin();
- for ( ; aCIter != myConstraints.end(); aCIter++) {
- if (aNewStorage->isInteract(FeaturePtr(aCIter->first)))
- aNewStorage->addConstraint(aCIter->first, aDummyVec);
- else
- anUnusedConstraints.push_back(aCIter->first);
- }
-
- // Check the unused constraints once again, because they may become interacted with new storage since adding constraints
- std::list<ConstraintPtr>::iterator aUnuseIt = anUnusedConstraints.begin();
- while (aUnuseIt != anUnusedConstraints.end()) {
- if (aNewStorage->isInteract(FeaturePtr(*aUnuseIt))) {
- aNewStorage->addConstraint(*aUnuseIt, aDummyVec);
- anUnusedConstraints.erase(aUnuseIt);
- aUnuseIt = anUnusedConstraints.begin();
- continue;
- }
- aUnuseIt++;
- }
-
- std::list<SketchSolver_Group*>::iterator aCutsIter;
- // Remove unused constraints
- for (aUnuseIt = anUnusedConstraints.begin(); aUnuseIt != anUnusedConstraints.end(); ++aUnuseIt)
- removeConstraint(*aUnuseIt);
-
- SketchSolver_Group* aBaseGroup;
- for (aUnuseIt = anUnusedConstraints.begin(); aUnuseIt != anUnusedConstraints.end(); ++aUnuseIt) {
- aBaseGroup = 0;
- aCutsIter = theCuts.begin();
- // Try to append constraint to the current group
- if (isInteract(*aUnuseIt)) {
- changeConstraint(*aUnuseIt);
- aBaseGroup = this;
- } else {
- // Try to append constraint to already existent group
- for (; aCutsIter != theCuts.end(); ++aCutsIter)
- if ((*aCutsIter)->isInteract(*aUnuseIt)) {
- (*aCutsIter)->changeConstraint(*aUnuseIt);
- break;
- }
- }
-
- if (aCutsIter == theCuts.end() && !aBaseGroup) {
- // Add new group
- SketchSolver_Group* aGroup = new SketchSolver_Group(mySketch);
- aGroup->changeConstraint(*aUnuseIt);
- theCuts.push_back(aGroup);
- } else {
- if (!aBaseGroup)
- aBaseGroup = *aCutsIter++;
- // Find other groups interacting with constraint
- for (; aCutsIter != theCuts.end(); ++aCutsIter)
- if ((*aCutsIter)->isInteract(*aUnuseIt)) {
- aBaseGroup->mergeGroups(**aCutsIter);
- std::list<SketchSolver_Group*>::iterator aRemoveIt = aCutsIter--;
- theCuts.erase(aRemoveIt);
- }
- }
- }
+ std::string aDoFMsg;
+ static const std::string aMsgContext("Sketch");
+ int aDoF = mySketchSolver->dof();
+ /// "DoF = 0" content of string value is used in PartSet by Sketch edit
+ /// If it is changed, it should be corrected also there
+ //if (aDoF == 0) {
+ // static const std::string aMsgDoF("Sketch is fully fixed (DoF = 0)");
+ // aDoFMsg = Config_Translator::translate(aMsgContext, aMsgDoF);
+ //} else {
+ // static const std::string aMsgDoF("DoF (degrees of freedom) = %1");
+ // Events_InfoMessage aMsg(aMsgContext, aMsgDoF);
+ // aMsg.addParameter(aDoF);
+ // aDoFMsg = Config_Translator::translate(aMsg);
+ //}
+ //// store Unicode value for translated message about DoF
+ //size_t aLen = aDoFMsg.size();
+ //std::wstring aWStr(aLen, L'#');
+ //mbstowcs(&aWStr[0], aDoFMsg.c_str(), aLen);
+ //mySketch->string(SketchPlugin_Sketch::SOLVER_DOF())->setValue(aWStr);
+
+ std::ostringstream aStr;
+ aStr << aDoF;
+ mySketch->string(SketchPlugin_Sketch::SOLVER_DOF())->setValue(aStr.str());
+
+ if (aDoF > 0 && myDOF <= 0)
+ sendMessage(EVENT_SKETCH_UNDER_CONSTRAINED, mySketch, aDoF);
+ else if (aDoF == 0 && myDOF != 0)
+ sendMessage(EVENT_SKETCH_FULLY_CONSTRAINED, mySketch, aDoF);
+ else if (aDoF < 0)
+ sendMessage(EVENT_SKETCH_OVER_CONSTRAINED, mySketch, aDoF);
+
+ myDOF = aDoF;