while (aFeatIter != myFeatures.end()) {
aCIter = aFeatIter->second.find(theConstraint);
if (aCIter != aFeatIter->second.end()) {
- aFeatIter->second.erase(aCIter);
- if (aFeatIter->second.empty()) {
- MapFeatureConstraint::iterator aTmpIter = aFeatIter; // stores iterator for the next element, while the current is deleting
- aTmpIter++;
- myFeatures.erase(aFeatIter);
- aFeatIter = aTmpIter;
- continue;
- }
+ FeaturePtr aFeature = aFeatIter->first;
+ aFeatIter++;
+ removeFeature(aFeature, theConstraint);
+ continue;
}
aFeatIter++;
}
void SketchSolver_FeatureStorage::removeFeature(FeaturePtr theFeature)
{
MapFeatureConstraint::iterator aFeatIter = myFeatures.find(theFeature);
- if (aFeatIter != myFeatures.end())
+ if (aFeatIter == myFeatures.end())
return; // no such feature
std::set<ConstraintPtr> aConstraints = aFeatIter->second;
void SketchSolver_FeatureStorage::removeFeature(FeaturePtr theFeature, ConstraintPtr theConstraint)
{
MapFeatureConstraint::iterator aFeatIter = myFeatures.find(theFeature);
- if (aFeatIter != myFeatures.end())
+ if (aFeatIter == myFeatures.end())
return; // no such feature
std::list<AttributePtr> anAttributes = theFeature->data()->attributes(std::string());
void SketchSolver_FeatureStorage::removeAttribute(AttributePtr theAttribute, FeaturePtr theFeature)
{
MapAttributeFeature::iterator anAttrIter = myAttributes.find(theAttribute);
- if (anAttrIter != myAttributes.end())
+ if (anAttrIter == myAttributes.end())
return; // no such attribute
anAttrIter->second.erase(theFeature);
anUnusedConstraints.push_back(*anIter);
}
- std::vector<SketchSolver_Group*>::iterator aCutsIter;
+ // Check the unused constraints once again, because they may become interacted with new storage since adding constraints
std::vector<ConstraintPtr>::iterator aUnuseIt = anUnusedConstraints.begin();
+ while (aUnuseIt != anUnusedConstraints.end()) {
+ if (aNewFeatStorage->isInteract(*aUnuseIt)) {
+ size_t aShift = aUnuseIt - anUnusedConstraints.begin();
+ anUnusedConstraints.erase(aUnuseIt);
+ aUnuseIt = anUnusedConstraints.begin() + aShift;
+ continue;
+ }
+ aUnuseIt++;
+ }
+
+ std::vector<SketchSolver_Group*>::iterator aCutsIter;
+ aUnuseIt = anUnusedConstraints.begin();
for ( ; aUnuseIt != anUnusedConstraints.end(); aUnuseIt++) {
// Remove unused constraints
removeConstraint(*aUnuseIt);