1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: GeomAPI_Shape.cpp
4 // Created: 23 Apr 2014
5 // Author: Mikhail PONIKAROV
7 #include<GeomAPI_Shape.h>
9 #include <TopoDS_Shape.hxx>
10 #include <BRepBndLib.hxx>
11 #include <Bnd_Box.hxx>
12 #include <BRepTools.hxx>
16 #define MY_SHAPE static_cast<TopoDS_Shape*>(myImpl)
18 GeomAPI_Shape::GeomAPI_Shape()
19 : GeomAPI_Interface(new TopoDS_Shape())
23 bool GeomAPI_Shape::isNull() const
25 return MY_SHAPE->IsNull() == Standard_True;
28 bool GeomAPI_Shape::isEqual(const std::shared_ptr<GeomAPI_Shape> theShape) const
31 return theShape->isNull();
32 if (theShape->isNull())
35 return MY_SHAPE->IsEqual(theShape->impl<TopoDS_Shape>()) == Standard_True;
38 bool GeomAPI_Shape::isVertex() const
40 const TopoDS_Shape& aShape = const_cast<GeomAPI_Shape*>(this)->impl<TopoDS_Shape>();
41 return !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX;
44 bool GeomAPI_Shape::isEdge() const
46 const TopoDS_Shape& aShape = const_cast<GeomAPI_Shape*>(this)->impl<TopoDS_Shape>();
47 return aShape.ShapeType() == TopAbs_EDGE;
50 bool GeomAPI_Shape::isFace() const
52 const TopoDS_Shape& aShape = const_cast<GeomAPI_Shape*>(this)->impl<TopoDS_Shape>();
53 return aShape.ShapeType() == TopAbs_FACE;
56 bool GeomAPI_Shape::computeSize(double& theXmin, double& theYmin, double& theZmin,
57 double& theXmax, double& theYmax, double& theZmax) const
59 const TopoDS_Shape& aShape = const_cast<GeomAPI_Shape*>(this)->impl<TopoDS_Shape>();
63 BRepBndLib::Add(aShape, aBndBox);
64 aBndBox.Get(theXmin, theYmin, theZmin, theXmax, theYmax, theZmax);
68 std::string GeomAPI_Shape::getShapeStream() const
70 std::ostringstream aStream;
71 const TopoDS_Shape& aShape = const_cast<GeomAPI_Shape*>(this)->impl<TopoDS_Shape>();
72 BRepTools::Write(aShape, aStream);