Salome HOME
Compsolids in boolean operations
[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   merge(*theDataMap.get());
48 }
49
50 bool GeomAPI_DataMapOfShapeShape::isBound (std::shared_ptr<GeomAPI_Shape> theKey)
51 {
52   bool flag(false);
53   if(impl<TopTools_DataMapOfShapeShape>().IsBound(theKey->impl<TopoDS_Shape>()))
54     flag = true;
55   return flag;
56 }
57
58 const std::shared_ptr<GeomAPI_Shape> GeomAPI_DataMapOfShapeShape::find(std::shared_ptr<GeomAPI_Shape> theKey)
59 {
60   std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());  
61   aShape->setImpl(new TopoDS_Shape(impl<TopTools_DataMapOfShapeShape>().Find(theKey->impl<TopoDS_Shape>())));
62   return aShape;
63 }  
64
65 bool GeomAPI_DataMapOfShapeShape::unBind(std::shared_ptr<GeomAPI_Shape> theKey)
66 {
67   bool flag(false);
68   if(implPtr<TopTools_DataMapOfShapeShape>()->UnBind(theKey->impl<TopoDS_Shape>()))
69   flag = true;
70   return flag;
71 }
72
73  GeomAPI_DataMapOfShapeShape::~GeomAPI_DataMapOfShapeShape()
74  {
75   if (!empty()) {
76     implPtr<TopTools_DataMapOfShapeShape>()->Clear();
77   }
78  }