X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGeomAPI%2FGeomAPI_DataMapOfShapeShape.cpp;h=a311cafbc6901e894b52da3aa8c6a201d3297799;hb=c57d2a7f1a57af01656e47e2e510990492404fce;hp=c42ef1562edac8a5ea29487a597c983ba77c68ba;hpb=3874b57fe5aba25ff5aee2a07654fc23c1ee8eb0;p=modules%2Fshaper.git diff --git a/src/GeomAPI/GeomAPI_DataMapOfShapeShape.cpp b/src/GeomAPI/GeomAPI_DataMapOfShapeShape.cpp index c42ef1562..a311cafbc 100644 --- a/src/GeomAPI/GeomAPI_DataMapOfShapeShape.cpp +++ b/src/GeomAPI/GeomAPI_DataMapOfShapeShape.cpp @@ -1,41 +1,68 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: GeomAPI_DataMapOfShapeShape.cpp -// Created: 28 Oct 2014 -// Author: Sergey Zaritchny +// Copyright (C) 2014-2019 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// #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(); } -/// Size int GeomAPI_DataMapOfShapeShape::size() { return implPtr()->Extent(); } -/// Adds the Key to the Map with the Item. Returns True if the Key was not already in the map -bool GeomAPI_DataMapOfShapeShape::bind (std::shared_ptr theKey, std::shared_ptr theItem) +bool GeomAPI_DataMapOfShapeShape::bind(std::shared_ptr theKey, + std::shared_ptr theItem) { bool flag(false); - if(implPtr()->Bind(theKey->impl(), theItem->impl())) - flag = true; + if (implPtr()->Bind(theKey->impl(), + theItem->impl())) + 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); @@ -44,27 +71,26 @@ 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) +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()))); + 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 + }