From d1dc8f87e34c04590ec4f8ee7e04ba3e90539117 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Thu, 5 Dec 2019 09:34:54 +0000 Subject: [PATCH] EgtExecutor : - aggiunta funzione Exe/Lua AddAnotherOutlineToPart - in ExeAutomaticPac aggiunta gestione di pezzi con tagli inclinati. --- EXE_NstAutoNesting.cpp | 16 ++++++++++++++++ EXE_NstPartNesting.cpp | 33 +++++++++++++++++++++++---------- LUA_Nesting.cpp | 17 +++++++++++++++++ 3 files changed, 56 insertions(+), 10 deletions(-) diff --git a/EXE_NstAutoNesting.cpp b/EXE_NstAutoNesting.cpp index 86d1911..e8e8305 100644 --- a/EXE_NstAutoNesting.cpp +++ b/EXE_NstAutoNesting.cpp @@ -137,6 +137,22 @@ ExeAutoNestAddPart( int nPartId, int nOutlineId, bool bCanFlip, bool bCanRotate, return true ; } +//----------------------------------------------------------------------------- +bool +ExeAddAnotherOutlineToPart( int nPartId, int nAnotherOutlineId) +{ + if ( IsNull( s_pAutoNester)) + return false ; + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // recupero un contorno aggiuntivo del pezzo + PolyArc AnotherOutline ; + if ( ! MyGetOutline( pGeomDB, nAnotherOutlineId, AnotherOutline)) + return false ; + // aggiungo un contorno aggiuntivo al pezzo + return s_pAutoNester->AddAnotherOutlineToPart( nPartId, AnotherOutline) ; +} + //----------------------------------------------------------------------------- bool ExeAutoNestAddToolOutlineToPart( int nPartId, int nToolOutlineId) diff --git a/EXE_NstPartNesting.cpp b/EXE_NstPartNesting.cpp index 2d90873..a8fc5ec 100644 --- a/EXE_NstPartNesting.cpp +++ b/EXE_NstPartNesting.cpp @@ -2109,12 +2109,18 @@ ExeAutomaticPackParts( INTVECTOR& vIds, bool bMinimizeOnXvsY, bool bReducedCut, // recupero regione del pezzo int nRegId = GetFlatPartRegion( pGeomDB, nId) ; ExeAutoNestAddDefectToSheet( nSheetId, nRegId) ; + // recupero eventuale regione in basso del pezzo + int nDwnRegId = GetFlatPartDownRegion( pGeomDB, nId) ; + if ( nDwnRegId != GDB_ID_NULL) + ExeAutoNestAddDefectToSheet( nSheetId, nDwnRegId) ; // recupero regioni dei tagli del pezzo INTVECTOR vCutReg ; - if ( GetFlatPartCutRegions( pGeomDB, nId, bReducedCut, vCutReg)) { - for ( int nRegId : vCutReg) - ExeAutoNestAddDefectToSheet( nSheetId, nRegId) ; - } + if ( ! GetFlatPartCutRegions( pGeomDB, nId, bReducedCut, vCutReg)) + return false ; + // recupero eventuali regioni in basso dei tagli del pezzo + GetFlatPartDownCutRegions( pGeomDB, nId, bReducedCut, vCutReg) ; + for ( int nRegId : vCutReg) + ExeAutoNestAddDefectToSheet( nSheetId, nRegId) ; } } nId = ( bInRoot ? ExeGetNextPart( nId, true) : ExeGetNextGroup( nId)) ; @@ -2123,16 +2129,23 @@ ExeAutomaticPackParts( INTVECTOR& vIds, bool bMinimizeOnXvsY, bool bReducedCut, // Assegno i pezzi da nestare for ( int nPartId : vIds) { nPartId = abs( nPartId) ; - // recupero regione del pezzo e flag rotazione abilitata - int nRegId = GetFlatPartRegion( pGeomDB, nPartId) ; + // flag rotazione bool bEnableRot = ! pGeomDB->ExistsInfo( nPartId, NST_PART_ROT) ; + // recupero regione del pezzo + int nRegId = GetFlatPartRegion( pGeomDB, nPartId) ; ExeAutoNestAddPart( nPartId, nRegId, false, bEnableRot, 0.0, 0, 1) ; + // recupero eventuale regione in basso del pezzo + int nDwnRegId = GetFlatPartDownRegion( pGeomDB, nPartId) ; + if ( nDwnRegId != GDB_ID_NULL) + ExeAddAnotherOutlineToPart( nPartId, nDwnRegId) ; // recupero regioni dei tagli del pezzo INTVECTOR vCutReg ; - if ( GetFlatPartCutRegions( pGeomDB, nPartId, bReducedCut, vCutReg)) { - for ( int nRegId : vCutReg) - ExeAutoNestAddToolOutlineToPart( nPartId, nRegId) ; - } + if ( ! GetFlatPartCutRegions( pGeomDB, nPartId, bReducedCut, vCutReg)) + return false ; + // recupero eventuali regioni in basso dei tagli del pezzo + GetFlatPartDownCutRegions( pGeomDB, nPartId, bReducedCut, vCutReg) ; + for ( int nRegId : vCutReg) + ExeAutoNestAddToolOutlineToPart( nPartId, nRegId) ; } // Eseguo il nesting diff --git a/LUA_Nesting.cpp b/LUA_Nesting.cpp index 0616da7..a51e42e 100644 --- a/LUA_Nesting.cpp +++ b/LUA_Nesting.cpp @@ -171,6 +171,22 @@ LuaAutoNestAddPart( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaAutoNestAddAnotherOutlineToPart( lua_State* L) +{ + // 2 parametri : nPartId, nAnotherOutlineId + int nPartId ; + LuaCheckParam( L, 1, nPartId) + int nAnotherOutlineId ; + LuaCheckParam( L, 2, nAnotherOutlineId) + // aggiungo un contorno aggiuntivo al pezzo indicato + bool bOk = ExeAddAnotherOutlineToPart( nPartId, nAnotherOutlineId) ; + // restituisco il risultato + LuaSetParam( L, bOk) ; + return 1 ; +} + //------------------------------------------------------------------------------- static int LuaAutoNestAddToolOutlineToPart( lua_State* L) @@ -325,6 +341,7 @@ LuaInstallNesting( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtAutoNestAddDefectToSheet", LuaAutoNestAddDefectToSheet) ; bOk = bOk && luaMgr.RegisterFunction( "EgtAutoNestAddSheet", LuaAutoNestAddSheet) ; bOk = bOk && luaMgr.RegisterFunction( "EgtAutoNestAddPart", LuaAutoNestAddPart) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtAutoNestAddAnotherOutlineToPart", LuaAutoNestAddAnotherOutlineToPart) ; bOk = bOk && luaMgr.RegisterFunction( "EgtAutoNestAddToolOutlineToPart", LuaAutoNestAddToolOutlineToPart) ; bOk = bOk && luaMgr.RegisterFunction( "EgtAutoNestSetInterpartGap", LuaAutoNestSetInterpartGap) ; bOk = bOk && luaMgr.RegisterFunction( "EgtAutoNestCompute", LuaAutoNestCompute) ;