1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: ConstructionPlugin_Plane.cpp
4 // Created: 12 Dec 2014
5 // Author: Vitaly Smetannikov
7 #include "ConstructionPlugin_Plane.h"
9 #include <ModelAPI_AttributeSelection.h>
10 #include <ModelAPI_AttributeDouble.h>
11 #include <ModelAPI_ResultConstruction.h>
12 #include <GeomAlgoAPI_FaceBuilder.h>
15 #define PLANE_SIZE 300
17 ConstructionPlugin_Plane::ConstructionPlugin_Plane()
21 void ConstructionPlugin_Plane::initAttributes()
23 data()->addAttribute(FACE_ATTR, ModelAPI_AttributeSelection::type());
24 data()->addAttribute(DISTANCE_ATTR, ModelAPI_AttributeDouble::type());
27 void ConstructionPlugin_Plane::execute()
29 AttributeSelectionPtr aFaceAttr = data()->selection(FACE_ATTR);
30 AttributeDoublePtr aDistAttr = data()->real(DISTANCE_ATTR);
31 if ((aFaceAttr.get() != NULL) && (aDistAttr.get() != NULL) &&
32 aFaceAttr->isInitialized() && aDistAttr->isInitialized()) {
34 double aDist = aDistAttr->value();
35 GeomShapePtr aShape = aFaceAttr->value();
36 if (aShape.get() != NULL) {
37 std::shared_ptr<GeomAPI_Pln> aPln = GeomAlgoAPI_FaceBuilder::plane(aShape);
38 std::shared_ptr<GeomAPI_Pnt> aOrig = aPln->location();
39 std::shared_ptr<GeomAPI_Dir> aDir = aPln->direction();
41 aOrig->translate(aDir, aDist);
42 std::shared_ptr<GeomAPI_Shape> aPlane =
43 GeomAlgoAPI_FaceBuilder::square(aOrig, aDir, PLANE_SIZE);
44 ResultConstructionPtr aConstr = document()->createConstruction(data());
45 aConstr->setShape(aPlane);
51 void ConstructionPlugin_Plane::customisePresentation(AISObjectPtr thePrs)
53 thePrs->setColor(50, 255, 50);
54 thePrs->setTransparensy(0.6);