EgtMachKernel :
- aggiunte funzioni per gestione preview utensile in lavorazione.
This commit is contained in:
+130
-24
@@ -118,32 +118,11 @@ Machining::GetEndPoint( Point3d& ptEnd) const
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Machining::ShowTool( int nPath, double dFraz) const
|
||||
Machining::PrepareToolPreview( void) const
|
||||
{
|
||||
// verifico validità gestore DB geometrico
|
||||
// verifico validità gestori DB geometrico e CAM
|
||||
if ( m_pGeomDB == nullptr || m_pMchMgr == nullptr)
|
||||
return false ;
|
||||
Machine* pMch = m_pMchMgr->GetCurrMachine() ;
|
||||
if ( pMch == nullptr)
|
||||
return false ;
|
||||
// recupero gruppo per geometria di lavorazione (Cutter Location)
|
||||
int nClId = m_pGeomDB->GetFirstNameInGroup( GetOwner(), MCH_CL) ;
|
||||
if ( nClId == GDB_ID_NULL)
|
||||
return false ;
|
||||
// recupero la prima entità del primo sottogruppo
|
||||
int nEntId = m_pGeomDB->GetFirstInGroup( m_pGeomDB->GetFirstGroupInGroup( nClId)) ;
|
||||
if ( nEntId == GDB_ID_NULL)
|
||||
return false ;
|
||||
string sName ; m_pGeomDB->GetName( nEntId, sName) ;
|
||||
if ( sName == MCH_CL_CLIMB)
|
||||
nEntId = m_pGeomDB->GetNext( nEntId) ;
|
||||
// recupero i dati di questa entità
|
||||
const CamData* pCamData = GetCamData( m_pGeomDB->GetUserObj( nEntId)) ;
|
||||
if ( pCamData == nullptr)
|
||||
return false ;
|
||||
Point3d ptEnd = pCamData->GetEndPoint() ;
|
||||
Vector3d vtTool = pCamData->GetToolDir() ;
|
||||
Vector3d vtBAux = pCamData->GetBackAuxDir() ;
|
||||
// creo o svuoto gruppo per anteprima utensile
|
||||
int nStId = m_pGeomDB->GetFirstNameInGroup( GetOwner(), MCH_ST) ;
|
||||
// se non c'è, lo aggiungo
|
||||
@@ -157,9 +136,136 @@ Machining::ShowTool( int nPath, double dFraz) const
|
||||
// altrimenti lo svuoto
|
||||
else
|
||||
m_pGeomDB->EmptyGroup( nStId) ;
|
||||
// se necessario, imposto l'utensile corrente
|
||||
string sCurrTool ; m_pMchMgr->GetCalcTool( sCurrTool) ;
|
||||
if ( ! EqualNoCase( sCurrTool, GetToolName())) {
|
||||
if ( ! m_pMchMgr->SetCalcTool( GetToolName(), GetHeadName(), GetExitNbr()))
|
||||
return false ;
|
||||
}
|
||||
// copio la testa della lavorazione nel gruppo
|
||||
int nHeadId = m_pMchMgr->GetHeadId( GetHeadName()) ;
|
||||
int nId = m_pGeomDB->CopyGlob( nHeadId, GDB_ID_NULL, nStId) ;
|
||||
m_pGeomDB->SetStatus( nId, GDB_ST_OFF) ;
|
||||
return ( nId != GDB_ID_NULL) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Machining::RemoveToolPreview( void) const
|
||||
{
|
||||
// verifico validità gestore DB geometrico
|
||||
if ( m_pGeomDB == nullptr)
|
||||
return false ;
|
||||
// recupero gruppo per anteprima utensile
|
||||
int nStId = m_pGeomDB->GetFirstNameInGroup( GetOwner(), MCH_ST) ;
|
||||
// lo svuoto
|
||||
m_pGeomDB->EmptyGroup( nStId) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
GetToolPreviewNext( IGeomDB* pGeomDB, int nEntId, int nParentId)
|
||||
{
|
||||
// recupero la successiva
|
||||
int nNewId = (( nEntId != GDB_ID_NULL) ? pGeomDB->GetNext( nEntId) : pGeomDB->GetFirstInGroup( nParentId)) ;
|
||||
int nNewParentId = nParentId ;
|
||||
// ciclo nei gruppi successivi
|
||||
do {
|
||||
// ciclo nel gruppo
|
||||
while ( nNewId != GDB_ID_NULL) {
|
||||
string sName ; pGeomDB->GetName( nNewId, sName) ;
|
||||
if ( sName != MCH_CL_CLIMB && sName != MCH_CL_RISE)
|
||||
break ;
|
||||
nNewId = pGeomDB->GetNext( nNewId) ;
|
||||
}
|
||||
// se trovata, esco
|
||||
if ( nNewId != GDB_ID_NULL)
|
||||
return nNewId ;
|
||||
// recupero la prima entità del successivo gruppo
|
||||
nNewParentId = pGeomDB->GetNextGroup( nNewParentId) ;
|
||||
nNewId = pGeomDB->GetFirstInGroup( nNewParentId) ;
|
||||
} while ( nNewId != GDB_ID_NULL) ;
|
||||
return GDB_ID_NULL ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
GetToolPreviewPrev( IGeomDB* pGeomDB, int nEntId, int nParentId)
|
||||
{
|
||||
// recupero la precedente
|
||||
int nNewId = (( nEntId != GDB_ID_NULL) ? pGeomDB->GetPrev( nEntId) : pGeomDB->GetLastInGroup( nParentId)) ;
|
||||
int nNewParentId = nParentId ;
|
||||
// ciclo nei gruppi precedenti
|
||||
do {
|
||||
// ciclo nel gruppo
|
||||
while ( nNewId != GDB_ID_NULL) {
|
||||
string sName ; pGeomDB->GetName( nNewId, sName) ;
|
||||
if ( sName != MCH_CL_CLIMB && sName != MCH_CL_RISE)
|
||||
break ;
|
||||
nNewId = pGeomDB->GetPrev( nNewId) ;
|
||||
}
|
||||
// se trovata, esco
|
||||
if ( nNewId != GDB_ID_NULL)
|
||||
return nNewId ;
|
||||
// recupero l'ultima entità del precedente gruppo
|
||||
nNewParentId = pGeomDB->GetPrevGroup( nNewParentId) ;
|
||||
nNewId = pGeomDB->GetLastInGroup( nNewParentId) ;
|
||||
} while ( nNewId != GDB_ID_NULL) ;
|
||||
return GDB_ID_NULL ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
Machining::ToolPreview( int nEntId, int nFlag) const
|
||||
{
|
||||
// verifico validità gestori DB geometrico e CAM
|
||||
if ( m_pGeomDB == nullptr || m_pMchMgr == nullptr)
|
||||
return GDB_ID_NULL ;
|
||||
// recupero gruppo per geometria di lavorazione (Cutter Location)
|
||||
int nClId = m_pGeomDB->GetFirstNameInGroup( GetOwner(), MCH_CL) ;
|
||||
if ( nClId == GDB_ID_NULL)
|
||||
return GDB_ID_NULL ;
|
||||
// se entità nulla
|
||||
if ( nEntId == GDB_ID_NULL || ! m_pGeomDB->ExistsObj( nEntId)) {
|
||||
// recupero il gruppo di appartenenza
|
||||
int nParentId = m_pGeomDB->GetFirstGroupInGroup( nClId) ;
|
||||
// se richiesta successiva
|
||||
if ( nFlag == MCH_TPM_AFTER)
|
||||
nEntId = GetToolPreviewNext( m_pGeomDB, nEntId, nParentId) ;
|
||||
// se richiesta precedente
|
||||
else if ( nFlag == MCH_TPM_BEFORE)
|
||||
nEntId = GetToolPreviewPrev( m_pGeomDB, nEntId, nParentId) ;
|
||||
// altrimenti richiesta corrente
|
||||
else
|
||||
nEntId = GDB_ID_NULL ;
|
||||
}
|
||||
// altrimenti
|
||||
else {
|
||||
// verifico che l'entità stia in un sottogruppo di CL
|
||||
int nParentId = m_pGeomDB->GetParentId( nEntId) ;
|
||||
if ( m_pGeomDB->GetParentId( nParentId) == nClId) {
|
||||
// se richiesta successiva
|
||||
if ( nFlag == MCH_TPM_AFTER)
|
||||
nEntId = GetToolPreviewNext( m_pGeomDB, nEntId, nParentId) ;
|
||||
// se richiesta precedente
|
||||
else if ( nFlag == MCH_TPM_BEFORE)
|
||||
nEntId = GetToolPreviewPrev( m_pGeomDB, nEntId, nParentId) ;
|
||||
}
|
||||
else
|
||||
nEntId = GDB_ID_NULL ;
|
||||
}
|
||||
// recupero i dati di questa entità
|
||||
const CamData* pCamData = GetCamData( m_pGeomDB->GetUserObj( nEntId)) ;
|
||||
if ( pCamData == nullptr)
|
||||
return GDB_ID_NULL ;
|
||||
Point3d ptEnd = pCamData->GetEndPoint() ;
|
||||
Vector3d vtTool = pCamData->GetToolDir() ;
|
||||
Vector3d vtBAux = pCamData->GetBackAuxDir() ;
|
||||
// recupero la testa nel gruppo per anteprima utensile
|
||||
int nId = m_pGeomDB->GetFirstGroupInGroup( m_pGeomDB->GetFirstNameInGroup( GetOwner(), MCH_ST)) ;
|
||||
if ( nId == GDB_ID_NULL)
|
||||
return GDB_ID_NULL ;
|
||||
m_pGeomDB->SetStatus( nId, GDB_ST_ON) ;
|
||||
// dati correnti testa/uscita
|
||||
int nExitId = m_pGeomDB->GetFirstNameInGroup( nId, MCH_EXIT + ToString( GetExitNbr())) ;
|
||||
@@ -187,7 +293,7 @@ Machining::ShowTool( int nPath, double dFraz) const
|
||||
frHead.ToGlob( frShow) ;
|
||||
*(m_pGeomDB->GetGroupFrame( nId)) = frHead ;
|
||||
|
||||
return true ;
|
||||
return nEntId ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user