Salome HOME
Merge branch 'master' of newgeom:newgeom.git
[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 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_FaceBuilder::square(
11   std::shared_ptr<GeomAPI_Pnt> theCenter, std::shared_ptr<GeomAPI_Dir> theNormal,
12   const double theSize)
13 {
14   gp_Pnt* aCenter = static_cast<gp_Pnt*>(theCenter->implementation());
15   gp_Dir* aDir = static_cast<gp_Dir*>(theNormal->implementation());
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   std::shared_ptr<GeomAPI_Shape> aRes(new GeomAPI_Shape);
21   aRes->setImplementation(new TopoDS_Shape(aFaceBuilder.Face()));
22   return aRes;
23 }