Salome HOME
Fix for stable processing of mirror constraint (eliminating SolveSpace problems)
[modules/shaper.git] / src / GeomAPI / GeomAPI_Shape.cpp
index 36fa298ef1b2e48dad1c9dcef4bca6136fba4ba4..78d5105ee98e9e55bd110eba04b3445c85033c0c 100644 (file)
@@ -7,6 +7,11 @@
 #include<GeomAPI_Shape.h>
 
 #include <TopoDS_Shape.hxx>
+#include <BRepBndLib.hxx>
+#include <Bnd_Box.hxx>
+#include <BRepTools.hxx>
+
+#include <sstream>
 
 #define MY_SHAPE static_cast<TopoDS_Shape*>(myImpl)
 
@@ -22,6 +27,8 @@ bool GeomAPI_Shape::isNull() const
 
 bool GeomAPI_Shape::isEqual(const std::shared_ptr<GeomAPI_Shape> theShape) const
 {
+  if (!theShape.get())
+    return false;
   if (isNull())
     return theShape->isNull();
   if (theShape->isNull())
@@ -47,3 +54,23 @@ bool GeomAPI_Shape::isFace() const
   const TopoDS_Shape& aShape = const_cast<GeomAPI_Shape*>(this)->impl<TopoDS_Shape>();
   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<GeomAPI_Shape*>(this)->impl<TopoDS_Shape>();
+  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<GeomAPI_Shape*>(this)->impl<TopoDS_Shape>();
+  BRepTools::Write(aShape, aStream);
+  return aStream.str();
+}