X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGeomAPI%2FGeomAPI_Shape.cpp;h=78d5105ee98e9e55bd110eba04b3445c85033c0c;hb=ce9008bdda3fa14d6fa6c61360541249ccf43ce0;hp=ded2008375e370727b818657712fae59ee2c7634;hpb=9d39123efbd6bde772377542ce40fb51f7925c1f;p=modules%2Fshaper.git diff --git a/src/GeomAPI/GeomAPI_Shape.cpp b/src/GeomAPI/GeomAPI_Shape.cpp index ded200837..78d5105ee 100644 --- a/src/GeomAPI/GeomAPI_Shape.cpp +++ b/src/GeomAPI/GeomAPI_Shape.cpp @@ -1,18 +1,76 @@ +// 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 -#define MY_PNT static_cast(myImpl) +#define MY_SHAPE static_cast(myImpl) 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.ShapeType() == TopAbs_EDGE; +} + +bool GeomAPI_Shape::isFace() const +{ + const TopoDS_Shape& aShape = const_cast(this)->impl(); + return aShape.ShapeType() == TopAbs_FACE; +} + +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; } -bool GeomAPI_Shape::isNull() +std::string GeomAPI_Shape::getShapeStream() const { - return MY_SHAPE->IsNull(); + std::ostringstream aStream; + const TopoDS_Shape& aShape = const_cast(this)->impl(); + BRepTools::Write(aShape, aStream); + return aStream.str(); }