myStorage->update(theFeature->baseAttribute(), GID_OUTOFGROUP);
else if (theFeature->baseFeature())
myStorage->update(theFeature->baseFeature(), GID_OUTOFGROUP);
+
+ if (myBaseConstraint)
+ myStorage->addConstraint(myBaseConstraint, std::list<ConstraintWrapperPtr>());
}
void SketchSolver_ConstraintFixed::getAttributes(
#include <ModelAPI_AttributeRefList.h>
#include <SketchPlugin_Arc.h>
#include <SketchPlugin_Circle.h>
+#include <SketchPlugin_ConstraintRigid.h>
/// \brief Verify two vectors of constraints are equal.
return false;
}
+static bool isUsed(ConstraintPtr theConstraint, AttributePtr theAttribute)
+{
+ if (!theConstraint || !theAttribute)
+ return false;
+ std::list<AttributePtr> anAttrList = theConstraint->data()->attributes(std::string());
+ std::list<AttributePtr>::const_iterator anIt = anAttrList.begin();
+ for (; anIt != anAttrList.end(); ++anIt) {
+ if (*anIt == theAttribute)
+ return true;
+ AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(*anIt);
+ if (aRefAttr && !aRefAttr->isObject() && aRefAttr->attr() == theAttribute)
+ return true;
+ }
+ return false;
+}
+
bool SketchSolver_Storage::isUsed(FeaturePtr theFeature) const
{
if (myFeatureMap.find(theFeature) != myFeatureMap.end())
std::map<ConstraintPtr, std::list<ConstraintWrapperPtr> >::const_iterator
aCIt = myConstraintMap.begin();
std::list<ConstraintWrapperPtr>::const_iterator aCWIt;
- for (; aCIt != myConstraintMap.end(); ++aCIt)
+ for (; aCIt != myConstraintMap.end(); ++aCIt) {
for (aCWIt = aCIt->second.begin(); aCWIt != aCIt->second.end(); ++aCWIt)
if (::isUsed(*aCWIt, anAttribute))
return true;
+ // Additional check for the Fixed constraints, which have no wrapper associated.
+ if (aCIt->first->getKind() == SketchPlugin_ConstraintRigid::ID() &&
+ ::isUsed(aCIt->first, anAttribute))
+ return true;
+ }
// check in features
std::map<FeaturePtr, EntityWrapperPtr>::const_iterator aFIt = myFeatureMap.begin();
for (; aFIt != myFeatureMap.end(); ++aFIt)
return true;
bool isFullyRemoved = removeConstraint((Slvs_hConstraint)aConstraint->id());
+ isFullyRemoved = SketchSolver_Storage::remove(theConstraint) && isFullyRemoved;
// remove point-point coincidence
if (aConstraint->type() == CONSTRAINT_PT_PT_COINCIDENT)
- isFullyRemoved = removeCoincidence(theConstraint);
-
- return SketchSolver_Storage::remove(theConstraint) && isFullyRemoved;
+ isFullyRemoved = removeCoincidence(theConstraint) && isFullyRemoved;
+ return isFullyRemoved;
}
bool SolveSpaceSolver_Storage::remove(EntityWrapperPtr theEntity)
if (!theEntity)
return false;
+ // Additional check for entity to be used in point-point coincidence
+ bool isCoincide = false;
+ if (theEntity->type() == ENTITY_POINT) {
+ CoincidentPointsMap::const_iterator anIt = myCoincidentPoints.begin();
+ std::set<EntityWrapperPtr>::const_iterator aCIt;
+ for (; anIt != myCoincidentPoints.end(); ++anIt) {
+ if (anIt->first == theEntity)
+ break;
+ for (aCIt = anIt->second.begin(); aCIt != anIt->second.end(); ++aCIt)
+ if (*aCIt == theEntity)
+ break;
+ if (aCIt != anIt->second.end())
+ break;
+ }
+ if (anIt != myCoincidentPoints.end()) {
+ if (anIt->first != theEntity && isUsed(anIt->first->baseAttribute()))
+ isCoincide = true;
+ for (aCIt = anIt->second.begin(); !isCoincide && aCIt != anIt->second.end(); ++aCIt)
+ if (*aCIt != theEntity && isUsed((*aCIt)->baseAttribute()))
+ isCoincide = true;
+ }
+ }
+
std::shared_ptr<SolveSpaceSolver_EntityWrapper> anEntity =
std::dynamic_pointer_cast<SolveSpaceSolver_EntityWrapper>(theEntity);
- bool isFullyRemoved = removeEntity((Slvs_hEntity)anEntity->id());
+ bool isFullyRemoved = isCoincide ? true : removeEntity((Slvs_hEntity)anEntity->id());
return SketchSolver_Storage::remove(theEntity) && isFullyRemoved;
}