1 // File: SketchPlugin_Sketch.cxx
2 // Created: 27 Mar 2014
3 // Author: Mikhail PONIKAROV
5 #include "SketchPlugin_Sketch.h"
6 #include <ModelAPI_Data.h>
7 #include <GeomAlgoAPI_FaceBuilder.h>
8 #include <GeomAlgoAPI_CompoundBuilder.h>
12 // face of the square-face displayed for selection of general plane
13 const double PLANE_SIZE = 200;
15 SketchPlugin_Sketch::SketchPlugin_Sketch()
19 void SketchPlugin_Sketch::initAttributes()
21 //data()->addAttribute(PART_ATTR_DOC_REF, ModelAPI_AttributeDocRef::type());
24 void SketchPlugin_Sketch::execute()
28 const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Sketch::preview()
30 std::list<boost::shared_ptr<GeomAPI_Shape> > aFaces;
32 addPlane(1, 0, 0, aFaces); // YZ plane
33 addPlane(0, 1, 0, aFaces); // XZ plane
34 addPlane(0, 0, 1, aFaces); // XY plane
35 boost::shared_ptr<GeomAPI_Shape> aCompound = GeomAlgoAPI_CompoundBuilder::compound(aFaces);
36 setPreview(aCompound);
41 void SketchPlugin_Sketch::addPlane(double theX, double theY, double theZ,
42 std::list<boost::shared_ptr<GeomAPI_Shape> >& theShapes) const
44 boost::shared_ptr<GeomAPI_Pnt> anOrigin(new GeomAPI_Pnt(0, 0, 0));
45 boost::shared_ptr<GeomAPI_Dir> aNormal(new GeomAPI_Dir(theX, theY, theZ));
46 boost::shared_ptr<GeomAPI_Shape> aFace =
47 GeomAlgoAPI_FaceBuilder::square(anOrigin, aNormal, PLANE_SIZE);
48 theShapes.push_back(aFace);