X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGeomAPI%2FGeomAPI_Shape.cpp;h=a957eb3b6219ca18468d13cdc280234c189cdbcd;hb=69ff21c1bc1af665be9419918f64f5a7d1878cbd;hp=e662ea2548c0c26cb72e81cd89b65684cb874a0c;hpb=c80e8ac643930b858f4f653e2659896ba587b165;p=modules%2Fshaper.git diff --git a/src/GeomAPI/GeomAPI_Shape.cpp b/src/GeomAPI/GeomAPI_Shape.cpp index e662ea254..a957eb3b6 100644 --- a/src/GeomAPI/GeomAPI_Shape.cpp +++ b/src/GeomAPI/GeomAPI_Shape.cpp @@ -1,13 +1,109 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + // File: GeomAPI_Shape.cpp // Created: 23 Apr 2014 // Author: Mikhail PONIKAROV #include -#include +#include +#include +#include +#include +#include + +#include -#define MY_PNT static_cast(myImpl) +#define MY_SHAPE implPtr() GeomAPI_Shape::GeomAPI_Shape() - : GeomAPI_Interface(new TopoDS_Shape()) -{} + : GeomAPI_Interface(new TopoDS_Shape()) +{ +} + +bool GeomAPI_Shape::isNull() const +{ + return MY_SHAPE->IsNull() == Standard_True; +} + +bool GeomAPI_Shape::isEqual(const std::shared_ptr theShape) const +{ + if (!theShape.get()) + return false; + if (isNull()) + return theShape->isNull(); + if (theShape->isNull()) + return false; + + return MY_SHAPE->IsEqual(theShape->impl()) == Standard_True; +} + +bool GeomAPI_Shape::isVertex() const +{ + const TopoDS_Shape& aShape = const_cast(this)->impl(); + return !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX; +} + +bool GeomAPI_Shape::isEdge() const +{ + const TopoDS_Shape& aShape = const_cast(this)->impl(); + 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; +} + +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(); +}