906ecb1fe2
- aggiunta ExeVerifyCutAsSplitting - aggiunta LuaVerifyMachining.
187 lines
7.0 KiB
C++
187 lines
7.0 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2015-2016
|
|
//----------------------------------------------------------------------------
|
|
// File : EXE_NstMachining.cpp Data : 08.02.16 Versione : 1.6n1
|
|
// Contenuto : Funzioni Nesting di lavorazione per EXE.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 08.02.16 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
//--------------------------- Include ----------------------------------------
|
|
#include "stdafx.h"
|
|
#include "EXE.h"
|
|
#include "EXE_Const.h"
|
|
#include "EXE_Macro.h"
|
|
#include "EXE_Nst.h"
|
|
#include "/EgtDev/Include/EXeExecutor.h"
|
|
#include "/EgtDev/Include/EXeConst.h"
|
|
#include "/EgtDev/Include/EGkSimpleCDSurfFrMove.h"
|
|
#include "/EgtDev/Include/EMkOperationConst.h"
|
|
#include "/EgtDev/Include/EMkMachiningConst.h"
|
|
#include "/EgtDev/Include/EMkMachiningGeoConst.h"
|
|
|
|
using namespace std ;
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
ExeVerifyMachining( int nMchId, int& nResult)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, false)
|
|
|
|
// Flag per calcolo box
|
|
const int BBF_MY_FLAG = BBF_ONLY_VISIBLE | BBF_IGNORE_TEXT | BBF_IGNORE_DIM ;
|
|
|
|
// Recupero il box e le regioni della lavorazione
|
|
BBox3d b3Mch ;
|
|
INTVECTOR vMchRReg, vMchLiReg, vMchLoReg ;
|
|
// recupero gruppo preview lavorazioni nella lavorazione
|
|
int nPVGrp = pGeomDB->GetFirstNameInGroup( nMchId, MCH_PV) ;
|
|
if ( nPVGrp == GDB_ID_NULL)
|
|
return false ;
|
|
// se vuoto, cerco il rimando al preview nel pezzo
|
|
if ( pGeomDB->GetGroupObjs( nPVGrp) == 0 &&
|
|
! pGeomDB->GetInfo( nPVGrp, "PvId", nPVGrp))
|
|
return false ;
|
|
// ciclo sui percorsi utensile (CL)
|
|
int nClId = pGeomDB->GetFirstGroupInGroup( nPVGrp) ;
|
|
while ( nClId != GDB_ID_NULL) {
|
|
// tagli ridotti
|
|
int nCrId = pGeomDB->GetFirstNameInGroup( nClId, MCH_PV_RRCUT) ;
|
|
while ( nCrId != GDB_ID_NULL) {
|
|
BBox3d b3Reg ;
|
|
if ( ! pGeomDB->GetGlobalBBox( nCrId, b3Reg, BBF_MY_FLAG))
|
|
return false ;
|
|
b3Mch.Add( b3Reg) ;
|
|
vMchRReg.emplace_back( nCrId) ;
|
|
nCrId = pGeomDB->GetNextName( nCrId, MCH_PV_RRCUT) ;
|
|
}
|
|
// ingressi
|
|
int nLiId = pGeomDB->GetFirstNameInGroup( nClId, MCH_PV_RLICUT) ;
|
|
while ( nLiId != GDB_ID_NULL) {
|
|
BBox3d b3Reg ;
|
|
if ( ! pGeomDB->GetGlobalBBox( nLiId, b3Reg, BBF_MY_FLAG))
|
|
return false ;
|
|
b3Mch.Add( b3Reg) ;
|
|
vMchLiReg.emplace_back( nLiId) ;
|
|
nLiId = pGeomDB->GetNextName( nLiId, MCH_PV_RLICUT) ;
|
|
}
|
|
// uscite
|
|
int nLoId = pGeomDB->GetFirstNameInGroup( nClId, MCH_PV_RLOCUT) ;
|
|
while ( nLoId != GDB_ID_NULL) {
|
|
BBox3d b3Reg ;
|
|
if ( ! pGeomDB->GetGlobalBBox( nLoId, b3Reg, BBF_MY_FLAG))
|
|
return false ;
|
|
b3Mch.Add( b3Reg) ;
|
|
vMchLoReg.emplace_back( nLoId) ;
|
|
nLoId = pGeomDB->GetNextName( nLoId, MCH_PV_RLOCUT) ;
|
|
}
|
|
// passo al successivo percorso utensile
|
|
nClId = pGeomDB->GetNextGroup( nClId) ;
|
|
}
|
|
|
|
// Recupero il pezzo cui è associata la lavorazione
|
|
int nMchPartId = GDB_ID_NULL ;
|
|
SELVECTOR vIds ;
|
|
if ( ExeSetCurrMachining( nMchId) && ExeGetMachiningGeometry( vIds) && ! vIds.empty())
|
|
nMchPartId = pGeomDB->GetParentId( pGeomDB->GetParentId( vIds[0].nId)) ;
|
|
|
|
// Determino le regioni di tutti gli altri pezzi compresi nella regione della lavorazione
|
|
INTVECTOR vOthReg ;
|
|
int nRawId = ExeGetFirstRawPart() ;
|
|
while ( nRawId != GDB_ID_NULL) {
|
|
int nId = ExeGetFirstGroupInGroup( nRawId) ;
|
|
while ( nId != GDB_ID_NULL) {
|
|
if ( nId != nMchPartId) {
|
|
BBox3d b3Part ;
|
|
if ( pGeomDB->GetGlobalBBox( nId, b3Part, BBF_MY_FLAG) &&
|
|
b3Mch.OverlapsXY( b3Part)) {
|
|
// recupero regione del pezzo
|
|
int nRegId = GetFlatPartRegion( pGeomDB, nId) ;
|
|
if ( nRegId != GDB_ID_NULL)
|
|
vOthReg.emplace_back( nRegId) ;
|
|
else
|
|
return false ;
|
|
}
|
|
}
|
|
nId = ExeGetNextGroup( nId) ;
|
|
}
|
|
nRawId = ExeGetNextRawPart( nRawId) ;
|
|
}
|
|
|
|
// Eseguo verifiche
|
|
nResult = FMI_NONE ;
|
|
// confronto la regione di attacco della lavorazione con le regioni degli altri pezzi
|
|
for ( int nMchRegId : vMchLiReg) {
|
|
for ( int nOthRegId : vOthReg) {
|
|
if ( ExeSurfFrChunkSimpleClassify( nMchRegId, 0, nOthRegId, 0) != REGC_OUT)
|
|
nResult |= FMI_LI ;
|
|
}
|
|
}
|
|
// confronto la regione ridotta della lavorazione con le regioni degli altri pezzi
|
|
for ( int nMchRegId : vMchRReg) {
|
|
for ( int nOthRegId : vOthReg) {
|
|
if ( ExeSurfFrChunkSimpleClassify( nMchRegId, 0, nOthRegId, 0) != REGC_OUT)
|
|
nResult |= FMI_RM ;
|
|
}
|
|
}
|
|
// confronto la regione di uscitao della lavorazione con le regioni degli altri pezzi
|
|
for ( int nMchRegId : vMchLoReg) {
|
|
for ( int nOthRegId : vOthReg) {
|
|
if ( ExeSurfFrChunkSimpleClassify( nMchRegId, 0, nOthRegId, 0) != REGC_OUT)
|
|
nResult |= FMI_LO ;
|
|
}
|
|
}
|
|
|
|
return true ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
ExeVerifyCutAsSplitting( int nMchId)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_MACHMGR( pGseCtx, false)
|
|
|
|
// verifico che la lavorazione indicata sia veramente un taglio con lama
|
|
if ( pGseCtx->m_pMachMgr->GetOperationType( nMchId) != OPER_SAWING)
|
|
return false ;
|
|
|
|
// recupero la lavorazione corrente
|
|
int nCurrMch = pGseCtx->m_pMachMgr->GetCurrMachining() ;
|
|
// imposto la nuova lavorazione corrente
|
|
pGseCtx->m_pMachMgr->SetCurrMachining( nMchId) ;
|
|
// recupero attacco e uscita correnti della lavorazione
|
|
int nLiType ;
|
|
pGseCtx->m_pMachMgr->GetMachiningParam( MPA_LEADINTYPE, nLiType) ;
|
|
int nLoType ;
|
|
pGseCtx->m_pMachMgr->GetMachiningParam( MPA_LEADOUTTYPE, nLoType) ;
|
|
// se diversi da attacco/uscita al bordo grezzo, li cambio
|
|
bool bToModif = ( ( nLiType != SAW_LI_EXT_CENT && nLiType != SAW_LI_EXT_OUT) || nLoType != SAW_LO_EXT) ;
|
|
if ( bToModif) {
|
|
pGseCtx->m_pMachMgr->SetMachiningParam( MPA_LEADINTYPE, SAW_LI_EXT_CENT) ;
|
|
pGseCtx->m_pMachMgr->SetMachiningParam( MPA_LEADOUTTYPE, SAW_LO_EXT) ;
|
|
}
|
|
// aggiorno preview
|
|
pGseCtx->m_pMachMgr->MachiningPreview( true) ;
|
|
// verifico interferenza
|
|
bool bOk ;
|
|
int nResult ;
|
|
bOk = ( ExeVerifyMachining( nMchId, nResult) && nResult == FMI_NONE) ;
|
|
// se attacco/uscita modificati, li ripristino e riaggiorno preview
|
|
if ( bToModif) {
|
|
pGseCtx->m_pMachMgr->SetMachiningParam( MPA_LEADINTYPE, nLiType) ;
|
|
pGseCtx->m_pMachMgr->SetMachiningParam( MPA_LEADOUTTYPE, nLoType) ;
|
|
pGseCtx->m_pMachMgr->MachiningPreview( true) ;
|
|
}
|
|
// ripristino lavorazione corrente
|
|
pGseCtx->m_pMachMgr->SetCurrMachining( nCurrMch) ;
|
|
|
|
// restituisco il risultato
|
|
return bOk ;
|
|
}
|