X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMDS%2FSMDS_MeshIDFactory.cxx;h=cc765d8665910c5424f82372544ec8acaa6ecd03;hb=6b1de623316c78e9bc6e18b7e2a98883bd800ff1;hp=1b8b17ae551dab0420cfc3cf1d1c3b6ad48f5dd1;hpb=bd8f1aee7c78f7d2eb82bd4fec5e08c9e3d280ce;p=modules%2Fsmesh.git diff --git a/src/SMDS/SMDS_MeshIDFactory.cxx b/src/SMDS/SMDS_MeshIDFactory.cxx index 1b8b17ae5..cc765d866 100644 --- a/src/SMDS/SMDS_MeshIDFactory.cxx +++ b/src/SMDS/SMDS_MeshIDFactory.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -6,7 +6,7 @@ // 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. +// 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 @@ -42,25 +42,23 @@ SMDS_MeshIDFactory::SMDS_MeshIDFactory():myMaxID(0), myMesh(0) int SMDS_MeshIDFactory::GetFreeID() { - int newid; - if (myPoolOfID.empty()) - { - newid = ++myMaxID; - //MESSAGE("GetFreeID new " << newid); - } - else - { - set::iterator i = myPoolOfID.begin(); - newid = *i;//myPoolOfID.top(); - myPoolOfID.erase( i );//myPoolOfID.pop(); - //MESSAGE("GetFreeID pool " << newid); - } - return newid; + int newid; + if (myPoolOfID.empty()) + { + newid = ++myMaxID; + } + else + { + set::iterator i = myPoolOfID.begin(); + newid = *i; + myPoolOfID.erase( i ); + } + return newid; } //======================================================================= //function : ReleaseID -//purpose : +//purpose : //======================================================================= void SMDS_MeshIDFactory::ReleaseID(int ID, int vtkId) { @@ -79,11 +77,13 @@ void SMDS_MeshIDFactory::ReleaseID(int ID, int vtkId) while ( i != myPoolOfID.begin() && myMaxID == *i ) { --myMaxID; --i; } - if ( myMaxID == *i ) + if ( myMaxID == *i ) { --myMaxID; // begin of myPoolOfID reached - else - ++i; - myPoolOfID.erase( i, myPoolOfID.end() ); + myPoolOfID.clear(); + } + else if ( myMaxID < ID-1 ) { + myPoolOfID.erase( ++i, myPoolOfID.end() ); + } } } } @@ -91,24 +91,23 @@ void SMDS_MeshIDFactory::ReleaseID(int ID, int vtkId) void SMDS_MeshIDFactory::Clear() { - myMaxID = 0; - myPoolOfID.clear(); + myMaxID = 0; + myPoolOfID.clear(); } void SMDS_MeshIDFactory::SetMesh(SMDS_Mesh *mesh) { - myMesh = mesh; + myMesh = mesh; } SMDS_Mesh* SMDS_MeshIDFactory::GetMesh() { - return myMesh; + return myMesh; } void SMDS_MeshIDFactory::emptyPool(int maxId) { - MESSAGE("SMDS_MeshIDFactory::emptyPool " << myMaxID << " --> " << maxId); - myMaxID = maxId; - myPoolOfID.clear(); + myMaxID = maxId; + myPoolOfID.clear(); }