]> SALOME platform Git repositories - modules/shaper.git/blob - src/GeomAPI/GeomAPI_DataMapOfShapeShape.cpp
Salome HOME
Adding Naming DS for Placement operation.
[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 /// Size 
22 int GeomAPI_DataMapOfShapeShape::size()
23 {
24   return implPtr<TopTools_DataMapOfShapeShape>()->Extent();
25 }
26
27 /// Adds the Key <K> to  the Map <me>  with  the  Item. Returns True  if the Key  was not already in the map
28 bool GeomAPI_DataMapOfShapeShape::bind (std::shared_ptr<GeomAPI_Shape> theKey, std::shared_ptr<GeomAPI_Shape> theItem)
29 {
30   bool flag(false);
31   if(implPtr<TopTools_DataMapOfShapeShape>()->Bind(theKey->impl<TopoDS_Shape>(), theItem->impl<TopoDS_Shape>()))
32         flag = true;
33   return flag;
34 }
35
36 /// Returns true if theKey is stored  in the map.
37 bool GeomAPI_DataMapOfShapeShape::isBound (std::shared_ptr<GeomAPI_Shape> theKey)
38 {
39   bool flag(false);
40   if(impl<TopTools_DataMapOfShapeShape>().IsBound(theKey->impl<TopoDS_Shape>()))
41     flag = true;
42   return flag;
43 }
44
45 /// Returns  the Item stored  with the Key in the Map. To be checked before with isBound()
46 const std::shared_ptr<GeomAPI_Shape> GeomAPI_DataMapOfShapeShape::find(std::shared_ptr<GeomAPI_Shape> theKey)
47 {
48   std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());  
49   aShape->setImpl(new TopoDS_Shape(impl<TopTools_DataMapOfShapeShape>().Find(theKey->impl<TopoDS_Shape>())));
50   return aShape;
51 }  
52   
53 /// Removes the Key from the  map. Returns true if the Key was in the Map
54 bool GeomAPI_DataMapOfShapeShape::unBind(std::shared_ptr<GeomAPI_Shape> theKey)
55 {
56   bool flag(false);
57   if(implPtr<TopTools_DataMapOfShapeShape>()->UnBind(theKey->impl<TopoDS_Shape>()))
58         flag = true;
59   return flag;
60 }
61
62  GeomAPI_DataMapOfShapeShape::~GeomAPI_DataMapOfShapeShape()
63  {
64   if (myImpl) {
65         implPtr<TopTools_DataMapOfShapeShape>()->Clear();
66     //delete myImpl;
67   }
68  }