Salome HOME
Templates for implementation of Geom classes receiving
[modules/shaper.git] / src / GeomAlgoAPI / GeomAlgoAPI_FaceBuilder.cpp
1 // File:        GeomAlgoAPI_FaceBuilder.cpp
2 // Created:     23 Apr 2014
3 // Author:      Mikhail PONIKAROV
4
5 #include <GeomAlgoAPI_FaceBuilder.h>
6 #include <gp_Pln.hxx>
7 #include <BRepBuilderAPI_MakeFace.hxx>
8 #include <TopoDS_Face.hxx>
9
10 boost::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_FaceBuilder::square(
11   boost::shared_ptr<GeomAPI_Pnt> theCenter, boost::shared_ptr<GeomAPI_Dir> theNormal,
12   const double theSize)
13 {
14   const gp_Pnt& aCenter = theCenter->impl<gp_Pnt>();
15   const gp_Dir& aDir = theNormal->impl<gp_Dir>();
16   gp_Pln aPlane(aCenter, aDir);
17   // half of the size in each direction from the center
18   BRepBuilderAPI_MakeFace aFaceBuilder(aPlane, 
19     -theSize / 2., theSize / 2., -theSize / 2., theSize / 2.);
20   boost::shared_ptr<GeomAPI_Shape> aRes(new GeomAPI_Shape);
21   aRes->setImpl(new TopoDS_Shape(aFaceBuilder.Face()));
22   return aRes;
23 }