Salome HOME
Boost has been removed from code
[modules/shaper.git] / src / GeomAPI / GeomAPI_DataMapOfShapeShape.cpp
1 // File:        GeomAPI_DataMapOfShapeShape.cpp
2 // Created:     28 Oct 2014
3 // Author:      Sergey Zaritchny
4
5 #include <GeomAPI_Shape.h>
6 #include <GeomAPI_DataMapOfShapeShape.h>
7 #include <TopTools_DataMapOfShapeShape.hxx>
8 #include <TopoDS_Shape.hxx>
9 using namespace std;
10
11
12 GeomAPI_DataMapOfShapeShape::GeomAPI_DataMapOfShapeShape()
13         :GeomAPI_Interface((void *)new TopTools_DataMapOfShapeShape){}
14
15 /// Clear 
16 void GeomAPI_DataMapOfShapeShape::clear()
17 {
18   implPtr<TopTools_DataMapOfShapeShape>()->Clear();
19 }
20
21 /// Adds the Key <K> to  the Map <me>  with  the  Item. Returns True  if the Key  was not already in the map
22 bool GeomAPI_DataMapOfShapeShape::bind (std::shared_ptr<GeomAPI_Shape> theKey, std::shared_ptr<GeomAPI_Shape> theItem)
23 {
24   bool flag(false);
25   if(implPtr<TopTools_DataMapOfShapeShape>()->Bind(theKey->impl<TopoDS_Shape>(), theItem->impl<TopoDS_Shape>()))
26         flag = true;
27   return flag;
28 }
29
30 /// Returns true if theKey is stored  in the map.
31 bool GeomAPI_DataMapOfShapeShape::isBound (std::shared_ptr<GeomAPI_Shape> theKey)
32 {
33   bool flag(false);
34   if(impl<TopTools_DataMapOfShapeShape>().IsBound(theKey->impl<TopoDS_Shape>()))
35     flag = true;
36   return flag;
37 }
38
39 /// Returns  the Item stored  with the Key in the Map. To be checked before with isBound()
40 const std::shared_ptr<GeomAPI_Shape> GeomAPI_DataMapOfShapeShape::find(std::shared_ptr<GeomAPI_Shape> theKey)
41 {
42   std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());  
43   aShape->setImpl(new TopoDS_Shape(impl<TopTools_DataMapOfShapeShape>().Find(theKey->impl<TopoDS_Shape>())));
44   return aShape;
45 }  
46   
47 /// Removes the Key from the  map. Returns true if the Key was in the Map
48 bool GeomAPI_DataMapOfShapeShape::unBind(std::shared_ptr<GeomAPI_Shape> theKey)
49 {
50   bool flag(false);
51   if(implPtr<TopTools_DataMapOfShapeShape>()->UnBind(theKey->impl<TopoDS_Shape>()))
52         flag = true;
53   return flag;
54 }
55
56  GeomAPI_DataMapOfShapeShape::~GeomAPI_DataMapOfShapeShape()
57  {
58   if (myImpl) {
59         implPtr<TopTools_DataMapOfShapeShape>()->Clear();
60     //delete myImpl;
61   }
62  }