diff --git a/EXE_NstAutoNesting.cpp b/EXE_NstAutoNesting.cpp index 41ba106..3a9ab4c 100644 --- a/EXE_NstAutoNesting.cpp +++ b/EXE_NstAutoNesting.cpp @@ -18,6 +18,8 @@ #include "EXE_Const.h" #include "DllNesting.h" #include "/EgtDev/Include/EGkCurve.h" +#include "/EgtDev/Include/EGkCurveComposite.h" +#include "/EgtDev/Include/EGkOffsetCurve.h" #include "/EgtDev/Include/EGkSurfFlatRegion.h" #include "/EgtDev/Include/ENsAutoNester.h" #include "/EgtDev/Include/EGnStringUtils.h" @@ -48,7 +50,7 @@ ExeAutoNestStart( void) //----------------------------------------------------------------------------- bool -ExeAutoNestAddSheet( int nSheetId, int nOutlineId, int nPriority, int nCount) +ExeAutoNestAddSheet( int nSheetId, int nOutlineId, double dKerf, int nPriority, int nCount) { if ( IsNull( s_pAutoNester)) return false ; @@ -85,13 +87,32 @@ ExeAutoNestAddSheet( int nSheetId, int nOutlineId, int nPriority, int nCount) Outline.Mirror( ORIG, Z_AX) ; else return false ; - // aggiungo il pezzo + // se richiesto kerf ( sempre nullo o positivo) + if ( dKerf > 10 * EPS_SMALL) { + // curva di contorno + PtrOwner pCompo( CreateCurveComposite()) ; + if ( IsNull( pCompo) || ! pCompo->FromPolyArc( Outline)) + return false ; + // verifico sia CCW + double dArea ; pCompo->GetAreaXY( dArea) ; + if ( dArea < 0) + pCompo->Invert() ; + // eseguo offset + OffsetCurve OffsCrv ; + if ( ! OffsCrv.Make( pCompo, - dKerf, ICurve::OFF_FILLET)) + return false ; + PtrOwner pOffs( OffsCrv.GetLongerCurve()) ; + // riassegno a PolyArc + if ( IsNull( pOffs) || ! pOffs->ApproxWithArcs( LIN_TOL_FINE, ANG_TOL_STD_DEG, Outline)) + return false ; + } + // aggiungo il pannello return s_pAutoNester->AddSheet( nSheetId, Outline, nPriority, nCount) ; } //----------------------------------------------------------------------------- bool -ExeAutoNestAddPart( int nPartId, int nOutlineId, int nCount) +ExeAutoNestAddPart( int nPartId, int nOutlineId, bool bCanFlip, bool bCanRotate, int nPriority, int nCount) { if ( IsNull( s_pAutoNester)) return false ; @@ -129,7 +150,7 @@ ExeAutoNestAddPart( int nPartId, int nOutlineId, int nCount) else return false ; // aggiungo il pezzo - if ( ! s_pAutoNester->AddPart( nPartId, Outline, nCount)) + if ( ! s_pAutoNester->AddPart( nPartId, Outline, bCanFlip, bCanRotate, nPriority, nCount)) return false ; // incremento contatore pezzi s_nTotParts += nCount ; @@ -183,20 +204,20 @@ ExeAutoNestPrintResults( const string& sHtmlFile) //----------------------------------------------------------------------------- bool -ExeAutoNestGetResults( int& nNestedParts, int& nTotParts, int& nTotSheets, int& nDiffSheets, double& dTotFillRatio) +ExeAutoNestGetResults( int& nNestedParts, int& nParts, int& nSheets, int& nNestings, double& dTotFillRatio) { if ( IsNull( s_pAutoNester) || ! s_pAutoNester->GetResults( s_dTotFillRatio, s_vANestInfo)) return false ; nNestedParts = 0 ; - nTotParts = s_nTotParts ; - nTotSheets = 0 ; - nDiffSheets = 0 ; + nParts = s_nTotParts ; + nSheets = 0 ; + nNestings = 0 ; dTotFillRatio = s_dTotFillRatio ; for ( int i = 0 ; i < int( s_vANestInfo.size()) ; ++ i) { // se sheet if ( s_vANestInfo[i].nType > 0) { - ++ nDiffSheets ; - nTotSheets += s_vANestInfo[i].nType ; + ++ nNestings ; + nSheets += s_vANestInfo[i].nType ; nNestedParts += s_vANestInfo[i].nFlag * s_vANestInfo[i].nType ; } } diff --git a/EgtExecutor.rc b/EgtExecutor.rc index d264ac8..2133dba 100644 Binary files a/EgtExecutor.rc and b/EgtExecutor.rc differ diff --git a/LUA_Nesting.cpp b/LUA_Nesting.cpp index 06749d6..5ec0647 100644 --- a/LUA_Nesting.cpp +++ b/LUA_Nesting.cpp @@ -108,18 +108,20 @@ LuaAutoNestStart( lua_State* L) static int LuaAutoNestAddSheet( lua_State* L) { - // 4 parametri : nSheetId, nOutlineId, nPriority, nCount + // 5 parametri : nSheetId, nOutlineId, dKerf, nPriority, nCount int nSheetId ; LuaCheckParam( L, 1, nSheetId) int nOutlineId ; LuaCheckParam( L, 2, nOutlineId) + double dKerf ; + LuaCheckParam( L, 3, dKerf) int nPriority ; - LuaCheckParam( L, 3, nPriority) + LuaCheckParam( L, 4, nPriority) int nCount ; - LuaCheckParam( L, 4, nCount) + LuaCheckParam( L, 5, nCount) LuaClearStack( L) ; // aggiungo un pannello al nesting corrente - bool bOk = ExeAutoNestAddSheet( nSheetId, nOutlineId, nPriority, nCount) ; + bool bOk = ExeAutoNestAddSheet( nSheetId, nOutlineId, dKerf, nPriority, nCount) ; // restituisco il risultato LuaSetParam( L, bOk) ; return 1 ; @@ -129,16 +131,22 @@ LuaAutoNestAddSheet( lua_State* L) static int LuaAutoNestAddPart( lua_State* L) { - // 3 parametri : nPartId, nOutlineId, nCount + // 6 parametri : nPartId, nOutlineId, bCanFlip, bCanRotate, nPriority, nCount int nPartId ; LuaCheckParam( L, 1, nPartId) int nOutlineId ; LuaCheckParam( L, 2, nOutlineId) + bool bCanFlip ; + LuaCheckParam( L, 3, bCanFlip) + bool bCanRotate ; + LuaCheckParam( L, 4, bCanRotate) + int nPriority ; + LuaCheckParam( L, 5, nPriority) int nCount ; - LuaCheckParam( L, 3, nCount) + LuaCheckParam( L, 6, nCount) LuaClearStack( L) ; // aggiungo un pezzo al nesting corrente - bool bOk = ExeAutoNestAddPart( nPartId, nOutlineId, nCount) ; + bool bOk = ExeAutoNestAddPart( nPartId, nOutlineId, bCanFlip, bCanRotate, nPriority, nCount) ; // restituisco il risultato LuaSetParam( L, bOk) ; return 1 ; @@ -193,7 +201,7 @@ LuaAutoNestGetComputationStatus( lua_State* L) { // nessun parametro LuaClearStack( L) ; - // lancio calcolo del nesting + // recupero lo stato di esecuzione del nesting int nStatus ; bool bOk = ExeAutoNestGetComputationStatus( nStatus) ; // restituisco il risultato @@ -224,14 +232,14 @@ LuaAutoNestGetResults( lua_State* L) // nessun parametro LuaClearStack( L) ; // recupero il risultato della soluzione - int nNestedParts, nTotParts, nTotSheets, nDiffSheets ; double dTotFillRatio ; - bool bOk = ExeAutoNestGetResults( nNestedParts, nTotParts, nTotSheets, nDiffSheets, dTotFillRatio) ; + int nNestedParts, nParts, nSheets, nNestings ; double dTotFillRatio ; + bool bOk = ExeAutoNestGetResults( nNestedParts, nParts, nSheets, nNestings, dTotFillRatio) ; // restituisco il risultato if ( bOk) { LuaSetParam( L, nNestedParts) ; - LuaSetParam( L, nTotParts) ; - LuaSetParam( L, nTotSheets) ; - LuaSetParam( L, nDiffSheets) ; + LuaSetParam( L, nParts) ; + LuaSetParam( L, nSheets) ; + LuaSetParam( L, nNestings) ; LuaSetParam( L, dTotFillRatio) ; return 5 ; }