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