diff --git a/EgtMachKernel.rc b/EgtMachKernel.rc index 77b1d72..8669870 100644 Binary files a/EgtMachKernel.rc and b/EgtMachKernel.rc differ diff --git a/MachConst.h b/MachConst.h index b479e7f..7004b77 100644 --- a/MachConst.h +++ b/MachConst.h @@ -20,6 +20,22 @@ // Radice di tutta la gestione delle lavorazioni const std::string MACH_BASE = "MachBase" ; // Chiave per nome macchina in macchinata -const std::string MACH_KEY_MACHINE = "Machine" ; +const std::string MACH_MACHINE_KEY = "Machine" ; +// Gruppo della macchina in una macchinata +const std::string MACH_GEOM_GROUP = "MGeo" ; +// Gruppo dell'attrezzaggio in una macchinata +const std::string MACH_SETUP_GROUP = "Setup" ; +// Gruppo dei grezzi in una macchinata +const std::string MACH_RAW_GROUP = "Raws" ; +// Gruppo delle operazioni in una macchinata +const std::string MACH_OPER_GROUP = "Opers" ; // Nome del grezzo const std::string MACH_RAW_PART = "RawPart" ; +// Nome del solido del grezzo +const std::string MACH_RAW_SOLID = "RawSolid" ; +// Nome del punto che rappresenta il centro del grezzo +const std::string MACH_RAW_CENTER = "RawCenter" ; + +//---------------------------------------------------------------------------- +// Minimo spessore del grezzo +const double RAW_MIN_H = 1 ; diff --git a/MachMgr.cpp b/MachMgr.cpp index 66cde97..622b7d8 100644 --- a/MachMgr.cpp +++ b/MachMgr.cpp @@ -16,11 +16,16 @@ #include "DllMain.h" #include "MachMgr.h" #include "MachConst.h" -#include "/EgtDev/Include/EGnStringUtils.h" -#include "/EgtDev/Include/SELkKeyProc.h" -#include "/EgtDev/Include/EgtKeyCodes.h" +#include "/EgtDev/Include/EGkCurveComposite.h" +#include "/EgtDev/Include/EGkGdbIterator.h" +#include "/EgtDev/Include/EGkGeoPoint3d.h" #include "/EgtDev/Include/EGkStmStandard.h" +#include "/EgtDev/Include/EGkStmFromCurves.h" +#include "/EgtDev/Include/EGkGdbConst.h" +#include "/EgtDev/Include/EGnStringUtils.h" +#include "/EgtDev/Include/EgtKeyCodes.h" #include "/EgtDev/Include/EgtPointerOwner.h" +#include "/EgtDev/Include/SELkKeyProc.h" #include using namespace std ; @@ -55,7 +60,7 @@ MachMgr::MachMgr( void) { m_pGeomDB = nullptr ; m_nMachBaseId = GDB_ID_NULL ; - m_nMGroupCurr = 0 ; + m_nCurrMGrpId = GDB_ID_NULL ; } //---------------------------------------------------------------------------- @@ -64,8 +69,7 @@ MachMgr::Init( IGeomDB* pGeomDB) { m_pGeomDB = pGeomDB ; m_nMachBaseId = GDB_ID_NULL ; - m_vMGroupId.clear() ; - m_nMGroupCurr = 0 ; + m_nCurrMGrpId = GDB_ID_NULL ; return ( m_pGeomDB != nullptr) ; } @@ -73,20 +77,21 @@ MachMgr::Init( IGeomDB* pGeomDB) bool MachMgr::Update( void) { - // reset - m_nMachBaseId = GDB_ID_NULL ; - m_nMGroupCurr = 0 ; - m_vMGroupId.clear() ; // ricerca del gruppo base per le lavorazioni - if ( ! FindMachBase( GDB_ID_ROOT, m_nMachBaseId)) - return true ; - // aggiornamento altri dati + m_nMachBaseId = FindMachBase( GDB_ID_ROOT) ; + // imposto gruppo di lavorazione corrente a nessuno + m_nCurrMGrpId = GDB_ID_NULL ; + // verifico i gruppi di lavorazione int nId = m_pGeomDB->GetFirstGroupInGroup( m_nMachBaseId) ; while ( nId != GDB_ID_NULL) { - // inserisco id del gruppo nel vettore dei gruppi di lavorazione - m_vMGroupId.push_back( nId) ; + // recupero successivo + int nNextId = m_pGeomDB->GetNextGroup( nId) ; + // se non è gruppo di lavoro, lo elimino + MachGrp mgData ; + if ( ! VerifyMachGroup( nId, mgData)) + m_pGeomDB->Erase( nId) ; // passo al successivo - nId = m_pGeomDB->GetNextGroup( nId) ; + nId = nNextId ; } return true ; } @@ -99,23 +104,27 @@ MachMgr::Insert( int nInsGrp) if ( ! CreateMachBase()) return false ; // cerco MachBase nel gruppo di inserimento - int nInsMachBaseId ; - if ( ! FindMachBase( nInsGrp, nInsMachBaseId)) + int nInsMachBaseId = FindMachBase( nInsGrp) ; + if ( nInsMachBaseId == GDB_ID_NULL) return true ; // ciclo sui suoi gruppi int nId = m_pGeomDB->GetFirstGroupInGroup( nInsMachBaseId) ; while ( nId != GDB_ID_NULL) { // prossimo gruppo int nNextId = m_pGeomDB->GetNextGroup( nId) ; - // recupero il nome e se già presente lo modifico - string sName ; - if ( ! m_pGeomDB->GetName( nId, sName) || - ! GetMachGroupNewName( sName) || - ! m_pGeomDB->SetName( nId, sName)) - return false ; - // sposto il gruppo - if ( ! m_pGeomDB->Relocate( nId, m_nMachBaseId, GDB_LAST_SON)) - return false ; + // se gruppo di lavoro + MachGrp mgData ; + if ( VerifyMachGroup( nId, mgData)) { + // recupero il nome e se già presente lo modifico + string sName ; + if ( ! m_pGeomDB->GetName( nId, sName) || + ! GetMachGroupNewName( sName) || + ! m_pGeomDB->SetName( nId, sName)) + return false ; + // sposto il gruppo + if ( ! m_pGeomDB->Relocate( nId, m_nMachBaseId, GDB_LAST_SON)) + return false ; + } // passo al prossimo nId = nNextId ; } @@ -128,32 +137,29 @@ bool MachMgr::IsMachBase( int nId) const { int nLevel ; - string sName ; + std::string sName ; return ( m_pGeomDB != nullptr && m_pGeomDB->GetLevel( nId, nLevel) && nLevel == GDB_LV_SYSTEM && m_pGeomDB->GetName( nId, sName) && sName == MACH_BASE) ; } //---------------------------------------------------------------------------- -bool -MachMgr::FindMachBase( int nGroup, int& nMachBase) const +int +MachMgr::FindMachBase( int nGroup) const { // verifica collegamento a DB geometrico if ( m_pGeomDB == nullptr) - return false ; + return GDB_ID_NULL ; // cerco il gruppo di base delle macchinate nel gruppo passato int nId = m_pGeomDB->GetFirstGroupInGroup( nGroup) ; while ( nId != GDB_ID_NULL) { // verifico se gruppo cercato - if ( IsMachBase( nId)) { - if ( &nMachBase != nullptr) - nMachBase = nId ; - return true ; - } + if ( IsMachBase( nId)) + return nId ; // passo al successivo nId = m_pGeomDB->GetNextGroup( nId) ; } - return false ; + return GDB_ID_NULL ; } //---------------------------------------------------------------------------- @@ -199,8 +205,35 @@ MachMgr::GetMachGroupNbr( void) const // verifica del gruppo base per le lavorazioni if ( ! VerifyMachBase()) return 0 ; - // ritorno numero di gruppi di lavorazioni - return ( int( m_vMGroupId.size())) ; + // ritorno numero di gruppi di lavorazione + return m_pGeomDB->GetGroupObjs( m_nMachBaseId) ; +} + +//---------------------------------------------------------------------------- +int +MachMgr::GetFirstMachGroup( void) const +{ + // verifica del gruppo base per le lavorazioni + if ( ! VerifyMachBase()) + return GDB_ID_NULL ; + // recupero il primo sottogruppo + int nId = m_pGeomDB->GetFirstGroupInGroup( m_nMachBaseId) ; + return nId ; +} + +//---------------------------------------------------------------------------- +int +MachMgr::GetNextMachGroup( int nId) const +{ + // verifica del gruppo base per le lavorazioni + if ( ! VerifyMachBase()) + return GDB_ID_NULL ; + // verifico che il gruppo ricevuto sia corretto + if ( m_pGeomDB->GetParentId( nId) != m_nMachBaseId) + return GDB_ID_NULL ; + // recupero il successivo sottogruppo + int nNextId = m_pGeomDB->GetNextGroup( nId) ; + return nNextId ; } //---------------------------------------------------------------------------- @@ -217,10 +250,9 @@ MachMgr::GetMachGroupNewName( string& sName) const return true ; } // verifico che il nome sia unico - int nId ; int nCount = 1 ; string sOrigName = sName ; - while ( GetMachGroupInd( sName, nId)) { + while ( GetMachGroupId( sName) != GDB_ID_NULL) { ++ nCount ; sName = sOrigName + "_" + ToString( nCount) ; } @@ -233,99 +265,188 @@ MachMgr::AddMachGroup( const string& sName, const string& sMachineName) { // verifica ed eventuale creazione del gruppo base per le lavorazioni if ( ! CreateMachBase()) - return 0 ; + return GDB_ID_NULL ; // verifico nome non vuoto e non esista già un gruppo con lo stesso nome - int nMGroup ; - if ( sName.empty() || GetMachGroupInd( sName, nMGroup)) - return 0 ; + if ( sName.empty() || GetMachGroupId( sName) != GDB_ID_NULL) + return GDB_ID_NULL ; // verifico esistenza della macchina // !!!! TO DO !!!! // inserisco il gruppo in coda int nNewId = m_pGeomDB->AddGroup( GDB_ID_NULL, m_nMachBaseId, GLOB_FRM) ; + if ( nNewId == GDB_ID_NULL) + return GDB_ID_NULL ; // assegno il nome m_pGeomDB->SetName( nNewId, sName) ; // assegno la macchina - m_pGeomDB->SetInfo( nNewId, MACH_KEY_MACHINE, sMachineName) ; - // aggiungo il gruppo al vettore degli indici - m_vMGroupId.push_back( nNewId) ; - m_nMGroupCurr = int( m_vMGroupId.size()) ; - // restituisco l'indice nel vettore ( +1) - return m_nMGroupCurr ; + m_pGeomDB->SetInfo( nNewId, MACH_MACHINE_KEY, sMachineName) ; + // creo il sottogruppo per la macchina + int nGeoMachId = m_pGeomDB->AddGroup( GDB_ID_NULL, nNewId, GLOB_FRM) ; + m_pGeomDB->SetName( nGeoMachId, MACH_GEOM_GROUP) ; + // creo il sottogruppo per l'attrezzaggio + int nSetupId = m_pGeomDB->AddGroup( GDB_ID_NULL, nNewId, GLOB_FRM) ; + m_pGeomDB->SetName( nSetupId, MACH_SETUP_GROUP) ; + // creo il sottogruppo per i grezzi + int nRawGroupId = m_pGeomDB->AddGroup( GDB_ID_NULL, nNewId, GLOB_FRM) ; + m_pGeomDB->SetName( nRawGroupId, MACH_RAW_GROUP) ; + // creo il sottogruppo per le operazioni + int nOperGroupId = m_pGeomDB->AddGroup( GDB_ID_NULL, nNewId, GLOB_FRM) ; + m_pGeomDB->SetName( nOperGroupId, MACH_OPER_GROUP) ; + // rendo corrente il gruppo + if ( ! SetCurrMachGroup( nNewId)) { + m_pGeomDB->Erase( nNewId) ; + return GDB_ID_NULL ; + } + // restituisco l'identificativo del gruppo + return nNewId ; } //---------------------------------------------------------------------------- bool -MachMgr::RemoveMachGroup( int nMGroup) +MachMgr::RemoveMachGroup( int nId) { // verifica del gruppo base per le lavorazioni if ( ! VerifyMachBase()) return false ; - // verifico validità indice gruppo da rimuovere - if ( nMGroup <= 0 || nMGroup > int( m_vMGroupId.size())) + // verifico sia veramente un gruppo di lavoro + if ( m_pGeomDB->GetParentId( nId) != m_nMachBaseId) return false ; + // se gruppo corrente, devo definire nuovo corrente + if ( m_nCurrMGrpId == nId) { + // passo al successivo e se non trovato al precedente + int nNextId = m_pGeomDB->GetNextGroup( nId) ; + if ( nNextId == GDB_ID_NULL) + nNextId = m_pGeomDB->GetPrevGroup( nId) ; + // imposto il nuovo corrente (potrebbe essere anche nessuno) + if ( nNextId != GDB_ID_NULL) + SetCurrMachGroup( nNextId) ; + else + ResetCurrMachGroup() ; + } // eseguo rimozione - m_pGeomDB->Erase( m_vMGroupId[nMGroup-1]) ; - // aggiorno vettore indici - for ( size_t i = nMGroup ; i < m_vMGroupId.size() ; ++i) - m_vMGroupId[i-1] = m_vMGroupId[i] ; - m_vMGroupId.pop_back() ; - // eventuale aggiornamento gruppo corrente - if ( m_nMGroupCurr == nMGroup) - m_nMGroupCurr = 0 ; - else if ( m_nMGroupCurr > nMGroup) - -- m_nMGroupCurr ; + m_pGeomDB->Erase( nId) ; return true ; } //---------------------------------------------------------------------------- bool -MachMgr::GetMachGroupName( int nMGroup, string& sName) const +MachMgr::VerifyMachGroup( int nId, MachGrp& mgData) const { - // verifica del parametro di ritorno - if ( &sName == nullptr) + // verifica del parametro + if ( &mgData == nullptr) return false ; - // verifica del gruppo base per le lavorazioni - if ( ! VerifyMachBase()) + // verifica collegamento a DB geometrico + if ( m_pGeomDB == nullptr) return false ; - // recupero il nome del gruppo riferito - return ( nMGroup > 0 && nMGroup <= int( m_vMGroupId.size()) && - m_pGeomDB->GetName( m_vMGroupId[nMGroup-1], sName)) ; + // scansiono i sottogruppi + PtrOwner pIter( CreateGdbIterator( m_pGeomDB)) ; + if ( IsNull( pIter)) + return false ; + bool bMGeo = false ; + bool bSetup = false ; + bool bRaw = false ; + bool bOper = false ; + bool bIter = pIter->GoToFirstGroupInGroup( nId) ; + while ( bIter) { + string sName ; + if ( pIter->GetName( sName)) { + if ( sName == MACH_GEOM_GROUP) { + if ( ! bMGeo) + mgData.MGeoGroupId = pIter->GetId() ; + bMGeo = true ; + } + else if ( sName == MACH_SETUP_GROUP) { + if ( ! bSetup) + mgData.SetupGroupId = pIter->GetId() ; + bSetup = true ; + } + else if ( sName == MACH_RAW_GROUP) { + if ( ! bRaw) + mgData.RawGroupId = pIter->GetId() ; + bRaw = true ; + } + else if ( sName == MACH_OPER_GROUP) { + if ( ! bOper) + mgData.OperGroupId = pIter->GetId() ; + bOper = true ; + } + } + // passo al successivo + bIter = pIter->GoToNextGroup() ; + } + return ( bMGeo && bSetup && bRaw && bOper) ; } //---------------------------------------------------------------------------- -bool -MachMgr::GetMachGroupInd( const std::string& sName, int& nMGroup) const +string +MachMgr::GetMachGroupName( int nId) const +{ + // verifica del gruppo base per le lavorazioni + if ( ! VerifyMachBase()) + return "" ; + // recupero il nome del gruppo riferito + string sName ; + m_pGeomDB->GetName( nId, sName) ; + return sName ; +} + +//---------------------------------------------------------------------------- +int +MachMgr::GetMachGroupId( const string& sName) const { // verifica dei parametri - if ( &sName == nullptr || &nMGroup == nullptr) + if ( &sName == nullptr || sName.empty()) return false ; // verifica del gruppo base per le lavorazioni if ( ! VerifyMachBase()) return false ; - // recupero l'indice del gruppo riferito - for ( size_t i = 0 ; i < m_vMGroupId.size() ; ++ i) { + // recupero l'identificativo del gruppo con il nome indicato + PtrOwner pIter( CreateGdbIterator( m_pGeomDB)) ; + if ( IsNull( pIter)) + return false ; + bool bIter = pIter->GoToFirstGroupInGroup( m_nMachBaseId) ; + while( bIter) { // verifico il nome string sMGroupName ; - if ( m_pGeomDB->GetName( m_vMGroupId[i], sMGroupName) && sMGroupName == sName) { - nMGroup = int( i + 1) ; - return true ; - } + if ( pIter->GetName( sMGroupName) && sMGroupName == sName) + return pIter->GetId() ; + // passo al successivo + bIter = pIter->GoToNextGroup() ; } - return false ; + return GDB_ID_NULL ; } //---------------------------------------------------------------------------- bool -MachMgr::SetCurrMachGroup( int nMGroup) +MachMgr::SetCurrMachGroup( int nId) { // verifica del gruppo base per le lavorazioni if ( ! VerifyMachBase()) return false ; - // verifica validità indice - if ( nMGroup <= 0 || nMGroup > int( m_vMGroupId.size())) + // verifico sia veramente un gruppo di lavoro + if ( m_pGeomDB->GetParentId( nId) != m_nMachBaseId) return false ; - // eseguo - m_nMGroupCurr = nMGroup ; + // recupero i suoi dati + MachGrp mgData ; + if ( ! VerifyMachGroup( nId, mgData)) { + m_nCurrMGrpId = GDB_ID_NULL ; + return false ; + } + // se esiste gruppo corrente, lo disabilito + if ( m_nCurrMGrpId != GDB_ID_NULL) { + // riporto i pezzi nei grezzi precedenti nella loro posizione standard + SwapParts( false) ; + // nascondo precedente gruppo corrente + m_pGeomDB->SetStatus( m_nCurrMGrpId, GDB_ST_OFF) ; + } + // imposto i dati del nuovo gruppo corrente + m_nCurrMGrpId = nId ; + m_cCurrMGrp = mgData ; + // porto i pezzi dalla loro posizione standard nei grezzi nuovi + SwapParts( true) ; + // nascondo pezzi rimasti sotto la radice + ShowRootParts( false) ; + // rendo visibile il nuovo gruppo corrente + m_pGeomDB->SetStatus( m_nCurrMGrpId, GDB_ST_ON) ; return true ; } @@ -333,47 +454,652 @@ MachMgr::SetCurrMachGroup( int nMGroup) bool MachMgr::ResetCurrMachGroup( void) { - m_nMGroupCurr = 0 ; - return VerifyMachBase() ; -} - -//---------------------------------------------------------------------------- -bool -MachMgr::GetCurrMachGroup( int& nMGroup) const -{ - // verifica del parametro di ritorno - if ( &nMGroup == nullptr) - return false ; // verifica del gruppo base per le lavorazioni if ( ! VerifyMachBase()) return false ; + // se non c'è gruppo corrente, posso uscire subito + if ( m_nCurrMGrpId == GDB_ID_NULL) + return true ; + // riporto i pezzi nei grezzi nella loro posizione standard + SwapParts( false) ; + // visualizzo pezzi rimasti sotto la radice + ShowRootParts( true) ; + // nascondo gruppo corrente + m_pGeomDB->SetStatus( m_nCurrMGrpId, GDB_ST_OFF) ; + // dichiaro nessun gruppo corrente + m_nCurrMGrpId = GDB_ID_NULL ; + return true ; +} + +//---------------------------------------------------------------------------- +int +MachMgr::GetCurrMachGroup( void) const +{ + // verifica del gruppo base per le lavorazioni + if ( ! VerifyMachBase()) + return GDB_ID_NULL ; // recupero l'indice del gruppo corrente - nMGroup = m_nMGroupCurr ; - return ( m_nMGroupCurr != 0) ; + return m_nCurrMGrpId ; } //---------------------------------------------------------------------------- int MachMgr::AddRawPart( const Point3d& ptOrig, double dWidth, double dLen, double dHeight, Color cCol) { - // verifica della macchinata - if ( ! VerifyMachBase() || m_nMGroupCurr == 0) - return false ; - // inserisco il gruppo del grezzo nella macchinata - int nRawId = m_pGeomDB->AddGroup( GDB_ID_NULL, m_vMGroupId[ m_nMGroupCurr - 1], Frame3d( ptOrig)) ; - if ( nRawId == GDB_ID_NULL) + // recupero il gruppo dei grezzi nella macchinata corrente + int nRawGroupId = GetCurrRawGroupId() ; + if ( nRawGroupId == GDB_ID_NULL) return GDB_ID_NULL ; - // assegno il nome - m_pGeomDB->SetName( nRawId, MACH_RAW_PART) ; - // assegno il colore - m_pGeomDB->SetMaterial( nRawId, cCol) ; // creo il solido PtrOwner pStm( GetSurfTriMeshBox( dWidth, dLen, dHeight)) ; if ( IsNull( pStm)) return GDB_ID_NULL ; - // lo inserisco nel gruppo - int nId = m_pGeomDB->AddGeoObj( GDB_ID_NULL, nRawId, Release( pStm)) ; - if ( nId == GDB_ID_NULL) + // inserisco il gruppo del grezzo nella macchinata + int nRawId = m_pGeomDB->AddGroup( GDB_ID_NULL, nRawGroupId, Frame3d( ptOrig)) ; + if ( nRawId == GDB_ID_NULL) return GDB_ID_NULL ; + // assegno il nome al gruppo + bool bOk = m_pGeomDB->SetName( nRawId, MACH_RAW_PART) ; + // inserisco il solido nel gruppo + int nId = m_pGeomDB->AddGeoObj( GDB_ID_NULL, nRawId, Release( pStm)) ; + bOk = bOk && ( nId != GDB_ID_NULL) ; + // assegno il nome al solido + bOk = bOk && m_pGeomDB->SetName( nId, MACH_RAW_SOLID) ; + // assegno il colore al solido + bOk = bOk && m_pGeomDB->SetMaterial( nId, cCol) ; + // calcolo il punto centro del solido + bOk = bOk && SetRawPartCenter( nRawId) ; + // se qualcosa è andato storto, cancello tutto + if ( ! bOk) { + m_pGeomDB->Erase( nRawId) ; + return GDB_ID_NULL ; + } + // tutto ok return nRawId ; -} \ No newline at end of file +} + +//---------------------------------------------------------------------------- +int +MachMgr::AddRawPart( int nCrvId, double dOverMat, double dZmin, double dHeight, Color cCol) +{ + // recupero il gruppo dei grezzi nella macchinata corrente + int nRawGroupId = GetCurrRawGroupId() ; + if ( nRawGroupId == GDB_ID_NULL) + return GDB_ID_NULL ; + // recupero l'ingombro della curva in globale + BBox3d b3Crv ; + if ( ! m_pGeomDB->GetGlobalBBox( nCrvId, b3Crv)) + return GDB_ID_NULL ; + // recupero il riferimento della curva + Frame3d frCrv ; + if ( ! m_pGeomDB->GetGlobFrame( nCrvId, frCrv)) + return GDB_ID_NULL ; + // recupero la curva + const ICurve* pCrv = GetCurve( m_pGeomDB->GetGeoObj( nCrvId)) ; + if ( pCrv == nullptr) + return GDB_ID_NULL ; + // copio la curva in una composita + PtrOwner pMyCrv( CreateCurveComposite()) ; + if ( IsNull( pMyCrv) || ! pMyCrv->AddCurve( *pCrv)) + return GDB_ID_NULL ; + // determino il riferimento del grezzo + Point3d ptOrig = b3Crv.GetMin() ; + ptOrig.z = dZmin ; + Frame3d frRaw( ptOrig) ; + // porto la curva in questo riferimento + pMyCrv->LocToLoc( frCrv, frRaw) ; + // la schiaccio a Z = 0 + if ( ! pMyCrv->Scale( Frame3d(), 1, 1, 0)) + return GDB_ID_NULL ; + // se non è chiusa, la chiudo + if ( ! pMyCrv->IsClosed()) + pMyCrv->Close() ; + // la oriento in senso CCW + double dAreaXY ; + if ( ! pMyCrv->GetAreaXY( dAreaXY)) + return GDB_ID_NULL ; + if ( dAreaXY < 0) + pMyCrv->Invert() ; + // ne eseguo l'offset + if ( ! pMyCrv->SimpleOffset( dOverMat, ICurve::OFF_EXTEND)) + return GDB_ID_NULL ; + // creo il solido + PtrOwner pStm( GetSurfTriMeshByExtrusion( Get( pMyCrv), Vector3d(0,0,dHeight), true)) ; + if ( IsNull( pStm)) + return GDB_ID_NULL ; + // inserisco il gruppo del grezzo nella macchinata + int nRawId = m_pGeomDB->AddGroup( GDB_ID_NULL, nRawGroupId, frRaw) ; + if ( nRawId == GDB_ID_NULL) + return GDB_ID_NULL ; + // assegno il nome al gruppo + bool bOk = m_pGeomDB->SetName( nRawId, MACH_RAW_PART) ; + // inserisco il solido nel gruppo + int nId = m_pGeomDB->AddGeoObj( GDB_ID_NULL, nRawId, Release( pStm)) ; + bOk = bOk && ( nId != GDB_ID_NULL) ; + // assegno il nome al solido + bOk = bOk && m_pGeomDB->SetName( nId, MACH_RAW_SOLID) ; + // assegno il colore al solido + bOk = bOk && m_pGeomDB->SetMaterial( nId, cCol) ; + // calcolo il punto centro del solido + bOk = bOk && SetRawPartCenter( nRawId) ; + // se qualcosa è andato storto, cancello tutto + if ( ! bOk) { + m_pGeomDB->Erase( nRawId) ; + return GDB_ID_NULL ; + } + // tutto ok + return nRawId ; +} + +//---------------------------------------------------------------------------- +int +MachMgr::AddRawPart( int nSurfId, Color cCol) +{ + // recupero il gruppo dei grezzi nella macchinata corrente + int nRawGroupId = GetCurrRawGroupId() ; + if ( nRawGroupId == GDB_ID_NULL) + return GDB_ID_NULL ; + // recupero l'ingombro della superficie in globale + BBox3d b3Crv ; + if ( ! m_pGeomDB->GetGlobalBBox( nSurfId, b3Crv)) + return GDB_ID_NULL ; + // inserisco il gruppo del grezzo nella macchinata + Frame3d frRaw( b3Crv.GetMin()) ; + int nRawId = m_pGeomDB->AddGroup( GDB_ID_NULL, nRawGroupId, frRaw) ; + if ( nRawId == GDB_ID_NULL) + return GDB_ID_NULL ; + // assegno il nome al gruppo + bool bOk = m_pGeomDB->SetName( nRawId, MACH_RAW_PART) ; + // copio la superficie nel gruppo + int nId = m_pGeomDB->CopyGlob( nSurfId, GDB_ID_NULL, nRawId) ; + bOk = bOk && ( nId != GDB_ID_NULL) ; + // assegno il nome al solido + bOk = bOk && m_pGeomDB->SetName( nId, MACH_RAW_SOLID) ; + // assegno il colore al solido + bOk = bOk && m_pGeomDB->SetMaterial( nId, cCol) ; + // rendo visibile il solido + bOk = bOk && m_pGeomDB->SetStatus( nId, GDB_ST_ON) ; + // calcolo il punto centro del solido + bOk = bOk && SetRawPartCenter( nRawId) ; + // se qualcosa è andato storto, cancello tutto + if ( ! bOk) { + m_pGeomDB->Erase( nRawId) ; + return GDB_ID_NULL ; + } + // nascondo la superficie originale + m_pGeomDB->SetStatus( nSurfId, GDB_ST_OFF) ; + // tutto ok + return nRawId ; +} + +//---------------------------------------------------------------------------- +int +MachMgr::AddRawPartWithPart( int nPartId, int nCrvSrfId, double dOverMat, Color cCol) +{ + // verifico il gruppo dei grezzi nella macchinata corrente + if ( GetCurrRawGroupId() == GDB_ID_NULL) + return GDB_ID_NULL ; + // verifico che il pezzo non sia già usato nella macchinata corrente + if ( m_pGeomDB->GetParentId( nPartId) != GDB_ID_ROOT) + return GDB_ID_NULL ; + // recupero il tipo di oggetto per definire il grezzo + int nGtype = m_pGeomDB->GetGeoType( nCrvSrfId) ; + // costruzione del grezzo + int nRawId = GDB_ID_NULL ; + // se grezzo da superficie (per ora senza possibilità di offset) + if ( ( nGtype & GEO_SURF) != 0) { + // inserisco il grezzo + nRawId = AddRawPart( nCrvSrfId, cCol) ; + } + // se altrimenti grezzo da contorno + else if ( ( nGtype & GEO_CURVE) != 0) { + // determino l'ingombro del pezzo + BBox3d b3Part ; + if ( ! m_pGeomDB->GetGlobalBBox( nPartId, b3Part)) + return GDB_ID_NULL ; + // inserisco il grezzo + double dZmin = b3Part.GetMin().z ; + double dH = ( b3Part.GetMax() - b3Part.GetMin()).z ; + if ( dH < RAW_MIN_H) + dH = RAW_MIN_H ; + nRawId = AddRawPart( nCrvSrfId, dOverMat, dZmin, dH, cCol) ; + } + // altrimenti grezzo rettangolare da ingombro pezzo + else { + // determino l'ingombro del pezzo + BBox3d b3Part ; + if ( ! m_pGeomDB->GetGlobalBBox( nPartId, b3Part)) + return GDB_ID_NULL ; + // deduco i dati del grezzo + Point3d ptMin = b3Part.GetMin() - Vector3d( dOverMat, dOverMat, 0) ; + Point3d ptMax = b3Part.GetMax() + Vector3d( dOverMat, dOverMat, 0) ; + Vector3d vtDiff = ptMax - ptMin ; + if ( vtDiff.z < RAW_MIN_H) + vtDiff.z = RAW_MIN_H ; + // inserisco il grezzo + nRawId = AddRawPart( ptMin, vtDiff.x, vtDiff.y, vtDiff.z, cCol) ; + } + // verifico il grezzo appena calcolato + if ( nRawId == GDB_ID_NULL) + return GDB_ID_NULL ; + // recupero il riferimento del grezzo + Frame3d frRaw ; + m_pGeomDB->GetGroupGlobFrame( nRawId, frRaw) ; + // determino il riferimento del pezzo rispetto al grezzo + Frame3d frPart ; + m_pGeomDB->GetGroupGlobFrame( nPartId, frPart) ; + frPart.ToLoc( frRaw) ; + // inserisco il pezzo + int nGroup = m_pGeomDB->AddGroup( GDB_ID_NULL, nRawId, frPart) ; + if ( nGroup == GDB_ID_NULL || + ! m_pGeomDB->GroupSwap( nPartId, nGroup, true, true)) + return GDB_ID_NULL ; + // mi assicuro sia visibile il pezzo e nascosto il gruppo + m_pGeomDB->SetStatus( nPartId, GDB_ST_ON) ; + m_pGeomDB->SetStatus( nGroup, GDB_ST_OFF) ; + return nRawId ; +} + +//---------------------------------------------------------------------------- +bool +MachMgr::AddPartToRawPart( int nPartId, const Point3d& ptPos, int nRawId) +{ + // verifica validità grezzo + if ( ! VerifyRawPart( nRawId)) + return false ; + // verifico che il pezzo non sia già usato nella macchinata corrente + if ( m_pGeomDB->GetParentId( nPartId) != GDB_ID_ROOT) + return false ; + // recupero il riferimento del grezzo + Frame3d frRaw ; + m_pGeomDB->GetGroupGlobFrame( nRawId, frRaw) ; + // recupero box del pezzo + BBox3d b3Part ; + if ( ! m_pGeomDB->GetGlobalBBox( nPartId, b3Part)) + return false ; + // recupero il riferimento del pezzo + Frame3d frPart ; + m_pGeomDB->GetGroupGlobFrame( nPartId, frPart) ; + // muovo riferimento del pezzo per posizionare correttamente nel grezzo + Vector3d vtMove = ptPos - b3Part.GetMin() ; + frPart.Translate( vtMove) ; + // esprimo questo riferimento rispetto al grezzo + frPart.ToLoc( frRaw) ; + // inserisco il pezzo + int nGroup = m_pGeomDB->AddGroup( GDB_ID_NULL, nRawId, frPart) ; + if ( nGroup == GDB_ID_NULL || + ! m_pGeomDB->GroupSwap( nPartId, nGroup, true, true)) + return false ; + // mi assicuro sia visibile il pezzo e nascosto il gruppo + m_pGeomDB->SetStatus( nPartId, GDB_ST_ON) ; + m_pGeomDB->SetStatus( nGroup, GDB_ST_OFF) ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +MachMgr::ModifyRawPartHeight( int nRawId, double dHeight) +{ + // la nuova altezza non può essere nulla + if ( dHeight < EPS_SMALL) + return false ; + // verifica validità grezzo + if ( ! VerifyRawPart( nRawId)) + return false ; + // recupero il solido del grezzo + int nRawSolId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ; + if ( nRawSolId == GDB_ID_NULL) + return false ; + // recupero il box del grezzo + BBox3d b3Raw ; + if ( ! m_pGeomDB->GetLocalBBox( nRawSolId, b3Raw)) + return false ; + // determino il coefficente di scalatura in Z + double dOldH = b3Raw.GetMax().z - b3Raw.GetMin().z ; + if ( dOldH < EPS_SMALL) + return false ; + double dCoeff = dHeight / dOldH ; + // eseguo scalatura + bool bOk = m_pGeomDB->Scale( nRawSolId, Frame3d( b3Raw.GetMin()), 1, 1, dCoeff) ; + // dichiaro centro da ricalcolare + ResetRawPartCenter( nRawId) ; + return bOk ; +} + +//---------------------------------------------------------------------------- +bool +MachMgr::RemoveRawPart( int nRawId) +{ + // verifica validità grezzo + if ( ! VerifyRawPart( nRawId)) + return false ; + // devo estrarre i pezzi e riportarli in lista generale + SwapRawPartParts( nRawId, false) ; + // cancello il grezzo + m_pGeomDB->Erase( nRawId) ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +MachMgr::VerifyRawPart( int nRawId) const +{ + // recupero il gruppo dei grezzi nella macchinata corrente + int nRawGroupId = GetCurrRawGroupId() ; + if ( nRawGroupId == GDB_ID_NULL) + return false ; + // verifico che questo grezzo ne faccia parte + if ( m_pGeomDB->GetParentId( nRawId) != nRawGroupId) + return false ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +MachMgr::TranslateRawPart( int nRawId, const Vector3d& vtMove) +{ + // verifica validità grezzo + if ( ! VerifyRawPart( nRawId)) + return false ; + // eseguo traslazione in globale + return m_pGeomDB->TranslateGlob( nRawId, vtMove) ; +} + +//---------------------------------------------------------------------------- +bool +MachMgr::RotateRawPart( int nRawId, const Vector3d& vtAx, double dAngRotDeg) +{ + // verifica validità grezzo + if ( ! VerifyRawPart( nRawId)) + return false ; + // recupero centro del grezzo + Point3d ptAx ; + if ( ! GetRawPartCenter( nRawId, ptAx)) + return false ; + // eseguo rotazione in globale attorno al centro del grezzo + return m_pGeomDB->RotateGlob( nRawId, ptAx, vtAx, dAngRotDeg) ; +} + +//---------------------------------------------------------------------------- +bool +MachMgr::MoveToCornerRawPart( int nRawId, const Point3d& ptP, int nFlag) +{ + // verifica validità grezzo + if ( ! VerifyRawPart( nRawId)) + return false ; + // recupero il solido + int nRawSolId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ; + // determino il box del grezzo (solo il solido ovviamente) + BBox3d b3Raw ; + if ( ! m_pGeomDB->GetGlobalBBox( nRawSolId, b3Raw)) + return false ; + // calcolo il movimento necessario + Vector3d vtMove ; + switch ( nFlag) { + case RPCR_TL : + vtMove = ptP - Point3d( b3Raw.GetMin().x, b3Raw.GetMax().y, b3Raw.GetMin().z) ; + break ; + case RPCR_TR : + vtMove = ptP - b3Raw.GetMax() ; + break ; + default : // RPCP_BL + vtMove = ptP - b3Raw.GetMin() ; + break ; + case RPCR_BR : + vtMove = ptP - Point3d( b3Raw.GetMax().x, b3Raw.GetMin().y, b3Raw.GetMin().z) ; + break ; + } + // eseguo traslazione in globale + return m_pGeomDB->TranslateGlob( nRawId, vtMove) ; +} + +//---------------------------------------------------------------------------- +bool +MachMgr::MoveToCenterRawPart( int nRawId, const Point3d& ptP, int nFlag) +{ + // verifica validità grezzo + if ( ! VerifyRawPart( nRawId)) + return false ; + // recupero il solido + int nRawSolId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ; + // determino il box del grezzo (solo il solido ovviamente) + BBox3d b3Raw ; + if ( ! m_pGeomDB->GetGlobalBBox( nRawSolId, b3Raw)) + return false ; + // ricavo il centro dal box (in generale non è il centro geometrico) + Point3d ptCen ; + b3Raw.GetCenter( ptCen) ; + // calcolo il movimento necessario + Vector3d vtMove ; + switch ( nFlag) { + case RPCE_TC : + vtMove = ptP - Point3d( ptCen.x, b3Raw.GetMax().y, ptCen.z) ; + break ; + default : // RPCE_ML + vtMove = ptP - Point3d( b3Raw.GetMin().x, ptCen.y, ptCen.z) ; + break ; + case RPCE_MR : + vtMove = ptP - Point3d( b3Raw.GetMax().x, ptCen.y, ptCen.z) ; + break ; + case RPCE_BC : + vtMove = ptP - Point3d( ptCen.x, b3Raw.GetMin().y, ptCen.z) ; + break ; + case RPCE_MC : + vtMove = ptP - Point3d( ptCen.x, ptCen.y, b3Raw.GetMin().z) ; + break ; + } + // eseguo traslazione in globale + return m_pGeomDB->TranslateGlob( nRawId, vtMove) ; +} + +//---------------------------------------------------------------------------- +bool +MachMgr::RemovePartFromRawPart( int nPartId) +{ + // verifico DB geometrico + if ( m_pGeomDB == nullptr) + return false ; + // recupero l'indice del grezzo + int nRawId = m_pGeomDB->GetParentId( nPartId) ; + // verifica validità grezzo + if ( ! VerifyRawPart( nRawId)) + return false ; + // devo riportare il pezzo in lista generale + int nBase ; + if ( m_pGeomDB->GetInfo( nPartId, GDB_SI_BASE, nBase)) { + // eseguo lo scambio + m_pGeomDB->GroupSwap( nPartId, nBase, true, true) ; + // mi assicuro sia nascosto + m_pGeomDB->SetStatus( nPartId, GDB_ST_OFF) ; + // cancello il gruppo di riferimento + m_pGeomDB->Erase( nBase) ; + return true ; + } + return false ; +} + +//---------------------------------------------------------------------------- +bool +MachMgr::TranslatePartInRawPart( int nPartId, const Vector3d& vtMove) +{ + // verifico DB geometrico + if ( m_pGeomDB == nullptr) + return false ; + // recupero l'indice del grezzo + int nRawId = m_pGeomDB->GetParentId( nPartId) ; + // verifica validità grezzo + if ( ! VerifyRawPart( nRawId)) + return false ; + // eseguo traslazione in globale + return m_pGeomDB->TranslateGlob( nPartId, vtMove) ; +} + +//---------------------------------------------------------------------------- +bool +MachMgr::RotatePartInRawPart( int nPartId, const Vector3d& vtAx, double dAngRotDeg) +{ + // verifico DB geometrico + if ( m_pGeomDB == nullptr) + return false ; + // recupero l'indice del grezzo + int nRawId = m_pGeomDB->GetParentId( nPartId) ; + // verifica validità grezzo + if ( ! VerifyRawPart( nRawId)) + return false ; + // recupero riferimento globale del pezzo + Frame3d frRef ; + if ( ! m_pGeomDB->GetGroupGlobFrame( nPartId, frRef)) + return false ; + // recupero box del pezzo in locale (non cambia con la giacitura globale) + BBox3d b3Box ; + if ( ! m_pGeomDB->GetLocalBBox( nPartId, b3Box)) + return false ; + // ne calcolo il centro e lo porto in globale + Point3d ptCen ; + b3Box.GetCenter( ptCen) ; + ptCen.ToGlob( frRef) ; + // eseguo rotazione in globale attorno al centro del pezzo + return m_pGeomDB->RotateGlob( nPartId, ptCen, vtAx, dAngRotDeg) ; +} + +//---------------------------------------------------------------------------- +bool +MachMgr::SetRawPartCenter( int nRawId) +{ + // recupero il solido + int nRawSolId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ; + const ISurfTriMesh* pStm = GetSurfTriMesh( m_pGeomDB->GetGeoObj( nRawSolId)) ; + if ( pStm == nullptr) + return false ; + // recupero il punto centro, se non esiste lo creo + int nGPntId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_CENTER) ; + if ( nGPntId == GDB_ID_NULL) { + PtrOwner pGeoPnt( CreateGeoPoint3d()) ; + nGPntId = m_pGeomDB->AddGeoObj( GDB_ID_NULL, nRawId, Release( pGeoPnt)) ; + m_pGeomDB->SetName( nGPntId, MACH_RAW_CENTER) ; + Color cCol ; + if ( m_pGeomDB->GetCalcMaterial( nRawSolId, cCol)) + m_pGeomDB->SetMaterial( nGPntId, cCol) ; + } + IGeoPoint3d* pGeoPnt = GetGeoPoint3d( m_pGeomDB->GetGeoObj( nGPntId)) ; + if ( pGeoPnt == nullptr) + return false ; + // calcolo il valore del centro + Point3d ptCen ; + if ( ! pStm->GetCentroid( ptCen)) + return false ; + // aggiorno e imposto modo a standard + return ( pGeoPnt->Set( ptCen) && m_pGeomDB->SetMode( nGPntId, GDB_MD_STD)) ; +} + +//---------------------------------------------------------------------------- +bool +MachMgr::ResetRawPartCenter( int nRawId) +{ + // recupero il punto centro + int nGPntId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_CENTER) ; + if ( nGPntId == GDB_ID_NULL) + return true ; + // imposto modo a bloccato + return m_pGeomDB->SetMode( nGPntId, GDB_MD_LOCKED) ; +} + +//---------------------------------------------------------------------------- +bool +MachMgr::GetRawPartCenter( int nRawId, Point3d& ptCen) +{ + // cerco di recuperare l'oggetto + int nGPntId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_CENTER) ; + // ne verifico la validità + int nMode ; + if ( nGPntId == GDB_ID_NULL || + ! m_pGeomDB->GetMode( nGPntId, nMode) || nMode != GDB_MD_STD) { + // provo a crearlo + SetRawPartCenter( nRawId) ; + nGPntId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_CENTER) ; + // se c'è ancora errore + if ( nGPntId == GDB_ID_NULL) + return false ; + } + // ne recupero il riferimento globale + Frame3d frGPnt ; + if ( ! m_pGeomDB->GetGlobFrame( nGPntId, frGPnt)) + return false ; + // recupero il punto + IGeoPoint3d* pGeoPnt = GetGeoPoint3d( m_pGeomDB->GetGeoObj( nGPntId)) ; + if ( pGeoPnt == nullptr) + return false ; + ptCen = pGeoPnt->GetPoint() ; + ptCen.ToGlob( frGPnt) ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +MachMgr::SwapParts( bool bToRawPart) +{ + // recupero il gruppo dei grezzi correnti + int nRawGroupId = GetCurrRawGroupId() ; + if ( nRawGroupId == GDB_ID_NULL) + return true ; + // ciclo sui grezzi + int nRawId = m_pGeomDB->GetFirstGroupInGroup( nRawGroupId) ; + while ( nRawId != GDB_ID_NULL) { + // sistemo i pezzi del grezzo + SwapRawPartParts( nRawId, bToRawPart) ; + // passo al successivo + nRawId = m_pGeomDB->GetNextGroup( nRawId) ; + } + return true ; +} + +//---------------------------------------------------------------------------- +bool +MachMgr::SwapRawPartParts( int nRawId, bool bToRawPart) +{ + // ciclo sui gruppi nel grezzo + int nId = m_pGeomDB->GetFirstGroupInGroup( nRawId) ; + while ( nId != GDB_ID_NULL) { + // recupero il successivo + int nNextId = m_pGeomDB->GetNextGroup( nId) ; + // se devo portare i pezzi dalla radice al grezzo + if ( bToRawPart) { + // se è un riferimento al pezzo + int nSou ; + if ( m_pGeomDB->GetInfo( nId, GDB_SI_SOURCE, nSou)) { + m_pGeomDB->GroupSwap( nSou, nId, true, true) ; + // mi assicuro sia visibile + m_pGeomDB->SetStatus( nSou, GDB_ST_ON) ; + } + } + // altrimenti dal grezzo alla radice + else { + // se è un pezzo spostato + int nBase ; + if ( m_pGeomDB->GetInfo( nId, GDB_SI_BASE, nBase)) { + m_pGeomDB->GroupSwap( nId, nBase, true, true) ; + // mi assicuro sia nascosto + m_pGeomDB->SetStatus( nId, GDB_ST_OFF) ; + } + } + // passo al successivo + nId = nNextId ; + } + return true ; +} + +//---------------------------------------------------------------------------- +bool +MachMgr::ShowRootParts( bool bShow) +{ + // ciclo sui gruppi in radice + int nId = m_pGeomDB->GetFirstGroupInGroup( GDB_ID_ROOT) ; + while ( nId != GDB_ID_NULL) { + // se pezzo, lo nascondo + if ( ! IsMachBase( nId)) + m_pGeomDB->SetStatus( nId, ( bShow ? GDB_ST_ON : GDB_ST_OFF)) ; + // passo al successivo + nId = m_pGeomDB->GetNextGroup( nId) ; + } + return true ; +} diff --git a/MachMgr.h b/MachMgr.h index 9519c16..3e23b2b 100644 --- a/MachMgr.h +++ b/MachMgr.h @@ -13,44 +13,93 @@ #pragma once +#include "MachConst.h" #include "/EgtDev/Include/EMkMachMgr.h" #include "/EgtDev/Include/EgtNumCollection.h" +//---------------------------------------------------------------------------- +struct MachGrp { + int MGeoGroupId ; + int SetupGroupId ; + int RawGroupId ; + int OperGroupId ; + MachGrp( void) + : MGeoGroupId( GDB_ID_NULL), SetupGroupId( GDB_ID_NULL), + RawGroupId( GDB_ID_NULL), OperGroupId( GDB_ID_NULL) {} + MachGrp( int MgId, int GgId, int SgId, int RgId, int OgId) + : MGeoGroupId( GgId), SetupGroupId( SgId), + RawGroupId( RgId), OperGroupId( OgId) {} +} ; + //---------------------------------------------------------------------------- class MachMgr : public IMachMgr { - public : // General virtual bool Init( IGeomDB* pGeomDB) ; virtual bool Update( void) ; virtual bool Insert( int nInsGrp) ; - // MachGroup + // MachGroups virtual int GetMachGroupNbr( void) const ; + virtual int GetFirstMachGroup( void) const ; + virtual int GetNextMachGroup( int nId) const ; virtual bool GetMachGroupNewName( std::string& sName) const ; virtual int AddMachGroup( const std::string& sName, const std::string& sMachineName) ; - virtual bool RemoveMachGroup( int nMGroup) ; - virtual bool GetMachGroupName( int nMGroup, std::string& sName) const ; - virtual bool GetMachGroupInd( const std::string& sName, int& nMGroup) const ; - virtual bool SetCurrMachGroup( int nMGroup) ; + virtual bool RemoveMachGroup( int nId) ; + virtual std::string GetMachGroupName( int nId) const ; + virtual int GetMachGroupId( const std::string& sName) const ; + virtual bool SetCurrMachGroup( int nId) ; virtual bool ResetCurrMachGroup( void) ; - virtual bool GetCurrMachGroup( int& nMGroup) const ; - // RawPart & Part + virtual int GetCurrMachGroup( void) const ; + // RawParts & Parts virtual int AddRawPart( const Point3d& ptOrig, double dWidth, double dLen, double dHeight, Color cCol) ; + virtual int AddRawPartWithPart( int nPartId, int nCrvSrfId, double dOverMat, Color cCol) ; + virtual bool AddPartToRawPart( int nPartId, const Point3d& ptPos, int nRawId) ; + virtual bool ModifyRawPartHeight( int nRawId, double dHeight) ; + virtual bool RemoveRawPart( int nRawId) ; + virtual bool TranslateRawPart( int nRawId, const Vector3d& vtMove) ; + virtual bool RotateRawPart( int nRawId, const Vector3d& vtAx, double dAngRotDeg) ; + virtual bool MoveToCornerRawPart( int nRawId, const Point3d& ptCorner, int nFlag) ; + virtual bool MoveToCenterRawPart( int nRawId, const Point3d& ptCenter, int nFlag) ; + virtual bool RemovePartFromRawPart( int nPartId) ; + virtual bool TranslatePartInRawPart( int nPartId, const Vector3d& vtMove) ; + virtual bool RotatePartInRawPart( int nPartId, const Vector3d& vtAx, double dAngRotDeg) ; public : MachMgr( void) ; private : inline bool IsMachBase( int nId) const ; - bool FindMachBase( int nGroup, int& nMachBase) const ; + int FindMachBase( int nGroupId) const ; bool VerifyMachBase( void) const ; bool CreateMachBase( void) ; + bool VerifyMachGroup( int nId, MachGrp& mgData) const ; + int GetCurrMGeoId( void) const + { return ( m_pGeomDB == nullptr) ? GDB_ID_NULL : + (( m_nCurrMGrpId == GDB_ID_NULL) ? GDB_ID_NULL : m_cCurrMGrp.MGeoGroupId) ; } + int GetCurrSetupId( void) const + { return ( m_pGeomDB == nullptr) ? GDB_ID_NULL : + (( m_nCurrMGrpId == GDB_ID_NULL) ? GDB_ID_NULL : m_cCurrMGrp.SetupGroupId) ; } + int GetCurrRawGroupId( void) const + { return ( m_pGeomDB == nullptr) ? GDB_ID_NULL : + (( m_nCurrMGrpId == GDB_ID_NULL) ? GDB_ID_NULL : m_cCurrMGrp.RawGroupId) ; } + int GetCurrOperId( void) const + { return ( m_pGeomDB == nullptr) ? GDB_ID_NULL : + (( m_nCurrMGrpId == GDB_ID_NULL) ? GDB_ID_NULL : m_cCurrMGrp.OperGroupId) ; } + int AddRawPart( int nCrvId, double dOverMat, double dZmin, double dHeight, Color cCol) ; + int AddRawPart( int nSurfId, Color cCol) ; + bool VerifyRawPart( int nRawId) const ; + bool SetRawPartCenter( int nRawId) ; + bool ResetRawPartCenter( int nRawId) ; + bool GetRawPartCenter( int nRawId, Point3d& ptCen) ; + bool SwapParts( bool bToRawPart) ; + bool SwapRawPartParts( int nRawId, bool bToRawPart) ; + bool ShowRootParts( bool bShow) ; private : - IGeomDB* m_pGeomDB ; - int m_nMachBaseId ; - INTVECTOR m_vMGroupId ; - int m_nMGroupCurr ; // 1-based + IGeomDB* m_pGeomDB ; + int m_nMachBaseId ; + int m_nCurrMGrpId ; + MachGrp m_cCurrMGrp ; } ;