X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGeomAPI%2FGeomAPI_Shape.cpp;h=a957eb3b6219ca18468d13cdc280234c189cdbcd;hb=69ff21c1bc1af665be9419918f64f5a7d1878cbd;hp=955fb123345d1151dc8d7bd4aa406bae5cf9d79a;hpb=7df39a23a9c0692ec712d6024888abf2b5699df9;p=modules%2Fshaper.git diff --git a/src/GeomAPI/GeomAPI_Shape.cpp b/src/GeomAPI/GeomAPI_Shape.cpp index 955fb1233..a957eb3b6 100644 --- a/src/GeomAPI/GeomAPI_Shape.cpp +++ b/src/GeomAPI/GeomAPI_Shape.cpp @@ -7,13 +7,14 @@ #include #include +#include #include #include #include #include -#define MY_SHAPE static_cast(myImpl) +#define MY_SHAPE implPtr() GeomAPI_Shape::GeomAPI_Shape() : GeomAPI_Interface(new TopoDS_Shape()) @@ -46,25 +47,45 @@ bool GeomAPI_Shape::isVertex() const bool GeomAPI_Shape::isEdge() const { const TopoDS_Shape& aShape = const_cast(this)->impl(); - return aShape.ShapeType() == TopAbs_EDGE; + return !aShape.IsNull() && aShape.ShapeType() == TopAbs_EDGE; } bool GeomAPI_Shape::isFace() const { const TopoDS_Shape& aShape = const_cast(this)->impl(); - return aShape.ShapeType() == TopAbs_FACE; + return !aShape.IsNull() && aShape.ShapeType() == TopAbs_FACE; } bool GeomAPI_Shape::isCompound() const { const TopoDS_Shape& aShape = const_cast(this)->impl(); - return aShape.ShapeType() == TopAbs_COMPOUND; + return !aShape.IsNull() && aShape.ShapeType() == TopAbs_COMPOUND; +} + +bool GeomAPI_Shape::isCompoundOfSolids() const +{ + const TopoDS_Shape& aShape = const_cast(this)->impl(); + 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(this)->impl(); - return aShape.ShapeType() == TopAbs_SOLID; + return !aShape.IsNull() && aShape.ShapeType() == TopAbs_SOLID; +} + +GeomAPI_Shape::ShapeType GeomAPI_Shape::shapeType() const +{ + const TopoDS_Shape& aShape = impl(); + return (ShapeType)aShape.ShapeType(); } bool GeomAPI_Shape::computeSize(double& theXmin, double& theYmin, double& theZmin,