bool SketchSolver_Constraint::checkAttributesChanged(ConstraintPtr theConstraint)
{
+ std::set<Slvs_hEntity> aCurAttrs; // list of currently used attributes
+ std::vector<Slvs_hConstraint>::const_iterator aConstrIter = mySlvsConstraints.begin();
+ for (; aConstrIter != mySlvsConstraints.end(); aConstrIter++) {
+ Slvs_Constraint aConstr = myStorage->getConstraint(*aConstrIter);
+ if (aConstr.ptA != SLVS_E_UNKNOWN) aCurAttrs.insert(aConstr.ptA);
+ if (aConstr.ptB != SLVS_E_UNKNOWN) aCurAttrs.insert(aConstr.ptB);
+ if (aConstr.entityA != SLVS_E_UNKNOWN) aCurAttrs.insert(aConstr.entityA);
+ if (aConstr.entityB != SLVS_E_UNKNOWN) aCurAttrs.insert(aConstr.entityB);
+ if (aConstr.entityC != SLVS_E_UNKNOWN) aCurAttrs.insert(aConstr.entityC);
+ if (aConstr.entityD != SLVS_E_UNKNOWN) aCurAttrs.insert(aConstr.entityD);
+ }
// Check the attrbutes of constraint are changed
ConstraintPtr aConstraint = theConstraint ? theConstraint : myBaseConstraint;
std::list<AttributePtr> anAttrList = aConstraint->data()->attributes(std::string());
if (aRefAttr) {
if (aRefAttr->isObject()) {
FeaturePtr aFeature = ModelAPI_Feature::feature(aRefAttr->object());
- if (aFeature && myFeatureMap.find(aFeature) == myFeatureMap.end())
+ std::map<FeaturePtr, Slvs_hEntity>::iterator aFIt = myFeatureMap.find(aFeature);
+ if (aFeature) {
+ if (aFIt == myFeatureMap.end())
+ return true;
+ // Additional check the points of entity
+ if (aCurAttrs.find(aFIt->second) == aCurAttrs.end()) {
+ Slvs_Entity anEntity = myStorage->getEntity(aFIt->second);
+ bool isFound = false;
+ for (int i = 0; i < 4 && !isFound; i++)
+ if (anEntity.point[i] != SLVS_E_UNKNOWN &&
+ aCurAttrs.find(anEntity.point[i]) != aCurAttrs.end())
+ isFound = true;
+ if (!isFound)
+ return true;
+ }
+ }
+ } else if (aRefAttr->attr()) {
+ std::map<AttributePtr, Slvs_hEntity>::iterator anAIt = myAttributeMap.find(aRefAttr->attr());
+ if (anAIt == myAttributeMap.end() || aCurAttrs.find(anAIt->second) == aCurAttrs.end())
return true;
- } else if (aRefAttr->attr() &&
- myAttributeMap.find(aRefAttr->attr()) == myAttributeMap.end())
- return true;
+ }
}
AttributeRefListPtr aRefList =
std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(*anAttrIter);
std::map<AttributePtr, Slvs_hParam>::iterator aTmpIter = aValIt++;
myValueMap.erase(aTmpIter);
}
+ for (size_t i = 0; i < mySlvsConstraints.size(); i++)
+ if (aRemovedConstraints.find(mySlvsConstraints[i]) != aRemovedConstraints.end()) {
+ mySlvsConstraints.erase(mySlvsConstraints.begin() + i);
+ i--;
+ }
}
void SketchSolver_Constraint::getAttributes(
{
cleanErrorMsg();
std::map<AttributePtr, Slvs_hEntity>::iterator anAttrIter = myAttributeMap.begin();
- for (; anAttrIter != myAttributeMap.end(); anAttrIter++) {
+ while (anAttrIter != myAttributeMap.end()) {
std::shared_ptr<GeomDataAPI_Point> aPoint =
std::dynamic_pointer_cast<GeomDataAPI_Point>(anAttrIter->first);
+ Slvs_Entity anEntity = myStorage->getEntity(anAttrIter->second);
+ if (anEntity.h == SLVS_E_UNKNOWN) {
+ std::map<AttributePtr, Slvs_hEntity>::iterator aTmpIter = anAttrIter++;
+ myAttributeMap.erase(aTmpIter);
+ continue;
+ }
if (aPoint) {
- Slvs_Entity anEntity = myStorage->getEntity(anAttrIter->second);
double aXYZ[3];
for (int i = 0; i < 3; i++) {
Slvs_Param aPar = myStorage->getParameter(anEntity.param[i]);
std::shared_ptr<GeomDataAPI_Point2D> aPoint2D =
std::dynamic_pointer_cast<GeomDataAPI_Point2D>(anAttrIter->first);
if (aPoint2D) {
- Slvs_Entity anEntity = myStorage->getEntity(anAttrIter->second);
double aXY[2];
for (int i = 0; i < 2; i++) {
Slvs_Param aPar = myStorage->getParameter(anEntity.param[i]);
AttributeDoublePtr aScalar =
std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(anAttrIter->first);
if (aScalar) {
- Slvs_Entity anEntity = myStorage->getEntity(anAttrIter->second);
Slvs_Param aPar = myStorage->getParameter(anEntity.param[0]);
if (fabs(aScalar->value() - aPar.val) > tolerance)
aScalar->setValue(aPar.val);
}
}
}
+ anAttrIter++;
}
std::map<AttributePtr, Slvs_hParam>::iterator aValIter = myValueMap.begin();