diff --git a/EgtGeomKernel.rc b/EgtGeomKernel.rc index c93f99c..764ec63 100644 Binary files a/EgtGeomKernel.rc and b/EgtGeomKernel.rc differ diff --git a/GeomDB.cpp b/GeomDB.cpp index 3ace107..a0f0a49 100644 --- a/GeomDB.cpp +++ b/GeomDB.cpp @@ -81,7 +81,7 @@ GeomDB::Init( void) // pulizia Clear() ; // imposto numero minimo buckets del map degli Id - m_IdManager.Init( 1024) ; + m_IdManager.Init( 8192) ; // imposto materiale di default m_GrpRadix.SetMaterial( Color()) ; // imposto riferimento griglia standard diff --git a/IdManager.h b/IdManager.h index 6ad3591..c8b03ee 100644 --- a/IdManager.h +++ b/IdManager.h @@ -14,6 +14,7 @@ #pragma once #include +#include //---------------------------------------------------------------------------- @@ -27,13 +28,13 @@ class IdManager bool Clear( void) { m_GdbIdMap.clear() ; m_nMaxId = 0 ; return true ; } GdbObj* FindObj( int nId) - { INTPGDBO_UMAP::iterator Iter = m_GdbIdMap.find( nId) ; + { auto Iter = m_GdbIdMap.find( nId) ; if ( Iter != m_GdbIdMap.end()) return Iter->second ; else return nullptr ; } const GdbObj* FindObj( int nId) const - { INTPGDBO_UMAP::const_iterator Iter = m_GdbIdMap.find( nId) ; + { auto Iter = m_GdbIdMap.find( nId) ; if ( Iter != m_GdbIdMap.end()) return Iter->second ; else @@ -45,7 +46,7 @@ class IdManager bool RemoveObj( int nId) { m_GdbIdMap.erase( nId) ; if ( nId == m_nMaxId && m_nMaxId > 0) - -- m_nMaxId ; + UpdateMaxId() ; return true ; } int GetNewId( void) const { return ( m_nMaxId + 1) ; } @@ -54,6 +55,11 @@ class IdManager void UpdateMaxId( int nId) { if ( nId > m_nMaxId) m_nMaxId = nId ; } + void UpdateMaxId( void) + { int nMaxId = 0 ; + for each (const auto& Igdbo in m_GdbIdMap) + nMaxId = std::max( nMaxId, Igdbo.first) ; + m_nMaxId = nMaxId ; } private : typedef std::unordered_map< int, GdbObj*> INTPGDBO_UMAP ;