EgtEsecutor :
- aggiornamenti per nesting automatico.
This commit is contained in:
+49
-80
@@ -48,6 +48,43 @@ ExeAutoNestStart( void)
|
||||
return s_pAutoNester->Start() ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
static bool
|
||||
MyGetOutline( IGeomDB* pGeomDB, int nOutlineId, PolyArc& Outline)
|
||||
{
|
||||
// recupero riferimento dell'Outline
|
||||
Frame3d frOutl ;
|
||||
if ( ! pGeomDB->GetGlobFrame( nOutlineId, frOutl))
|
||||
return false ;
|
||||
// recupero il tipo di oggetto
|
||||
int nType = pGeomDB->GetGeoType( nOutlineId) ;
|
||||
// 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<ICurve> 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 ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeAutoNestAddSheet( int nSheetId, int nOutlineId, double dKerf, int nPriority, int nCount)
|
||||
@@ -56,101 +93,33 @@ ExeAutoNestAddSheet( int nSheetId, int nOutlineId, double dKerf, int nPriority,
|
||||
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) ;
|
||||
// recupero il contorno
|
||||
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<ICurve> 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
|
||||
if ( ! MyGetOutline( pGeomDB, nOutlineId, Outline))
|
||||
return false ;
|
||||
// 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) ;
|
||||
return s_pAutoNester->AddSheet( nSheetId, Outline, dKerf, nPriority, nCount) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeAutoNestAddPart( int nPartId, int nOutlineId, bool bCanFlip, bool bCanRotate, int nPriority, int nCount)
|
||||
ExeAutoNestAddPart( int nPartId, int nOutlineId, int nToolOutlineId,
|
||||
bool bCanFlip, bool bCanRotate, double dRotStep, 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) ;
|
||||
// recupero il contorno
|
||||
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<ICurve> 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
|
||||
if ( ! MyGetOutline( pGeomDB, nOutlineId, Outline))
|
||||
return false ;
|
||||
// recupero evntuale contorno della lavorazione
|
||||
PolyArc ToolOutline ;
|
||||
if ( nToolOutlineId != GDB_ID_NULL && ! MyGetOutline( pGeomDB, nToolOutlineId, ToolOutline))
|
||||
return false ;
|
||||
// aggiungo il pezzo
|
||||
if ( ! s_pAutoNester->AddPart( nPartId, Outline, bCanFlip, bCanRotate, nPriority, nCount))
|
||||
if ( ! s_pAutoNester->AddPart( nPartId, Outline, ToolOutline, bCanFlip, bCanRotate, dRotStep, nPriority, nCount))
|
||||
return false ;
|
||||
// incremento contatore pezzi
|
||||
s_nTotParts += nCount ;
|
||||
|
||||
Reference in New Issue
Block a user