X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGeomAPI%2FGeomAPI_Shape.cpp;h=17e87d85c3cd3f668e7b1c1cdb3572b18a40a7a9;hb=29f1c8ff3eb53f7ba5dd54ead45d3e55775e5968;hp=0e5bcb010afce528fa68654ab66f867f918af232;hpb=93310e00f0ac95395137c842108790bf62e6425e;p=modules%2Fshaper.git diff --git a/src/GeomAPI/GeomAPI_Shape.cpp b/src/GeomAPI/GeomAPI_Shape.cpp index 0e5bcb010..17e87d85c 100644 --- a/src/GeomAPI/GeomAPI_Shape.cpp +++ b/src/GeomAPI/GeomAPI_Shape.cpp @@ -1,3 +1,5 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + // File: GeomAPI_Shape.cpp // Created: 23 Apr 2014 // Author: Mikhail PONIKAROV @@ -5,8 +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()) @@ -18,8 +26,10 @@ bool GeomAPI_Shape::isNull() const return MY_SHAPE->IsNull() == Standard_True; } -bool GeomAPI_Shape::isEqual(const boost::shared_ptr theShape) const +bool GeomAPI_Shape::isEqual(const std::shared_ptr theShape) const { + if (!theShape.get()) + return false; if (isNull()) return theShape->isNull(); if (theShape->isNull()) @@ -37,5 +47,69 @@ 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.IsNull() && aShape.ShapeType() == TopAbs_FACE; +} + +bool GeomAPI_Shape::isCompound() const +{ + const TopoDS_Shape& aShape = const_cast(this)->impl(); + 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.IsNull() && aShape.ShapeType() == TopAbs_SOLID; +} + +bool GeomAPI_Shape::isCompSolid() const +{ + const TopoDS_Shape& aShape = const_cast(this)->impl(); + return !aShape.IsNull() && aShape.ShapeType() == TopAbs_COMPSOLID; +} + +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, + double& theXmax, double& theYmax, double& theZmax) const +{ + const TopoDS_Shape& aShape = const_cast(this)->impl(); + if (aShape.IsNull()) + return false; + Bnd_Box aBndBox; + BRepBndLib::Add(aShape, aBndBox); + aBndBox.Get(theXmin, theYmin, theZmin, theXmax, theYmax, theZmax); + return true; +} + +std::string GeomAPI_Shape::getShapeStream() const +{ + std::ostringstream aStream; + const TopoDS_Shape& aShape = const_cast(this)->impl(); + BRepTools::Write(aShape, aStream); + return aStream.str(); }