Salome HOME
Issue #1834: Fix length of lines
[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, 
29                                        std::shared_ptr<GeomAPI_Shape> theItem)
30 {
31   bool flag(false);
32   if (implPtr<TopTools_DataMapOfShapeShape>()->Bind(theKey->impl<TopoDS_Shape>(), 
33                                                     theItem->impl<TopoDS_Shape>()))
34     flag = true;
35   return flag;
36 }
37
38 void GeomAPI_DataMapOfShapeShape::merge(const GeomAPI_DataMapOfShapeShape& theDataMap)
39 {
40   const TopTools_DataMapOfShapeShape& aDataMap = theDataMap.impl<TopTools_DataMapOfShapeShape>();
41   TopTools_DataMapOfShapeShape* myDataMap = implPtr<TopTools_DataMapOfShapeShape>();
42   for(TopTools_DataMapIteratorOfDataMapOfShapeShape anIt(aDataMap); anIt.More(); anIt.Next()) {
43     myDataMap->Bind(anIt.Key(), anIt.Value());
44   }
45 }
46
47 void GeomAPI_DataMapOfShapeShape::
48   merge(const std::shared_ptr<GeomAPI_DataMapOfShapeShape> theDataMap)
49 {
50   if(theDataMap.get()) {
51     merge(*theDataMap.get());
52   }
53 }
54
55 bool GeomAPI_DataMapOfShapeShape::isBound (std::shared_ptr<GeomAPI_Shape> theKey)
56 {
57   bool flag(false);
58   if(impl<TopTools_DataMapOfShapeShape>().IsBound(theKey->impl<TopoDS_Shape>()))
59     flag = true;
60   return flag;
61 }
62
63 const std::shared_ptr<GeomAPI_Shape> 
64   GeomAPI_DataMapOfShapeShape::find(std::shared_ptr<GeomAPI_Shape> theKey)
65 {
66   std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());  
67   aShape->setImpl(
68     new TopoDS_Shape(impl<TopTools_DataMapOfShapeShape>().Find(theKey->impl<TopoDS_Shape>())));
69   return aShape;
70 }  
71
72 bool GeomAPI_DataMapOfShapeShape::unBind(std::shared_ptr<GeomAPI_Shape> theKey)
73 {
74   bool flag(false);
75   if(implPtr<TopTools_DataMapOfShapeShape>()->UnBind(theKey->impl<TopoDS_Shape>()))
76   flag = true;
77   return flag;
78 }
79
80  GeomAPI_DataMapOfShapeShape::~GeomAPI_DataMapOfShapeShape()
81  {
82   if (!empty()) {
83     implPtr<TopTools_DataMapOfShapeShape>()->Clear();
84   }
85  }