Salome HOME
Issue #856: "show parent feature" should be available only on result bodies
[modules/shaper.git] / src / GeomAPI / GeomAPI_Shape.cpp
index 41f1278608c1656de5fac1923b387e989653f260..a957eb3b6219ca18468d13cdc280234c189cdbcd 100644 (file)
@@ -7,6 +7,7 @@
 #include<GeomAPI_Shape.h>
 
 #include <TopoDS_Shape.hxx>
+#include <TopoDS_Iterator.hxx>
 #include <BRepBndLib.hxx>
 #include <Bnd_Box.hxx>
 #include <BRepTools.hxx>
@@ -61,12 +62,32 @@ bool GeomAPI_Shape::isCompound() const
   return !aShape.IsNull() && aShape.ShapeType() == TopAbs_COMPOUND;
 }
 
+bool GeomAPI_Shape::isCompoundOfSolids() const
+{
+  const TopoDS_Shape& aShape = const_cast<GeomAPI_Shape*>(this)->impl<TopoDS_Shape>();
+  if (aShape.IsNull() || aShape.ShapeType() != TopAbs_COMPOUND)
+    return false;
+  bool isAtLeastOne = false;
+  for(TopoDS_Iterator aSubs(aShape); aSubs.More(); aSubs.Next()) {
+    if (aSubs.Value().IsNull() || aSubs.Value().ShapeType() != TopAbs_SOLID)
+      return false;
+    isAtLeastOne = true;
+  }
+  return isAtLeastOne;
+}
+
 bool GeomAPI_Shape::isSolid() const
 {
   const TopoDS_Shape& aShape = const_cast<GeomAPI_Shape*>(this)->impl<TopoDS_Shape>();
   return !aShape.IsNull() && aShape.ShapeType() == TopAbs_SOLID;
 }
 
+GeomAPI_Shape::ShapeType GeomAPI_Shape::shapeType() const
+{
+  const TopoDS_Shape& aShape = impl<TopoDS_Shape>();
+  return (ShapeType)aShape.ShapeType();
+}
+
 bool GeomAPI_Shape::computeSize(double& theXmin, double& theYmin, double& theZmin,
                                 double& theXmax, double& theYmax, double& theZmax) const
 {