#include<GeomAPI_Shape.h>
#include <TopoDS_Shape.hxx>
+#include <TopoDS_Iterator.hxx>
#include <BRepBndLib.hxx>
#include <Bnd_Box.hxx>
#include <BRepTools.hxx>
#include <sstream>
-#define MY_SHAPE static_cast<TopoDS_Shape*>(myImpl)
+#define MY_SHAPE implPtr<TopoDS_Shape>()
GeomAPI_Shape::GeomAPI_Shape()
: GeomAPI_Interface(new TopoDS_Shape())
bool GeomAPI_Shape::isEdge() const
{
const TopoDS_Shape& aShape = const_cast<GeomAPI_Shape*>(this)->impl<TopoDS_Shape>();
- return aShape.ShapeType() == TopAbs_EDGE;
+ return !aShape.IsNull() && aShape.ShapeType() == TopAbs_EDGE;
}
bool GeomAPI_Shape::isFace() const
{
const TopoDS_Shape& aShape = const_cast<GeomAPI_Shape*>(this)->impl<TopoDS_Shape>();
- return aShape.ShapeType() == TopAbs_FACE;
+ return !aShape.IsNull() && aShape.ShapeType() == TopAbs_FACE;
}
bool GeomAPI_Shape::isCompound() const
{
const TopoDS_Shape& aShape = const_cast<GeomAPI_Shape*>(this)->impl<TopoDS_Shape>();
- return aShape.ShapeType() == TopAbs_COMPOUND;
+ 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.ShapeType() == TopAbs_SOLID;
+ return !aShape.IsNull() && aShape.ShapeType() == TopAbs_SOLID;
+}
+
+bool GeomAPI_Shape::isCompSolid() const
+{
+ const TopoDS_Shape& aShape = const_cast<GeomAPI_Shape*>(this)->impl<TopoDS_Shape>();
+ return !aShape.IsNull() && aShape.ShapeType() == TopAbs_COMPSOLID;
+}
+
+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,