aCoPtIter->find(aConstrEnt[0]) != aCoPtIter->end(),
aCoPtIter->find(aConstrEnt[1]) != aCoPtIter->end(),
};
- if (isFound[0] && isFound[1]) // points are already connected by coincidence constraints => no need to additional one
+ if (isFound[0] && isFound[1]) // points are already connected by coincidence constraints => no need additional one
+ {
+ myExtraCoincidence.insert(theConstraint); // the constraint is stored for further purposes
return false;
+ }
if ((isFound[0] && !isFound[1]) || (!isFound[0] && isFound[1]))
{
if (aFirstFound != myCoincidentPoints.end())
break;
}
}
- // Add new group is no one is found
+ // Add new group if no one is found
if (aGrEntIter == aGroupsEntities.end())
{
std::set<Slvs_hEntity> aNewGrEnt;
std::map<boost::shared_ptr<SketchPlugin_Constraint>, Slvs_hConstraint>::reverse_iterator
aConstrIter = myConstraintMap.rbegin();
bool isAllValid = true;
- for ( ; isAllValid && aConstrIter != myConstraintMap.rend(); aConstrIter++)
+ bool isCCRemoved = false; // indicates that at least one of coincidence constraints was removed
+ while (isAllValid && aConstrIter != myConstraintMap.rend())
+ {
if (!aConstrIter->first->data()->isValid())
{
- removeConstraint(aConstrIter->first);
+ if (aConstrIter->first->getKind().compare("SketchConstraintCoincidence") == 0)
+ isCCRemoved = true;
+ std::map<boost::shared_ptr<SketchPlugin_Constraint>, Slvs_hConstraint>::reverse_iterator
+ aCopyIter = aConstrIter++;
+ removeConstraint(aCopyIter->first);
isAllValid = false;
}
+ else aConstrIter++;
+ }
+
+ // Probably, need to update coincidence constraints
+ if (isCCRemoved && !myExtraCoincidence.empty())
+ {
+ // Make a copy, because the new list of unused constrtaints will be generated
+ std::set< boost::shared_ptr<SketchPlugin_Constraint> > anExtraCopy = myExtraCoincidence;
+ myExtraCoincidence.clear();
+
+ std::set< boost::shared_ptr<SketchPlugin_Constraint> >::iterator
+ aCIter = anExtraCopy.begin();
+ for ( ; aCIter != anExtraCopy.end(); aCIter++)
+ if ((*aCIter)->data()->isValid())
+ changeConstraint(*aCIter);
+ }
+
return !isAllValid;
}
for ( ; aCoPtIter != myCoincidentPoints.end(); aCoPtIter++)
aCoPtIter->erase(*aRemIter);
}
+ if (myCoincidentPoints.size() == 1 && myCoincidentPoints.front().empty())
+ myCoincidentPoints.clear();
}
std::vector<Slvs_hParam> myTempPointWhereDragged; ///< Parameters of one of the points which is moved by user
Slvs_hEntity myTempPointWDrgdID; ///< Identifier of such point
std::list<Slvs_hConstraint> myTempConstraints; ///< The list of identifiers of temporary constraints (SLVS_C_WHERE_DRAGGED) applied for all other points moved by user
- // NOTE: First ID in the list corresponds to myTempPointWhereDragged parameters and does not added to myConstraints list
-
- std::vector< std::set<Slvs_hEntity> >
- myCoincidentPoints; ///< Stores the lists of identifiers of coincident points (to avoid unnecessary coincidence constraints)
// SketchPlugin entities
boost::shared_ptr<SketchPlugin_Feature>
myConstraintMap; ///< The map between SketchPlugin and SolveSpace constraints
std::map<boost::shared_ptr<ModelAPI_Attribute>, Slvs_hEntity>
myEntityMap; ///< The map between parameters of constraints and their equivalent SolveSpace entities
+
+ // Conincident items
+ std::vector< std::set<Slvs_hEntity> >
+ myCoincidentPoints; ///< Stores the lists of identifiers of coincident points (to avoid unnecessary coincidence constraints)
+ std::set< boost::shared_ptr<SketchPlugin_Constraint> >
+ myExtraCoincidence; ///< Additional coincidence constraints which are not necessary (coincidence between points already done
+ ///< by other constraints) but created by GUI tools. Useful when some coincidence constraints were removed
};
#endif