EgtNesting 2.1l2 :

- aggiunte nuove funzioni e fatte varie migliorie.
This commit is contained in:
Dario Sassi
2019-12-03 20:01:43 +00:00
parent 42d0cf99c3
commit adf61b1ea1
3 changed files with 79 additions and 16 deletions
+64 -12
View File
@@ -57,7 +57,7 @@ GetCNSPath( const PolyArc& Outline, vector<CNS_Element>& vElem)
// AutoNester
//----------------------------------------------------------------------------
AutoNester::AutoNester( void)
: m_pOrder( nullptr), m_pComp( nullptr)
: m_pOrder( nullptr), m_pComp( nullptr), m_dInterpartGap( 0)
{
}
@@ -81,6 +81,9 @@ AutoNester::Clear( void)
m_pOrder = nullptr ;
m_pComp = nullptr ;
}
m_IdSheetPtr.clear() ;
m_IdPartPtr.clear() ;
m_dInterpartGap = 0 ;
return true ;
}
@@ -99,7 +102,8 @@ AutoNester::AddSheet( int nSheetId, const PolyArc& Outline, double dKerf, int nP
{
if ( m_pOrder == nullptr)
return false ;
if ( ! Outline.IsClosed())
// verifico outline
if ( Outline.GetArcNbr() == 0 || ! Outline.IsClosed())
return false ;
// aggiungo contorno
vector<CNS_Element> vElem ;
@@ -111,16 +115,39 @@ AutoNester::AddSheet( int nSheetId, const PolyArc& Outline, double dKerf, int nP
CNS_SetSheetUserString( pSheet, ToString( nSheetId).c_str()) ;
CNS_SetSheetPriority( pSheet, nPriority) ;
CNS_SetNonRectangularSheetGaps( pSheet, dKerf, dKerf, dKerf, dKerf, dKerf) ;
// lo inserisco nel map
m_IdSheetPtr.emplace( nSheetId, pSheet) ;
return true ;
}
//----------------------------------------------------------------------------
bool
AutoNester::AddPart( int nPartId, const PolyArc& Outline, const PolyArc& ToolOutline,
bool bCanFlip, bool bCanRotate, double dRotStep, int nPriority, int nCount)
AutoNester::AddDefectToSheet( int nSheetId, const PolyArc& Outline)
{
if ( m_pOrder == nullptr)
return false ;
// verifico outline
if ( Outline.GetArcNbr() == 0 || ! Outline.IsClosed())
return false ;
// cerco lo sheet
const auto Iter = m_IdSheetPtr.find( nSheetId) ;
if ( Iter == m_IdSheetPtr.end())
return false ;
CNS_SheetPtr pSheet = Iter->second ;
// aggiungo difetto tramite suo contorno
vector<CNS_Element> vElem ;
GetCNSPath( Outline, vElem) ;
CNS_AddDefectToSheet( pSheet, int( vElem.size()), vElem.data()) ;
return true ;
}
//----------------------------------------------------------------------------
bool
AutoNester::AddPart( int nPartId, const PolyArc& Outline, bool bCanFlip, bool bCanRotate, double dRotStep, int nPriority, int nCount)
{
if ( m_pOrder == nullptr)
return false ;
// verifico outline
if ( Outline.GetArcNbr() == 0 || ! Outline.IsClosed())
return false ;
// aggiungo contorno
@@ -129,16 +156,33 @@ AutoNester::AddPart( int nPartId, const PolyArc& Outline, const PolyArc& ToolOut
CNS_PartPtr pPart = CNS_AddPart( m_pOrder, nCount, int( vElem.size()), vElem.data()) ;
if ( pPart == nullptr)
return false ;
// eventuale contorno esterno del percorso utensili
if ( ToolOutline.GetArcNbr() > 0 && ToolOutline.IsClosed()) {
vector<CNS_Element> vTOl ;
GetCNSPath( ToolOutline, vTOl) ;
CNS_AddToolPathToPart( pPart, int( vTOl.size()), vTOl.data()) ;
}
// altri dati
// imposto altri dati
CNS_SetPartUserString( pPart, ToString( nPartId).c_str()) ;
CNS_SetPartAuthorizations( pPart, ( bCanFlip ? 1 : 0), ( bCanRotate ? 1 : 0), dRotStep) ;
CNS_SetPartPriority( pPart, nPriority) ;
// lo inserisco nel map
m_IdPartPtr.emplace( nPartId, pPart) ;
return true ;
}
//----------------------------------------------------------------------------
bool
AutoNester::AddToolOutlineToPart( int nPartId, const PolyArc& ToolOutline)
{
if ( m_pOrder == nullptr)
return false ;
// verifico outline
if ( ToolOutline.GetArcNbr() == 0 || ! ToolOutline.IsClosed())
return false ;
// cerco il pezzo
const auto Iter = m_IdPartPtr.find( nPartId) ;
if ( Iter == m_IdPartPtr.end())
return false ;
CNS_PartPtr pPart = Iter->second ;
// aggiungo contorno di lavorazione
vector<CNS_Element> vElem ;
GetCNSPath( ToolOutline, vElem) ;
CNS_AddToolPathToPart( pPart, int( vElem.size()), vElem.data()) ;
return true ;
}
@@ -148,7 +192,7 @@ AutoNester::SetInterpartGap( double dGap)
{
if ( m_pOrder == nullptr)
return false ;
CNS_SetInterpartGap( m_pOrder, dGap) ;
m_dInterpartGap = max( 0., dGap) ;
return true ;
}
@@ -158,6 +202,14 @@ AutoNester::Compute( int nMaxTime)
{
if ( m_pOrder == nullptr)
return false ;
// se necessario, imposto i gap ( di default sono a 0)
if ( m_dInterpartGap > 10 * EPS_SMALL) {
// gap tra i pezzi
CNS_SetInterpartGap( m_pOrder, m_dInterpartGap) ;
// gap sui difetti
for ( auto Iter = m_IdSheetPtr.begin() ; Iter != m_IdSheetPtr.end() ; ++ Iter)
CNS_SetDefectGap( Iter->second, m_dInterpartGap) ;
}
// recupero i codici di sblocco del nesting
string sKeyId, sKeySign ;
SplitFirst( GetENsKey2(), "-", sKeyId, sKeySign) ;