]> SALOME platform Git repositories - modules/shaper.git/blob - src/GeomAPI/GeomAPI_DataMapOfShapeShape.cpp
Salome HOME
Update SketchPlugin_Projection feature (issue #1459)
[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 using namespace std;
13
14
15 GeomAPI_DataMapOfShapeShape::GeomAPI_DataMapOfShapeShape()
16 : GeomAPI_Interface(new TopTools_DataMapOfShapeShape){}
17
18 void GeomAPI_DataMapOfShapeShape::clear()
19 {
20   implPtr<TopTools_DataMapOfShapeShape>()->Clear();
21 }
22
23 int GeomAPI_DataMapOfShapeShape::size()
24 {
25   return implPtr<TopTools_DataMapOfShapeShape>()->Extent();
26 }
27
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 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::merge(const std::shared_ptr<GeomAPI_DataMapOfShapeShape> theDataMap)
46 {
47   if(theDataMap.get()) {
48     merge(*theDataMap.get());
49   }
50 }
51
52 bool GeomAPI_DataMapOfShapeShape::isBound (std::shared_ptr<GeomAPI_Shape> theKey)
53 {
54   bool flag(false);
55   if(impl<TopTools_DataMapOfShapeShape>().IsBound(theKey->impl<TopoDS_Shape>()))
56     flag = true;
57   return flag;
58 }
59
60 const std::shared_ptr<GeomAPI_Shape> GeomAPI_DataMapOfShapeShape::find(std::shared_ptr<GeomAPI_Shape> theKey)
61 {
62   std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());  
63   aShape->setImpl(new TopoDS_Shape(impl<TopTools_DataMapOfShapeShape>().Find(theKey->impl<TopoDS_Shape>())));
64   return aShape;
65 }  
66
67 bool GeomAPI_DataMapOfShapeShape::unBind(std::shared_ptr<GeomAPI_Shape> theKey)
68 {
69   bool flag(false);
70   if(implPtr<TopTools_DataMapOfShapeShape>()->UnBind(theKey->impl<TopoDS_Shape>()))
71   flag = true;
72   return flag;
73 }
74
75  GeomAPI_DataMapOfShapeShape::~GeomAPI_DataMapOfShapeShape()
76  {
77   if (!empty()) {
78     implPtr<TopTools_DataMapOfShapeShape>()->Clear();
79   }
80  }