Salome HOME
Dump with geometrical selection
[modules/shaper.git] / src / GeomAPI / GeomAPI_Shell.cpp
index 5b7713a96a4e7f5bae799e120cc4d4fd5229cd51..baab4a1a9fd9cfb12db13622f5dbc75803655aaa 100644 (file)
@@ -32,6 +32,8 @@
 #include "GeomAPI_XYZ.h"
 
 #include <BRep_Builder.hxx>
+#include <BRepGProp.hxx>
+#include <GProp_GProps.hxx>
 #include <Precision.hxx>
 #include <TopExp_Explorer.hxx>
 #include <TopoDS.hxx>
@@ -365,3 +367,20 @@ std::shared_ptr<GeomAPI_Box> GeomAPI_Shell::getParallelepiped() const
                                   aPlanes[anIndex].myHeight));
   return aBox;
 }
+
+//=================================================================================================
+GeomPointPtr GeomAPI_Shell::middlePoint() const
+{
+  GeomPointPtr anInnerPoint;
+
+  const TopoDS_Shell& aShell = impl<TopoDS_Shell>();
+  if (aShell.IsNull())
+    return anInnerPoint;
+
+  GProp_GProps aProps;
+  BRepGProp::SurfaceProperties(aShell, aProps, 1.e-4);
+
+  gp_Pnt aPnt = aProps.CentreOfMass();
+  anInnerPoint = GeomPointPtr(new GeomAPI_Pnt(aPnt.X(), aPnt.Y(), aPnt.Z()));
+  return anInnerPoint;
+}