Salome HOME
Issue #2148: Moving an arc displays a circle
[modules/shaper.git] / src / GeomAPI / GeomAPI_DataMapOfShapeShape.cpp
index c42ef1562edac8a5ea29487a597c983ba77c68ba..977616ffa8e298a298f35e5434163dda278ec77c 100644 (file)
@@ -7,35 +7,49 @@
 #include <GeomAPI_Shape.h>
 #include <GeomAPI_DataMapOfShapeShape.h>
 #include <TopTools_DataMapOfShapeShape.hxx>
+#include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
 #include <TopoDS_Shape.hxx>
-using namespace std;
-
 
 GeomAPI_DataMapOfShapeShape::GeomAPI_DataMapOfShapeShape()
-       :GeomAPI_Interface((void *)new TopTools_DataMapOfShapeShape){}
+: GeomAPI_Interface(new TopTools_DataMapOfShapeShape){}
 
-/// Clear 
 void GeomAPI_DataMapOfShapeShape::clear()
 {
   implPtr<TopTools_DataMapOfShapeShape>()->Clear();
 }
 
-/// Size 
 int GeomAPI_DataMapOfShapeShape::size()
 {
   return implPtr<TopTools_DataMapOfShapeShape>()->Extent();
 }
 
-/// Adds the Key <K> to  the Map <me>  with  the  Item. Returns True  if the Key  was not already in the map
-bool GeomAPI_DataMapOfShapeShape::bind (std::shared_ptr<GeomAPI_Shape> theKey, std::shared_ptr<GeomAPI_Shape> theItem)
+bool GeomAPI_DataMapOfShapeShape::bind(std::shared_ptr<GeomAPI_Shape> theKey,
+                                       std::shared_ptr<GeomAPI_Shape> theItem)
 {
   bool flag(false);
-  if(implPtr<TopTools_DataMapOfShapeShape>()->Bind(theKey->impl<TopoDS_Shape>(), theItem->impl<TopoDS_Shape>()))
-       flag = true;
+  if (implPtr<TopTools_DataMapOfShapeShape>()->Bind(theKey->impl<TopoDS_Shape>(),
+                                                    theItem->impl<TopoDS_Shape>()))
+    flag = true;
   return flag;
 }
 
-/// Returns true if theKey is stored  in the map.
+void GeomAPI_DataMapOfShapeShape::merge(const GeomAPI_DataMapOfShapeShape& theDataMap)
+{
+  const TopTools_DataMapOfShapeShape& aDataMap = theDataMap.impl<TopTools_DataMapOfShapeShape>();
+  TopTools_DataMapOfShapeShape* myDataMap = implPtr<TopTools_DataMapOfShapeShape>();
+  for(TopTools_DataMapIteratorOfDataMapOfShapeShape anIt(aDataMap); anIt.More(); anIt.Next()) {
+    myDataMap->Bind(anIt.Key(), anIt.Value());
+  }
+}
+
+void GeomAPI_DataMapOfShapeShape::
+  merge(const std::shared_ptr<GeomAPI_DataMapOfShapeShape> theDataMap)
+{
+  if(theDataMap.get()) {
+    merge(*theDataMap.get());
+  }
+}
+
 bool GeomAPI_DataMapOfShapeShape::isBound (std::shared_ptr<GeomAPI_Shape> theKey)
 {
   bool flag(false);
@@ -44,27 +58,26 @@ bool GeomAPI_DataMapOfShapeShape::isBound (std::shared_ptr<GeomAPI_Shape> theKey
   return flag;
 }
 
-/// Returns  the Item stored  with the Key in the Map. To be checked before with isBound()
-const std::shared_ptr<GeomAPI_Shape> GeomAPI_DataMapOfShapeShape::find(std::shared_ptr<GeomAPI_Shape> theKey)
+const std::shared_ptr<GeomAPI_Shape>
+  GeomAPI_DataMapOfShapeShape::find(std::shared_ptr<GeomAPI_Shape> theKey)
 {
-  std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());  
-  aShape->setImpl(new TopoDS_Shape(impl<TopTools_DataMapOfShapeShape>().Find(theKey->impl<TopoDS_Shape>())));
+  std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
+  aShape->setImpl(
+    new TopoDS_Shape(impl<TopTools_DataMapOfShapeShape>().Find(theKey->impl<TopoDS_Shape>())));
   return aShape;
-}  
-  
-/// Removes the Key from the  map. Returns true if the Key was in the Map
+}
+
 bool GeomAPI_DataMapOfShapeShape::unBind(std::shared_ptr<GeomAPI_Shape> theKey)
 {
   bool flag(false);
   if(implPtr<TopTools_DataMapOfShapeShape>()->UnBind(theKey->impl<TopoDS_Shape>()))
-       flag = true;
+  flag = true;
   return flag;
 }
 
  GeomAPI_DataMapOfShapeShape::~GeomAPI_DataMapOfShapeShape()
  {
-  if (myImpl) {
-       implPtr<TopTools_DataMapOfShapeShape>()->Clear();
-    //delete myImpl;
+  if (!empty()) {
+    implPtr<TopTools_DataMapOfShapeShape>()->Clear();
   }
- }
\ No newline at end of file
+ }