From 0d337c6aaddd7303ebe3188f1b2866018a7d8a6f Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 2 Dec 2019 07:31:22 +0000 Subject: [PATCH] EgtExecutor 2.1k6 : - aggiunta gestione libreria di Nesting Automatico e relativa protezione - aggiunta funzione ExeSetLineAttribs per impostare spessore linee in grafica. --- DllNesting.cpp | 164 ++++++++++++++++++++++++++++ DllNesting.h | 29 +++++ EXE_CAvTool.cpp | 2 +- EXE_General.cpp | 16 ++- EXE_NstAutoNesting.cpp | 210 ++++++++++++++++++++++++++++++++++++ EXE_Scene.cpp | 10 ++ EXE_ShortestPath.cpp | 2 +- EgtExecutor.rc | Bin 16184 -> 16184 bytes EgtExecutor.vcxproj | 3 + EgtExecutor.vcxproj.filters | 9 ++ LUA_Nesting.cpp | 173 +++++++++++++++++++++++++++++ 11 files changed, 615 insertions(+), 3 deletions(-) create mode 100644 DllNesting.cpp create mode 100644 DllNesting.h create mode 100644 EXE_NstAutoNesting.cpp diff --git a/DllNesting.cpp b/DllNesting.cpp new file mode 100644 index 0000000..6ca5f71 --- /dev/null +++ b/DllNesting.cpp @@ -0,0 +1,164 @@ +//---------------------------------------------------------------------------- +// EgalTech 2019-2019 +//---------------------------------------------------------------------------- +// File : DllNesting.cpp Data : 28.11.19 Versione : 2.1k6 +// Contenuto : Funzioni di gestione della libreria opzionale EgtNesting. +// +// +// +// Modifiche : 28.11.19 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +//--------------------------- Include ---------------------------------------- +#include "stdafx.h" +#include "EXE.h" +#include "DllNesting.h" +#include "/EgtDev/Include/ENsDllMain.h" +#define NOMINMAX +#include + +using namespace std ; + +//----------------------------------------------------------------------------- +// Nome della libreria +#if defined( _WIN64) && defined( _DEBUG) + static const wchar_t* ENS_NAME = L"EgtNestingD64.dll" ; +#elif defined( _WIN64) + static const wchar_t* ENS_NAME = L"EgtNestingR64.dll" ; +#elif defined( _WIN32) && defined( _DEBUG) + static const wchar_t* ENS_NAME = L"EgtNestingD32.dll" ; +#else + static const wchar_t* ENS_NAME = L"EgtNestingR32.dll" ; +#endif +// Nome delle funzioni caricate +static const char* ENS_SETENSLOGGER = "SetENsLogger" ; +static const char* ENS_GETENSVERSION = "GetENsVersion" ; +static const char* ENS_SETENSKEY = "SetENsKey" ; +static const char* ENS_SETENSKEY2 = "SetENsKey2" ; +static const char* ENS_CREATEAUTONESTER = "CreateAutoNester" ; + + +//----------------------------------------------------------------------------- +HMODULE s_hENs = nullptr ; + +//----------------------------------------------------------------------------- +bool +LoadNestingDll( ILogger* pLogger, const string& sKey, const string& sKey2) +{ + // verifico la chiave + if ( ! TestKeyForENs( sKey, 0, pLogger)) { + FreeNestingDll() ; + return false ; + } + // se già caricata + if ( s_hENs != nullptr) + return true ; + // carico la libreria EgtNesting + s_hENs = LoadLibrary( ENS_NAME) ; + if ( s_hENs == nullptr) + return false ; + // imposto logger + MySetENsLogger( pLogger) ; + // imposto i codici della chiave + MySetENsKey( sKey) ; + // imposto i codici della seconda chiave + MySetENsKey2( sKey2) ; + return true ; +} + +//----------------------------------------------------------------------------- +bool +FreeNestingDll( void) +{ + // se non è già caricata + if ( s_hENs == nullptr) + return true ; + // libero la libreria EgtNesting + FreeLibrary( s_hENs) ; + s_hENs = nullptr ; + return true ; +} + +//----------------------------------------------------------------------------- +bool +IsLoadedNestingDll( void) +{ + return ( s_hENs != nullptr) ; +} + +//----------------------------------------------------------------------------- +void +MySetENsLogger( ILogger* pLogger) +{ + // verifico caricamento libreria EgtNesting + if ( s_hENs == nullptr) + return ; + // recupero funzione che imposta il logger + typedef void (* PF_SetENsLogger) ( ILogger* pLogger) ; + PF_SetENsLogger pFun = (PF_SetENsLogger)GetProcAddress( s_hENs, ENS_SETENSLOGGER) ; + if ( pFun == nullptr) + return ; + pFun( pLogger) ; +} + +//----------------------------------------------------------------------------- +const char* +MyGetENsVersion( void) +{ + // verifico caricamento libreria EgtNesting + if ( s_hENs == nullptr) + return "" ; + // recupero funzione che restituisce la versione della libreria + typedef const char* (* PF_GetEMkVersion) ( void) ; + PF_GetEMkVersion pFun = (PF_GetEMkVersion)GetProcAddress( s_hENs, ENS_GETENSVERSION) ; + if ( pFun == nullptr) + return "" ; + return pFun() ; +} + +//----------------------------------------------------------------------------- +void +MySetENsKey( const string& sKey) +{ + // verifico caricamento libreria EgtNesting + if ( s_hENs == nullptr) + return ; + // recupero funzione che imposta i codici di protezione + typedef void (* PF_SetENsKey) ( const string& sKey) ; + PF_SetENsKey pFun = (PF_SetENsKey)GetProcAddress( s_hENs, ENS_SETENSKEY) ; + if ( pFun == nullptr) + return ; + pFun( sKey) ; +} + +//----------------------------------------------------------------------------- +void +MySetENsKey2( const string& sKey2) +{ + // verifico caricamento libreria EgtNesting + if ( s_hENs == nullptr) + return ; + // recupero funzione che imposta i codici di protezione + typedef void (* PF_SetENsKey2) ( const string& sKey2) ; + PF_SetENsKey2 pFun = (PF_SetENsKey2)GetProcAddress( s_hENs, ENS_SETENSKEY2) ; + if ( pFun == nullptr) + return ; + pFun( sKey2) ; +} + +//----------------------------------------------------------------------------- +IAutoNester* +MyCreateAutoNester( void) +{ + // verifico caricamento libreria EgtNesting + if ( s_hENs == nullptr) + return nullptr ; + // recupero funzione creazione oggetto + typedef IAutoNester* (* PF_CreateAutoNester) ( void) ; + PF_CreateAutoNester pFun = (PF_CreateAutoNester)GetProcAddress( s_hENs, ENS_CREATEAUTONESTER) ; + if ( pFun == nullptr) + return nullptr ; + return pFun() ; +} diff --git a/DllNesting.h b/DllNesting.h new file mode 100644 index 0000000..89d6db9 --- /dev/null +++ b/DllNesting.h @@ -0,0 +1,29 @@ +//---------------------------------------------------------------------------- +// EgalTech 2015-2015 +//---------------------------------------------------------------------------- +// File : DllNesting.h Data : 28.11.19 Versione : 2.1k6 +// Contenuto : Dichiarazioni funzioni per libreria opzionale EgtNesting. +// +// +// +// Modifiche : 28.11.19 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +#pragma once + +#include + +class ILogger ; +class IAutoNester ; + +//---------------------------------------------------------------------------- +bool LoadNestingDll( ILogger* pLogger, const std::string& sKey, const std::string& sKey2) ; +bool FreeNestingDll( void) ; +bool IsLoadedNestingDll( void) ; +void MySetENsLogger( ILogger* pLogger) ; +void MySetENsKey( const std::string& sKey) ; +void MySetENsKey2( const std::string& sKey2) ; +const char* MyGetENsVersion( void) ; +IAutoNester* MyCreateAutoNester( void) ; diff --git a/EXE_CAvTool.cpp b/EXE_CAvTool.cpp index 68aa6d4..11cc447 100644 --- a/EXE_CAvTool.cpp +++ b/EXE_CAvTool.cpp @@ -29,7 +29,7 @@ using namespace std ; //---------------------------------------------------------------------------- -PtrOwner s_pCAvTlStm( CreateCAvToolSurfTm()) ; +static PtrOwner s_pCAvTlStm( CreateCAvToolSurfTm()) ; //---------------------------------------------------------------------------- bool diff --git a/EXE_General.cpp b/EXE_General.cpp index 7791a1f..e25d0d9 100644 --- a/EXE_General.cpp +++ b/EXE_General.cpp @@ -7,7 +7,7 @@ // // // Modifiche : 01.09.14 DS Creazione modulo. -// +// 28.11.19 DS Aggiunto caricamento opzionale del Nesting. // //---------------------------------------------------------------------------- @@ -18,6 +18,7 @@ #include "DllGraphics.h" #include "DllExchange.h" #include "DllMachKernel.h" +#include "DllNesting.h" #include "/EgtDev/Include/EXeExecutor.h" #include "/EgtDev/Include/EXeDllMain.h" #include "/EgtDev/Include/EGnDllMain.h" @@ -46,6 +47,7 @@ static string s_sKey ; static int s_nKeyType = KEY_LOCK_TYPE_ANY ; static int s_nKeyExpDays = 0 ; static int s_nKeyOptExpDays = 0 ; +static string s_sNestKey ; static string s_sIniFile ; static bool s_bEnableUI = true ; static pfProcEvents s_pFunProcEvents = nullptr ; @@ -106,6 +108,10 @@ ExeInit( int nDebug, const string& sLogFile, const string& sLogMsg) if ( LoadMachKernelDll( s_pGenLog, s_sKey)) LOG_INFO( s_pGenLog, MyGetEMkVersion()) + // carico libreria neting opzionale + if ( LoadNestingDll( s_pGenLog, s_sKey, s_sNestKey)) + LOG_INFO( s_pGenLog, MyGetENsVersion()) + // Info sulla protezione e sul sistema string sTmp ; if ( ExeGetKeyInfo( sTmp)) @@ -194,6 +200,14 @@ ExeSetKey( const string& sKey) return true ; } +//----------------------------------------------------------------------------- +bool +ExeSetNestKey( const string& sNestKey) +{ + s_sNestKey = sNestKey ; + return true ; +} + //----------------------------------------------------------------------------- bool ExeSetLockType( int nType) diff --git a/EXE_NstAutoNesting.cpp b/EXE_NstAutoNesting.cpp new file mode 100644 index 0000000..3de672b --- /dev/null +++ b/EXE_NstAutoNesting.cpp @@ -0,0 +1,210 @@ +//---------------------------------------------------------------------------- +// EgalTech 2019-2019 +//---------------------------------------------------------------------------- +// File : EXE_NstAutoNesting.cpp Data : 28.11.19 Versione : 2.1k6 +// Contenuto : Funzioni Automatic Nesting per EXE. +// +// +// +// Modifiche : 28.11.19 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +//--------------------------- Include ---------------------------------------- +#include "stdafx.h" +#include "EXE.h" +#include "EXE_Macro.h" +#include "EXE_Const.h" +#include "DllNesting.h" +#include "/EgtDev/Include/EGkCurve.h" +#include "/EgtDev/Include/EGkSurfFlatRegion.h" +#include "/EgtDev/Include/ENsAutoNester.h" +#include "/EgtDev/Include/EGnStringUtils.h" +#include "/EgtDev/Include/EgtPointerOwner.h" +#include "/EgtDev/Include/SELkLockId.h" + +using namespace std ; + +//----------------------------------------------------------------------------- +static PtrOwner s_pAutoNester ; +static int s_nTotParts ; +static double s_dTotFillRatio ; +static ANIVECT s_vANestInfo ; + +//----------------------------------------------------------------------------- +bool +ExeAutoNestStart( void) +{ + s_nTotParts = 0 ; + s_dTotFillRatio = 0 ; + if ( IsNull( s_pAutoNester)) { + s_pAutoNester.Set( MyCreateAutoNester()) ; + if ( IsNull( s_pAutoNester)) + return false ; + } + return s_pAutoNester->Start() ; +} + +//----------------------------------------------------------------------------- +bool +ExeAutoNestAddSheet( int nSheetId, int nOutlineId, int nPriority, int nCount) +{ + if ( IsNull( s_pAutoNester)) + return false ; + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // recupero riferimento dell'Outline + Frame3d frOutl ; + if ( ! pGeomDB->GetGlobFrame( nOutlineId, frOutl)) + return false ; + // recupero il tipo di oggetto + int nType = pGeomDB->GetGeoType( nOutlineId) ; + PolyArc Outline ; + // recupero la curva di contorno + if ( ( nType & GEO_CURVE) != 0) { + const ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( nOutlineId)) ; + if ( pCrv == nullptr || ! pCrv->ApproxWithArcs( LIN_TOL_FINE, ANG_TOL_STD_DEG, Outline)) + return false ; + } + else if ( nType == SRF_FLATRGN) { + const ISurfFlatRegion* pSfr = GetSurfFlatRegion( pGeomDB->GetGeoObj( nOutlineId)) ; + if ( pSfr == nullptr) + return false ; + PtrOwner pCrv( pSfr->GetLoop( 0, 0)) ; + if ( IsNull( pCrv) || ! pCrv->ApproxWithArcs( LIN_TOL_FINE, ANG_TOL_STD_DEG, Outline)) + return false ; + } + // la porto in globale + Outline.ToGlob( frOutl) ; + // verifico direzione di estrusione + Vector3d vtExtr = Outline.GetExtrusion() ; + if ( vtExtr.IsZplus()) + ; + else if ( vtExtr.IsZminus()) + Outline.Mirror( ORIG, Z_AX) ; + else + return false ; + // aggiungo il pezzo + return s_pAutoNester->AddSheet( nSheetId, Outline, nPriority, nCount) ; +} + +//----------------------------------------------------------------------------- +bool +ExeAutoNestAddPart( int nPartId, int nOutlineId, int nCount) +{ + if ( IsNull( s_pAutoNester)) + return false ; + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // recupero riferimento dell'Outline + Frame3d frOutl ; + if ( ! pGeomDB->GetGlobFrame( nOutlineId, frOutl)) + return false ; + // recupero il tipo di oggetto + int nType = pGeomDB->GetGeoType( nOutlineId) ; + PolyArc Outline ; + // recupero la curva di contorno + if ( ( nType & GEO_CURVE) != 0) { + const ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( nOutlineId)) ; + if ( pCrv == nullptr || ! pCrv->ApproxWithArcs( LIN_TOL_FINE, ANG_TOL_STD_DEG, Outline)) + return false ; + } + else if ( nType == SRF_FLATRGN) { + const ISurfFlatRegion* pSfr = GetSurfFlatRegion( pGeomDB->GetGeoObj( nOutlineId)) ; + if ( pSfr == nullptr) + return false ; + PtrOwner pCrv( pSfr->GetLoop( 0, 0)) ; + if ( IsNull( pCrv) || ! pCrv->ApproxWithArcs( LIN_TOL_FINE, ANG_TOL_STD_DEG, Outline)) + return false ; + } + // la porto in globale + Outline.ToGlob( frOutl) ; + // verifico direzione di estrusione + Vector3d vtExtr = Outline.GetExtrusion() ; + if ( vtExtr.IsZplus()) + ; + else if ( vtExtr.IsZminus()) + Outline.Mirror( ORIG, Z_AX) ; + else + return false ; + // aggiungo il pezzo + if ( ! s_pAutoNester->AddPart( nPartId, Outline, nCount)) + return false ; + // incremento contatore pezzi + s_nTotParts += nCount ; + return true ; +} + +//----------------------------------------------------------------------------- +bool +ExeAutoNestSetInterpartGap( double dGap) +{ + if ( IsNull( s_pAutoNester)) + return false ; + return s_pAutoNester->SetInterpartGap( dGap) ; +} + +//----------------------------------------------------------------------------- +bool +ExeAutoNestCompute( int nMaxTime) +{ + if ( IsNull( s_pAutoNester)) + return false ; + return s_pAutoNester->Compute( nMaxTime) ; +} + +//----------------------------------------------------------------------------- +bool +ExeAutoNestGetComputationStatus( int& nStatus) +{ + if ( IsNull( s_pAutoNester)) + return false ; + return s_pAutoNester->GetComputationStatus( nStatus) ; +} + +//----------------------------------------------------------------------------- +bool +ExeAutoNestPrintResults( const string& sHtmlFile) +{ + if ( IsNull( s_pAutoNester)) + return false ; + return s_pAutoNester->PrintResults( sHtmlFile) ; +} + +//----------------------------------------------------------------------------- +bool +ExeAutoNestGetResults( int& nNestedParts, int& nTotParts, int& nTotSheets, int& nDiffSheets, double& dTotFillRatio) +{ + if ( IsNull( s_pAutoNester) || ! s_pAutoNester->GetResults( s_dTotFillRatio, s_vANestInfo)) + return false ; + nNestedParts = 0 ; + nTotParts = s_nTotParts ; + nTotSheets = 0 ; + nDiffSheets = 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 ; + nNestedParts += s_vANestInfo[i].nFlag * s_vANestInfo[i].nType ; + } + } + return true ; +} + +//----------------------------------------------------------------------------- +bool +ExeAutoNestGetOneResult( int nInd, int& nType, int& nId, int& nFlag, double& dX, double& dY, double& dAngRot) +{ + if ( nInd < 0 || nInd >= int( s_vANestInfo.size())) + return false ; + nType = s_vANestInfo[nInd].nType ; + nId = s_vANestInfo[nInd].nId ; + nFlag = s_vANestInfo[nInd].nFlag ; + dX = s_vANestInfo[nInd].dX ; + dY = s_vANestInfo[nInd].dY ; + dAngRot = s_vANestInfo[nInd].dAngRot ; + return true ; +} \ No newline at end of file diff --git a/EXE_Scene.cpp b/EXE_Scene.cpp index d027b77..c3ac264 100644 --- a/EXE_Scene.cpp +++ b/EXE_Scene.cpp @@ -97,6 +97,16 @@ ExeGetBackground( Color& TopCol, Color& BottomCol) return true ; } +//----------------------------------------------------------------------------- +bool +ExeSetLineAttribs( int nWidth) +{ + IEGrScene* pScene = GetCurrScene() ; + VERIFY_SCENE( pScene, false) + // imposto lo spessore delle linee + return pScene->SetLineWidth( nWidth) ; +} + //----------------------------------------------------------------------------- bool ExeSetMarkAttribs( Color MarkCol) diff --git a/EXE_ShortestPath.cpp b/EXE_ShortestPath.cpp index d7a22cd..ebac7b5 100644 --- a/EXE_ShortestPath.cpp +++ b/EXE_ShortestPath.cpp @@ -32,7 +32,7 @@ static PtrOwner< IShortestPath> s_pSP ; bool ExeSpInit( void) { - // creo l'oggetto per il calolo del percorso minimo (ShortestPath) + // creo l'oggetto per il calcolo del percorso minimo (ShortestPath) s_pSP.Set( CreateShortestPath()) ; return ( ! IsNull( s_pSP)) ; } diff --git a/EgtExecutor.rc b/EgtExecutor.rc index 6fcacc0ae0b4a7a8004d2cfb86b2fed9de71d5d7..d264ac85ae03d3d0bc2ccef310977b46b9c6ccda 100644 GIT binary patch delta 97 zcmdl{x1(;uA2vp_%@@V4Gflq2na5~0Ignd-a{*Tk3sCf++-0W82LxfF21;&>n->Y| cF@rU@0x76sKgP|Iq`|@mV0KKOlQUCw| delta 97 zcmdl{x1(;uA2vqQ%@@V4Gflq2na5~4Ignd-a{*Tk3sCf++-0W82LxfF21;&>n->Y| cF@rU@0x76sKgP|Iq`|@mV0K6d|N&o-= diff --git a/EgtExecutor.vcxproj b/EgtExecutor.vcxproj index 77add61..04857ed 100644 --- a/EgtExecutor.vcxproj +++ b/EgtExecutor.vcxproj @@ -222,6 +222,7 @@ copy $(TargetPath) \EgtProg\Dll64 + @@ -240,12 +241,14 @@ copy $(TargetPath) \EgtProg\Dll64 + + diff --git a/EgtExecutor.vcxproj.filters b/EgtExecutor.vcxproj.filters index dffc7d2..d0c7bf9 100644 --- a/EgtExecutor.vcxproj.filters +++ b/EgtExecutor.vcxproj.filters @@ -105,6 +105,9 @@ File di intestazione + + File di intestazione + @@ -335,6 +338,12 @@ File di origine\LUA + + File di origine\Optional Dll + + + File di origine\EXE + diff --git a/LUA_Nesting.cpp b/LUA_Nesting.cpp index 75076f1..27a4606 100644 --- a/LUA_Nesting.cpp +++ b/LUA_Nesting.cpp @@ -91,6 +91,170 @@ LuaVerifyMachining( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaAutoNestStart( lua_State* L) +{ + // nessu parametro + LuaClearStack( L) ; + // imposto inizio nuovo nesting + bool bOk = ExeAutoNestStart() ; + // restituisco il risultato + LuaSetParam( L, bOk) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaAutoNestAddSheet( lua_State* L) +{ + // 4 parametri : nSheetId, nOutlineId, nPriority, nCount + int nSheetId ; + LuaCheckParam( L, 1, nSheetId) + int nOutlineId ; + LuaCheckParam( L, 2, nOutlineId) + int nPriority ; + LuaCheckParam( L, 3, nPriority) + int nCount ; + LuaCheckParam( L, 4, nCount) + LuaClearStack( L) ; + // aggiungo un pannello al nesting corrente + bool bOk = ExeAutoNestAddSheet( nSheetId, nOutlineId, nPriority, nCount) ; + // restituisco il risultato + LuaSetParam( L, bOk) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaAutoNestAddPart( lua_State* L) +{ + // 3 parametri : nPartId, nOutlineId, nCount + int nPartId ; + LuaCheckParam( L, 1, nPartId) + int nOutlineId ; + LuaCheckParam( L, 2, nOutlineId) + int nCount ; + LuaCheckParam( L, 3, nCount) + LuaClearStack( L) ; + // aggiungo un pezzo al nesting corrente + bool bOk = ExeAutoNestAddPart( nPartId, nOutlineId, nCount) ; + // restituisco il risultato + LuaSetParam( L, bOk) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaAutoNestSetInterpartGap( lua_State* L) +{ + // 1 parametro : dGap + double dGap ; + LuaCheckParam( L, 1, dGap) + LuaClearStack( L) ; + // imposto la distanza minima tra i pezzi al nesting corrente + bool bOk = ExeAutoNestSetInterpartGap( dGap) ; + // restituisco il risultato + LuaSetParam( L, bOk) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaAutoNestCompute( lua_State* L) +{ + // 1 parametro : nMaxTime (ms) + int nMaxTime ; + LuaCheckParam( L, 1, nMaxTime) + LuaClearStack( L) ; + // lancio calcolo del nesting + bool bOk = ExeAutoNestCompute( nMaxTime) ; + // restituisco il risultato + LuaSetParam( L, bOk) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaAutoNestGetComputationStatus( lua_State* L) +{ + // nessun parametro + LuaClearStack( L) ; + // lancio calcolo del nesting + int nStatus ; + bool bOk = ExeAutoNestGetComputationStatus( nStatus) ; + // restituisco il risultato + LuaSetParam( L, bOk) ; + LuaSetParam( L, nStatus) ; + return 2 ; +} + +//------------------------------------------------------------------------------- +static int +LuaAutoNestPrintResults( lua_State* L) +{ + // 1 parametro : sHtmlFile + string sHtmlFile ; + LuaCheckParam( L, 1, sHtmlFile) + LuaClearStack( L) ; + // lancio stampa soluzione corrente + bool bOk = ExeAutoNestPrintResults( sHtmlFile) ; + // restituisco il risultato + LuaSetParam( L, bOk) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +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) ; + // restituisco il risultato + if ( bOk) { + LuaSetParam( L, nNestedParts) ; + LuaSetParam( L, nTotParts) ; + LuaSetParam( L, nTotSheets) ; + LuaSetParam( L, nDiffSheets) ; + LuaSetParam( L, dTotFillRatio) ; + return 5 ; + } + else { + LuaSetParam( L) ; + return 1 ; + } +} + +//------------------------------------------------------------------------------- +static int +LuaAutoNestGetOneResult( lua_State* L) +{ + // 1 parametro : nInd + int nInd ; + LuaCheckParam( L, 1, nInd) + LuaClearStack( L) ; + // recupero i risultati del nesting + int nType, nId, nFlag ; double dX, dY, dAngRot ; + bool bOk = ExeAutoNestGetOneResult( nInd, nType, nId, nFlag, dX, dY, dAngRot) ; + // restituisco il risultato + if ( bOk) { + LuaSetParam( L, nType) ; + LuaSetParam( L, nId) ; + LuaSetParam( L, nFlag) ; + LuaSetParam( L, dX) ; + LuaSetParam( L, dY) ; + LuaSetParam( L, dAngRot) ; + return 6 ; + } + else { + LuaSetParam( L) ; + return 1 ; + } +} + //------------------------------------------------------------------------------- bool LuaInstallNesting( LuaMgr& luaMgr) @@ -99,6 +263,15 @@ LuaInstallNesting( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtPackBox", LuaPackBox) ; bOk = bOk && luaMgr.RegisterFunction( "EgtPackBoxCluster", LuaPackBoxCluster) ; bOk = bOk && luaMgr.RegisterFunction( "EgtVerifyMachining", LuaVerifyMachining) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtAutoNestStart", LuaAutoNestStart) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtAutoNestAddSheet", LuaAutoNestAddSheet) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtAutoNestAddPart", LuaAutoNestAddPart) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtAutoNestSetInterpartGap", LuaAutoNestSetInterpartGap) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtAutoNestCompute", LuaAutoNestCompute) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtAutoNestGetComputationStatus", LuaAutoNestGetComputationStatus) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtAutoNestPrintResults", LuaAutoNestPrintResults) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtAutoNestGetResults", LuaAutoNestGetResults) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtAutoNestGetOneResult", LuaAutoNestGetOneResult) ; return bOk ; }