EgtNesting 2.7i2 :
- aggiunte funzioni per calcolo shear sequence.
This commit is contained in:
+82
-6
@@ -21,6 +21,7 @@
|
||||
#include "/EgtDev/Extern/Optalog/Include/cns_tooling.h"
|
||||
#include "/EgtDev/Extern/Optalog/Include/cns_restricted_zone.h"
|
||||
#include "/EgtDev/Extern/Optalog/Include/cns_textile.h"
|
||||
#include "/EgtDev/Extern/Optalog/Include/cns_shear_sequence.h"
|
||||
#include "/EgtDev/Extern/Optalog/Include/cns_egaltech.h"
|
||||
#include "/EgtDev/Include/SELkLockId.h"
|
||||
|
||||
@@ -59,7 +60,7 @@ GetCNSPath( const PolyArc& Outline, double dOffsX, double dOffsY, vector<CNS_Ele
|
||||
// AutoNester
|
||||
//----------------------------------------------------------------------------
|
||||
AutoNester::AutoNester( void)
|
||||
: m_pOrder( nullptr), m_pComp( nullptr), m_dInterpartGap( 0)
|
||||
: m_pOrder( nullptr), m_pComp( nullptr), m_dInterpartGap( 0), m_dShearGap( 0), m_bGuillotine( false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -87,6 +88,8 @@ AutoNester::Clear( void)
|
||||
m_IdRzCstrPtr.clear() ;
|
||||
m_IdPartPtr.clear() ;
|
||||
m_dInterpartGap = 0 ;
|
||||
m_dShearGap = 0 ;
|
||||
m_bGuillotine = false ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -106,6 +109,7 @@ AutoNester::SetGuillotineMode( void)
|
||||
if ( m_pOrder == nullptr)
|
||||
return false ;
|
||||
CNS_SetShearMode( m_pOrder, 1) ;
|
||||
m_bGuillotine = true ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -153,7 +157,7 @@ AutoNester::AddSheet( int nSheetId, const PolyArc& Outline, double dKerf, int nP
|
||||
dOffsY = ptMin.y ;
|
||||
// imposto altri dati
|
||||
CNS_SetSheetGaps( pSheet, dKerf, dKerf, dKerf, dKerf) ;
|
||||
// se richiesto, ritorno che è un rettangolo
|
||||
// se richiesto, ritorno che è un rettangolo
|
||||
if ( pbIsRect != nullptr)
|
||||
*pbIsRect = true ;
|
||||
}
|
||||
@@ -167,7 +171,7 @@ AutoNester::AddSheet( int nSheetId, const PolyArc& Outline, double dKerf, int nP
|
||||
return false ;
|
||||
// imposto altri dati
|
||||
CNS_SetNonRectangularSheetGaps( pSheet, dKerf, dKerf, dKerf, dKerf, dKerf) ;
|
||||
// se richiesto, ritorno che non è un rettangolo
|
||||
// se richiesto, ritorno che non è un rettangolo
|
||||
if ( pbIsRect != nullptr)
|
||||
*pbIsRect = false ;
|
||||
}
|
||||
@@ -175,7 +179,7 @@ AutoNester::AddSheet( int nSheetId, const PolyArc& Outline, double dKerf, int nP
|
||||
CNS_SetSheetUserString( pSheet, ToString( nSheetId).c_str()) ;
|
||||
CNS_SetSheetPriority( pSheet, nPriority) ;
|
||||
// lo inserisco nel map
|
||||
m_IdSheetInfo.emplace( nSheetId, SheetInfo( pSheet, dOffsX, dOffsY)) ;
|
||||
m_IdSheetInfo.emplace( nSheetId, SheetInfo( pSheet, dOffsX, dOffsY, dKerf)) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -416,6 +420,16 @@ AutoNester::SetInterpartGap( double dGap)
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
AutoNester::SetShearGap( double dShearGap)
|
||||
{
|
||||
if ( m_pOrder == nullptr)
|
||||
return false ;
|
||||
m_dShearGap = max( 0., dShearGap) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
AutoNester::SetReportFile( const string& sReportFile)
|
||||
@@ -438,6 +452,10 @@ AutoNester::Compute( bool bMinimizeOnXvsY, int nMaxTime)
|
||||
for ( auto Iter = m_IdSheetInfo.begin() ; Iter != m_IdSheetInfo.end() ; ++ Iter)
|
||||
CNS_SetDefectGap( Iter->second.pSheet, m_dInterpartGap) ;
|
||||
}
|
||||
// shear gap
|
||||
if ( m_dShearGap > 10 * EPS_SMALL)
|
||||
CNS_SetShearGap( m_pOrder, m_dShearGap) ;
|
||||
|
||||
// per evitare pezzi posti inutilmente di sghembo su ultimo pannello
|
||||
CNS_SetObjective( m_pOrder, ( bMinimizeOnXvsY ? CNS_IntelligentMinimizeX : CNS_IntelligentMinimizeY)) ;
|
||||
// recupero i codici di sblocco del nesting
|
||||
@@ -491,7 +509,7 @@ AutoNester::GetComputationStatus( int& nStatus)
|
||||
bool
|
||||
AutoNester::GetResults( double& dTotFillRatio, ANIVECT& vANI)
|
||||
{
|
||||
// verifico validità calcolo
|
||||
// verifico validità calcolo
|
||||
if ( m_pComp == nullptr)
|
||||
return false ;
|
||||
// recupero la soluzione
|
||||
@@ -537,11 +555,69 @@ AutoNester::GetResults( double& dTotFillRatio, ANIVECT& vANI)
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
AutoNester::CalcShearSequence( int nNesting, PNTVECTOR& vPtStart, PNTVECTOR& vPtEnd)
|
||||
{
|
||||
vPtStart.clear() ;
|
||||
vPtEnd.clear() ;
|
||||
|
||||
// verifico se impostata modalità ghigliottina
|
||||
if ( ! m_bGuillotine)
|
||||
return false ;
|
||||
// verifico vincolo con intergap tra i pezzi
|
||||
if ( m_dShearGap < m_dInterpartGap - EPS_SMALL)
|
||||
return false ;
|
||||
// verifico validità calcolo
|
||||
if ( m_pComp == nullptr)
|
||||
return false ;
|
||||
// recupero la soluzione
|
||||
CNS_SolutionPtr pSol = CNS_GetSolution( m_pComp) ;
|
||||
if ( pSol == nullptr)
|
||||
return false ;
|
||||
// recupero il nesting richiesto
|
||||
int nNestCount = CNS_GetNumberOfNestings( pSol) ;
|
||||
if ( nNesting < 0 || nNesting > nNestCount - 1)
|
||||
return false ;
|
||||
CNS_NestingPtr pNest = CNS_GetNesting( pSol, nNesting) ;
|
||||
// recupero pannello
|
||||
CNS_SheetPtr pSheet = CNS_GetSheet( pNest) ;
|
||||
const char* szSheetId = CNS_GetSheetUserString( pSheet) ;
|
||||
int nSheetId = 999 ;
|
||||
if ( szSheetId != nullptr)
|
||||
FromString( szSheetId, nSheetId) ;
|
||||
const auto Iter = m_IdSheetInfo.find( nSheetId) ;
|
||||
|
||||
// verifico vincolo con kerf del pannello
|
||||
double dSheetKerf = ( Iter != m_IdSheetInfo.end() ? Iter->second.dKerf : 0) ;
|
||||
if ( dSheetKerf > EPS_SMALL && m_dShearGap > dSheetKerf + EPS_SMALL)
|
||||
return false ;
|
||||
|
||||
// offset per origine pannello
|
||||
double dOffsX = ( Iter != m_IdSheetInfo.end() ? Iter->second.dOffsX : 0) ;
|
||||
double dOffsY = ( Iter != m_IdSheetInfo.end() ? Iter->second.dOffsY : 0) ;
|
||||
|
||||
// calcolo shear sequence
|
||||
CNS_ShearSequencePtr pShearSeq = CNS_ComputeShearSequence( pNest) ;
|
||||
int nCnt = CNS_GetNumberOfElementsInShearSequence( pShearSeq) ;
|
||||
vPtStart.reserve( nCnt) ;
|
||||
vPtEnd.reserve( nCnt) ;
|
||||
for ( int j = 0 ; j < nCnt ; j ++) {
|
||||
double dStartX, dEndX, dStartY, dEndY ;
|
||||
CNS_GetElementInShearSequence( pShearSeq, j, &dStartX, &dStartY, &dEndX, &dEndY) ;
|
||||
vPtStart.emplace_back( dStartX + dOffsX, dStartY + dOffsY, 0) ;
|
||||
vPtEnd.emplace_back( dEndX + dOffsX, dEndY + dOffsY, 0) ;
|
||||
}
|
||||
CNS_DeleteShearSequence( pShearSeq) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
AutoNester::PrintResults( const string& sHtmlFile)
|
||||
{
|
||||
// verifico validità calcolo
|
||||
// verifico validità calcolo
|
||||
if ( m_pComp == nullptr)
|
||||
return false ;
|
||||
// recupero la soluzione
|
||||
|
||||
Reference in New Issue
Block a user