X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGeomAPI%2FGeomAPI_Shape.cpp;h=5a84a3d98680abc7ba2753556332fe53b31bffb1;hb=0448acdd8e8c1e1638a2cf861e42e915966b2034;hp=30e2f342522498a2ea66f752eedd880f513b7584;hpb=cd9217d7e87997ec8bc150a6d8c389e742ca0f84;p=modules%2Fshaper.git diff --git a/src/GeomAPI/GeomAPI_Shape.cpp b/src/GeomAPI/GeomAPI_Shape.cpp index 30e2f3425..5a84a3d98 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,27 +7,68 @@ #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()) { } -bool GeomAPI_Shape::isNull() +bool GeomAPI_Shape::isNull() const { - return MY_SHAPE->IsNull(); + return MY_SHAPE->IsNull() == Standard_True; +} + +bool GeomAPI_Shape::isEqual(const std::shared_ptr theShape) const +{ + 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.TShape()->ShapeType() == TopAbs_VERTEX; + return !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX; } bool GeomAPI_Shape::isEdge() const { const TopoDS_Shape& aShape = const_cast(this)->impl(); - return aShape.TShape()->ShapeType() == TopAbs_EDGE; + 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; +} + +std::string GeomAPI_Shape::getShapeStream() const +{ + std::ostringstream aStream; + const TopoDS_Shape& aShape = const_cast(this)->impl(); + BRepTools::Write(aShape, aStream); + return aStream.str(); }