EgtExecutor 2.1l1 :

- migliorie a nesting automatico.
This commit is contained in:
Dario Sassi
2019-12-02 18:36:42 +00:00
parent d4f903c336
commit a5bdacf601
3 changed files with 52 additions and 23 deletions
+31 -10
View File
@@ -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<ICurveComposite> 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<ICurve> 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 ;
}
}
BIN
View File
Binary file not shown.
+21 -13
View File
@@ -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 ;
}