diff --git a/EXE.h b/EXE.h index fa1b90b..6e5f909 100644 --- a/EXE.h +++ b/EXE.h @@ -32,5 +32,9 @@ ILogger* GetCmdLogger( void) ; bool SetCmdLog( bool bVal) ; bool IsCmdLog( void) ; +//---------------------------------------------------------------------------- +bool ExeInsertMachMgr( int nInsGrp) ; + //---------------------------------------------------------------------------- bool ExeIsDuploBase( IGeomDB* pGeomDB, int nId) ; +bool ExeInsertDuplo( int nInsGrp) ; diff --git a/EXE_GdbPartLayers.cpp b/EXE_GdbPartLayers.cpp index 1b730cb..90e1337 100644 --- a/EXE_GdbPartLayers.cpp +++ b/EXE_GdbPartLayers.cpp @@ -816,3 +816,35 @@ ExeDuploGetOriginal( int nDupId) pGeomDB->GetInfo( nDupId, GDB_SI_DUPSOU, nOrigId) ; return nOrigId ; } + +//----------------------------------------------------------------------------- +bool +ExeInsertDuplo( int nInsGrp) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // Cerco il gruppo dei duplicati sotto il gruppo di inserimento + int nInsDplId = pGeomDB->GetFirstNameInGroup( nInsGrp, DUPLO_BASE) ; + if ( nInsDplId == GDB_ID_NULL) + return true ; + // Recupero il gruppo base dei duplicati + int nDuploBaseId = GetDuploBase( pGeomDB, true) ; + if ( nDuploBaseId == GDB_ID_NULL) + return false ; + // Sistemo i duplicati + int nId = pGeomDB->GetFirstInGroup( nInsDplId) ; + while ( nId != GDB_ID_NULL) { + int nNextId = pGeomDB->GetNext( nId) ; + int nSouId ; + if ( pGeomDB->GetInfo( nId, GDB_SI_DUPSOU, nSouId) && ExeIsPart( nSouId)) { + pGeomDB->Relocate( nId, nDuploBaseId) ; + } + else + pGeomDB->Erase( nId) ; + nId = nNextId ; + } + // Rimuovo il gruppo dei duplicati di inserimento + pGeomDB->Erase( nInsDplId) ; + + return true ; +} diff --git a/EXE_GeomDB.cpp b/EXE_GeomDB.cpp index 3470037..9b23606 100644 --- a/EXE_GeomDB.cpp +++ b/EXE_GeomDB.cpp @@ -349,6 +349,8 @@ ExeInsertFile( const string& sFilePath) IMachMgr* pMchMgr = GetCurrMachMgr() ; if ( pMchMgr != nullptr) bOk = bOk && ExeInsertMachMgr( nGrp) ; + // sistemo eventuali pezzi duplicati + bOk = bOk && ExeInsertDuplo( nGrp) ; // sposto i gruppi rimasti sotto la radice nId = pGeomDB->GetFirstGroupInGroup( nGrp) ; while ( bOk && nId != GDB_ID_NULL) {