+ AttributePointPtr aPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point>
+ (aPoint->data()->attribute("point3d"));
+ aPointAttr->setValue(theX, theY, theZ);
+ aPoint->string("creation_method")->setValue("by_xyz");
+ aPoint->data()->setName(theName);
+ // don't show automatically created feature in the features history
+ aPoint->setInHistory(aPoint, false);
+
+ // the point should be executed in order to build the feature result immediatelly
+ // the results are to be hidden in the plugin
+ aPoint->execute();
+ aPoint->data()->execState(ModelAPI_StateDone);
+ aPoint->firstResult()->data()->execState(ModelAPI_StateDone);
+
+ return aPoint;
+}
+
+FeaturePtr InitializationPlugin_Plugin::createAxis(DocumentPtr theDoc, FeaturePtr theOrigin,
+ double theX, double theY, double theZ)
+{
+ std::shared_ptr<ModelAPI_Feature> aAxis = theDoc->addFeature("Axis");
+ aAxis->string("CreationMethod")->setValue("AxisByPointAndDirection");
+
+ ResultPtr aResult = theOrigin->firstResult();
+ aAxis->selection("FirstPoint")->setValue(aResult, aResult->shape());
+
+ aAxis->real("X_Direction")->setValue(theX);
+ aAxis->real("Y_Direction")->setValue(theY);
+ aAxis->real("Z_Direction")->setValue(theZ);
+
+ if (theX != 0) {
+ aAxis->data()->setName(L"OX");
+ } else if (theY != 0) {
+ aAxis->data()->setName(L"OY");
+ } else if (theZ != 0) {
+ aAxis->data()->setName(L"OZ");
+ }
+ // don't show automatically created feature in the features history
+ aAxis->setInHistory(aAxis, false);
+ aAxis->execute();
+ aAxis->data()->execState(ModelAPI_StateDone);
+ aAxis->firstResult()->data()->execState(ModelAPI_StateDone);
+
+ return aAxis;
+}
+
+void InitializationPlugin_Plugin::createPart(DocumentPtr thePartSet)
+{
+ std::shared_ptr<ModelAPI_Feature> aPart = thePartSet->addFeature("Part");
+ if (aPart.get())
+ aPart->execute(); // to initialize and activate this part document