]> SALOME platform Git repositories - modules/shaper.git/blob - src/GeomAPI/GeomAPI_DataMapOfShapeShape.cpp
Salome HOME
Fix for the issue #2401
[modules/shaper.git] / src / GeomAPI / GeomAPI_DataMapOfShapeShape.cpp
1 // Copyright (C) 2014-2017  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #include <GeomAPI_Shape.h>
22 #include <GeomAPI_DataMapOfShapeShape.h>
23 #include <TopTools_DataMapOfShapeShape.hxx>
24 #include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
25 #include <TopoDS_Shape.hxx>
26
27 GeomAPI_DataMapOfShapeShape::GeomAPI_DataMapOfShapeShape()
28 : GeomAPI_Interface(new TopTools_DataMapOfShapeShape){}
29
30 void GeomAPI_DataMapOfShapeShape::clear()
31 {
32   implPtr<TopTools_DataMapOfShapeShape>()->Clear();
33 }
34
35 int GeomAPI_DataMapOfShapeShape::size()
36 {
37   return implPtr<TopTools_DataMapOfShapeShape>()->Extent();
38 }
39
40 bool GeomAPI_DataMapOfShapeShape::bind(std::shared_ptr<GeomAPI_Shape> theKey,
41                                        std::shared_ptr<GeomAPI_Shape> theItem)
42 {
43   bool flag(false);
44   if (implPtr<TopTools_DataMapOfShapeShape>()->Bind(theKey->impl<TopoDS_Shape>(),
45                                                     theItem->impl<TopoDS_Shape>()))
46     flag = true;
47   return flag;
48 }
49
50 void GeomAPI_DataMapOfShapeShape::merge(const GeomAPI_DataMapOfShapeShape& theDataMap)
51 {
52   const TopTools_DataMapOfShapeShape& aDataMap = theDataMap.impl<TopTools_DataMapOfShapeShape>();
53   TopTools_DataMapOfShapeShape* myDataMap = implPtr<TopTools_DataMapOfShapeShape>();
54   for(TopTools_DataMapIteratorOfDataMapOfShapeShape anIt(aDataMap); anIt.More(); anIt.Next()) {
55     myDataMap->Bind(anIt.Key(), anIt.Value());
56   }
57 }
58
59 void GeomAPI_DataMapOfShapeShape::
60   merge(const std::shared_ptr<GeomAPI_DataMapOfShapeShape> theDataMap)
61 {
62   if(theDataMap.get()) {
63     merge(*theDataMap.get());
64   }
65 }
66
67 bool GeomAPI_DataMapOfShapeShape::isBound (std::shared_ptr<GeomAPI_Shape> theKey)
68 {
69   bool flag(false);
70   if(impl<TopTools_DataMapOfShapeShape>().IsBound(theKey->impl<TopoDS_Shape>()))
71     flag = true;
72   return flag;
73 }
74
75 const std::shared_ptr<GeomAPI_Shape>
76   GeomAPI_DataMapOfShapeShape::find(std::shared_ptr<GeomAPI_Shape> theKey)
77 {
78   std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
79   aShape->setImpl(
80     new TopoDS_Shape(impl<TopTools_DataMapOfShapeShape>().Find(theKey->impl<TopoDS_Shape>())));
81   return aShape;
82 }
83
84 bool GeomAPI_DataMapOfShapeShape::unBind(std::shared_ptr<GeomAPI_Shape> theKey)
85 {
86   bool flag(false);
87   if(implPtr<TopTools_DataMapOfShapeShape>()->UnBind(theKey->impl<TopoDS_Shape>()))
88   flag = true;
89   return flag;
90 }
91
92  GeomAPI_DataMapOfShapeShape::~GeomAPI_DataMapOfShapeShape()
93  {
94   if (!empty()) {
95     implPtr<TopTools_DataMapOfShapeShape>()->Clear();
96   }
97  }