]> SALOME platform Git repositories - modules/shaper.git/blob - src/GeomAPI/GeomAPI_DataMapOfShapeShape.cpp
Salome HOME
Improve code coverage for elliptic arcs.
[modules/shaper.git] / src / GeomAPI / GeomAPI_DataMapOfShapeShape.cpp
1 // Copyright (C) 2014-2019  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 email : webmaster.salome@opencascade.com
18 //
19
20 #include <GeomAPI_Shape.h>
21 #include <GeomAPI_DataMapOfShapeShape.h>
22 #include <TopTools_DataMapOfShapeShape.hxx>
23 #include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
24 #include <TopoDS_Shape.hxx>
25
26 GeomAPI_DataMapOfShapeShape::GeomAPI_DataMapOfShapeShape()
27 : GeomAPI_Interface(new TopTools_DataMapOfShapeShape){}
28
29 void GeomAPI_DataMapOfShapeShape::clear()
30 {
31   implPtr<TopTools_DataMapOfShapeShape>()->Clear();
32 }
33
34 int GeomAPI_DataMapOfShapeShape::size()
35 {
36   return implPtr<TopTools_DataMapOfShapeShape>()->Extent();
37 }
38
39 bool GeomAPI_DataMapOfShapeShape::bind(std::shared_ptr<GeomAPI_Shape> theKey,
40                                        std::shared_ptr<GeomAPI_Shape> theItem)
41 {
42   bool flag(false);
43   if (implPtr<TopTools_DataMapOfShapeShape>()->Bind(theKey->impl<TopoDS_Shape>(),
44                                                     theItem->impl<TopoDS_Shape>()))
45     flag = true;
46   return flag;
47 }
48
49 void GeomAPI_DataMapOfShapeShape::merge(const GeomAPI_DataMapOfShapeShape& theDataMap)
50 {
51   const TopTools_DataMapOfShapeShape& aDataMap = theDataMap.impl<TopTools_DataMapOfShapeShape>();
52   TopTools_DataMapOfShapeShape* myDataMap = implPtr<TopTools_DataMapOfShapeShape>();
53   for(TopTools_DataMapIteratorOfDataMapOfShapeShape anIt(aDataMap); anIt.More(); anIt.Next()) {
54     myDataMap->Bind(anIt.Key(), anIt.Value());
55   }
56 }
57
58 void GeomAPI_DataMapOfShapeShape::
59   merge(const std::shared_ptr<GeomAPI_DataMapOfShapeShape> theDataMap)
60 {
61   if(theDataMap.get()) {
62     merge(*theDataMap.get());
63   }
64 }
65
66 bool GeomAPI_DataMapOfShapeShape::isBound (std::shared_ptr<GeomAPI_Shape> theKey)
67 {
68   bool flag(false);
69   if(impl<TopTools_DataMapOfShapeShape>().IsBound(theKey->impl<TopoDS_Shape>()))
70     flag = true;
71   return flag;
72 }
73
74 const std::shared_ptr<GeomAPI_Shape>
75   GeomAPI_DataMapOfShapeShape::find(std::shared_ptr<GeomAPI_Shape> theKey)
76 {
77   std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
78   aShape->setImpl(
79     new TopoDS_Shape(impl<TopTools_DataMapOfShapeShape>().Find(theKey->impl<TopoDS_Shape>())));
80   return aShape;
81 }
82
83 bool GeomAPI_DataMapOfShapeShape::unBind(std::shared_ptr<GeomAPI_Shape> theKey)
84 {
85   bool flag(false);
86   if(implPtr<TopTools_DataMapOfShapeShape>()->UnBind(theKey->impl<TopoDS_Shape>()))
87   flag = true;
88   return flag;
89 }
90
91  GeomAPI_DataMapOfShapeShape::~GeomAPI_DataMapOfShapeShape()
92  {
93   if (!empty()) {
94     implPtr<TopTools_DataMapOfShapeShape>()->Clear();
95   }
96  }