X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGeomAPI%2FGeomAPI_DataMapOfShapeShape.cpp;h=a21ac5f04297702f079461ee8e642134d5239984;hb=e32f95642855a63da2727cb324ce2a75632a712f;hp=c20e9fd89161620b560adca7347eb54eecfa5259;hpb=35a88fdd724349275bbff32b9596a44e7cd422e2;p=modules%2Fshaper.git diff --git a/src/GeomAPI/GeomAPI_DataMapOfShapeShape.cpp b/src/GeomAPI/GeomAPI_DataMapOfShapeShape.cpp index c20e9fd89..a21ac5f04 100644 --- a/src/GeomAPI/GeomAPI_DataMapOfShapeShape.cpp +++ b/src/GeomAPI/GeomAPI_DataMapOfShapeShape.cpp @@ -1,3 +1,5 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + // File: GeomAPI_DataMapOfShapeShape.cpp // Created: 28 Oct 2014 // Author: Sergey Zaritchny @@ -5,29 +7,48 @@ #include #include #include +#include #include using namespace std; GeomAPI_DataMapOfShapeShape::GeomAPI_DataMapOfShapeShape() - :GeomAPI_Interface((void *)new TopTools_DataMapOfShapeShape){} +: GeomAPI_Interface(new TopTools_DataMapOfShapeShape){} -/// Clear void GeomAPI_DataMapOfShapeShape::clear() { implPtr()->Clear(); } -/// Adds the Key to the Map with the Item. Returns True if the Key was not already in the map +int GeomAPI_DataMapOfShapeShape::size() +{ + return implPtr()->Extent(); +} + bool GeomAPI_DataMapOfShapeShape::bind (std::shared_ptr theKey, std::shared_ptr theItem) { bool flag(false); if(implPtr()->Bind(theKey->impl(), theItem->impl())) - flag = true; + 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* myDataMap = implPtr(); + for(TopTools_DataMapIteratorOfDataMapOfShapeShape anIt(aDataMap); anIt.More(); anIt.Next()) { + myDataMap->Bind(anIt.Key(), anIt.Value()); + } +} + +void GeomAPI_DataMapOfShapeShape::merge(const std::shared_ptr theDataMap) +{ + if(theDataMap.get()) { + merge(*theDataMap.get()); + } +} + bool GeomAPI_DataMapOfShapeShape::isBound (std::shared_ptr theKey) { bool flag(false); @@ -36,27 +57,24 @@ bool GeomAPI_DataMapOfShapeShape::isBound (std::shared_ptr theKey return flag; } -/// Returns the Item stored with the Key in the Map. To be checked before with isBound() const std::shared_ptr GeomAPI_DataMapOfShapeShape::find(std::shared_ptr theKey) { std::shared_ptr aShape(new GeomAPI_Shape()); aShape->setImpl(new TopoDS_Shape(impl().Find(theKey->impl()))); return aShape; } - -/// Removes the Key from the map. Returns true if the Key was in the Map + bool GeomAPI_DataMapOfShapeShape::unBind(std::shared_ptr theKey) { bool flag(false); if(implPtr()->UnBind(theKey->impl())) - flag = true; + flag = true; return flag; } GeomAPI_DataMapOfShapeShape::~GeomAPI_DataMapOfShapeShape() { - if (myImpl) { - implPtr()->Clear(); - //delete myImpl; + if (!empty()) { + implPtr()->Clear(); } - } \ No newline at end of file + }