}
// Value if exists
+ DataPtr aData = myBaseConstraint->data();
+ if (!aData) return;
AttributeDoublePtr aValueAttr = std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
- myBaseConstraint->data()->attribute(SketchPlugin_Constraint::VALUE()));
+ myBaseConstraint->attribute(SketchPlugin_Constraint::VALUE()));
double aValue = aValueAttr ? aValueAttr->value() : 0.0;
// Update constraint
if (aResult != SLVS_E_UNKNOWN) {
Slvs_Entity anEnt = myStorage->getEntity(aResult);
theType = anEnt.type;
+ myAttributeMap[theEntity] = aResult;
return aResult;
}
}
if (aResult != SLVS_E_UNKNOWN) {
Slvs_Entity anEnt = myStorage->getEntity(aResult);
theType = anEnt.type;
+ myFeatureMap[theEntity] = aResult;
return aResult;
}
}
#include <GeomDataAPI_Point.h>
#include <GeomDataAPI_Point2D.h>
#include <ModelAPI_AttributeDouble.h>
-#include <ModelAPI_AttributeRefList.h>
#include <ModelAPI_Document.h>
#include <ModelAPI_Events.h>
#include <ModelAPI_ResultConstruction.h>
myTempConstraints.insert(aConstraint);
}
}
+ // Fix base features for mirror
+ if (theConstraint->getKind() == SketchPlugin_ConstraintMirror::ID()) {
+ AttributeRefListPtr aRefList = std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(
+ theConstraint->attribute(SketchPlugin_ConstraintMirror::ENTITY_B()));
+ fixFeaturesList(aRefList);
+ }
if (!myFeatureStorage)
myFeatureStorage = FeatureStoragePtr(new SketchSolver_FeatureStorage);
myTempConstraints.insert(aConstraint);
}
+// ============================================================================
+// Function: fixFeaturesList
+// Class: SketchSolver_Group
+// Purpose: Apply temporary rigid constraints for the list of features
+// ============================================================================
+void SketchSolver_Group::fixFeaturesList(AttributeRefListPtr theList)
+{
+ std::list<ObjectPtr> aList = theList->list();
+ std::list<ObjectPtr>::iterator anIt = aList.begin();
+ for (; anIt != aList.end(); anIt++) {
+ if (!(*anIt))
+ continue;
+ FeaturePtr aFeature = ModelAPI_Feature::feature(*anIt);
+ SolverConstraintPtr aConstraint =
+ SketchSolver_Builder::getInstance()->createRigidConstraint(aFeature);
+ if (!aConstraint)
+ continue;
+ aConstraint->setGroup(this);
+ aConstraint->setStorage(myStorage);
+ myTempConstraints.insert(aConstraint);
+ }
+}
+
// ============================================================================
// Function: addWorkplane
// Class: SketchSolver_Group
#include <SketchPlugin_Constraint.h>
#include <ModelAPI_Data.h>
#include <ModelAPI_Feature.h>
-
+#include <ModelAPI_AttributeRefList.h>
#include <memory>
#include <list>
*/
bool addWorkplane(CompositeFeaturePtr theSketch);
+ /// \brief Apply temporary rigid constraints for the list of features
+ void fixFeaturesList(AttributeRefListPtr theList);
+
private:
Slvs_hGroup myID; ///< Index of the group
Slvs_hEntity myWorkplaneID; ///< Index of workplane, the group is based on