From 906ecb1fe26aff6815e02d64270dfed39387b344 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 8 Feb 2016 10:51:34 +0000 Subject: [PATCH] EgtExecutor 1.6n1 : - aggiunta ExeVerifyCutAsSplitting - aggiunta LuaVerifyMachining. --- EXE_Nst.h | 23 +++++ EXE_NstMachining.cpp | 186 ++++++++++++++++++++++++++++++++++++ EXE_NstPartNesting.cpp | 86 ++--------------- EgtExecutor.rc | Bin 11710 -> 11694 bytes EgtExecutor.vcxproj | 2 + EgtExecutor.vcxproj.filters | 6 ++ LUA_Nesting.cpp | 24 ++++- 7 files changed, 245 insertions(+), 82 deletions(-) create mode 100644 EXE_Nst.h create mode 100644 EXE_NstMachining.cpp diff --git a/EXE_Nst.h b/EXE_Nst.h new file mode 100644 index 0000000..f367f56 --- /dev/null +++ b/EXE_Nst.h @@ -0,0 +1,23 @@ +//---------------------------------------------------------------------------- +// EgalTech 2016-2016 +//---------------------------------------------------------------------------- +// File : EXE_Nst.h Data : 08.02.16 Versione : 1.6n1 +// Contenuto : Dichiarazioni locali per moduli Nesting di EXE. +// +// +// +// Modifiche : 08.02.16 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +#pragma once + +class IGeomDB ; + +//---------------------------------------------------------------------------- +int GetFlatPartRegion( IGeomDB* pGeomDB, int nId) ; +bool GetFlatPartCutRegions( IGeomDB* pGeomDB, int nId, bool bReduced, INTVECTOR& vCrId) ; +int GetFlatPartFromRegion( IGeomDB* pGeomDB, int nId) ; +int GetFlatPartFromCut( IGeomDB* pGeomDB, int nId) ; +int GetGeometryFromCut( IGeomDB* pGeomDB, IMachMgr* pMachMgr, int nId) ; diff --git a/EXE_NstMachining.cpp b/EXE_NstMachining.cpp new file mode 100644 index 0000000..066988d --- /dev/null +++ b/EXE_NstMachining.cpp @@ -0,0 +1,186 @@ +//---------------------------------------------------------------------------- +// 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 ; +} diff --git a/EXE_NstPartNesting.cpp b/EXE_NstPartNesting.cpp index 69083ea..c06c1a6 100644 --- a/EXE_NstPartNesting.cpp +++ b/EXE_NstPartNesting.cpp @@ -16,6 +16,7 @@ #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/EGkCurveLine.h" @@ -25,7 +26,6 @@ #include "/EgtDev/Include/EGkStringUtils3d.h" #include "/EgtDev/Include/EMkMachiningGeoConst.h" #include "/EgtDev/Include/EgtPointerOwner.h" -#include using namespace std ; @@ -44,7 +44,7 @@ struct SCollInfoEx : public SCollInfo } ; //---------------------------------------------------------------------------- -static int +int GetFlatPartRegion( IGeomDB* pGeomDB, int nId) { // recupero regione del pezzo (è la prima del sottogruppo di nome Region) @@ -59,7 +59,7 @@ GetFlatPartRegion( IGeomDB* pGeomDB, int nId) } //---------------------------------------------------------------------------- -static bool +bool GetFlatPartCutRegions( IGeomDB* pGeomDB, int nId, bool bReduced, INTVECTOR& vCrId) { // recupero gruppo preview lavorazioni del pezzo @@ -84,7 +84,7 @@ GetFlatPartCutRegions( IGeomDB* pGeomDB, int nId, bool bReduced, INTVECTOR& vCrI } //---------------------------------------------------------------------------- -static int +int GetFlatPartFromRegion( IGeomDB* pGeomDB, int nId) { // verifico che il layer di appartenenza sia una regione @@ -97,7 +97,7 @@ GetFlatPartFromRegion( IGeomDB* pGeomDB, int nId) } //---------------------------------------------------------------------------- -static int +int GetFlatPartFromCut( IGeomDB* pGeomDB, int nId) { // verifico appartenga al gruppo PreView (padre di padre di padre) @@ -110,7 +110,7 @@ GetFlatPartFromCut( IGeomDB* pGeomDB, int nId) } //---------------------------------------------------------------------------- -static int +int GetGeometryFromCut( IGeomDB* pGeomDB, IMachMgr* pMachMgr, int nId) { // verifico appartenga ad una lavorazione @@ -1236,77 +1236,3 @@ ExeGetPartClusterCenterGlob( const INTVECTOR& vIds, Point3d& ptCen) return true ; } - -//---------------------------------------------------------------------------- -bool -ExeVerifyMachining( int nMchId, bool bReduced, int nRawId) -{ - 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 vMchReg ; - // 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) { - int nCrId = pGeomDB->GetFirstNameInGroup( nClId, ( bReduced ? MCH_PV_RRCUT : MCH_PV_RCUT)) ; - while ( nCrId != GDB_ID_NULL) { - BBox3d b3Reg ; - if ( ! pGeomDB->GetGlobalBBox( nCrId, b3Reg, BBF_MY_FLAG)) - return false ; - b3Mch.Add( b3Reg) ; - vMchReg.emplace_back( nCrId) ; - nCrId = pGeomDB->GetNextName( nCrId, ( bReduced ? MCH_PV_RRCUT : MCH_PV_RCUT)) ; - } - 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 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) ; - } - - // Eseguo verifiche - bool bOk = true ; - // confronto la regione della lavorazione con le regioni degli altri pezzi - for ( int nMchRegId : vMchReg) { - for ( int nOthRegId : vOthReg) { - if ( ExeSurfFrChunkSimpleClassify( nMchRegId, 0, nOthRegId, 0) != REGC_OUT) - bOk = false ; - } - } - - return bOk ; -} diff --git a/EgtExecutor.rc b/EgtExecutor.rc index af60755c30adbf79c9cdaa5c4e76d5bd21420246..6f104772e9e36f1d45eb3cd8d2e327cdfb514e84 100644 GIT binary patch delta 97 zcmdlNy)Jsg4>o2K2A$0x`A#xTKE_$Yn73I`s+Mu{A#N>ZsDvXkP*6~*lyUPaVYnbz ZwZP;}k~v@<%UPg`uQEZ!1eMlu0|0o5Ain?r delta 105 zcmZ1%y)Syh4>ndK1|0^&&F95#GEKh1nZuj|{0nULP`~Uy| diff --git a/EgtExecutor.vcxproj b/EgtExecutor.vcxproj index 4f89adc..0e34a77 100644 --- a/EgtExecutor.vcxproj +++ b/EgtExecutor.vcxproj @@ -220,6 +220,7 @@ copy $(TargetPath) \EgtProg\Dll64 + @@ -229,6 +230,7 @@ copy $(TargetPath) \EgtProg\Dll64 + diff --git a/EgtExecutor.vcxproj.filters b/EgtExecutor.vcxproj.filters index 0476471..5540f8a 100644 --- a/EgtExecutor.vcxproj.filters +++ b/EgtExecutor.vcxproj.filters @@ -96,6 +96,9 @@ File di intestazione\Include + + File di intestazione + @@ -272,6 +275,9 @@ File di origine\EXE + + File di origine\EXE + diff --git a/LUA_Nesting.cpp b/LUA_Nesting.cpp index f95015b..2adc660 100644 --- a/LUA_Nesting.cpp +++ b/LUA_Nesting.cpp @@ -38,7 +38,7 @@ LuaPackBox( lua_State* L) bool bBottomUp ; LuaCheckParam( L, 7, bBottomUp) LuaClearStack( L) ; - // recupero il numero di macchinate + // eseguo il nesting del pezzo int nTot = ExePackBox( nId, dXmin, dYmin, dXmax, dYmax, dOffs, bBottomUp) ; // restituisco il risultato LuaSetParam( L, nTot) ; @@ -65,13 +65,32 @@ LuaPackBoxCluster( lua_State* L) bool bBottomUp ; LuaCheckParam( L, 7, bBottomUp) LuaClearStack( L) ; - // recupero il numero di macchinate + // eseguo il nesting dell'insieme di pezzi int nTot = ExePackBoxCluster( vIds, dXmin, dYmin, dXmax, dYmax, dOffs, bBottomUp) ; // restituisco il risultato LuaSetParam( L, nTot) ; return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaVerifyMachining( lua_State* L) +{ + // 1 parametro : OperId + int nOperId ; + LuaCheckParam( L, 1, nOperId) + LuaClearStack( L) ; + // eseguo la verifica di interferenza della lavorazione + int nFlag ; + bool bOk = ExeVerifyMachining( nOperId, nFlag) ; + // restituisco il risultato + if ( bOk) + LuaSetParam( L, nFlag) ; + else + LuaSetParam( L) ; + return 1 ; +} + //------------------------------------------------------------------------------- bool LuaInstallNesting( LuaMgr& luaMgr) @@ -79,6 +98,7 @@ LuaInstallNesting( LuaMgr& luaMgr) bool bOk = ( &luaMgr != nullptr) ; bOk = bOk && luaMgr.RegisterFunction( "EgtPackBox", LuaPackBox) ; bOk = bOk && luaMgr.RegisterFunction( "EgtPackBoxCluster", LuaPackBoxCluster) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtVerifyMachining", LuaVerifyMachining) ; return bOk ; }