EgtMachKernel :
- sistemazioni per scalpellatura e svuotatura.
This commit is contained in:
+374
-291
@@ -42,8 +42,12 @@ using namespace std ;
|
||||
// 2508 = "Error in Pocketing : Entity GetElevation"
|
||||
// 2509 = "Error in Pocketing : missing aggregate from bottom"
|
||||
// 2510 = "Error in Pocketing : path too far from part sides"
|
||||
// 2511 = "Error in Pocketing : Offset not computable"
|
||||
// 2512 = "Error in Pocketing : Toolpath not computable"
|
||||
// 2511 = "Error in Pocketing : toolpath allocation failed"
|
||||
// 2512 = "Error in Pocketing : Offset not computable"
|
||||
// 2513 = "Error in Pocketing : Toolpath not computable"
|
||||
// 2514 = "Error in Pocketing : LeadIn not computable"
|
||||
// 2515 = "Error in Pocketing : LeadOut not computable"
|
||||
// 2516 = "Error in Pocketing : Link not computable"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
USEROBJ_REGISTER( "EMkPocketing", Pocketing) ;
|
||||
@@ -1143,9 +1147,19 @@ Pocketing::ProcessPath( int nPathId, int nPvId, int nClId)
|
||||
SetPathId( nPxId) ;
|
||||
SetToolDir( vtTool) ;
|
||||
|
||||
// Se una sola passata
|
||||
if ( ! AddSpiralIn( pCompo, vtTool, vtExtr, dDepth, dElev, bSplitArcs))
|
||||
return false ;
|
||||
// Eseguo la lavorazione a seconda del tipo
|
||||
switch ( m_Params.m_nSubType) {
|
||||
case POCKET_SUB_ZIGZAG :
|
||||
case POCKET_SUB_ONEWAY :
|
||||
case POCKET_SUB_SPIRALIN :
|
||||
if ( ! AddSpiralIn( pCompo, vtTool, vtExtr, dDepth, dElev, bSplitArcs))
|
||||
return false ;
|
||||
break ;
|
||||
case POCKET_SUB_SPIRALOUT :
|
||||
if ( ! AddSpiralOut( pCompo, vtTool, vtExtr, dDepth, dElev, bSplitArcs))
|
||||
return false ;
|
||||
break ;
|
||||
}
|
||||
|
||||
// assegno al gruppo l'ingombro del percorso di lavoro
|
||||
BBox3d b3Grp ;
|
||||
@@ -1367,9 +1381,326 @@ Pocketing::AddSpiralIn( const ICurveComposite* pCompo, const Vector3d& vtTool, c
|
||||
// lunghezza di approccio/retrazione
|
||||
double dAppr = m_Params.m_dStartPos ;
|
||||
|
||||
// curva di lavorazione
|
||||
// calcolo la spirale dall'esterno all'interno e la curva che unisce inizio e fine
|
||||
PtrOwner<ICurveComposite> pMCrv( CreateCurveComposite()) ;
|
||||
PtrOwner<ICurveComposite> pRCrv( CreateCurveComposite()) ;
|
||||
if ( IsNull( pMCrv) || IsNull( pRCrv)) {
|
||||
m_pMchMgr->SetLastError( 2511, "Error in Pocketing : toolpath allocation failed") ;
|
||||
return false ;
|
||||
}
|
||||
if ( ! CalcSpiral( pCompo, Get( pMCrv), Get( pRCrv)))
|
||||
return false ;
|
||||
|
||||
// determino numero e affondamento degli step
|
||||
int nStep = 1 ;
|
||||
if ( m_Params.m_dStep > 100 * EPS_SMALL)
|
||||
nStep = max( 1, static_cast<int>( ceil( dElev / m_Params.m_dStep))) ;
|
||||
double dStep = dElev / nStep ;
|
||||
|
||||
int nMaxInd = pMCrv->GetCurveCount() - 1 ;
|
||||
int nMaxRInd = pRCrv->GetCurveCount() - 1 ;
|
||||
|
||||
// ciclo sugli step
|
||||
for ( int j = 1 ; j <= nStep ; ++ j) {
|
||||
// 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( ::GetCurve( pCrvC->Clone())) ;
|
||||
if ( IsNull( pCurve))
|
||||
return false ;
|
||||
// aggiungo affondamento
|
||||
pCurve->Translate( - vtTool * ( dDepth - dElev + j * dStep)) ;
|
||||
// se prima entità
|
||||
if ( i == 0 ) {
|
||||
// dati inizio entità
|
||||
Point3d ptStart ;
|
||||
pCurve->GetStartPoint( ptStart) ;
|
||||
Vector3d vtStart ;
|
||||
pCurve->GetStartDir( vtStart) ;
|
||||
// determino inizio attacco
|
||||
Point3d ptP1 ;
|
||||
if ( ! CalcLeadInStart( ptStart, vtStart, vtExtr, ptP1))
|
||||
return false ;
|
||||
// se primo step, approccio e affondo
|
||||
if ( j == 1) {
|
||||
// determino elevazione su inizio attacco
|
||||
double dStElev ;
|
||||
if ( ! GetElevation( m_nPhase, ptStart - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), dStElev))
|
||||
dStElev = dElev ;
|
||||
dStElev -= ( ptP1 - ptStart) * vtExtr ;
|
||||
// approccio al punto iniziale
|
||||
if ( ! AddApproach( ptP1, vtTool, dSafeZ, dStElev, dAppr))
|
||||
return false ;
|
||||
// aggiungo attacco
|
||||
SetFeed( GetStartFeed()) ;
|
||||
if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtExtr, bSplitArcs)) {
|
||||
m_pMchMgr->SetLastError( 2514, "Error in Pocketing : LeadIn not computable") ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// altrimenti solo collegamento
|
||||
else {
|
||||
// per ora solo collegamento diretto !!! da estendere !!!
|
||||
SetFeed( GetStartFeed()) ;
|
||||
if ( AddLinearMove( ptP1) == GDB_ID_NULL) {
|
||||
m_pMchMgr->SetLastError( 2516, "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à
|
||||
if ( i == nMaxInd) {
|
||||
// se step intermedio, ritorno all'inizio direttamente
|
||||
if ( j < nStep) {
|
||||
// ciclo sulle curve elementari del percorso di ritorno
|
||||
for ( int k = 0 ; k <= nMaxRInd ; ++ k) {
|
||||
// curva corrente
|
||||
const ICurve* pCrvR = pRCrv->GetCurve( k) ;
|
||||
// copio la curva
|
||||
PtrOwner<ICurve> pRet( ::GetCurve( pCrvR->Clone())) ;
|
||||
if ( IsNull( pRet))
|
||||
return false ;
|
||||
// aggiungo affondamento
|
||||
pRet->Translate( - vtTool * ( dDepth - dElev + j * dStep)) ;
|
||||
// elaborazioni sulla curva corrente
|
||||
if ( pRet->GetType() == CRV_LINE) {
|
||||
ICurveLine* pLine = GetCurveLine( pRet) ;
|
||||
Point3d ptP3 = pLine->GetEnd() ;
|
||||
SetFeed( GetFeed()) ;
|
||||
if ( AddLinearMove( ptP3) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
else if ( pRet->GetType() == CRV_ARC) {
|
||||
ICurveArc* pArc = GetCurveArc( pRet) ;
|
||||
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 ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// atrimenti ultimo step, uscita e retrazione
|
||||
else {
|
||||
// dati fine entità
|
||||
Point3d ptEnd ;
|
||||
pCurve->GetEndPoint( ptEnd) ;
|
||||
Vector3d vtEnd ;
|
||||
pCurve->GetEndDir( vtEnd) ;
|
||||
// aggiungo uscita
|
||||
Point3d ptP1 ;
|
||||
SetFeed( GetStartFeed()) ;
|
||||
if ( ! AddLeadOut( ptEnd, vtEnd, vtExtr, ptP1)) {
|
||||
m_pMchMgr->SetLastError( 2515, "Error in Pocketing : LeadOut not computable") ;
|
||||
return false ;
|
||||
}
|
||||
// determino elevazione su fine uscita
|
||||
double dEndElev ;
|
||||
if ( ! GetElevation( m_nPhase, ptEnd - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), dEndElev))
|
||||
dEndElev = dElev ;
|
||||
dEndElev -= ( ptP1 - ptEnd) * vtExtr ;
|
||||
// aggiungo retrazione
|
||||
if ( ! AddRetract( ptP1, vtTool, dSafeZ, dEndElev, dAppr))
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Pocketing::AddSpiralOut( const ICurveComposite* pCompo, const Vector3d& vtTool, const Vector3d& vtExtr,
|
||||
double dDepth, double dElev, bool bSplitArcs)
|
||||
{
|
||||
// recupero distanza di sicurezza
|
||||
double dSafeZ = m_pMchMgr->GetCurrMachiningsMgr()->GetSafeZ() ;
|
||||
// lunghezza di approccio/retrazione
|
||||
double dAppr = m_Params.m_dStartPos ;
|
||||
|
||||
// calcolo la spirale dall'interno all'esterno
|
||||
PtrOwner<ICurveComposite> pMCrv( CreateCurveComposite()) ;
|
||||
PtrOwner<ICurveComposite> pRCrv( CreateCurveComposite()) ;
|
||||
if ( IsNull( pMCrv) || IsNull( pRCrv)) {
|
||||
m_pMchMgr->SetLastError( 2511, "Error in Pocketing : toolpath allocation failed") ;
|
||||
return false ;
|
||||
}
|
||||
if ( ! CalcSpiral( pCompo, Get( pMCrv), Get( pRCrv)))
|
||||
return false ;
|
||||
pMCrv->Invert() ;
|
||||
pRCrv->Invert() ;
|
||||
|
||||
// determino numero e affondamento degli step
|
||||
int nStep = 1 ;
|
||||
if ( m_Params.m_dStep > 100 * EPS_SMALL)
|
||||
nStep = max( 1, static_cast<int>( ceil( dElev / m_Params.m_dStep))) ;
|
||||
double dStep = dElev / nStep ;
|
||||
|
||||
int nMaxInd = pMCrv->GetCurveCount() - 1 ;
|
||||
int nMaxRInd = pRCrv->GetCurveCount() - 1 ;
|
||||
|
||||
// ciclo sugli step
|
||||
for ( int j = 1 ; j <= nStep ; ++ j) {
|
||||
// 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( ::GetCurve( pCrvC->Clone())) ;
|
||||
if ( IsNull( pCurve))
|
||||
return false ;
|
||||
// aggiungo affondamento
|
||||
pCurve->Translate( - vtTool * ( dDepth - dElev + j * dStep)) ;
|
||||
// se prima entità
|
||||
if ( i == 0 ) {
|
||||
// dati inizio entità
|
||||
Point3d ptStart ;
|
||||
pCurve->GetStartPoint( ptStart) ;
|
||||
Vector3d vtStart ;
|
||||
pCurve->GetStartDir( vtStart) ;
|
||||
// determino inizio attacco
|
||||
Point3d ptP1 ;
|
||||
if ( ! CalcLeadInStart( ptStart, vtStart, vtExtr, ptP1))
|
||||
return false ;
|
||||
// se primo step, approccio e affondo
|
||||
if ( j == 1) {
|
||||
// determino elevazione su inizio attacco
|
||||
double dStElev ;
|
||||
if ( ! GetElevation( m_nPhase, ptStart - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), dStElev))
|
||||
dStElev = dElev ;
|
||||
dStElev -= ( ptP1 - ptStart) * vtExtr ;
|
||||
// approccio al punto iniziale
|
||||
if ( ! AddApproach( ptP1, vtTool, dSafeZ, dStElev, dAppr))
|
||||
return false ;
|
||||
// aggiungo attacco
|
||||
SetFeed( GetStartFeed()) ;
|
||||
if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtExtr, bSplitArcs)) {
|
||||
m_pMchMgr->SetLastError( 2514, "Error in Pocketing : LeadIn not computable") ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// altrimenti solo collegamento
|
||||
else {
|
||||
// per ora solo collegamento diretto !!! da estendere !!!
|
||||
SetFeed( GetStartFeed()) ;
|
||||
if ( AddLinearMove( ptP1) == GDB_ID_NULL) {
|
||||
m_pMchMgr->SetLastError( 2516, "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à
|
||||
if ( i == nMaxInd) {
|
||||
// se step intermedio, ritorno all'inizio direttamente
|
||||
if ( j < nStep) {
|
||||
// ciclo sulle curve elementari del percorso di ritorno
|
||||
for ( int k = 0 ; k <= nMaxRInd ; ++ k) {
|
||||
// curva corrente
|
||||
const ICurve* pCrvR = pRCrv->GetCurve( k) ;
|
||||
// copio la curva
|
||||
PtrOwner<ICurve> pRet( ::GetCurve( pCrvR->Clone())) ;
|
||||
if ( IsNull( pRet))
|
||||
return false ;
|
||||
// aggiungo affondamento
|
||||
pRet->Translate( - vtTool * ( dDepth - dElev + j * dStep)) ;
|
||||
// elaborazioni sulla curva corrente
|
||||
if ( pRet->GetType() == CRV_LINE) {
|
||||
ICurveLine* pLine = GetCurveLine( pRet) ;
|
||||
Point3d ptP3 = pLine->GetEnd() ;
|
||||
SetFeed( GetFeed()) ;
|
||||
if ( AddLinearMove( ptP3) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
else if ( pRet->GetType() == CRV_ARC) {
|
||||
ICurveArc* pArc = GetCurveArc( pRet) ;
|
||||
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 ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// atrimenti ultimo step, uscita e retrazione
|
||||
else {
|
||||
// dati fine entità
|
||||
Point3d ptEnd ;
|
||||
pCurve->GetEndPoint( ptEnd) ;
|
||||
Vector3d vtEnd ;
|
||||
pCurve->GetEndDir( vtEnd) ;
|
||||
// aggiungo uscita
|
||||
Point3d ptP1 ;
|
||||
SetFeed( GetStartFeed()) ;
|
||||
if ( ! AddLeadOut( ptEnd, vtEnd, vtExtr, ptP1)) {
|
||||
m_pMchMgr->SetLastError( 2515, "Error in Pocketing : LeadOut not computable") ;
|
||||
return false ;
|
||||
}
|
||||
// determino elevazione su fine uscita
|
||||
double dEndElev ;
|
||||
if ( ! GetElevation( m_nPhase, ptEnd - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), dEndElev))
|
||||
dEndElev = dElev ;
|
||||
dEndElev -= ( ptP1 - ptEnd) * vtExtr ;
|
||||
// aggiungo retrazione
|
||||
if ( ! AddRetract( ptP1, vtTool, dSafeZ, dEndElev, dAppr))
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Pocketing::CalcSpiral( const ICurveComposite* pCompo, ICurveComposite* pMCrv, ICurveComposite* pRCrv)
|
||||
{
|
||||
// primo offset pari al raggio utensile + sovramateriale
|
||||
double dOffs = 0.5 * m_TParams.m_dDiam + GetOffsR() ;
|
||||
|
||||
@@ -1383,7 +1714,7 @@ Pocketing::AddSpiralIn( const ICurveComposite* pCompo, const Vector3d& vtTool, c
|
||||
// calcolo
|
||||
OffsetCurve OffsCrv ;
|
||||
if ( ! OffsCrv.Make( pCurr, - dOffs, ICurve::OFF_FILLET)) {
|
||||
m_pMchMgr->SetLastError( 2511, "Error in Pocketing : Offset not computable") ;
|
||||
m_pMchMgr->SetLastError( 2512, "Error in Pocketing : Offset not computable") ;
|
||||
return false ;
|
||||
}
|
||||
// accodo la curva offsettata al percorso di lavoro
|
||||
@@ -1392,8 +1723,14 @@ Pocketing::AddSpiralIn( const ICurveComposite* pCompo, const Vector3d& vtTool, c
|
||||
if ( pMCrv->GetCurveCount() > 0) {
|
||||
Point3d ptStart ;
|
||||
pOffs->GetStartPoint( ptStart) ;
|
||||
// aggiungo al percorso principale
|
||||
pMCrv->AddLine( ptStart) ;
|
||||
// copio nel percorso di ritorno
|
||||
pRCrv->AddCurve( *pMCrv->GetLastCurve()) ;
|
||||
}
|
||||
// se richiesta percorrenza invertita
|
||||
if ( m_Params.m_bInvert)
|
||||
pOffs->Invert() ;
|
||||
// aggiungo la curva
|
||||
pMCrv->AddCurve( Release( pOffs)) ;
|
||||
}
|
||||
@@ -1413,91 +1750,13 @@ Pocketing::AddSpiralIn( const ICurveComposite* pCompo, const Vector3d& vtTool, c
|
||||
|
||||
// verifico il percorso di lavoro
|
||||
if ( pMCrv->GetCurveCount() == 0) {
|
||||
m_pMchMgr->SetLastError( 2512, "Error in Pocketing : Toolpath not computable") ;
|
||||
m_pMchMgr->SetLastError( 2513, "Error in Pocketing : Toolpath not computable") ;
|
||||
return false ;
|
||||
}
|
||||
// compatto e inverto il percorso di ritorno
|
||||
pRCrv->MergeCurves( 10 * EPS_SMALL, 10 * EPS_ANG_SMALL, false) ;
|
||||
pRCrv->Invert() ;
|
||||
|
||||
// ciclo sulle curve elementari
|
||||
int nMaxInd = pMCrv->GetCurveCount() - 1 ;
|
||||
for ( int i = 0 ; i <= nMaxInd ; ++ i) {
|
||||
// curva corrente
|
||||
const ICurve* pCrvC = pMCrv->GetCurve( i) ;
|
||||
// copio la curva
|
||||
PtrOwner<ICurve> pCurve( ::GetCurve( pCrvC->Clone())) ;
|
||||
if ( IsNull( pCurve))
|
||||
return false ;
|
||||
// aggiungo affondamento
|
||||
pCurve->Translate( - vtTool * dDepth) ;
|
||||
// se prima entità, approccio e affondo
|
||||
if ( i == 0) {
|
||||
// dati inizio entità
|
||||
Point3d ptStart ;
|
||||
pCurve->GetStartPoint( ptStart) ;
|
||||
Vector3d vtStart ;
|
||||
pCurve->GetStartDir( vtStart) ;
|
||||
// determino inizio attacco
|
||||
Point3d ptP1 ;
|
||||
if ( ! CalcLeadInStart( ptStart, vtStart, vtExtr, false, ptP1))
|
||||
return false ;
|
||||
// determino elevazione su inizio attacco
|
||||
double dStElev ;
|
||||
if ( ! GetElevation( m_nPhase, ptStart - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), dStElev))
|
||||
dStElev = dElev ;
|
||||
dStElev -= ( ptP1 - ptStart) * vtExtr ;
|
||||
// approccio al punto iniziale
|
||||
if ( ! AddApproach( ptP1, vtTool, dSafeZ, dStElev, dAppr))
|
||||
return false ;
|
||||
// aggiungo attacco
|
||||
SetFeed( GetStartFeed()) ;
|
||||
if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtExtr, false, bSplitArcs)) {
|
||||
LOG_INFO( GetEMkLogger(), "Error in Milling : 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 ;
|
||||
}
|
||||
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à, uscita e retrazione
|
||||
if ( i == nMaxInd) {
|
||||
// dati fine entità
|
||||
Point3d ptEnd ;
|
||||
pCurve->GetEndPoint( ptEnd) ;
|
||||
Vector3d vtEnd ;
|
||||
pCurve->GetEndDir( vtEnd) ;
|
||||
// aggiungo uscita
|
||||
Point3d ptP1 ;
|
||||
SetFeed( GetStartFeed()) ;
|
||||
if ( ! AddLeadOut( ptEnd, vtEnd, vtExtr, false, bSplitArcs, ptP1)) {
|
||||
LOG_INFO( GetEMkLogger(), "Error in Milling : LeadOut not computable") ;
|
||||
return false ;
|
||||
}
|
||||
// determino elevazione su fine uscita
|
||||
double dEndElev ;
|
||||
if ( ! GetElevation( m_nPhase, ptEnd - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), dEndElev))
|
||||
dEndElev = dElev ;
|
||||
dEndElev -= ( ptP1 - ptEnd) * vtExtr ;
|
||||
// aggiungo retrazione
|
||||
if ( ! AddRetract( ptP1, vtTool, dSafeZ, dEndElev, dAppr))
|
||||
return false ;
|
||||
// per lame non è necessario
|
||||
}
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -1628,44 +1887,26 @@ Pocketing::AddRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Pocketing::CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtN, bool bInvert,
|
||||
Point3d& ptP1)
|
||||
Pocketing::CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtN,
|
||||
Point3d& ptP1)
|
||||
{
|
||||
// Assegno tipo e parametri
|
||||
int nType = m_Params.m_nLeadInType ;
|
||||
double dTang = m_Params.m_dLiTang ;
|
||||
double dPerp = 0 ;
|
||||
double dElev = 0 ;
|
||||
// se step invertito
|
||||
if ( bInvert) {
|
||||
switch ( m_Params.m_nLeadOutType) {
|
||||
case MILL_LO_LINEAR : nType = MILL_LI_LINEAR ; break ;
|
||||
case MILL_LO_TANGENT : nType = MILL_LI_TANGENT ; break ;
|
||||
case MILL_LO_GLIDE : nType = MILL_LI_GLIDE ; break ;
|
||||
case MILL_LO_AS_LI : /* resta inalterato */ ; break ;
|
||||
default : nType = MILL_LI_NONE ; break ;
|
||||
}
|
||||
if ( m_Params.m_nLeadOutType != MILL_LO_AS_LI) {
|
||||
dTang = m_Params.m_dLoTang ;
|
||||
dPerp = 0 ;
|
||||
dElev = 0 ;
|
||||
}
|
||||
}
|
||||
double dLen= m_Params.m_dLiTang ;
|
||||
// senso di rotazione da dir tg a dir esterna
|
||||
bool bCcwRot = true ;
|
||||
// Calcolo punto iniziale
|
||||
switch ( nType) {
|
||||
case MILL_LI_NONE :
|
||||
case POCKET_LI_NONE :
|
||||
ptP1 = ptStart ;
|
||||
return true ;
|
||||
case MILL_LI_LINEAR :
|
||||
case MILL_LI_TANGENT : {
|
||||
Vector3d vtPerp = vtStart ;
|
||||
vtPerp.Rotate( vtN, ( bCcwRot ? 90 : - 90)) ;
|
||||
ptP1 = ptStart - vtStart * dTang + vtPerp * dPerp + vtN * dElev ;
|
||||
return true ;
|
||||
}
|
||||
case MILL_LI_GLIDE :
|
||||
case POCKET_LI_GLIDE :
|
||||
|
||||
return false ;
|
||||
case POCKET_LI_ZIGZAG :
|
||||
// !!! DA FARE !!!
|
||||
return false ;
|
||||
case POCKET_LI_HELIX :
|
||||
// !!! DA FARE !!!
|
||||
return false ;
|
||||
default :
|
||||
@@ -1676,98 +1917,29 @@ Pocketing::CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart, con
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Pocketing::AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d& vtStart,
|
||||
const Vector3d& vtN, bool bInvert, bool bSplitArcs)
|
||||
const Vector3d& vtN, bool bSplitArcs)
|
||||
{
|
||||
// Assegno il tipo
|
||||
int nType = m_Params.m_nLeadInType ;
|
||||
// se step invertito
|
||||
if ( bInvert) {
|
||||
switch ( m_Params.m_nLeadOutType) {
|
||||
case MILL_LO_LINEAR : nType = MILL_LI_LINEAR ; break ;
|
||||
case MILL_LO_TANGENT : nType = MILL_LI_TANGENT ; break ;
|
||||
case MILL_LO_GLIDE : nType = MILL_LI_GLIDE ; break ;
|
||||
case MILL_LO_AS_LI : /* resta inalterato */ ; break ;
|
||||
default : nType = MILL_LI_NONE ; break ;
|
||||
}
|
||||
}
|
||||
// se archi da spezzare
|
||||
if ( bSplitArcs) {
|
||||
if ( nType == MILL_LI_TANGENT)
|
||||
nType = MILL_LI_LINEAR ;
|
||||
if ( nType == MILL_LI_HELIX)
|
||||
nType = MILL_LI_ZIGZAG ;
|
||||
if ( nType == POCKET_LI_HELIX)
|
||||
nType = POCKET_LI_ZIGZAG ;
|
||||
}
|
||||
// se parametri tg e perp entrambi nulli, allora nessun attacco
|
||||
// se parametro tg nullo, allora nessun attacco
|
||||
if ( (( ptStart - ptP1) ^ vtN).IsSmall())
|
||||
nType = MILL_LI_NONE ;
|
||||
nType = POCKET_LI_NONE ;
|
||||
// Eseguo a seconda del tipo
|
||||
switch ( nType) {
|
||||
case MILL_LI_NONE :
|
||||
case POCKET_LI_NONE :
|
||||
return true ;
|
||||
case MILL_LI_LINEAR :
|
||||
return ( AddLinearMove( ptStart, MCH_CL_LEADIN) != GDB_ID_NULL) ;
|
||||
case MILL_LI_TANGENT :
|
||||
{
|
||||
PtrOwner<ICurve> pCrv( GetArc2PVN( ptStart, ptP1, - vtStart, vtN)) ;
|
||||
if ( IsNull( pCrv))
|
||||
return false ;
|
||||
pCrv->Invert() ;
|
||||
if ( pCrv->GetType() == CRV_LINE) {
|
||||
ICurveLine* pLine = GetCurveLine( pCrv) ;
|
||||
Point3d ptP3 = pLine->GetEnd() ;
|
||||
return ( AddLinearMove( ptP3, MCH_CL_LEADIN) != GDB_ID_NULL) ;
|
||||
}
|
||||
else if ( pCrv->GetType() == CRV_ARC) {
|
||||
ICurveArc* pArc = GetCurveArc( pCrv) ;
|
||||
Point3d ptCen = pArc->GetCenter() ;
|
||||
double dAngCen = pArc->GetAngCenter() ;
|
||||
Vector3d vtN = pArc->GetNormVersor() ;
|
||||
Point3d ptP3 ;
|
||||
pArc->GetEndPoint( ptP3) ;
|
||||
// se angolo al centro minore del limite, un solo arco
|
||||
const double MAX_ANG_CEN = 150 + EPS_ANG_SMALL ;
|
||||
if ( abs( dAngCen) < MAX_ANG_CEN) {
|
||||
if ( AddArcMove( ptP3, ptCen, dAngCen, vtN, MCH_CL_LEADIN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
// altrimenti due archi
|
||||
else if ( abs( dAngCen) < 2 * MAX_ANG_CEN){
|
||||
Point3d ptMid ;
|
||||
pArc->GetMidPoint( ptMid) ;
|
||||
// prima metà arco
|
||||
if ( AddArcMove( ptMid, ptCen, dAngCen / 2, vtN, MCH_CL_LEADIN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
// seconda metà arco
|
||||
if ( AddArcMove( ptP3, ptCen, dAngCen / 2, vtN, MCH_CL_LEADIN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
// oppure tre archi
|
||||
else {
|
||||
Point3d ptTmp ;
|
||||
// primo terzo
|
||||
pArc->GetPointD1D2( 1. / 3, ICurve::FROM_MINUS, ptTmp) ;
|
||||
if ( AddArcMove( ptTmp, ptCen, dAngCen / 3, vtN, MCH_CL_LEADIN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
// secondo terzo
|
||||
ptCen.z = ptTmp.z ;
|
||||
pArc->GetPointD1D2( 2. / 3, ICurve::FROM_MINUS, ptTmp) ;
|
||||
if ( AddArcMove( ptTmp, ptCen, dAngCen / 3, vtN, MCH_CL_LEADIN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
// ultimo terzo
|
||||
ptCen.z = ptTmp.z ;
|
||||
if ( AddArcMove( ptP3, ptCen, dAngCen / 3, vtN, MCH_CL_LEADIN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
case MILL_LI_GLIDE :
|
||||
case POCKET_LI_GLIDE :
|
||||
// !!! DA FARE !!!
|
||||
return false ;
|
||||
case MILL_LI_ZIGZAG :
|
||||
case POCKET_LI_ZIGZAG :
|
||||
// !!! DA FARE !!!
|
||||
return false ;
|
||||
case MILL_LI_HELIX :
|
||||
case POCKET_LI_HELIX :
|
||||
// !!! DA FARE !!!
|
||||
return false ;
|
||||
default :
|
||||
@@ -1778,113 +1950,24 @@ Pocketing::AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Pocketing::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d& vtN,
|
||||
bool bInvert, bool bSplitArcs, Point3d& ptP1)
|
||||
Point3d& ptP1)
|
||||
{
|
||||
// assegno i parametri
|
||||
int nType = m_Params.m_nLeadOutType ;
|
||||
double dTang = m_Params.m_dLoTang ;
|
||||
double dPerp = 0 ;
|
||||
double dElev = 0 ;
|
||||
// se uscita come ingresso o step invertito
|
||||
if ( nType == MILL_LO_AS_LI || bInvert) {
|
||||
switch ( m_Params.m_nLeadInType) {
|
||||
case MILL_LI_LINEAR : nType = MILL_LO_LINEAR ; break ;
|
||||
case MILL_LI_TANGENT : nType = MILL_LO_TANGENT ; break ;
|
||||
case MILL_LI_GLIDE : nType = MILL_LO_GLIDE ; break ;
|
||||
case MILL_LI_ZIGZAG : nType = MILL_LO_LINEAR ; break ;
|
||||
case MILL_LI_HELIX : nType = MILL_LO_TANGENT ; break ;
|
||||
default : nType = MILL_LO_NONE ; break ;
|
||||
}
|
||||
dTang = m_Params.m_dLiTang ;
|
||||
dPerp = 0 ;
|
||||
dElev = 0 ;
|
||||
}
|
||||
if ( bSplitArcs) {
|
||||
if ( nType == MILL_LO_TANGENT)
|
||||
nType = MILL_LO_LINEAR ;
|
||||
}
|
||||
// se parametri nulli, allora nessuna uscita
|
||||
if ( abs( dTang) < EPS_SMALL && abs( dPerp) < EPS_SMALL )
|
||||
nType = MILL_LO_NONE ;
|
||||
// se parametrt tg nullo, allora nessuna uscita
|
||||
if ( abs( dTang) < EPS_SMALL)
|
||||
nType = POCKET_LO_NONE ;
|
||||
// senso di rotazione da dir tg a dir esterna
|
||||
bool bCcwRot = true ;
|
||||
// eseguo a seconda del tipo
|
||||
switch ( nType) {
|
||||
case MILL_LO_NONE :
|
||||
case POCKET_LO_NONE :
|
||||
ptP1 = ptEnd ;
|
||||
return true ;
|
||||
case MILL_LO_LINEAR :
|
||||
{
|
||||
if ( dTang < 10 * EPS_SMALL && abs( dPerp) < EPS_SMALL)
|
||||
return false ;
|
||||
Vector3d vtPerp = vtEnd ;
|
||||
vtPerp.Rotate( vtN, ( bCcwRot ? 90 : - 90)) ;
|
||||
ptP1 = ptEnd + vtEnd * dTang + vtPerp * dPerp + vtN * dElev ;
|
||||
return ( AddLinearMove( ptP1, MCH_CL_LEADOUT) != GDB_ID_NULL) ;
|
||||
}
|
||||
case MILL_LO_TANGENT :
|
||||
{
|
||||
// calcolo punto finale dell'uscita
|
||||
if ( dTang < 10 * EPS_SMALL && abs( dPerp) < EPS_SMALL)
|
||||
return false ;
|
||||
Vector3d vtPerp = vtEnd ;
|
||||
vtPerp.Rotate( vtN, ( bCcwRot ? 90 : - 90)) ;
|
||||
ptP1 = ptEnd + vtEnd * dTang + vtPerp * dPerp + vtN * dElev ;
|
||||
// inserisco uscita
|
||||
PtrOwner<ICurve> pCrv( GetArc2PVN( ptEnd, ptP1, vtEnd, vtN)) ;
|
||||
if ( IsNull( pCrv))
|
||||
return false ;
|
||||
if ( pCrv->GetType() == CRV_LINE) {
|
||||
ICurveLine* pLine = GetCurveLine( pCrv) ;
|
||||
Point3d ptP3 = pLine->GetEnd() ;
|
||||
return ( AddLinearMove( ptP3, MCH_CL_LEADOUT) != GDB_ID_NULL) ;
|
||||
}
|
||||
else if ( pCrv->GetType() == CRV_ARC) {
|
||||
ICurveArc* pArc = GetCurveArc( pCrv) ;
|
||||
Point3d ptCen = pArc->GetCenter() ;
|
||||
double dAngCen = pArc->GetAngCenter() ;
|
||||
Vector3d vtN = pArc->GetNormVersor() ;
|
||||
Point3d ptP3 ;
|
||||
pArc->GetEndPoint( ptP3) ;
|
||||
// se angolo al centro minore del limite, un solo arco
|
||||
const double MAX_ANG_CEN = 150 + EPS_ANG_SMALL ;
|
||||
if ( abs( dAngCen) < MAX_ANG_CEN) {
|
||||
if ( AddArcMove( ptP3, ptCen, dAngCen, vtN, MCH_CL_LEADOUT) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
// altrimenti due archi
|
||||
else if ( abs( dAngCen) < 2 * MAX_ANG_CEN){
|
||||
Point3d ptMid ;
|
||||
pArc->GetMidPoint( ptMid) ;
|
||||
// prima metà arco
|
||||
if ( AddArcMove( ptMid, ptCen, dAngCen / 2, vtN, MCH_CL_LEADOUT) == GDB_ID_NULL)
|
||||
return false ;
|
||||
// seconda metà arco
|
||||
ptCen.z = ptMid.z ;
|
||||
if ( AddArcMove( ptP3, ptCen, dAngCen / 2, vtN, MCH_CL_LEADOUT) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
// oppure tre archi
|
||||
else {
|
||||
Point3d ptTmp ;
|
||||
// primo terzo
|
||||
pArc->GetPointD1D2( 1. / 3, ICurve::FROM_MINUS, ptTmp) ;
|
||||
if ( AddArcMove( ptTmp, ptCen, dAngCen / 3, vtN, MCH_CL_LEADOUT) == GDB_ID_NULL)
|
||||
return false ;
|
||||
// secondo terzo
|
||||
ptCen.z = ptTmp.z ;
|
||||
pArc->GetPointD1D2( 2. / 3, ICurve::FROM_MINUS, ptTmp) ;
|
||||
if ( AddArcMove( ptTmp, ptCen, dAngCen / 3, vtN, MCH_CL_LEADOUT) == GDB_ID_NULL)
|
||||
return false ;
|
||||
// ultimo terzo
|
||||
ptCen.z = ptTmp.z ;
|
||||
if ( AddArcMove( ptP3, ptCen, dAngCen / 3, vtN, MCH_CL_LEADOUT) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
case MILL_LO_GLIDE :
|
||||
case POCKET_LO_GLIDE :
|
||||
// !!! DA FARE !!!
|
||||
return false ;
|
||||
default :
|
||||
|
||||
Reference in New Issue
Block a user