Salome HOME
Fix compilation errors (part 2)
[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 <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
11 #include <TopoDS_Shape.hxx>
12
13 GeomAPI_DataMapOfShapeShape::GeomAPI_DataMapOfShapeShape()
14 : GeomAPI_Interface(new TopTools_DataMapOfShapeShape){}
15
16 void GeomAPI_DataMapOfShapeShape::clear()
17 {
18   implPtr<TopTools_DataMapOfShapeShape>()->Clear();
19 }
20
21 int GeomAPI_DataMapOfShapeShape::size()
22 {
23   return implPtr<TopTools_DataMapOfShapeShape>()->Extent();
24 }
25
26 bool GeomAPI_DataMapOfShapeShape::bind(std::shared_ptr<GeomAPI_Shape> theKey,
27                                        std::shared_ptr<GeomAPI_Shape> theItem)
28 {
29   bool flag(false);
30   if (implPtr<TopTools_DataMapOfShapeShape>()->Bind(theKey->impl<TopoDS_Shape>(),
31                                                     theItem->impl<TopoDS_Shape>()))
32     flag = true;
33   return flag;
34 }
35
36 void GeomAPI_DataMapOfShapeShape::merge(const GeomAPI_DataMapOfShapeShape& theDataMap)
37 {
38   const TopTools_DataMapOfShapeShape& aDataMap = theDataMap.impl<TopTools_DataMapOfShapeShape>();
39   TopTools_DataMapOfShapeShape* myDataMap = implPtr<TopTools_DataMapOfShapeShape>();
40   for(TopTools_DataMapIteratorOfDataMapOfShapeShape anIt(aDataMap); anIt.More(); anIt.Next()) {
41     myDataMap->Bind(anIt.Key(), anIt.Value());
42   }
43 }
44
45 void GeomAPI_DataMapOfShapeShape::
46   merge(const std::shared_ptr<GeomAPI_DataMapOfShapeShape> theDataMap)
47 {
48   if(theDataMap.get()) {
49     merge(*theDataMap.get());
50   }
51 }
52
53 bool GeomAPI_DataMapOfShapeShape::isBound (std::shared_ptr<GeomAPI_Shape> theKey)
54 {
55   bool flag(false);
56   if(impl<TopTools_DataMapOfShapeShape>().IsBound(theKey->impl<TopoDS_Shape>()))
57     flag = true;
58   return flag;
59 }
60
61 const std::shared_ptr<GeomAPI_Shape>
62   GeomAPI_DataMapOfShapeShape::find(std::shared_ptr<GeomAPI_Shape> theKey)
63 {
64   std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
65   aShape->setImpl(
66     new TopoDS_Shape(impl<TopTools_DataMapOfShapeShape>().Find(theKey->impl<TopoDS_Shape>())));
67   return aShape;
68 }
69
70 bool GeomAPI_DataMapOfShapeShape::unBind(std::shared_ptr<GeomAPI_Shape> theKey)
71 {
72   bool flag(false);
73   if(implPtr<TopTools_DataMapOfShapeShape>()->UnBind(theKey->impl<TopoDS_Shape>()))
74   flag = true;
75   return flag;
76 }
77
78  GeomAPI_DataMapOfShapeShape::~GeomAPI_DataMapOfShapeShape()
79  {
80   if (!empty()) {
81     implPtr<TopTools_DataMapOfShapeShape>()->Clear();
82   }
83  }