Salome HOME
Merge branch 'Dev_1.1.0' of newgeom:newgeom into Dev_1.1.0
[modules/shaper.git] / src / GeomAPI / GeomAPI_DataMapOfShapeShape.cpp
index b573c5a0ad685452a4fcffdce14b17864843c0e4..97e3f10683127f11da42d3fe25b3b18ba3540267 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAPI_DataMapOfShapeShape.cpp
 // Created:     28 Oct 2014
 // Author:      Sergey Zaritchny
@@ -5,20 +7,24 @@
 #include <GeomAPI_Shape.h>
 #include <GeomAPI_DataMapOfShapeShape.h>
 #include <TopTools_DataMapOfShapeShape.hxx>
+#include <TopoDS_Shape.hxx>
 using namespace std;
 
 
 GeomAPI_DataMapOfShapeShape::GeomAPI_DataMapOfShapeShape()
        :GeomAPI_Interface((void *)new TopTools_DataMapOfShapeShape){}
 
-/// Clear 
 void GeomAPI_DataMapOfShapeShape::clear()
 {
   implPtr<TopTools_DataMapOfShapeShape>()->Clear();
 }
 
-/// Adds the Key <K> to  the Map <me>  with  the  Item. Returns True  if the Key  was not already in the map
-bool GeomAPI_DataMapOfShapeShape::bind (const boost::shared_ptr<GeomAPI_Shape>& theKey, const boost::shared_ptr<GeomAPI_Shape>& theItem)
+int GeomAPI_DataMapOfShapeShape::size()
+{
+  return implPtr<TopTools_DataMapOfShapeShape>()->Extent();
+}
+
+bool GeomAPI_DataMapOfShapeShape::bind (std::shared_ptr<GeomAPI_Shape> theKey, std::shared_ptr<GeomAPI_Shape> theItem)
 {
   bool flag(false);
   if(implPtr<TopTools_DataMapOfShapeShape>()->Bind(theKey->impl<TopoDS_Shape>(), theItem->impl<TopoDS_Shape>()))
@@ -26,8 +32,7 @@ bool GeomAPI_DataMapOfShapeShape::bind (const boost::shared_ptr<GeomAPI_Shape>&
   return flag;
 }
 
-/// Returns true if theKey is stored  in the map.
-bool GeomAPI_DataMapOfShapeShape::isBound (const boost::shared_ptr<GeomAPI_Shape>& theKey)
+bool GeomAPI_DataMapOfShapeShape::isBound (std::shared_ptr<GeomAPI_Shape> theKey)
 {
   bool flag(false);
   if(impl<TopTools_DataMapOfShapeShape>().IsBound(theKey->impl<TopoDS_Shape>()))
@@ -35,19 +40,25 @@ bool GeomAPI_DataMapOfShapeShape::isBound (const boost::shared_ptr<GeomAPI_Shape
   return flag;
 }
 
-/// Returns  the Item stored  with the Key in the Map. To be checked before with isBound()
-const boost::shared_ptr<GeomAPI_Shape> GeomAPI_DataMapOfShapeShape::find(const boost::shared_ptr<GeomAPI_Shape>& theKey)
+const std::shared_ptr<GeomAPI_Shape> GeomAPI_DataMapOfShapeShape::find(std::shared_ptr<GeomAPI_Shape> theKey)
 {
-  boost::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());  
-  aShape->setImpl((void *)&(impl<TopTools_DataMapOfShapeShape>().Find(theKey->impl<TopoDS_Shape>())));
+  std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());  
+  aShape->setImpl(new TopoDS_Shape(impl<TopTools_DataMapOfShapeShape>().Find(theKey->impl<TopoDS_Shape>())));
   return aShape;
 }  
   
-/// Removes the Key from the  map. Returns true if the Key was in the Map
-bool GeomAPI_DataMapOfShapeShape::unBind(const boost::shared_ptr<GeomAPI_Shape>& theKey)
+bool GeomAPI_DataMapOfShapeShape::unBind(std::shared_ptr<GeomAPI_Shape> theKey)
 {
   bool flag(false);
   if(implPtr<TopTools_DataMapOfShapeShape>()->UnBind(theKey->impl<TopoDS_Shape>()))
        flag = true;
   return flag;
-}
\ No newline at end of file
+}
+
+ GeomAPI_DataMapOfShapeShape::~GeomAPI_DataMapOfShapeShape()
+ {
+  if (myImpl) {
+       implPtr<TopTools_DataMapOfShapeShape>()->Clear();
+    //delete myImpl;
+  }
+ }
\ No newline at end of file