EgtMachKernel :
- primo codice per Lead In/out.
This commit is contained in:
+266
-180
@@ -5742,50 +5742,61 @@ Pocketing::AddSpiralIn( ISURFFRPOVECTOR& vSfr, const vector<ICRVCOMPOPOVECTOR>&
|
||||
int nStep = int( vSfr.size()) ;
|
||||
// determino lo step classico ( senza considerare gli step extra)
|
||||
double dStep = dElev / nStep ;
|
||||
// Dati Spiral dello step precedente ( j-1)
|
||||
Point3d ptP1, ptStartPrec ; // per LeadIn attuale e precedente
|
||||
BOOLVECTOR vbMidOutPrec ; // flags per effettiva entrata precedente da fuori dal grezzo
|
||||
ICRVCOMPOPOVECTOR vMCrv_step_prec ; // vettore delle curve dei percorsi di svuotatura dello step precedente
|
||||
ICRVCOMPOPOVECTOR vRCrv_step_prec ; // vettore delle curve dei percorsi di ritorno dello step precedente
|
||||
ICRVCOMPOPOVECTOR vMCrv_step_prec_tot ; // vettore delle curve dei percorsi di svuotatura dello step precedente con entrata
|
||||
ICRVCOMPOPOVECTOR vRCrv_step_prec_tot ; // vettore delle curve dei percorsi di ritorno dello step precedente con uscita
|
||||
vector<Vector3d> vvtMidOutPrec ; // vettore dei versori delle direzioni di uscita dello step precedente
|
||||
INTVECTOR vnRegTot_prec ; // vettore dei numeri delle regioni formate dal primo Offset nello step precedente
|
||||
BOOLVECTOR vbOptTrap_prec ; // flags per caso ottimizzato svuotratura dello step precedente
|
||||
int nOffs_act = 0 ; // Shift indice dei vettori causato da nReg
|
||||
|
||||
// scorro il vettore delle FlatRegion ( calcolate per ogni step j-esimo)
|
||||
for ( int j = 1 ; j <= nStep ; ++ j) {
|
||||
|
||||
// se superficie non valida, passo alla prossima
|
||||
if ( IsNull( vSfr[j-1]) || ! vSfr[j-1]->IsValid())
|
||||
continue ;
|
||||
// ciclo sui chunk della superificie da svuotare
|
||||
|
||||
// superifice per ingressi ed uscite
|
||||
PtrOwner<ISurfFlatRegion> pSrfLeanInOut( CloneSurfFlatRegion( vSfr[j-1])) ;
|
||||
if ( IsNull( pSrfLeanInOut))
|
||||
return false ;
|
||||
|
||||
// se lo step attuale è cambiato rispetto al precedente...
|
||||
if ( vbChangedPrec[j-1]) {
|
||||
// Flush info step precedente
|
||||
vMCrv_step_prec.clear() ;
|
||||
vRCrv_step_prec.clear() ;
|
||||
vnRegTot_prec.clear() ;
|
||||
vbMidOutPrec.clear() ;
|
||||
vvtMidOutPrec.clear() ;
|
||||
vbOptTrap_prec.clear() ;
|
||||
nOffs_act = 0 ;
|
||||
}
|
||||
|
||||
// creo le entità per lo step corrente
|
||||
ICRVCOMPOPOVECTOR vMCrv, vRCrv ;
|
||||
BOOLVECTOR vbOut ;
|
||||
INTVECTOR vnRegTot ;
|
||||
|
||||
// ciclo sui chunk della superficie da svuotare
|
||||
for ( int c = 0 ; c < vSfr[j-1]->GetChunkCount() ; ++ c) {
|
||||
|
||||
// copio il chunk c-esimo
|
||||
PtrOwner<ISurfFlatRegion> pSrfChunk( GetSurfFlatRegion( vSfr[j-1]->CloneChunk( c))) ;
|
||||
if ( IsNull( pSrfChunk))
|
||||
return false ;
|
||||
|
||||
Point3d ptP1, ptStartPrec ; // per LeadIn attuale e precedente
|
||||
BOOLVECTOR vbMidOutPrec ; // flags per effettiva entrata precedente da fuori dal grezzo
|
||||
ICRVCOMPOPOVECTOR vMCrv_step_prec ; // vettore delle curve dei percorsidi svuotatura dello step precedente
|
||||
ICRVCOMPOPOVECTOR vRCrv_step_prec ; // vettore delle curve dei percorsi di ritorno dello step precedente
|
||||
vector<Vector3d> vvtMidOutPrec ; // vettore dei versori delle direzioni di uscita dello step precedente
|
||||
INTVECTOR vnRegTot_prec ; // vettore dei numeri delle regioni formate dal primo Offset nello step precedente
|
||||
BOOLVECTOR vbOptTrap_prec ; // flags per caso ottimizzato svuotratura dello step precedente
|
||||
int nOffs_act = 0 ; // Shift indice dei vettori causato da nReg
|
||||
nOffs_act = 0 ; // reset indice dei vettori per step precedenti
|
||||
|
||||
if ( vbChangedPrec[j-1]) {
|
||||
// se lo step attuale è cambiato rispetto al precedente -> Flush info step precedente
|
||||
vMCrv_step_prec.clear() ;
|
||||
vRCrv_step_prec.clear() ;
|
||||
vnRegTot_prec.clear() ;
|
||||
vbMidOutPrec.clear() ;
|
||||
vvtMidOutPrec.clear() ;
|
||||
vbOptTrap_prec.clear() ;
|
||||
}
|
||||
|
||||
const int MAX_REGS = 50 ;
|
||||
int nReg = 0 ; // chunk nuovo corrente da svuotare
|
||||
|
||||
// ciclo su tutte le regioni che posso ottenere col primo Offset del chunk cc-esimo
|
||||
while ( nReg < MAX_REGS) {
|
||||
|
||||
// superifice per ingressi ed uscite
|
||||
PtrOwner<ISurfFlatRegion> pSrfLeanInOut( CloneSurfFlatRegion( vSfr[j-1])) ;
|
||||
if ( IsNull( pSrfLeanInOut))
|
||||
return false ;
|
||||
|
||||
// calcolo la spirale dall'esterno all'interno e la curva che unisce inizio e fine
|
||||
PtrOwner<ICurveComposite> pMCrv( CreateCurveComposite()) ; // percorso di svuotatura
|
||||
PtrOwner<ICurveComposite> pRCrv( CreateCurveComposite()) ; // percorso di ritorno
|
||||
@@ -5804,8 +5815,8 @@ Pocketing::AddSpiralIn( ISURFFRPOVECTOR& vSfr, const vector<ICRVCOMPOPOVECTOR>&
|
||||
|
||||
bool bOptimizedTrap = false ; // se ho un caso spirale o trapezio
|
||||
|
||||
// NB. se la superficie è rimasta la stessa, utilizzo pMCrv e pRCrv dello step precedente
|
||||
// ( non c'è bisogno di ricalcolare tutti i percorsi)
|
||||
// NB. se la superficie è rimasta la stessa, utilizzo pMCrv e pRCrv dello step precedente
|
||||
// ( non c'è bisogno di ricalcolare tutti i percorsi)
|
||||
if ( ! vbChangedPrec[j-1] && j != 1) {
|
||||
if ( nOffs_act > int( vMCrv_step_prec.size()) - 1)
|
||||
break ;
|
||||
@@ -5818,7 +5829,7 @@ Pocketing::AddSpiralIn( ISURFFRPOVECTOR& vSfr, const vector<ICRVCOMPOPOVECTOR>&
|
||||
bOptimizedTrap = vbOptTrap_prec[nOffs_act] ;
|
||||
}
|
||||
else {
|
||||
// se lucidatura con epicicli
|
||||
// se lucidatura con epicicli
|
||||
if ( m_TParams.m_nType == TT_MILL_POLISHING && m_Params.m_dEpicyclesRad > EPS_SMALL) {
|
||||
// verifico che i parametri lucidatura siano sensati
|
||||
if ( m_Params.m_dEpicyclesDist < 100 * EPS_SMALL) {
|
||||
@@ -5843,7 +5854,7 @@ Pocketing::AddSpiralIn( ISURFFRPOVECTOR& vSfr, const vector<ICRVCOMPOPOVECTOR>&
|
||||
// se terminate le regioni, esco
|
||||
if ( pMCrv->GetCurveCount() == 0)
|
||||
break ; // passo al chunk originale successivo
|
||||
|
||||
|
||||
if ( m_TParams.m_nType == TT_MILL_POLISHING && m_Params.m_dEpicyclesRad > EPS_SMALL) {
|
||||
// riporto il diametro dell'utensile al valore originale
|
||||
m_TParams.m_dDiam -= 2 * m_Params.m_dEpicyclesRad ;
|
||||
@@ -5886,12 +5897,8 @@ Pocketing::AddSpiralIn( ISURFFRPOVECTOR& vSfr, const vector<ICRVCOMPOPOVECTOR>&
|
||||
ptOut.Translate( -vVtTrasl[j-1]) ; // lo ritraslo sulla curva
|
||||
// aggiungo un tratto lineare all'inizio del percorso di svuotatura
|
||||
pMCrv->AddLine( ptOut, false) ;
|
||||
// assegno la sua Feed
|
||||
//AssignFeedForLineInOut( pMCrv, true) ;
|
||||
// aggiungo un tratto lineare alla fine del percorso di svuotatura
|
||||
pRCrv->AddLine( ptOut, true) ;
|
||||
// assegno la sua Feed
|
||||
//AssignFeedForLineInOut( pRCrv, false) ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5900,11 +5907,8 @@ Pocketing::AddSpiralIn( ISURFFRPOVECTOR& vSfr, const vector<ICRVCOMPOPOVECTOR>&
|
||||
if ( bOptimizedTrap) {
|
||||
AdjustTrapezoidSpiralForLeadInLeadOut( pMCrv, pRCrv, vtTool, dDepth, nOutsideRaw) ;
|
||||
bOutStart = ( nOutsideRaw > 0) ;
|
||||
// imposto la Feed
|
||||
//AssignFeedSpiralOpt( 1, pMCrv) ;
|
||||
//AssignFeedForReturnPath( pRCrv) ;
|
||||
}
|
||||
|
||||
|
||||
// verifico se l'ingresso è da considerare fuori dal grezzo anche se dentro
|
||||
bForcedOutStart = ( bMidOut && m_bOpenOutRaw) ;
|
||||
|
||||
@@ -5923,163 +5927,245 @@ Pocketing::AddSpiralIn( ISURFFRPOVECTOR& vSfr, const vector<ICRVCOMPOPOVECTOR>&
|
||||
&& ( j % 2 == 0))
|
||||
pMCrv->Invert() ;
|
||||
|
||||
++nReg ; // incremento del numero di regioni trovate
|
||||
++ nOffs_act ; // shift indice
|
||||
++ nReg ; // incremento del numero di regioni trovate
|
||||
++ nOffs_act ; // shift indice
|
||||
|
||||
int nMaxInd = pMCrv->GetCurveCount() - 1 ;
|
||||
int nMaxRInd = pRCrv->GetCurveCount() - 1 ;
|
||||
// salvo i dati Spiral correnti
|
||||
vMCrv.emplace_back( Release( pMCrv)) ;
|
||||
vRCrv.emplace_back( Release( pRCrv)) ;
|
||||
vbOut.push_back( bOutStart || bForcedOutStart) ;
|
||||
vnRegTot.push_back( nRegTot) ;
|
||||
}
|
||||
}
|
||||
|
||||
// determino l'affondamento attuale
|
||||
double dSink = dElev - dDepth + dMaxElev - vVtTrasl[j-1].Len() ;
|
||||
// 3 punti critici per entrate ed uscite
|
||||
Point3d ptA, ptB ;
|
||||
|
||||
// ciclo sulle curve elementari
|
||||
for ( int i = 0 ; i <= nMaxInd ; ++ i) {
|
||||
// curva corrente
|
||||
const ICurve* pCrvC = pMCrv->GetCurve( i) ;
|
||||
// copio la curva
|
||||
PtrOwner<ICurve> pCurve( pCrvC->Clone()) ;
|
||||
if ( IsNull( pCurve))
|
||||
// per ogni entità trovata...
|
||||
int nSpiralEntity = int( vMCrv.size()) ;
|
||||
for ( int e = 0 ; e < nSpiralEntity ; ++ e) {
|
||||
|
||||
// se non sono al primo step, regolo l'uscita all'ultima entità dello step precedente
|
||||
if ( j != 1) {
|
||||
// DEVO AVERE PTE PRECEDNETE E PTS ATTUALE
|
||||
// CALCOLO LA QUOTA CORRETTA
|
||||
|
||||
// uscita e retrazione entità precedente
|
||||
// dati fine entità
|
||||
Point3d ptEnd ;
|
||||
pCurve->GetEndPoint( ptEnd) ;
|
||||
Vector3d vtEnd ;
|
||||
pCurve->GetEndDir( vtEnd) ;
|
||||
// aggiungo uscita
|
||||
Point3d ptP1 ;
|
||||
double dEndElev = dElev ;
|
||||
SetFeed( GetEndFeed()) ;
|
||||
if ( ! AddLeadOut( ptEnd, vtEnd, vtExtr, vRCrv[e], bSplitArcs, false, ptP1, dEndElev, true)) {
|
||||
m_pMchMgr->SetLastError( 2416, "Error in Pocketing : LeadOut not computable") ;
|
||||
return false ;
|
||||
}
|
||||
// aggiungo retrazione
|
||||
if ( ! AddRetract( ptP1, vtTool, dSafeZ, dSafeAggrBottZ, dEndElev, dAppr)) {
|
||||
m_pMchMgr->SetLastError( 2417, "Error in Pocketing : Retract not computable") ;
|
||||
return false ;
|
||||
}
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
// recupero l'indice massimo delle sottocurve
|
||||
int nMaxInd = vMCrv[e]->GetCurveCount() - 1 ;
|
||||
int nMaxRInd = vRCrv[e]->GetCurveCount() - 1 ;
|
||||
|
||||
// ciclo sulle curve elementari
|
||||
for ( int i = 0 ; i <= nMaxInd ; ++ i) {
|
||||
// curva corrente
|
||||
const ICurve* pCrvC = vMCrv[e]->GetCurve( i) ;
|
||||
// copio la curva
|
||||
PtrOwner<ICurve> pCurve( pCrvC->Clone()) ;
|
||||
if ( IsNull( pCurve))
|
||||
return false ;
|
||||
// se prima entità
|
||||
if ( i == 0) {
|
||||
// dati inizio entità
|
||||
Point3d ptStart ;
|
||||
pCurve->GetStartPoint( ptStart) ;
|
||||
Vector3d vtStart ;
|
||||
pCurve->GetStartDir( vtStart) ;
|
||||
// se prima etità in assoluto
|
||||
if ( e == 1 && j == 1) {
|
||||
// LeadIn
|
||||
if ( ! CalcLeadInStart( ptStart, vtStart, vtExtr, vRCrv[e], ptP1)) {
|
||||
m_pMchMgr->SetLastError( 2415, "Error in Pocketing : LeadIn not computable") ;
|
||||
return false ;
|
||||
}
|
||||
// determino elevazione su inizio attacco ( se non trovata, l'elevazione è nStep)
|
||||
double dStElev ;
|
||||
if ( ! GetElevation( m_nPhase, ptStart - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), vtTool, dStElev))
|
||||
dStElev = dStep ;
|
||||
bool bAhUnderRaw = m_bAboveHead && ! m_bAggrBottom && ! m_bTiltingTab &&
|
||||
GetAhPointUnderRaw( ptP1, vtTool, 0, GetRadiusForStartEndElevation(),
|
||||
m_TParams.m_dLen, false, dSafeZ, vtTool, dStElev) ;
|
||||
bool bUhAboveRaw = ! m_bAboveHead &&
|
||||
GetUhPointAboveRaw( ptP1, vtTool, 0, GetRadiusForStartEndElevation(),
|
||||
m_TParams.m_dLen, false, dSafeZ, vtTool, dStElev) ;
|
||||
if ( bAhUnderRaw || bUhAboveRaw || m_bTiltingTab)
|
||||
dStElev = max( dStElev, dStep) ;
|
||||
dStElev -= ( ptP1 - ptStart) * vtExtr ;
|
||||
// se attacco a zigzag o a spirale o a scivolo, l'elevazione va nell'attacco
|
||||
if ( GetLeadInType() == POCKET_LI_ZIGZAG ||
|
||||
GetLeadInType() == POCKET_LI_HELIX ||
|
||||
GetLeadInType() == POCKET_LI_GLIDE) {
|
||||
ptP1 += vtExtr * ( dStElev + LIO_ELEV_TOL) ;
|
||||
dStElev = -LIO_ELEV_TOL ;
|
||||
}
|
||||
// approccio al punto iniziale
|
||||
if ( ! AddApproach( ptP1, vtTool, dSafeZ, dSafeAggrBottZ, dStElev, dAppr, vbOut[e])) {
|
||||
m_pMchMgr->SetLastError( 2414, "Error in Pocketing : Approach not computable") ;
|
||||
return false ;
|
||||
}
|
||||
// aggiungo attacco
|
||||
SetFeed( GetStartFeed()) ;
|
||||
if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtExtr, pSrfLeanInOut, vRCrv[e], !m_Params.m_bInvert, bSplitArcs, vbOut[e])) {
|
||||
m_pMchMgr->SetLastError( 2415, "Error in Pocketing : LeadIn not computable") ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// se devo scendere nella stessa posizione... solo collegaento
|
||||
else if ( vbChangedPrec[j-1] && vSfr[j-2]->GetChunkCount() == 1 && vnRegTot[e] == 1) {
|
||||
SetFeed( GetStartFeed()) ;
|
||||
GetCurrPos( ptP1) ;
|
||||
if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtExtr, pSrfLeanInOut, vRCrv[e], !m_Params.m_bInvert, bSplitArcs, vbOut[e])) {
|
||||
m_pMchMgr->SetLastError( 2418, "Error in Pocketing : Link not computable") ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Ricalcolo il punto di attacco sopra al PtStart ( modificato in precedenza dal PtOut) quando :
|
||||
// 1) sono nel primo Step o ...
|
||||
// 2) la superificie è diversa da quello dello step precedente o ...
|
||||
// 3) il numero di chunk allo step precedente è maggiore di 1 o ...
|
||||
// 4) dal primo offset del chunk cc-esimo ottengo più regioni
|
||||
|
||||
if ( ! CalcLeadInStart( ptStart, vtStart, vtExtr, vRCrv[e], ptP1)) {
|
||||
m_pMchMgr->SetLastError( 2415, "Error in Pocketing : LeadIn not computable") ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
// determino elevazione su inizio attacco ( se non trovata, l'elevazione è nStep)
|
||||
double dStElev ;
|
||||
if ( ! GetElevation( m_nPhase, ptStart - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), vtTool, dStElev))
|
||||
dStElev = dStep ;
|
||||
bool bAhUnderRaw = m_bAboveHead && ! m_bAggrBottom && ! m_bTiltingTab &&
|
||||
GetAhPointUnderRaw( ptP1, vtTool, 0, GetRadiusForStartEndElevation(),
|
||||
m_TParams.m_dLen, false, dSafeZ, vtTool, dStElev) ;
|
||||
bool bUhAboveRaw = ! m_bAboveHead &&
|
||||
GetUhPointAboveRaw( ptP1, vtTool, 0, GetRadiusForStartEndElevation(),
|
||||
m_TParams.m_dLen, false, dSafeZ, vtTool, dStElev) ;
|
||||
if ( bAhUnderRaw || bUhAboveRaw || m_bTiltingTab)
|
||||
dStElev = max( dStElev, dStep) ;
|
||||
dStElev -= ( ptP1 - ptStart) * vtExtr ;
|
||||
// se attacco a zigzag o a spirale o a scivolo, l'elevazione va nell'attacco
|
||||
if ( GetLeadInType() == POCKET_LI_ZIGZAG ||
|
||||
GetLeadInType() == POCKET_LI_HELIX ||
|
||||
GetLeadInType() == POCKET_LI_GLIDE) {
|
||||
ptP1 += vtExtr * ( dStElev + LIO_ELEV_TOL) ;
|
||||
dStElev = -LIO_ELEV_TOL ;
|
||||
}
|
||||
// approccio al punto iniziale
|
||||
if ( ! AddApproach( ptP1, vtTool, dSafeZ, dSafeAggrBottZ, dStElev, dAppr, vbOut[e])) {
|
||||
m_pMchMgr->SetLastError( 2414, "Error in Pocketing : Approach not computable") ;
|
||||
return false ;
|
||||
}
|
||||
// aggiungo attacco
|
||||
SetFeed( GetStartFeed()) ;
|
||||
if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtExtr, pSrfLeanInOut, vRCrv[e], !m_Params.m_bInvert, bSplitArcs, vbOut[e])) {
|
||||
m_pMchMgr->SetLastError( 2415, "Error in Pocketing : LeadIn not computable") ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// elaborazioni sulla curva corrente
|
||||
if ( pCurve->GetType() == CRV_LINE) {
|
||||
ICurveLine* pLine = GetCurveLine( pCurve) ;
|
||||
Point3d ptP3 = pLine->GetEnd() ;
|
||||
SetFeed( GetFeed()) ;
|
||||
if ( AddLinearMove( ptP3) == GDB_ID_NULL)
|
||||
return false ;
|
||||
// se prima entità
|
||||
if ( i == 0) {
|
||||
// dati inizio entità
|
||||
Point3d ptStart ;
|
||||
pCurve->GetStartPoint( ptStart) ;
|
||||
Vector3d vtStart ;
|
||||
pCurve->GetStartDir( vtStart) ;
|
||||
// Entrata ...
|
||||
if ( j == 1 || vbChangedPrec[j-1] || vSfr[j-2]->GetChunkCount() > 1 || nRegTot > 1) {
|
||||
// Ricalcolo il punto di attacco sopra al PtStart ( modificato in precedenza dal PtOut) quando :
|
||||
// 1) sono nel primo Step o ...
|
||||
// 2) la superificie è diversa da quello dello step precedente o ...
|
||||
// 3) il numero di chunk allo step precedente è maggiore di 1 o ...
|
||||
// 4) dal primo offset del chunk cc-esimo ottengo più regioni
|
||||
}
|
||||
else if ( pCurve->GetType() == CRV_ARC) {
|
||||
ICurveArc* pArc = GetCurveArc( pCurve) ;
|
||||
Point3d ptCen = pArc->GetCenter() ;
|
||||
double dAngCen = pArc->GetAngCenter() ;
|
||||
Vector3d vtN = pArc->GetNormVersor() ;
|
||||
Point3d ptP3 ;
|
||||
pArc->GetEndPoint( ptP3) ;
|
||||
SetFeed( GetFeed()) ;
|
||||
if ( AddArcMove( ptP3, ptCen, dAngCen, vtN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
// se ultima entità -> passo al chunk cc successivo o allo step sotto
|
||||
if ( i == nMaxInd) {
|
||||
// Uscita ...
|
||||
if ( j < nStep && vSfr[j-1]->GetChunkCount() == 1 && ! vbChangedPrec[j] && vnRegTot[e] == 1) {
|
||||
// Effettuo l'uscita quando :
|
||||
// 1) non sono nello step intermedio e ...
|
||||
// 2) il numero di Chunk allo step attuale è 1 e ...
|
||||
// 3) la superificie non è cambiata dalla precedente e ...
|
||||
// 4) dal primo offset del chunk cc-esimo non si sono create altre regioni da svuotare
|
||||
|
||||
if ( ! CalcLeadInStart( ptStart, vtStart, vtExtr, pRCrv, ptP1)) {
|
||||
m_pMchMgr->SetLastError( 2415, "Error in Pocketing : LeadIn not computable") ;
|
||||
// se necessario ritorno all'inizio
|
||||
if ( nMaxRInd >= 0) {
|
||||
// copio la curva di ritorno
|
||||
PtrOwner<ICurveComposite> pRet( vRCrv[e]->Clone()) ;
|
||||
if ( IsNull( pRet))
|
||||
return false ;
|
||||
}
|
||||
|
||||
// determino elevazione su inizio attacco ( se non trovata, l'elevazione è nStep)
|
||||
double dStElev ;
|
||||
if ( ! GetElevation( m_nPhase, ptStart - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), vtTool, dStElev))
|
||||
dStElev = dStep ;
|
||||
bool bAhUnderRaw = m_bAboveHead && ! m_bAggrBottom && ! m_bTiltingTab &&
|
||||
GetAhPointUnderRaw( ptP1, vtTool, 0, GetRadiusForStartEndElevation(),
|
||||
m_TParams.m_dLen, false, dSafeZ, vtTool, dStElev) ;
|
||||
bool bUhAboveRaw = ! m_bAboveHead &&
|
||||
GetUhPointAboveRaw( ptP1, vtTool, 0, GetRadiusForStartEndElevation(),
|
||||
m_TParams.m_dLen, false, dSafeZ, vtTool, dStElev) ;
|
||||
if ( bAhUnderRaw || bUhAboveRaw || m_bTiltingTab)
|
||||
dStElev = max( dStElev, dStep) ;
|
||||
dStElev -= ( ptP1 - ptStart) * vtExtr ;
|
||||
// se attacco a zigzag o a spirale o a scivolo, l'elevazione va nell'attacco
|
||||
if ( GetLeadInType() == POCKET_LI_ZIGZAG ||
|
||||
GetLeadInType() == POCKET_LI_HELIX ||
|
||||
GetLeadInType() == POCKET_LI_GLIDE) {
|
||||
ptP1 += vtExtr * ( dStElev + LIO_ELEV_TOL) ;
|
||||
dStElev = -LIO_ELEV_TOL ;
|
||||
}
|
||||
// approccio al punto iniziale
|
||||
if ( ! AddApproach( ptP1, vtTool, dSafeZ, dSafeAggrBottZ, dStElev, dAppr, bOutStart || bForcedOutStart)) {
|
||||
m_pMchMgr->SetLastError( 2414, "Error in Pocketing : Approach not computable") ;
|
||||
return false ;
|
||||
}
|
||||
// aggiungo attacco
|
||||
SetFeed( GetStartFeed()) ;
|
||||
if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtExtr, pSrfLeanInOut, pRCrv, !m_Params.m_bInvert, bSplitArcs, bOutStart || bForcedOutStart)) {
|
||||
m_pMchMgr->SetLastError( 2415, "Error in Pocketing : LeadIn not computable") ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// altrimenti solo collegamento
|
||||
else {
|
||||
SetFeed( GetStartFeed()) ;
|
||||
GetCurrPos( ptP1) ;
|
||||
if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtExtr, pSrfLeanInOut, pRCrv, !m_Params.m_bInvert, bSplitArcs, bOutStart || bForcedOutStart)) {
|
||||
m_pMchMgr->SetLastError( 2418, "Error in Pocketing : Link not computable") ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// elaborazioni sulla curva corrente
|
||||
if ( pCurve->GetType() == CRV_LINE) {
|
||||
ICurveLine* pLine = GetCurveLine( pCurve) ;
|
||||
Point3d ptP3 = pLine->GetEnd() ;
|
||||
SetFeed( GetFeed()) ;
|
||||
if ( AddLinearMove( ptP3) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
else if ( pCurve->GetType() == CRV_ARC) {
|
||||
ICurveArc* pArc = GetCurveArc( pCurve) ;
|
||||
Point3d ptCen = pArc->GetCenter() ;
|
||||
double dAngCen = pArc->GetAngCenter() ;
|
||||
Vector3d vtN = pArc->GetNormVersor() ;
|
||||
Point3d ptP3 ;
|
||||
pArc->GetEndPoint( ptP3) ;
|
||||
SetFeed( GetFeed()) ;
|
||||
if ( AddArcMove( ptP3, ptCen, dAngCen, vtN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
// se ultima entità -> passo al chunk cc successivo o allo step sotto
|
||||
if ( i == nMaxInd) {
|
||||
// Uscita ...
|
||||
if ( j < nStep && vSfr[j-1]->GetChunkCount() == 1 && ! vbChangedPrec[j] && nRegTot == 1) {
|
||||
// Effettuo l'uscita quando :
|
||||
// 1) non sono nello step intermedio e ...
|
||||
// 2) il numero di Chunk allo step attuale è 1 e ...
|
||||
// 3) la superificie non è cambiata dalla precedente e ...
|
||||
// 4) dal primo offset del chunk cc-esimo non si sono create altre regioni da svuotare
|
||||
|
||||
// se necessario ritorno all'inizio
|
||||
if ( nMaxRInd >= 0) {
|
||||
// copio la curva di ritorno
|
||||
PtrOwner<ICurveComposite> pRet( pRCrv->Clone()) ;
|
||||
if ( IsNull( pRet))
|
||||
return false ;
|
||||
// aggiungo affondamento
|
||||
//pRet->Translate( vVtTrasl[j-1]) ;
|
||||
// se attacco a scivolo, accorcio della lunghezza dell'attacco
|
||||
if ( GetLeadInType() == POCKET_LI_GLIDE) {
|
||||
double dLen ; pRet->GetLength( dLen) ;
|
||||
if ( dLen > m_Params.m_dLiTang + 10 * EPS_SMALL) {
|
||||
if ( ! pRet->TrimEndAtLen( dLen - m_Params.m_dLiTang))
|
||||
pRet->Clear() ;
|
||||
}
|
||||
else
|
||||
// aggiungo affondamento
|
||||
//pRet->Translate( vVtTrasl[j-1]) ;
|
||||
// se attacco a scivolo, accorcio della lunghezza dell'attacco
|
||||
if ( GetLeadInType() == POCKET_LI_GLIDE) {
|
||||
double dLen ; pRet->GetLength( dLen) ;
|
||||
if ( dLen > m_Params.m_dLiTang + 10 * EPS_SMALL) {
|
||||
if ( ! pRet->TrimEndAtLen( dLen - m_Params.m_dLiTang))
|
||||
pRet->Clear() ;
|
||||
}
|
||||
// emetto
|
||||
SetFeed( GetFeed()) ;
|
||||
if ( pRet->GetCurveCount() > 0 && AddCurveMove( pRet) == GDB_ID_NULL)
|
||||
return false ;
|
||||
else
|
||||
pRet->Clear() ;
|
||||
}
|
||||
// emetto
|
||||
SetFeed( GetFeed()) ;
|
||||
if ( pRet->GetCurveCount() > 0 && AddCurveMove( pRet) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
// atrimenti ultimo step, uscita e retrazione
|
||||
else {
|
||||
// dati fine entità
|
||||
Point3d ptEnd ;
|
||||
pCurve->GetEndPoint( ptEnd) ;
|
||||
Vector3d vtEnd ;
|
||||
pCurve->GetEndDir( vtEnd) ;
|
||||
// aggiungo uscita
|
||||
Point3d ptP1 ;
|
||||
double dEndElev = dElev ;
|
||||
SetFeed( GetEndFeed()) ;
|
||||
if ( ! AddLeadOut( ptEnd, vtEnd, vtExtr, pRCrv, bSplitArcs, false, ptP1, dEndElev, true)) {
|
||||
m_pMchMgr->SetLastError( 2416, "Error in Pocketing : LeadOut not computable") ;
|
||||
return false ;
|
||||
}
|
||||
// aggiungo retrazione
|
||||
if ( ! AddRetract( ptP1, vtTool, dSafeZ, dSafeAggrBottZ, dEndElev, dAppr)) {
|
||||
m_pMchMgr->SetLastError( 2417, "Error in Pocketing : Retract not computable") ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// atrimenti ultimo step, uscita e retrazione
|
||||
else {
|
||||
// dati fine entità
|
||||
Point3d ptEnd ;
|
||||
pCurve->GetEndPoint( ptEnd) ;
|
||||
Vector3d vtEnd ;
|
||||
pCurve->GetEndDir( vtEnd) ;
|
||||
// aggiungo uscita
|
||||
Point3d ptP1 ;
|
||||
double dEndElev = dElev ;
|
||||
SetFeed( GetEndFeed()) ;
|
||||
if ( ! AddLeadOut( ptEnd, vtEnd, vtExtr, vRCrv[e], bSplitArcs, false, ptP1, dEndElev, true)) {
|
||||
m_pMchMgr->SetLastError( 2416, "Error in Pocketing : LeadOut not computable") ;
|
||||
return false ;
|
||||
}
|
||||
// aggiungo retrazione
|
||||
if ( ! AddRetract( ptP1, vtTool, dSafeZ, dSafeAggrBottZ, dEndElev, dAppr)) {
|
||||
m_pMchMgr->SetLastError( 2417, "Error in Pocketing : Retract not computable") ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// aggiorno i dati Spiral
|
||||
vMCrv_step_prec_tot.swap( vMCrv) ;
|
||||
vRCrv_step_prec_tot.swap( vRCrv) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
|
||||
Reference in New Issue
Block a user