8ac8373376
- aggiunti calcolo angoli e assi lineari macchina.
94 lines
3.8 KiB
C++
94 lines
3.8 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2015-2015
|
|
//----------------------------------------------------------------------------
|
|
// File : MachineHeads.cpp Data : 10.05.15 Versione : 1.6e3
|
|
// Contenuto : Implementazione gestione macchina : funzioni per teste.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 10.05.15 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
//--------------------------- Include ----------------------------------------
|
|
#include "stdafx.h"
|
|
#include "MachMgr.h"
|
|
#include "DllMain.h"
|
|
#include "/EgtDev/Include/EGnStringUtils.h"
|
|
#include "/EgtDev/Include/EGnFileUtils.h"
|
|
|
|
using namespace std ;
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Machine::LoadTool( const string& sHead, int nExit, const string& sTool)
|
|
{
|
|
// recupero il gruppo della testa
|
|
int nHdGrp = GetGroup( sHead) ;
|
|
if ( nHdGrp == GDB_ID_NULL || ! IsHeadGroup( nHdGrp))
|
|
return false ;
|
|
// cerco il gruppo dell'uscita in quello della testa
|
|
string sExit = "T" + ToString( nExit) ;
|
|
int nExGrp = m_pMchMgr->m_pGeomDB->GetFirstNameInGroup( nHdGrp, sExit) ;
|
|
if ( nExGrp == GDB_ID_NULL || m_pMchMgr->m_pGeomDB->GetGdbType( nExGrp) != GDB_TY_GROUP)
|
|
return false ;
|
|
// se utensile già montato, abilito ed esco
|
|
string sOldTool ;
|
|
if ( m_pMchMgr->m_pGeomDB->GetInfo( nExGrp, "Tool", sOldTool) && sTool == sOldTool)
|
|
return EnableHeadInSet( sHead) ;
|
|
// verifico esistenza file utensile
|
|
string sToolFile = m_sMachineDir + "\\" + TOOLS_DIR + "\\" + sTool + ".Nge" ;
|
|
if ( ! ExistsFile( sToolFile))
|
|
return false ;
|
|
// pulisco il gruppo dell'uscita
|
|
m_pMchMgr->m_pGeomDB->EmptyGroup( nExGrp) ;
|
|
// inserisco l'utensile nel gruppo
|
|
if ( ! m_pMchMgr->m_pGeomDB->Load( sToolFile, nExGrp))
|
|
return false ;
|
|
int nTGrpId = m_pMchMgr->m_pGeomDB->GetFirstGroupInGroup( nExGrp) ;
|
|
int nSolidId = m_pMchMgr->m_pGeomDB->GetFirstNameInGroup( nTGrpId, "SOLID") ;
|
|
if ( nSolidId == GDB_ID_NULL)
|
|
return false ;
|
|
m_pMchMgr->m_pGeomDB->RelocateGlob( nSolidId, nExGrp, GDB_FIRST_SON) ;
|
|
m_pMchMgr->m_pGeomDB->Erase( nTGrpId) ;
|
|
m_pMchMgr->m_pGeomDB->SetName( nSolidId, sTool) ;
|
|
// lo ruoto 90 deg attorno alla X locale
|
|
int nT = m_pMchMgr->m_pGeomDB->GetFirstGroupInGroup( nExGrp) ;
|
|
if ( nT == GDB_ID_NULL)
|
|
return false ;
|
|
m_pMchMgr->m_pGeomDB->Rotate( nT, ORIG, X_AX, 90) ;
|
|
m_pMchMgr->m_pGeomDB->SetInfo( nExGrp, "Tool", sTool) ;
|
|
return EnableHeadInSet( sHead) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Machine::ResetHeadSet( const string& sHead)
|
|
{
|
|
// recupero il set della testa
|
|
STRVECTOR vsHSet ;
|
|
if ( ! GetHSet( sHead, vsHSet))
|
|
return false ;
|
|
// ciclo su tutte le teste dell'insieme per svuotarle
|
|
for ( size_t i = 0 ; i < vsHSet.size() ; ++ i) {
|
|
// recupero il gruppo della testa
|
|
int nHdGrp = GetGroup( vsHSet[i]) ;
|
|
if ( nHdGrp == GDB_ID_NULL || ! IsHeadGroup( nHdGrp))
|
|
return false ;
|
|
// ciclo sulle sue uscite
|
|
for ( int j = 1 ; true ; ++ j) {
|
|
// recupero il gruppo dell'uscita
|
|
string sExit = "T" + ToString( j) ;
|
|
int nExGrp = m_pMchMgr->m_pGeomDB->GetFirstNameInGroup( nHdGrp, sExit) ;
|
|
if ( nExGrp == GDB_ID_NULL || m_pMchMgr->m_pGeomDB->GetGdbType( nExGrp) != GDB_TY_GROUP)
|
|
break ;
|
|
// pulisco il gruppo dell'uscita
|
|
m_pMchMgr->m_pGeomDB->EmptyGroup( nExGrp) ;
|
|
m_pMchMgr->m_pGeomDB->RemoveInfo( nExGrp, "Tool") ;
|
|
}
|
|
// visualizzo solo la prima testa
|
|
m_pMchMgr->m_pGeomDB->SetStatus( nHdGrp, ( i == 0 ? GDB_ST_ON : GDB_ST_OFF)) ;
|
|
}
|
|
return true ;
|
|
} |