Salome HOME
Make plane as close as possible to selected shape by its size
[modules/shaper.git] / src / GeomAlgoAPI / GeomAlgoAPI_FaceBuilder.cpp
index 9816c160eca4f85ec422f50814da9d5c28d9bb75..2dc527d9d5462e97016396853b31144b6e9f754a 100644 (file)
@@ -52,3 +52,21 @@ std::shared_ptr<GeomAPI_Pln> GeomAlgoAPI_FaceBuilder::plane(
   aResult = std::shared_ptr<GeomAPI_Pln>(new GeomAPI_Pln(aA, aB, aC, aD));
   return aResult;
 }
+
+
+std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_FaceBuilder::
+  planarFace(std::shared_ptr<GeomAPI_Pln> thePlane,
+             double theX, double theY,
+             double theWidth, double theHeight)
+{
+  double aA, aB, aC, aD;
+  thePlane->coefficients(aA, aB, aC, aD);
+  gp_Pln aPlane(aA, aB, aC, aD);
+
+  // half of the size in each direction from the center
+  BRepBuilderAPI_MakeFace aFaceBuilder(aPlane, theX, theX + theWidth, 
+                                       theY, theY + theHeight);
+  std::shared_ptr<GeomAPI_Shape> aRes(new GeomAPI_Shape);
+  aRes->setImpl(new TopoDS_Shape(aFaceBuilder.Face()));
+  return aRes;
+}
\ No newline at end of file