EgtNesting :

- modifiche per kerf e tooling.
This commit is contained in:
Dario Sassi
2019-12-03 14:30:30 +00:00
parent 17c5d09647
commit 42d0cf99c3
2 changed files with 43 additions and 29 deletions
+40 -27
View File
@@ -18,6 +18,7 @@
#include "/EgtDev/Include/ENsDllMain.h"
#include "/EgtDev/Include/EGkPolyArc.h"
#include "/EgtDev/Extern/Optalog/Include/cns.h"
#include "/EgtDev/Extern/Optalog/Include/cns_tooling.h"
#include "/EgtDev/Extern/Optalog/Include/cns_egaltech.h"
#include "/EgtDev/Include/SELkLockId.h"
@@ -34,6 +35,24 @@ CreateAutoNester( void)
return static_cast<IAutoNester*> ( new(nothrow) AutoNester) ;
}
//----------------------------------------------------------------------------
static void
GetCNSPath( const PolyArc& Outline, vector<CNS_Element>& vElem)
{
// converto nel formato Optalog
int nElem = Outline.GetPointNbr() ;
if ( Outline.IsClosed())
-- nElem ;
vElem.reserve( nElem) ;
Point3d ptIni, ptFin ; double dBulge ;
bool bNext = Outline.GetFirstArc( ptIni, ptFin, dBulge) ;
while ( bNext) {
double dLeftDeflection = - dBulge * DistXY( ptIni, ptFin) / 2 ;
vElem.push_back( { ptFin.x, ptFin.y, dLeftDeflection}) ;
bNext = Outline.GetNextArc( ptIni, ptFin, dBulge) ;
}
}
//----------------------------------------------------------------------------
// AutoNester
//----------------------------------------------------------------------------
@@ -76,55 +95,49 @@ AutoNester::Start( void)
//----------------------------------------------------------------------------
bool
AutoNester::AddSheet( int nSheetId, const PolyArc& Outline, int nPriority, int nCount)
AutoNester::AddSheet( int nSheetId, const PolyArc& Outline, double dKerf, int nPriority, int nCount)
{
if ( m_pOrder == nullptr)
return false ;
if ( ! Outline.IsClosed())
return false ;
// contorno nel formato Optalog
const int nElem = Outline.GetPointNbr() - 1 ;
vector<CNS_Element> vElem ; vElem.reserve( nElem) ;
Point3d ptIni, ptFin ; double dBulge ;
bool bNext = Outline.GetFirstArc( ptIni, ptFin, dBulge) ;
while ( bNext) {
double dLeftDeflection = - dBulge * DistXY( ptIni, ptFin) / 2 ;
vElem.push_back( { ptFin.x, ptFin.y, dLeftDeflection}) ;
bNext = Outline.GetNextArc( ptIni, ptFin, dBulge) ;
}
// aggiungo
// aggiungo contorno
vector<CNS_Element> vElem ;
GetCNSPath( Outline, vElem) ;
CNS_SheetPtr pSheet = CNS_AddNonRectangularSheet( m_pOrder, nCount, int( vElem.size()), vElem.data()) ;
if ( pSheet == nullptr)
return false ;
// imposto altri dati
CNS_SetSheetUserString( pSheet, ToString( nSheetId).c_str()) ;
CNS_SetSheetPriority( pSheet, nPriority) ;
CNS_SetNonRectangularSheetGaps( pSheet, dKerf, dKerf, dKerf, dKerf, dKerf) ;
return true ;
}
//----------------------------------------------------------------------------
bool
AutoNester::AddPart( int nPartId, const PolyArc& Outline, bool bCanFlip, bool bCanRotate, int nPriority, int nCount)
AutoNester::AddPart( int nPartId, const PolyArc& Outline, const PolyArc& ToolOutline,
bool bCanFlip, bool bCanRotate, double dRotStep, int nPriority, int nCount)
{
if ( m_pOrder == nullptr)
return false ;
if ( ! Outline.IsClosed())
if ( Outline.GetArcNbr() == 0 || ! Outline.IsClosed())
return false ;
// contorno nel formato Optalog
const int nElem = Outline.GetPointNbr() - 1 ;
vector<CNS_Element> vElem ; vElem.reserve( nElem) ;
Point3d ptIni, ptFin ; double dBulge ;
bool bNext = Outline.GetFirstArc( ptIni, ptFin, dBulge) ;
while ( bNext) {
double dLeftDeflection = - dBulge * DistXY( ptIni, ptFin) / 2 ;
vElem.push_back( { ptFin.x, ptFin.y, dLeftDeflection}) ;
bNext = Outline.GetNextArc( ptIni, ptFin, dBulge) ;
}
// aggiungo
// aggiungo contorno
vector<CNS_Element> vElem ;
GetCNSPath( Outline, vElem) ;
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
CNS_SetPartUserString( pPart, ToString( nPartId).c_str()) ;
CNS_SetPartAuthorizations( pPart, ( bCanFlip ? 1 : 0), ( bCanRotate ? 1 : 0), 0) ;
CNS_SetPartAuthorizations( pPart, ( bCanFlip ? 1 : 0), ( bCanRotate ? 1 : 0), dRotStep) ;
CNS_SetPartPriority( pPart, nPriority) ;
return true ;
}
@@ -155,7 +168,7 @@ AutoNester::Compute( int nMaxTime)
// passo i codici al nester
CNS_UnLockLaunchingOrderOxy( m_pOrder, sKeyId.c_str(), sKeySign.c_str()) ;
// lancio l'esecuzione
m_pComp = CNS_LaunchLocalComputation( m_pOrder, nMaxTime / 1000.) ;
m_pComp = CNS_LaunchLocalComputation( m_pOrder, nMaxTime) ;
return ( m_pComp != nullptr) ;
}