Salome HOME
b573c5a0ad685452a4fcffdce14b17864843c0e4
[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 using namespace std;
9
10
11 GeomAPI_DataMapOfShapeShape::GeomAPI_DataMapOfShapeShape()
12         :GeomAPI_Interface((void *)new TopTools_DataMapOfShapeShape){}
13
14 /// Clear 
15 void GeomAPI_DataMapOfShapeShape::clear()
16 {
17   implPtr<TopTools_DataMapOfShapeShape>()->Clear();
18 }
19
20 /// Adds the Key <K> to  the Map <me>  with  the  Item. Returns True  if the Key  was not already in the map
21 bool GeomAPI_DataMapOfShapeShape::bind (const boost::shared_ptr<GeomAPI_Shape>& theKey, const boost::shared_ptr<GeomAPI_Shape>& theItem)
22 {
23   bool flag(false);
24   if(implPtr<TopTools_DataMapOfShapeShape>()->Bind(theKey->impl<TopoDS_Shape>(), theItem->impl<TopoDS_Shape>()))
25         flag = true;
26   return flag;
27 }
28
29 /// Returns true if theKey is stored  in the map.
30 bool GeomAPI_DataMapOfShapeShape::isBound (const boost::shared_ptr<GeomAPI_Shape>& theKey)
31 {
32   bool flag(false);
33   if(impl<TopTools_DataMapOfShapeShape>().IsBound(theKey->impl<TopoDS_Shape>()))
34     flag = true;
35   return flag;
36 }
37
38 /// Returns  the Item stored  with the Key in the Map. To be checked before with isBound()
39 const boost::shared_ptr<GeomAPI_Shape> GeomAPI_DataMapOfShapeShape::find(const boost::shared_ptr<GeomAPI_Shape>& theKey)
40 {
41   boost::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());  
42   aShape->setImpl((void *)&(impl<TopTools_DataMapOfShapeShape>().Find(theKey->impl<TopoDS_Shape>())));
43   return aShape;
44 }  
45   
46 /// Removes the Key from the  map. Returns true if the Key was in the Map
47 bool GeomAPI_DataMapOfShapeShape::unBind(const boost::shared_ptr<GeomAPI_Shape>& theKey)
48 {
49   bool flag(false);
50   if(implPtr<TopTools_DataMapOfShapeShape>()->UnBind(theKey->impl<TopoDS_Shape>()))
51         flag = true;
52   return flag;
53 }