+ AttributeDoublePtr anAttrA = real(ConstructionPlugin_Plane::A());
+ AttributeDoublePtr anAttrB = real(ConstructionPlugin_Plane::B());
+ AttributeDoublePtr anAttrC = real(ConstructionPlugin_Plane::C());
+ AttributeDoublePtr anAttrD = real(ConstructionPlugin_Plane::D());
+ std::shared_ptr<GeomAPI_Shape> aPlaneFace;
+ if ((anAttrA.get() != NULL) && (anAttrB.get() != NULL) &&
+ (anAttrC.get() != NULL) && (anAttrD.get() != NULL) &&
+ anAttrA->isInitialized() && anAttrB->isInitialized() &&
+ anAttrC->isInitialized() && anAttrD->isInitialized() ) {
+ double aA = anAttrA->value(), aB = anAttrB->value(),
+ aC = anAttrC->value(), aD = anAttrD->value();
+ std::shared_ptr<GeomAPI_Pln> aPlane =
+ std::shared_ptr<GeomAPI_Pln>(new GeomAPI_Pln(aA, aB, aC, aD));
+ double aSize = Config_PropManager::integer(SKETCH_TAB_NAME, "planes_size");
+ aSize *= 4.;
+ aPlaneFace = GeomAlgoAPI_FaceBuilder::squareFace(aPlane, aSize);
+ }
+ return aPlaneFace;
+}
+
+//==================================================================================================
+std::shared_ptr<GeomAPI_Shape> ConstructionPlugin_Plane::createByThreePoints()
+{
+ // Get first point.
+ AttributeSelectionPtr aPointSelection1 = selection(POINT1());
+ GeomShapePtr aPointShape1 = aPointSelection1->value();
+ if(!aPointShape1.get()) {
+ aPointShape1 = aPointSelection1->context()->shape();
+ }
+ std::shared_ptr<GeomAPI_Vertex> aVertex1(new GeomAPI_Vertex(aPointShape1));
+
+ // Get second point.
+ AttributeSelectionPtr aPointSelection2 = selection(POINT2());
+ GeomShapePtr aPointShape2 = aPointSelection2->value();
+ if(!aPointShape2.get()) {
+ aPointShape2 = aPointSelection2->context()->shape();
+ }
+ std::shared_ptr<GeomAPI_Vertex> aVertex2(new GeomAPI_Vertex(aPointShape2));
+
+ // Get third point.
+ AttributeSelectionPtr aPointSelection3 = selection(POINT3());
+ GeomShapePtr aPointShape3 = aPointSelection3->value();
+ if(!aPointShape3.get()) {
+ aPointShape3 = aPointSelection3->context()->shape();
+ }
+ std::shared_ptr<GeomAPI_Vertex> aVertex3(new GeomAPI_Vertex(aPointShape3));
+
+ GeomShapePtr aRes = faceByThreeVertices(aVertex1, aVertex2, aVertex3);
+
+ return aRes;
+}
+
+//==================================================================================================
+std::shared_ptr<GeomAPI_Shape> ConstructionPlugin_Plane::createByLineAndPoint()
+{
+ // Get edge.
+ AttributeSelectionPtr anEdgeSelection = selection(LINE());
+ GeomShapePtr aLineShape = anEdgeSelection->value();
+ if(!aLineShape.get()) {
+ aLineShape = anEdgeSelection->context()->shape();
+ }
+ std::shared_ptr<GeomAPI_Edge> anEdge(new GeomAPI_Edge(aLineShape));
+
+ // Get point.
+ AttributeSelectionPtr aPointSelection = selection(POINT());
+ GeomShapePtr aPointShape = aPointSelection->value();
+ if(!aPointShape.get()) {
+ aPointShape = aPointSelection->context()->shape();
+ }
+ std::shared_ptr<GeomAPI_Vertex> aVertex(new GeomAPI_Vertex(aPointShape));
+
+ // Get perpendicular flag.
+ bool anIsPerpendicular= boolean(PERPENDICULAR())->value();
+
+ GeomShapePtr aRes;
+ if(anIsPerpendicular) {
+ std::shared_ptr<GeomAPI_Lin> aLin = anEdge->line();
+ std::shared_ptr<GeomAPI_Pnt> aPnt = aVertex->point();
+ std::shared_ptr<GeomAPI_Pln> aNewPln(new GeomAPI_Pln(aPnt, aLin->direction()));
+ double aSize = aLin->distance(aPnt) * 2;
+ // point may belong to line, so for the face size use maximum distance between point and line
+ // and the line size (distance between the start and end point)
+ double aDistance = anEdge->firstPoint()->distance(anEdge->lastPoint());
+ aRes = GeomAlgoAPI_FaceBuilder::squareFace(aNewPln, aSize > aDistance ? aSize : aDistance);
+ } else {
+ std::shared_ptr<GeomAPI_Vertex> aV1, aV2;
+ GeomAlgoAPI_ShapeTools::findBounds(anEdge, aV1, aV2);
+ aRes = faceByThreeVertices(aV1, aV2, aVertex);
+ }
+
+ return aRes;
+}
+
+//==================================================================================================
+std::shared_ptr<GeomAPI_Shape> ConstructionPlugin_Plane::createByDistanceFromOther()
+{
+ AttributeSelectionPtr aFaceAttr = data()->selection(ConstructionPlugin_Plane::PLANE());