- // Fix base features for fillet
- if (isNewConstraint && theConstraint->getKind() == SketchPlugin_ConstraintFillet::ID()) {
- std::list<AttributePtr> anAttrList =
- theConstraint->data()->attributes(ModelAPI_AttributeRefAttr::typeId());
- std::list<AttributePtr>::iterator anAttrIter = anAttrList.begin();
- for (; anAttrIter != anAttrList.end(); anAttrIter++) {
- AttributeRefAttrPtr aRefAttr =
- std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(*anAttrIter);
- if (!aRefAttr || !aRefAttr->isObject())
- continue;
- FeaturePtr aFeature = ModelAPI_Feature::feature(aRefAttr->object());
- SolverConstraintPtr aConstraint =
- SketchSolver_Builder::getInstance()->createRigidConstraint(aFeature);
- if (!aConstraint)
- continue;
- aConstraint->setGroup(this);
- aConstraint->setStorage(myStorage);
- setTemporary(aConstraint);
- }
- }
- // Fix mirror line
- if (theConstraint->getKind() == SketchPlugin_ConstraintMirror::ID()) {
- AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
- theConstraint->attribute(SketchPlugin_ConstraintMirror::ENTITY_A()));
- if (aRefAttr && aRefAttr->isObject()) {
- FeaturePtr aFeature = ModelAPI_Feature::feature(aRefAttr->object());
- if (aFeature) {
- SolverConstraintPtr aConstraint =
- SketchSolver_Builder::getInstance()->createRigidConstraint(aFeature);
- if (aConstraint) {
- aConstraint->setGroup(this);
- aConstraint->setStorage(myStorage);
- setTemporary(aConstraint);
- }
- }
- }
- }
-
- if (!myFeatureStorage)
- myFeatureStorage = FeatureStoragePtr(new SketchSolver_FeatureStorage);
- myFeatureStorage->changeConstraint(theConstraint);
-
- // Check the attributes of constraint are given by parametric expression
- std::list<AttributePtr> anAttributes =
- theConstraint->data()->attributes(ModelAPI_AttributeRefAttr::typeId());
- std::list<AttributePtr>::iterator anAttrIt = anAttributes.begin();
- for (; anAttrIt != anAttributes.end(); ++anAttrIt) {
- AttributeRefAttrPtr aRefAttr =
- std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(*anAttrIt);
- if (!aRefAttr)
- continue;
-
- std::shared_ptr<GeomDataAPI_Point2D> aPoint;
- if (aRefAttr->isObject()) {
- FeaturePtr aFeat = ModelAPI_Feature::feature(aRefAttr->object());
- if (aFeat->getKind() != SketchPlugin_Point::ID())
- continue;
- aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- aFeat->attribute(SketchPlugin_Point::COORD_ID()));
- } else
- aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aRefAttr->attr());
-
- if (!aPoint || (aPoint->textX().empty() && aPoint->textY().empty()))
- continue;
-
- std::map<AttributePtr, SolverConstraintPtr>::iterator aFound =
- myParametricConstraints.find(aPoint);
- if (aFound == myParametricConstraints.end()) {
- SolverConstraintPtr aConstraint =
- SketchSolver_Builder::getInstance()->createParametricConstraint(aPoint);
- if (!aConstraint)
- continue;
- aConstraint->setGroup(this);
- aConstraint->setStorage(myStorage);
- myParametricConstraints[aPoint] = aConstraint;
- } else
- aFound->second->update();
- }
-