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
33 return theShape->isNull();
34 if (theShape->isNull())
37 return MY_SHAPE->IsEqual(theShape->impl<TopoDS_Shape>()) == Standard_True;
40 bool GeomAPI_Shape::isVertex() const
42 const TopoDS_Shape& aShape = const_cast<GeomAPI_Shape*>(this)->impl<TopoDS_Shape>();
43 return !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX;
46 bool GeomAPI_Shape::isEdge() const
48 const TopoDS_Shape& aShape = const_cast<GeomAPI_Shape*>(this)->impl<TopoDS_Shape>();
49 return aShape.ShapeType() == TopAbs_EDGE;
52 bool GeomAPI_Shape::isFace() const
54 const TopoDS_Shape& aShape = const_cast<GeomAPI_Shape*>(this)->impl<TopoDS_Shape>();
55 return aShape.ShapeType() == TopAbs_FACE;
58 bool GeomAPI_Shape::computeSize(double& theXmin, double& theYmin, double& theZmin,
59 double& theXmax, double& theYmax, double& theZmax) const
61 const TopoDS_Shape& aShape = const_cast<GeomAPI_Shape*>(this)->impl<TopoDS_Shape>();
65 BRepBndLib::Add(aShape, aBndBox);
66 aBndBox.Get(theXmin, theYmin, theZmin, theXmax, theYmax, theZmax);
70 std::string GeomAPI_Shape::getShapeStream() const
72 std::ostringstream aStream;
73 const TopoDS_Shape& aShape = const_cast<GeomAPI_Shape*>(this)->impl<TopoDS_Shape>();
74 BRepTools::Write(aShape, aStream);