diff --git a/EgtMachKernel.rc b/EgtMachKernel.rc index 5a9c2d4..8c23b91 100644 Binary files a/EgtMachKernel.rc and b/EgtMachKernel.rc differ diff --git a/FiveAxisMilling.cpp b/FiveAxisMilling.cpp index 849649e..7a84fa1 100644 --- a/FiveAxisMilling.cpp +++ b/FiveAxisMilling.cpp @@ -40,6 +40,7 @@ using namespace std ; // 3307 = "Error in FiveAxisMilling : link outstroke xx" // 3308 = "Error in FiveAxisMilling : post apply not calculable" // 3309 = "Error in FiveAxisMilling : Tool loading failed" +// 3310 = "Error in FiveAxisMilling : aggregate from bottom not allowed" // 3351 = "Warning in FiveAxisMilling : Skipped entity (xx)" // 3352 = "Warning in FiveAxisMilling : No machinable path" // 3353 = "Warning in FiveAxisMilling : Tool name changed (xx)" @@ -555,6 +556,12 @@ FiveAxisMilling::Apply( bool bRecalc, bool bPostApply) return false ; } + // non è prevista fresatura 5 assi con aggregato da sotto + if ( IsAggrBottom( m_TParams.m_sHead)) { + m_pMchMgr->SetLastError( 3310, "Error in FiveAxisMilling : aggregate from bottom not allowed") ; + return false ; + } + // verifico se necessario continuare nell'aggiornamento if ( ! bRecalc && ! bToolChanged && ( m_nStatus == MCH_ST_OK || ( ! bPostApply && m_nStatus == MCH_ST_NO_POSTAPPL))) { diff --git a/Generator.cpp b/Generator.cpp index 264d683..3dc0a58 100644 --- a/Generator.cpp +++ b/Generator.cpp @@ -53,8 +53,8 @@ Generator::Run( const string& sCncFile, const string& sInfo) int nRet = GetEGnKeyOptions( KEY_BASELIB_PROD, KEY_BASELIB_VER, KEY_BASELIB_LEV, nOpt1, nOpt2, nOptExpDays) ; if ( ! GetEMkNetHwKey()) - int nRet = GetKeyOptions( GetEMkKey(), KEY_BASELIB_PROD, KEY_BASELIB_VER, KEY_BASELIB_LEV, - nOpt1, nOpt2, nOptExpDays) ; + nRet = GetKeyOptions( GetEMkKey(), KEY_BASELIB_PROD, KEY_BASELIB_VER, KEY_BASELIB_LEV, + nOpt1, nOpt2, nOptExpDays) ; // Verifica della abilitazione bool bMinTime = false ; diff --git a/Pocketing.cpp b/Pocketing.cpp index 008ec25..7d8f685 100644 --- a/Pocketing.cpp +++ b/Pocketing.cpp @@ -140,10 +140,16 @@ Pocketing::Dump( string& sOut, bool bMM, const char* szNewLine) const sOut += GetClassName() + "[mm]" + szNewLine ; sOut += KEY_PHASE + EQUAL + ToString( m_nPhase) + szNewLine ; sOut += KEY_IDS + EQUAL + ToString( m_vId) + szNewLine ; - for ( int i = 0 ; i < m_Params.GetSize() ; ++ i) - sOut += m_Params.ToString( i) + szNewLine ; - for ( int i = 0 ; i < m_TParams.GetSize() ; ++ i) - sOut += m_TParams.ToString( i) + szNewLine ; + for ( int i = 0 ; i < m_Params.GetSize() ; ++ i) { + string sTmp = m_Params.ToString( i) ; + if ( ! IsEmptyOrSpaces( sTmp)) + sOut += sTmp + szNewLine ; + } + for ( int i = 0 ; i < m_TParams.GetSize() ; ++ i) { + string sTmp = m_TParams.ToString( i) ; + if ( ! IsEmptyOrSpaces( sTmp)) + sOut += sTmp + szNewLine ; + } sOut += KEY_NUM + EQUAL + ToString( m_nPockets) + szNewLine ; sOut += KEY_STAT + EQUAL + ToString( m_nStatus) + szNewLine ; diff --git a/SurfFinishing.cpp b/SurfFinishing.cpp index 71e5ff5..c89e335 100644 --- a/SurfFinishing.cpp +++ b/SurfFinishing.cpp @@ -62,6 +62,7 @@ using namespace std ; // 3119 = "Error in SurfFinishing : link outstroke" // 3120 = "Error in SurfFinishing : post apply not calculable" // 3121 = "Error in SurfFinishing : Linear Approx not computable" +// 3122 = "Error in SurfFinishing : aggregate from bottom not allowed" // 3151 = "Warning in SurfFinishing : Skipped entity (xx)" // 3152 = "Warning in SurfFinishing : No machinable path" // 3153 = "Warning in SurfFinishing : Tool name changed (xx)" @@ -494,6 +495,12 @@ SurfFinishing::Apply( bool bRecalc, bool bPostApply) return false ; } + // non è prevista finitura superficie con aggregato da sotto + if ( IsAggrBottom( m_TParams.m_sHead)) { + m_pMchMgr->SetLastError( 3122, "Error in SurfFinishing : aggregate from bottom not allowed") ; + return false ; + } + // verifico se necessario continuare nell'aggiornamento if ( ! bRecalc && ! bToolChanged && ( m_nStatus == MCH_ST_OK || ( ! bPostApply && m_nStatus == MCH_ST_NO_POSTAPPL))) { @@ -1230,11 +1237,14 @@ SurfFinishing::ProcessPath( int nPathId, int nPvId, int nClId) // Eseguo la lavorazione a seconda del tipo double dElev = dDepth ; switch ( m_Params.m_nSubType) { - case SURFFIN_SUB_ONEWAY : case SURFFIN_SUB_ZIGZAG : if ( ! AddZigZag( pCAvTlStm, frSurf, pCompo, vtTool, vtExtr, dDepth, dElev, bSplitArcs, bSkipMaxDown)) return false ; break ; + case SURFFIN_SUB_ONEWAY : + if ( ! AddOneWay( pCAvTlStm, frSurf, pCompo, vtTool, vtExtr, dDepth, dElev, bSplitArcs, bSkipMaxDown)) + return false ; + break ; case SURFFIN_SUB_SPIRALIN : if ( ! AddSpiral( pCAvTlStm, frSurf, pCompo, vtTool, vtExtr, dDepth, dElev, bSplitArcs, true)) return false ; @@ -1309,7 +1319,6 @@ SurfFinishing::AddZigZag( ICAvToolSurfTm* pCAvTlStm, const Frame3d& frSurf, { // recupero distanze di sicurezza double dSafeZ = m_pMchMgr->GetCurrMachiningsMgr()->GetSafeZ() ; - double dSafeAggrBottZ = m_pMchMgr->GetCurrMachiningsMgr()->GetSafeAggrBottZ() ; // lunghezza di approccio/retrazione double dAppr = m_Params.m_dStartPos ; @@ -1465,10 +1474,19 @@ SurfFinishing::AddZigZag( ICAvToolSurfTm* pCAvTlStm, const Frame3d& frSurf, pCurve->GetStartPoint( ptStart) ; Vector3d vtStart ; pCurve->GetStartDir( vtStart) ; + // vettore tangente iniziale non deve salire rispetto a estrusione (poi si prende opposto) + double dStartOnExtr = vtStart * vtExtr ; + if ( dStartOnExtr > 0) { + vtStart -= dStartOnExtr * vtExtr ; + vtStart.Normalize() ; + } // determino inizio attacco Point3d ptP1 ; if ( ! CalcLeadInStart( ptStart, vtStart, vtExtr, ptP1)) return false ; + // eventuale correzione inizio attacco per evitare interferenze + if ( ! GetLastGoodPoint( pCAvTlStm, frSurf, ptStart, ptP1, vtTool, ptP1)) + return false ; // determino elevazione su inizio attacco double dStElev ; if ( ! GetElevation( m_nPhase, ptStart - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), vtTool, dStElev)) @@ -1512,17 +1530,30 @@ SurfFinishing::AddZigZag( ICAvToolSurfTm* pCAvTlStm, const Frame3d& frSurf, pCurve->GetEndPoint( ptEnd) ; Vector3d vtEnd ; pCurve->GetEndDir( vtEnd) ; - // determino elevazione su uscita - double dEndElev ; - if ( ! GetElevation( m_nPhase, ptEnd - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), vtTool, dEndElev)) - dEndElev = dElev ; - // aggiungo uscita + // vettore tangente finale non deve scendere rispetto a estrusione + double dEndOnExtr = vtEnd * vtExtr ; + if ( dEndOnExtr < 0) { + vtEnd -= dEndOnExtr * vtExtr ; + vtEnd.Normalize() ; + } + // determino fine uscita Point3d ptP1 ; + if ( ! CalcLeadOutEnd( ptEnd, vtEnd, vtExtr, ptP1)) + return false ; + // eventuale correzione fine uscita per evitare interferenze + if ( ! GetLastGoodPoint( pCAvTlStm, frSurf, ptEnd, ptP1, vtTool, ptP1)) + return false ; + // aggiungo uscita SetFeed( GetEndFeed()) ; - if ( ! AddLeadOut( ptEnd, vtEnd, vtExtr, ptP1, bSplitArcs)) { + if ( ! AddLeadOut( ptEnd, vtEnd, ptP1, vtExtr, bSplitArcs)) { m_pMchMgr->SetLastError( 3114, "Error in SurfFinishing : LeadOut not computable") ; return false ; } + // determino elevazione su fine uscita + double dEndElev ; + if ( ! GetElevation( m_nPhase, ptEnd - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), vtTool, dEndElev)) + dEndElev = dElev ; + dEndElev -= ( ptP1 - ptEnd) * vtExtr ; // se non è ultimo tratto, aggiungo retrazione di collegamento if ( k < int( vpCrvs.size()) - 1) { if ( ! AddLinkRetract( ptP1, vtTool, dSafeZ, dEndElev, dAppr)) { @@ -1746,6 +1777,393 @@ SurfFinishing::CalcZigZag( const ICurveComposite* pOffs, return true ; } +//---------------------------------------------------------------------------- +bool +SurfFinishing::AddOneWay( ICAvToolSurfTm* pCAvTlStm, const Frame3d& frSurf, + const ICurveComposite* pCompo, const Vector3d& vtTool, const Vector3d& vtExtr, + double dDepth, double dElev, bool bSplitArcs, bool bSkipMaxDown) +{ + // recupero distanze di sicurezza + double dSafeZ = m_pMchMgr->GetCurrMachiningsMgr()->GetSafeZ() ; + // lunghezza di approccio/retrazione + double dAppr = m_Params.m_dStartPos ; + + // calcolo curva offsettata del raggio utensile + double dOffs = m_Params.m_dOverlap - 0.5 * m_TParams.m_dDiam ; + OffsetCurve OffsCrv ; + if ( ! OffsCrv.Make( pCompo, dOffs, ICurve::OFF_FILLET)) { + m_pMchMgr->SetLastError( 3109, "Error in SurfFinishing : Offset not computable") ; + return false ; + } + + // ciclo sulle curve risultanti + bool bStart = true ; + while ( OffsCrv.GetCurveCount() > 0) { + // recupero la prima curva di offset + PtrOwner pOffs ; + if ( ! pOffs.Set( ConvertCurveToComposite( OffsCrv.GetLongerCurve()))) { + m_pMchMgr->SetLastError( 3110, "Error in SurfFinishing : Toolpath not computable") ; + return false ; + } + // determino il riferimento di base e il box della svuotatura + Frame3d frPocket ; + Point3d ptCen ; pCompo->GetCentroid( ptCen) ; + frPocket.Set( ptCen, vtExtr) ; + frPocket.Rotate( ptCen, vtExtr, m_Params.m_dSideAngle) ; + pOffs->ToLoc( frPocket) ; + // calcolo i percorsi di svuotatura + ICRVCOMPOPOVECTOR vpCrvs ; + if ( ! CalcOneWay( pOffs, vpCrvs)) + return false ; + // ciclo sui percorsi + double dProgCoeff = 1. / max( int( vpCrvs.size()), 1) ; + for ( int k = 0 ; k < int( vpCrvs.size()) ; ++ k) { + // li correggo per non interferire con le superfici + if ( pCAvTlStm != nullptr) { + // approssimo la curva con una polilinea + PolyLine PL ; + if ( ! vpCrvs[k]->ApproxWithLines( LIN_TOL_STD, ANG_TOL_STD_DEG, ICurve::APL_SPECIAL, PL)) + return false ; + // eventuale aggiunta di punti per garantire max distanza + const double MIN_DIST = 1. ; + const double MAX_DIST = 50. ; + double dDist = Clamp( m_TParams.m_dDiam / 2, MIN_DIST, MAX_DIST) ; + if ( ! PL.AdjustForMaxSegmentLen( dDist)) + return false ; + // porto nel riferimento delle superfici + PL.LocToLoc( frPocket, frSurf) ; + // porto i dati geometrici in locale alle superfici + Vector3d vtAxL = vtTool ; + vtAxL.ToLoc( frSurf) ; + Vector3d vtMoveL = vtAxL ; + // traslo della lunghezza utensile diminuita dell'affondamento + PL.Translate( vtAxL * ( m_TParams.m_dLen - dDepth)) ; + // eseguo CAv + if ( ! pCAvTlStm->TestPath( PL.GetUPointList(), vtAxL, vtMoveL, m_Params.m_dApprox, ( k + 1) * dProgCoeff)) + return false ; + // contro-traslo della lunghezza utensile + PL.Translate( - vtAxL * m_TParams.m_dLen) ; + // riporto la polilinea nel riferimento della curva + PL.LocToLoc( frSurf, frPocket) ; + // elimino i punti allineati + PL.RemoveAlignedPoints( 0.8 * m_Params.m_dApprox) ; + // se richiesto, elimino i punti al massimo affondamento + if ( bSkipMaxDown) { + PNTULIST& vPntU = PL.GetUPointList() ; + bool bPrevDwn = true ; + Point3d ptPrev = P_INVALID ; + auto currPU = vPntU.begin() ; + while ( currPU != vPntU.end()) { + auto nextPU = next( currPU) ; + bool bNext = ( nextPU != vPntU.end()) ; + bool bNextDown = ( bNext ? nextPU->second > -m_Params.m_dApprox : true) ; + // punto corrente è al minimo + if ( currPU->second > -m_Params.m_dApprox) { + // se precedente e successivo al minimo, cancello e basta + if ( bPrevDwn && bNextDown) { + if ( ! ptPrev.IsValid() || abs( currPU->first.y - ptPrev.y) > 10 * EPS_SMALL) + ptPrev = currPU->first ; + currPU = vPntU.erase( currPU) ; + bPrevDwn = true ; + } + // se precedente ok e successivo al minimo, aggiungo opportuno movimento di uscita + else if ( ! bPrevDwn && bNextDown && bNext) { + Vector3d vtDir = nextPU->first - currPU->first ; + double dMove = vtDir.Len() ; + if ( dMove > 100 * EPS_SMALL) { + vtDir /= dMove ; + dMove = min( dMove, 2.) ; + Point3d ptNew = currPU->first + vtDir * dMove ; + ptPrev = ptNew ; + currPU = next( vPntU.insert( nextPU, { ptNew, 0})) ; + bPrevDwn = true ; + } + else { + ptPrev = currPU->first ; + currPU = nextPU ; + bPrevDwn = false ; + } + } + // se precedente al minimo e successivo ok, aggiungo opportuno movimento di ingresso + else if ( bPrevDwn && ptPrev.IsValid() && ! bNextDown) { + Vector3d vtDir = currPU->first - ptPrev ; + double dMove = vtDir.Len() ; + if ( dMove > 9 * EPS_SMALL) { + vtDir /= dMove ; + dMove = min( dMove, 2.) ; + Point3d ptNew = currPU->first - vtDir * dMove ; + vPntU.insert( currPU, { ptNew, 0}) ; + ptPrev = currPU->first ; + currPU = nextPU ; + } + else { + ptPrev = currPU->first ; + currPU = nextPU ; + } + bPrevDwn = true ; + } + // altrimenti va tenuto + else { + ptPrev = currPU->first ; + currPU = nextPU ; + bPrevDwn = true ; + } + } + // punto corrente sulla superficie + else { + ptPrev = currPU->first ; + currPU = nextPU ; + bPrevDwn = false ; + } + } + // se eliminati tutti i punti passo oltre + if ( PL.GetLineNbr() == 0) + continue ; + } + // creo una curva composita a partire dalla polilinea + PtrOwner< ICurveComposite> pCompo( CreateCurveComposite()) ; + if ( IsNull( pCompo) || ! pCompo->FromPolyLine( PL)) + return false ; + // sostituisco la vecchia curva con la nuova + vpCrvs[k].Set( pCompo) ; + } + // ciclo sulle curve elementari + int nMaxInd = vpCrvs[k]->GetCurveCount() - 1 ; + for ( int i = 0 ; i <= nMaxInd ; ++ i) { + // curva corrente + const ICurve* pCrvC = vpCrvs[k]->GetCurve( i) ; + // copio la curva + PtrOwner pCurve( pCrvC->Clone()) ; + if ( IsNull( pCurve)) + return false ; + pCurve->ToGlob( frPocket) ; + // se prima entità + if ( i == 0 ) { + // dati inizio entità + Point3d ptStart ; + pCurve->GetStartPoint( ptStart) ; + Vector3d vtStart ; + pCurve->GetStartDir( vtStart) ; + // vettore tangente iniziale non deve salire rispetto a estrusione (poi si prende opposto) + double dStartOnExtr = vtStart * vtExtr ; + if ( dStartOnExtr > 0) { + vtStart -= dStartOnExtr * vtExtr ; + vtStart.Normalize() ; + } + // determino inizio attacco + Point3d ptP1 ; + if ( ! CalcLeadInStart( ptStart, vtStart, vtExtr, ptP1)) + return false ; + // eventuale correzione inizio attacco per evitare interferenze + if ( ! GetLastGoodPoint( pCAvTlStm, frSurf, ptStart, ptP1, vtTool, ptP1)) + return false ; + // determino elevazione su inizio attacco + double dStElev ; + if ( ! GetElevation( m_nPhase, ptStart - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), vtTool, dStElev)) + dStElev = dElev ; + dStElev -= ( ptP1 - ptStart) * vtExtr ; + // se inizio, approccio globale al punto iniziale + if ( bStart) { + if ( ! AddApproach( ptP1, vtTool, dSafeZ, dStElev, dAppr)) { + m_pMchMgr->SetLastError( 3111, "Error in SurfFinishing : Approach not computable") ; + return false ; + } + bStart = false ; + } + // altrimenti, approccio di collegamento + else { + if ( ! AddLinkApproach( ptP1, vtTool, dSafeZ, dStElev, dAppr)) { + m_pMchMgr->SetLastError( 3112, "Error in SurfFinishing : Link not computable") ; + return false ; + } + } + // aggiungo attacco + SetFeed( GetStartFeed()) ; + if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtExtr, bSplitArcs)) { + m_pMchMgr->SetLastError( 3113, "Error in SurfFinishing : LeadIn not computable") ; + return false ; + } + } + // elaborazioni sulla curva corrente (sempre un segmento di retta) + ICurveLine* pLine = GetCurveLine( pCurve) ; + if ( pLine == nullptr) + return false ; + Point3d ptP3 = pLine->GetEnd() ; + Vector3d vtMove ; pLine->GetStartDir( vtMove) ; + SetFeed( GetRightFeed( vtMove, vtTool)) ; + if ( AddLinearMove( ptP3) == GDB_ID_NULL) + return false ; + // se ultima entità + if ( i == nMaxInd) { + // dati fine entità + Point3d ptEnd ; + pCurve->GetEndPoint( ptEnd) ; + Vector3d vtEnd ; + pCurve->GetEndDir( vtEnd) ; + // vettore tangente finale non deve scendere rispetto a estrusione + double dEndOnExtr = vtEnd * vtExtr ; + if ( dEndOnExtr < 0) { + vtEnd -= dEndOnExtr * vtExtr ; + vtEnd.Normalize() ; + } + // determino fine uscita + Point3d ptP1 ; + if ( ! CalcLeadOutEnd( ptEnd, vtEnd, vtExtr, ptP1)) + return false ; + // eventuale correzione fine uscita per evitare interferenze + if ( ! GetLastGoodPoint( pCAvTlStm, frSurf, ptEnd, ptP1, vtTool, ptP1)) + return false ; + // aggiungo uscita + SetFeed( GetEndFeed()) ; + if ( ! AddLeadOut( ptEnd, vtEnd, ptP1, vtExtr, bSplitArcs)) { + m_pMchMgr->SetLastError( 3114, "Error in SurfFinishing : LeadOut not computable") ; + return false ; + } + // determino elevazione su fine uscita + double dEndElev ; + if ( ! GetElevation( m_nPhase, ptEnd - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), vtTool, dEndElev)) + dEndElev = dElev ; + dEndElev -= ( ptP1 - ptEnd) * vtExtr ; + // se non è ultimo tratto, aggiungo retrazione di collegamento + if ( k < int( vpCrvs.size()) - 1) { + if ( ! AddLinkRetract( ptP1, vtTool, dSafeZ, dEndElev, dAppr)) { + m_pMchMgr->SetLastError( 3112, "Error in SurfFinishing : Link not computable") ; + return false ; + } + } + // altrimenti aggiungo retrazione finale + else { + if ( ! AddRetract( ptP1, vtTool, dSafeZ, dEndElev, dAppr)) { + m_pMchMgr->SetLastError( 3115, "Error in SurfFinishing : Retract not computable") ; + return false ; + } + } + } + } + } + } + + return true ; +} + +//---------------------------------------------------------------------------- +bool +SurfFinishing::CalcOneWay( const ICurveComposite* pOffs, + ICRVCOMPOPOVECTOR& vpCrvs) +{ + // ingombro del contorno offsettato + BBox3d b3Pocket ; + pOffs->GetLocalBBox( b3Pocket) ; + Point3d ptMin ; double dDimX, dDimY, dDimZ ; + b3Pocket.GetMinDim( ptMin, dDimX, dDimY, dDimZ) ; + + // lunghezza del contorno offsettato + double dLen ; pOffs->GetLength( dLen) ; + + // passi in Y + int nYStep = static_cast( ceil( ( dDimY - 20 * EPS_SMALL) / GetSideStep())) ; + double dYStep = ( nYStep > 0 ? ( dDimY - 20 * EPS_SMALL) / nYStep : 0) ; + + // tratto valido + struct Section { + bool bActive ; + Point3d ptS ; + Point3d ptE ; + double dOs ; + double dOe ; + } ; + // raccolta di tratti + typedef vector> VECVECSECT ; + + VECVECSECT vvSec ; + vvSec.resize( nYStep + 1) ; + + // calcolo le linee di svuotatura + int nCount = 0 ; + for ( int i = 0 ; i <= nYStep ; ++ i) { + // definisco la linea + PtrOwner pLine( CreateCurveLine()) ; + const double EXP_LEN = 1.0 ; + Point3d ptStart( ptMin.x - EXP_LEN, ptMin.y + 10 * EPS_SMALL + i * dYStep, ptMin.z + dDimZ) ; + if ( IsNull( pLine) || ! pLine->SetPVL( ptStart, X_AX, dDimX + 2 * EXP_LEN)) { + m_pMchMgr->SetLastError( 3110, "Error in SurfFinishing : Toolpath not computable") ; + return false ; + } + // calcolo la classificazione della curva rispetto al contorno esterno offsettato + IntersCurveCurve intCC( *pLine, *pOffs) ; + CRVCVECTOR ccClass ; + if ( ! intCC.GetCurveClassification( 0, EPS_SMALL, ccClass)) { + m_pMchMgr->SetLastError( 3110, "Error in SurfFinishing : Toolpath not computable") ; + return false ; + } + // determino gli intervalli di curva da conservare + Intervals inOk ; + for ( auto& ccOne : ccClass) { + if ( ccOne.nClass == CRVC_IN || ccOne.nClass == CRVC_ON_P || ccOne.nClass == CRVC_ON_M) + inOk.Add( ccOne.dParS, ccOne.dParE) ; + } + // inserisco i tratti validi (sempre secondo X+) + double dParS, dParE ; + bool bFound = inOk.GetFirst( dParS, dParE) ; + while ( bFound) { + // determino i dati della sezione + Section Sect ; + Sect.bActive = true ; + pLine->GetPointD1D2( dParS, ICurve::FROM_PLUS, Sect.ptS) ; + pLine->GetPointD1D2( dParE, ICurve::FROM_MINUS, Sect.ptE) ; + pOffs->GetParamAtPoint( Sect.ptS, Sect.dOs, 10 * EPS_SMALL) ; + pOffs->GetParamAtPoint( Sect.ptE, Sect.dOe, 10 * EPS_SMALL) ; + // inserisco nel contenitore + vvSec[i].emplace_back( Sect) ; + ++ nCount ; + // recupero successivo intervallo + bFound = inOk.GetNext( dParS, dParE) ; + } + } + + // creo i percorsi di svuotatura + vpCrvs.reserve( nCount) ; + int nI = -1, nJ = -1 ; + while ( true) { + // se sezione non valida + if ( nI < 0 || nJ < 0) { + // ricerco la prima valida + for ( int k = 0 ; k < int( vvSec.size()) && nI < 0 ; ++ k) { + for ( int l = 0 ; l < int( vvSec[k].size()) && nJ < 0 ; ++ l) { + if ( vvSec[k][l].bActive) { + nI = k ; + nJ = l ; + } + } + } + // se trovata, creo nuova curva composita + if ( nI >= 0 && nJ >= 0) { + // creo la curva + vpCrvs.emplace_back( CreateCurveComposite()) ; + // aggiungo punto iniziale + vpCrvs.back()->AddPoint( vvSec[nI][nJ].ptS) ; + } + // altrimenti, esco + else + break ; + } + // aggiungo la sezione alla curva + Section& Sec = vvSec[nI][nJ] ; + Sec.bActive = false ; + vpCrvs.back()->AddLine( vvSec[nI][nJ].ptE) ; + nI = -1 ; + nJ = -1 ; + } + + // se richiesta percorrenza invertita + if ( m_Params.m_bInvert) { + for ( auto& pCompo : vpCrvs) + pCompo->Invert() ; + } + + return true ; +} + //---------------------------------------------------------------------------- bool SurfFinishing::AddSpiral( ICAvToolSurfTm* pCAvTlStm, const Frame3d& frSurf, @@ -1754,7 +2172,6 @@ SurfFinishing::AddSpiral( ICAvToolSurfTm* pCAvTlStm, const Frame3d& frSurf, { // recupero distanze di sicurezza double dSafeZ = m_pMchMgr->GetCurrMachiningsMgr()->GetSafeZ() ; - double dSafeAggrBottZ = m_pMchMgr->GetCurrMachiningsMgr()->GetSafeAggrBottZ() ; // lunghezza di approccio/retrazione double dAppr = m_Params.m_dStartPos ; @@ -1833,10 +2250,19 @@ SurfFinishing::AddSpiral( ICAvToolSurfTm* pCAvTlStm, const Frame3d& frSurf, pCurve->GetStartPoint( ptStart) ; Vector3d vtStart ; pCurve->GetStartDir( vtStart) ; + // vettore tangente iniziale non deve salire rispetto a estrusione (poi si prende opposto) + double dStartOnExtr = vtStart * vtExtr ; + if ( dStartOnExtr > 0) { + vtStart -= dStartOnExtr * vtExtr ; + vtStart.Normalize() ; + } // determino inizio attacco Point3d ptP1 ; if ( ! CalcLeadInStart( ptStart, vtStart, vtExtr, ptP1)) return false ; + // eventuale correzione inizio attacco per evitare interferenze + if ( ! GetLastGoodPoint( pCAvTlStm, frSurf, ptStart, ptP1, vtTool, ptP1)) + return false ; // determino elevazione su inizio attacco double dStElev ; if ( ! GetElevation( m_nPhase, ptStart - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), vtTool, dStElev)) @@ -1880,17 +2306,30 @@ SurfFinishing::AddSpiral( ICAvToolSurfTm* pCAvTlStm, const Frame3d& frSurf, pCurve->GetEndPoint( ptEnd) ; Vector3d vtEnd ; pCurve->GetEndDir( vtEnd) ; - // determino elevazione su uscita - double dEndElev ; - if ( ! GetElevation( m_nPhase, ptEnd - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), vtTool, dEndElev)) - dEndElev = dElev ; - // aggiungo uscita + // vettore tangente finale non deve scendere rispetto a estrusione + double dEndOnExtr = vtEnd * vtExtr ; + if ( dEndOnExtr < 0) { + vtEnd -= dEndOnExtr * vtExtr ; + vtEnd.Normalize() ; + } + // determino fine uscita Point3d ptP1 ; + if ( ! CalcLeadOutEnd( ptEnd, vtEnd, vtExtr, ptP1)) + return false ; + // eventuale correzione fine uscita per evitare interferenze + if ( ! GetLastGoodPoint( pCAvTlStm, frSurf, ptEnd, ptP1, vtTool, ptP1)) + return false ; + // aggiungo uscita SetFeed( GetEndFeed()) ; - if ( ! AddLeadOut( ptEnd, vtEnd, vtExtr, ptP1, bSplitArcs)) { + if ( ! AddLeadOut( ptEnd, vtEnd, ptP1, vtExtr, bSplitArcs)) { m_pMchMgr->SetLastError( 3114, "Error in SurfFinishing : LeadOut not computable") ; return false ; } + // determino elevazione su fine uscita + double dEndElev ; + if ( ! GetElevation( m_nPhase, ptEnd - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), vtTool, dEndElev)) + dEndElev = dElev ; + dEndElev -= ( ptP1 - ptEnd) * vtExtr ; // se non è ultimo tratto, aggiungo retrazione di collegamento if ( false) { if ( ! AddLinkRetract( ptP1, vtTool, dSafeZ, dEndElev, dAppr)) { @@ -2146,7 +2585,7 @@ SurfFinishing::GetLeadInType( void) const bool SurfFinishing::CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtTool, Point3d& ptP1) const { - // Assegno il tipo + // Assegno tipo e parametri int nType = GetLeadInType() ; double dTang = m_Params.m_dLiTang ; double dPerp = m_Params.m_dLiPerp ; @@ -2162,8 +2601,8 @@ SurfFinishing::CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart, Vector3d vtRot = OrthoCompo( vtTool, vtStart) ; vtPerp.Rotate( vtRot, 0, -1) ; ptP1 = ptStart - vtStart * dTang + vtPerp * dPerp ; - return true ; } + return true ; default : return false ; } @@ -2173,10 +2612,11 @@ SurfFinishing::CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart, bool SurfFinishing::AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtTool, bool bSplitArcs) { + // Se inizio e fine coincidono, non devo fare alcunché + if ( AreSamePointApprox( ptP1, ptStart)) + return true ; // Assegno il tipo int nType = GetLeadInType() ; - double dTang = m_Params.m_dLiTang ; - double dPerp = m_Params.m_dLiPerp ; // Eseguo a seconda del tipo switch ( nType) { case SURFFIN_LI_NONE : @@ -2207,9 +2647,9 @@ SurfFinishing::GetLeadOutType( void) const //---------------------------------------------------------------------------- bool -SurfFinishing::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d& vtTool, Point3d& ptP1, bool bSplitArcs) +SurfFinishing::CalcLeadOutEnd( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d& vtTool, Point3d& ptP1) const { - // assegno i parametri + // Assegno tipo e parametri int nType = GetLeadOutType() ; double dTang = m_Params.m_dLoTang ; double dPerp = m_Params.m_dLoPerp ; @@ -2224,19 +2664,12 @@ SurfFinishing::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Ve dTang = m_Params.m_dLiTang ; dPerp = m_Params.m_dLiPerp ; } - // eseguo a seconda del tipo + // Calcolo punto finale switch ( nType) { case SURFFIN_LO_NONE : ptP1 = ptEnd ; return true ; case SURFFIN_LO_LINEAR : - { - Vector3d vtPerp = vtEnd ; - Vector3d vtRot = OrthoCompo( vtTool, vtEnd) ; - vtPerp.Rotate( vtRot, 0, -1) ; - ptP1 = ptEnd + vtEnd * dTang + vtPerp * dPerp ; - return ( AddLinearMove( ptP1, bSplitArcs, MCH_CL_LEADOUT) != GDB_ID_NULL) ; - } case SURFFIN_LO_TANGENT : { // calcolo punto finale dell'uscita @@ -2244,23 +2677,83 @@ SurfFinishing::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Ve Vector3d vtRot = OrthoCompo( vtTool, vtEnd) ; vtPerp.Rotate( vtRot, 0, -1) ; ptP1 = ptEnd + vtEnd * dTang + vtPerp * dPerp ; - // inserisco uscita - PtrOwner pCrv( GetArc2PVN( ptEnd, ptP1, vtEnd, vtTool)) ; - if ( IsNull( pCrv)) - return false ; - // assegno direzione finale dell'uscita - Vector3d vtDirF ; - if ( ! pCrv->GetEndDir( vtDirF)) - return false ; - bool bOk = true ; - // emetto movimento - return ( AddCurveMove( pCrv, bSplitArcs, MCH_CL_LEADOUT) != GDB_ID_NULL) ; } + return true ; default : return false ; } } +//---------------------------------------------------------------------------- +bool +SurfFinishing::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Point3d& ptP1, const Vector3d& vtTool, bool bSplitArcs) +{ + // Se inizio e fine coincidono, non devo fare alcunché + if ( AreSamePointApprox( ptEnd, ptP1)) + return true ; + // Assegno tipo e parametri + int nType = GetLeadOutType() ; + // se uscita come ingresso + if ( nType == SURFFIN_LO_AS_LI) { + int nLiType = GetLeadInType() ; + switch ( nLiType) { + case SURFFIN_LI_LINEAR : nType = SURFFIN_LO_LINEAR ; break ; + case SURFFIN_LI_TANGENT : nType = SURFFIN_LO_TANGENT ; break ; + default : nType = SURFFIN_LO_NONE ; break ; + } + } + // eseguo a seconda del tipo + switch ( nType) { + case SURFFIN_LO_NONE : + return true ; + case SURFFIN_LO_LINEAR : + return ( AddLinearMove( ptP1, bSplitArcs, MCH_CL_LEADOUT) != GDB_ID_NULL) ; + case SURFFIN_LO_TANGENT : + // inserisco uscita + PtrOwner pCrv( GetArc2PVN( ptEnd, ptP1, vtEnd, vtTool)) ; + if ( IsNull( pCrv)) + return false ; + // assegno direzione finale dell'uscita + Vector3d vtDirF ; + if ( ! pCrv->GetEndDir( vtDirF)) + return false ; + // emetto movimento + return ( AddCurveMove( pCrv, bSplitArcs, MCH_CL_LEADOUT) != GDB_ID_NULL) ; + } + + return true ; +} + +//---------------------------------------------------------------------------- +bool +SurfFinishing::GetLastGoodPoint( ICAvToolSurfTm* pCAvTlStm, const Frame3d& frSurf, + const Point3d& ptStart, const Point3d& ptEnd, const Vector3d& vtTool, Point3d& ptP1) +{ + // porto i punti e il versore nel riferimento superficie + Point3d ptStartL = GetToLoc( ptStart, frSurf) ; + Point3d ptEndL = GetToLoc( ptEnd, frSurf) ; + Vector3d vtToolL = GetToLoc( vtTool, frSurf) ; + // porto i punti dal tip al naso mandrino + ptStartL += vtToolL * m_TParams.m_dLen ; + ptEndL += vtToolL * m_TParams.m_dLen ; + // verifico che il movimento non interferisca con la superficie + PNTULIST lstPntU{ { ptStartL, 0}, { ptEndL, 1}} ; + if ( ! pCAvTlStm->TestPath( lstPntU, vtToolL, vtToolL, m_Params.m_dApprox, 0)) + return false ; + // cerco l'ultimo punto non spostato per evitare collisione + bool bFound = false ; + auto currPU = lstPntU.begin() ; + while ( ! bFound && currPU != lstPntU.end()) { + auto nextPU = next( currPU) ; + if ( nextPU == lstPntU.end() || nextPU->second < -m_Params.m_dApprox){ + bFound = true ; + ptP1 = GetToGlob( currPU->first - vtToolL * m_TParams.m_dLen, frSurf) ; + } + currPU = nextPU ; + } + return bFound ; +} + //---------------------------------------------------------------------------- double SurfFinishing::GetRightFeed( const Vector3d& vtMove, const Vector3d& vtTool) const diff --git a/SurfFinishing.h b/SurfFinishing.h index 2e768e6..d51f4ed 100644 --- a/SurfFinishing.h +++ b/SurfFinishing.h @@ -77,6 +77,10 @@ class SurfFinishing : public Machining const ICurveComposite* pCompo, const Vector3d& vtTool, const Vector3d& vtExtr, double dDepth, double dElev, bool bSplitArcs, bool bSkipMaxDown) ; bool CalcZigZag( const ICurveComposite* pOffs, ICRVCOMPOPOVECTOR& vpCrvs) ; + bool AddOneWay( ICAvToolSurfTm* pCAvTlStm, const Frame3d& frSurf, + const ICurveComposite* pCompo, const Vector3d& vtTool, const Vector3d& vtExtr, + double dDepth, double dElev, bool bSplitArcs, bool bSkipMaxDown) ; + bool CalcOneWay( const ICurveComposite* pOffs, ICRVCOMPOPOVECTOR& vpCrvs) ; bool AddSpiral( ICAvToolSurfTm* pCAvTlStm, const Frame3d& frSurf, const ICurveComposite* pCompo, const Vector3d& vtTool, const Vector3d& vtExtr, double dDepth, double dElev, bool bSplitArcs, bool bInVsOut) ; @@ -88,7 +92,10 @@ class SurfFinishing : public Machining bool AddRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dElev, double dAppr) ; bool CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtTool, Point3d& ptP1) const ; bool AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtTool, bool bSplitArcs) ; - bool AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d& vtTool, Point3d& ptP1, bool bSplitArcs) ; + bool CalcLeadOutEnd( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d& vtTool, Point3d& ptP1) const ; + bool AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Point3d& ptP1, const Vector3d& vtTool, bool bSplitArcs) ; + bool GetLastGoodPoint( ICAvToolSurfTm* pCAvTlStm, const Frame3d& frSurf, + const Point3d& ptStart, const Point3d& ptEnd, const Vector3d& vtTool, Point3d& ptP1) ; bool GetActiveSurfaces( INTVECTOR& vSurfId) const ; double GetRightFeed( const Vector3d& vtMove, const Vector3d& vtTool) const ; double GetRadiusForStartEndElevation( void) const ; diff --git a/SurfRoughing.cpp b/SurfRoughing.cpp index 87408c2..87855ee 100644 --- a/SurfRoughing.cpp +++ b/SurfRoughing.cpp @@ -62,6 +62,7 @@ using namespace std ; // 3019 = "Error in SurfRoughing : link outstroke" // 3020 = "Error in SurfRoughing : post apply not calculable" // 3021 = "Error in SurfRoughing : Linear Approx not computable" +// 3022 = "Error in SurfRoughing : aggregate from bottom not allowed" // 3051 = "Warning in SurfRoughing : Skipped entity (xx)" // 3052 = "Warning in SurfRoughing : No machinable path" // 3053 = "Warning in SurfRoughing : Tool name changed (xx)" @@ -341,6 +342,13 @@ SurfRoughing::SetParam( int nType, double dVal) m_nStatus |= MCH_ST_PARAM_MODIF ; m_Params.m_dOffsR = dVal ; return true ; + case MPA_OFFSL : + if ( AreSameLenValue( dVal, m_TParams.m_dOffsL)) + dVal = UNKNOWN_PAR ; + if ( ! AreSameLenValue( dVal, m_Params.m_dOffsL)) + m_nStatus |= MCH_ST_PARAM_MODIF ; + m_Params.m_dOffsL = dVal ; + return true ; case MPA_DEPTH: { string sVal = ToString( dVal) ; if ( sVal != m_Params.m_sDepth) @@ -352,10 +360,10 @@ SurfRoughing::SetParam( int nType, double dVal) m_nStatus |= MCH_ST_PARAM_MODIF ; m_Params.m_dStartPos = dVal ; return true ; - case MPA_OVERL : - if ( ! AreSameLenValue( dVal, m_Params.m_dOverlap)) + case MPA_STEP : + if ( ! AreSameLenValue( dVal, m_Params.m_dStep)) m_nStatus |= MCH_ST_PARAM_MODIF ; - m_Params.m_dOverlap = dVal ; + m_Params.m_dStep = dVal ; return true ; case MPA_SIDESTEP : if ( ! AreSameLenValue( dVal, m_Params.m_dSideStep)) @@ -494,6 +502,12 @@ SurfRoughing::Apply( bool bRecalc, bool bPostApply) return false ; } + // non è prevista sgrossatura superficie con aggregato da sotto + if ( IsAggrBottom( m_TParams.m_sHead)) { + m_pMchMgr->SetLastError( 3022, "Error in SurfRoughing : aggregate from bottom not allowed") ; + return false ; + } + // verifico se necessario continuare nell'aggiornamento if ( ! bRecalc && ! bToolChanged && ( m_nStatus == MCH_ST_OK || ( ! bPostApply && m_nStatus == MCH_ST_NO_POSTAPPL))) { @@ -706,13 +720,16 @@ SurfRoughing::GetParam( int nType, double& dVal) const dVal = GetTipFeed() ; return true ; case MPA_OFFSR : - dVal =GetOffsR() ; + dVal = GetOffsR() ; + return true ; + case MPA_OFFSL : + dVal = GetOffsL() ; return true ; case MPA_STARTPOS : dVal = m_Params.m_dStartPos ; return true ; - case MPA_OVERL : - dVal = m_Params.m_dOverlap ; + case MPA_STEP : + dVal = m_Params.m_dStep ; return true ; case MPA_SIDESTEP : dVal = m_Params.m_dSideStep ; @@ -1147,10 +1164,6 @@ SurfRoughing::ProcessPath( int nPathId, int nPvId, int nClId) return false ; } - // recupero flag di saltare parti a massimo affondamento - bool bSkipMaxDown = false ; - GetValInNotes( m_Params.m_sUserNotes, "SkipMaxDown", bSkipMaxDown) ; - // recupero nome del path string sPathName ; m_pGeomDB->GetName( nPathId, sPathName) ; @@ -1232,7 +1245,7 @@ SurfRoughing::ProcessPath( int nPathId, int nPvId, int nClId) switch ( m_Params.m_nSubType) { case SURFFIN_SUB_ONEWAY : case SURFFIN_SUB_ZIGZAG : - if ( ! AddZigZag( pCAvTlStm, frSurf, pCompo, vtTool, vtExtr, dDepth, dElev, bSplitArcs, bSkipMaxDown)) + if ( ! AddZigZag( pCAvTlStm, frSurf, pCompo, vtTool, vtExtr, dDepth, dElev, bSplitArcs)) return false ; break ; case SURFFIN_SUB_SPIRALIN : @@ -1305,16 +1318,15 @@ SurfRoughing::GetActiveSurfaces( INTVECTOR& vSurfId) const bool SurfRoughing::AddZigZag( ICAvToolSurfTm* pCAvTlStm, const Frame3d& frSurf, const ICurveComposite* pCompo, const Vector3d& vtTool, const Vector3d& vtExtr, - double dDepth, double dElev, bool bSplitArcs, bool bSkipMaxDown) + double dDepth, double dElev, bool bSplitArcs) { // recupero distanze di sicurezza double dSafeZ = m_pMchMgr->GetCurrMachiningsMgr()->GetSafeZ() ; - double dSafeAggrBottZ = m_pMchMgr->GetCurrMachiningsMgr()->GetSafeAggrBottZ() ; // lunghezza di approccio/retrazione double dAppr = m_Params.m_dStartPos ; // calcolo curva offsettata del raggio utensile - double dOffs = m_Params.m_dOverlap - 0.5 * m_TParams.m_dDiam ; + double dOffs = - 0.5 * m_TParams.m_dDiam ; OffsetCurve OffsCrv ; if ( ! OffsCrv.Make( pCompo, dOffs, ICurve::OFF_FILLET)) { m_pMchMgr->SetLastError( 3009, "Error in SurfRoughing : Offset not computable") ; @@ -1371,76 +1383,6 @@ SurfRoughing::AddZigZag( ICAvToolSurfTm* pCAvTlStm, const Frame3d& frSurf, PL.LocToLoc( frSurf, frPocket) ; // elimino i punti allineati PL.RemoveAlignedPoints( 0.8 * m_Params.m_dApprox) ; - // se richiesto, elimino i punti al massimo affondamento - if ( bSkipMaxDown) { - PNTULIST& vPntU = PL.GetUPointList() ; - bool bPrevDwn = true ; - Point3d ptPrev = P_INVALID ; - auto currPU = vPntU.begin() ; - while ( currPU != vPntU.end()) { - auto nextPU = next( currPU) ; - bool bNext = ( nextPU != vPntU.end()) ; - bool bNextDown = ( bNext ? nextPU->second > -m_Params.m_dApprox : true) ; - // punto corrente è al minimo - if ( currPU->second > -m_Params.m_dApprox) { - // se precedente e successivo al minimo, cancello e basta - if ( bPrevDwn && bNextDown) { - if ( ! ptPrev.IsValid() || abs( currPU->first.y - ptPrev.y) > 10 * EPS_SMALL) - ptPrev = currPU->first ; - currPU = vPntU.erase( currPU) ; - bPrevDwn = true ; - } - // se precedente ok e successivo al minimo, aggiungo opportuno movimento di uscita - else if ( ! bPrevDwn && bNextDown && bNext) { - Vector3d vtDir = nextPU->first - currPU->first ; - double dMove = vtDir.Len() ; - if ( dMove > 100 * EPS_SMALL) { - vtDir /= dMove ; - dMove = min( dMove, 2.) ; - Point3d ptNew = currPU->first + vtDir * dMove ; - ptPrev = ptNew ; - currPU = next( vPntU.insert( nextPU, { ptNew, 0})) ; - bPrevDwn = true ; - } - else { - ptPrev = currPU->first ; - currPU = nextPU ; - bPrevDwn = false ; - } - } - // se precedente al minimo e successivo ok, aggiungo opportuno movimento di ingresso - else if ( bPrevDwn && ptPrev.IsValid() && ! bNextDown) { - Vector3d vtDir = currPU->first - ptPrev ; - double dMove = vtDir.Len() ; - if ( dMove > 9 * EPS_SMALL) { - vtDir /= dMove ; - dMove = min( dMove, 2.) ; - Point3d ptNew = currPU->first - vtDir * dMove ; - vPntU.insert( currPU, { ptNew, 0}) ; - ptPrev = currPU->first ; - currPU = nextPU ; - } - else { - ptPrev = currPU->first ; - currPU = nextPU ; - } - bPrevDwn = true ; - } - // altrimenti va tenuto - else { - ptPrev = currPU->first ; - currPU = nextPU ; - bPrevDwn = true ; - } - } - // punto corrente sulla superficie - else { - ptPrev = currPU->first ; - currPU = nextPU ; - bPrevDwn = false ; - } - } - } // creo una curva composita a partire dalla polilinea PtrOwner< ICurveComposite> pCompo( CreateCurveComposite()) ; if ( IsNull( pCompo) || ! pCompo->FromPolyLine( PL)) @@ -1754,7 +1696,6 @@ SurfRoughing::AddSpiral( ICAvToolSurfTm* pCAvTlStm, const Frame3d& frSurf, { // recupero distanze di sicurezza double dSafeZ = m_pMchMgr->GetCurrMachiningsMgr()->GetSafeZ() ; - double dSafeAggrBottZ = m_pMchMgr->GetCurrMachiningsMgr()->GetSafeAggrBottZ() ; // lunghezza di approccio/retrazione double dAppr = m_Params.m_dStartPos ; @@ -1935,14 +1876,14 @@ SurfRoughing::CalcSpiral( const ICurveComposite* pCompo, bool bSplitArcs, { // primo offset pari al raggio utensile - overlap double dTRad = 0.5 * m_TParams.m_dDiam ; - double dOffs = dTRad - m_Params.m_dOverlap ; + double dOffs = dTRad ; // ciclo di offset verso l'interno const int MAX_ITER = 1000 ; int nIter = 0 ; PtrOwner pOffs ; const ICurve* pCurr = pCompo ; - double dCurrRad = GetCurveRadius( pCurr) + m_Params.m_dOverlap ; + double dCurrRad = GetCurveRadius( pCurr) ; while ( nIter < MAX_ITER) { // calcolo OffsetCurve OffsCrv ; @@ -1954,7 +1895,7 @@ SurfRoughing::CalcSpiral( const ICurveComposite* pCompo, bool bSplitArcs, PtrOwner pNextOffs( OffsCrv.GetLongerCurve()) ; double dRad = GetCurveRadius( pNextOffs) ; bool bNextOk = ( dRad > EPS_ZERO && dRad < dCurrRad) ; - bool bSmallRad = ( nIter == 0 ? dOffs < dTRad - m_Params.m_dOverlap + EPS_ZERO : dOffs < dTRad + EPS_ZERO) ; + bool bSmallRad = ( nIter == 0 ? dOffs < dTRad + EPS_ZERO : dOffs < dTRad + EPS_ZERO) ; // se completato step di offset, accodo la curva offsettata al percorso di lavoro if ( ! IsNull( pOffs) && ( bNextOk || bSmallRad)) { // verifico se aggiungere linea di congiunzione @@ -1985,7 +1926,7 @@ SurfRoughing::CalcSpiral( const ICurveComposite* pCompo, bool bSplitArcs, // se altrimenti riducibile, provo con offset ridotto al raggio utensile else if ( ! bSmallRad) { // nuovo valore pari al raggio - dOffs = ( nIter == 0 ? dTRad - m_Params.m_dOverlap : dTRad) ; + dOffs = dTRad ; } // altrimenti esco else @@ -2175,8 +2116,6 @@ SurfRoughing::AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vect { // Assegno il tipo int nType = GetLeadInType() ; - double dTang = m_Params.m_dLiTang ; - double dPerp = m_Params.m_dLiPerp ; // Eseguo a seconda del tipo switch ( nType) { case SURFFIN_LI_NONE : @@ -2252,7 +2191,6 @@ SurfRoughing::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vec Vector3d vtDirF ; if ( ! pCrv->GetEndDir( vtDirF)) return false ; - bool bOk = true ; // emetto movimento return ( AddCurveMove( pCrv, bSplitArcs, MCH_CL_LEADOUT) != GDB_ID_NULL) ; } diff --git a/SurfRoughing.h b/SurfRoughing.h index 853c809..43b4db3 100644 --- a/SurfRoughing.h +++ b/SurfRoughing.h @@ -75,7 +75,7 @@ class SurfRoughing : public Machining bool ProcessPath( int nPathId, int nPvId, int nClId) ; bool AddZigZag( ICAvToolSurfTm* pCAvTlStm, const Frame3d& frSurf, const ICurveComposite* pCompo, const Vector3d& vtTool, const Vector3d& vtExtr, - double dDepth, double dElev, bool bSplitArcs, bool bSkipMaxDown) ; + double dDepth, double dElev, bool bSplitArcs) ; bool CalcZigZag( const ICurveComposite* pOffs, ICRVCOMPOPOVECTOR& vpCrvs) ; bool AddSpiral( ICAvToolSurfTm* pCAvTlStm, const Frame3d& frSurf, const ICurveComposite* pCompo, const Vector3d& vtTool, const Vector3d& vtExtr, @@ -106,6 +106,8 @@ class SurfRoughing : public Machining { return ( IsNullLenValue( m_Params.m_dTipFeed) ? m_TParams.m_dTipFeed : m_Params.m_dTipFeed) ; } double GetOffsR() const { return ( IsUnknownValue( m_Params.m_dOffsR) ? m_TParams.m_dOffsR : m_Params.m_dOffsR) ; } + double GetOffsL() const + { return ( IsUnknownValue( m_Params.m_dOffsL) ? m_TParams.m_dOffsL : m_Params.m_dOffsL) ; } double GetSideStep( void) const { return Clamp( m_Params.m_dSideStep, 0.1, m_TParams.m_dTDiam) ; } int GetLeadInType( void) const ; @@ -113,7 +115,7 @@ class SurfRoughing : public Machining private : SELVECTOR m_vId ; // identificativi entità geometriche da lavorare - SurfRoughingData m_Params ; // parametri lavorazione + SurfRoughingData m_Params ; // parametri lavorazione ToolData m_TParams ; // parametri utensile double m_dTHoldBase ; // posizione base del porta-utensile double m_dTHoldLen ; // lunghezza del porta-utensile diff --git a/SurfRoughingData.cpp b/SurfRoughingData.cpp index cfb0d2c..0fd3ed0 100644 --- a/SurfRoughingData.cpp +++ b/SurfRoughingData.cpp @@ -44,13 +44,14 @@ enum nSurfRoughingKey { KEY_NAME, KEY_NNS, KEY_NNU, + KEY_OL, KEY_OR, - KEY_OVL, KEY_PS, KEY_S, KEY_SA, KEY_SCC, KEY_SS, + KEY_ST, KEY_SUBTYPE, KEY_TNAME, KEY_TUUID, @@ -76,13 +77,14 @@ static const array sSurfRoughingKey = { "NAME", "NNS", "NNU", + "OL", "OR", - "OVL", "PS", "S", "SA", "SCC", "SS", + "ST", "SUB", "TN", "TU", @@ -132,10 +134,11 @@ SurfRoughingData::CopyFrom( const MachiningData* pMdata) m_dStartFeed = pSdata->m_dStartFeed ; m_dTipFeed = pSdata->m_dTipFeed ; m_dOffsR = pSdata->m_dOffsR ; + m_dOffsL = pSdata->m_dOffsL ; m_bInvert = pSdata->m_bInvert ; m_sDepth = pSdata->m_sDepth ; m_dStartPos = pSdata->m_dStartPos ; - m_dOverlap = pSdata->m_dOverlap ; + m_dStep = pSdata->m_dStep ; m_dSideStep = pSdata->m_dSideStep ; m_nSubType = pSdata->m_nSubType ; m_dSideAngle = pSdata->m_dSideAngle ; @@ -176,10 +179,11 @@ SurfRoughingData::SameAs(const MachiningData* pMdata) const abs( m_dStartFeed - pSdata->m_dStartFeed) < EPS_MACH_LEN_PAR && abs( m_dTipFeed - pSdata->m_dTipFeed) < EPS_MACH_LEN_PAR && abs( m_dOffsR - pSdata->m_dOffsR) < EPS_MACH_LEN_PAR && + abs( m_dOffsL - pSdata->m_dOffsL) < EPS_MACH_LEN_PAR && m_bInvert == pSdata->m_bInvert && m_sDepth == pSdata->m_sDepth && abs( m_dStartPos - pSdata->m_dStartPos) < EPS_MACH_LEN_PAR && - abs( m_dOverlap - pSdata->m_dOverlap) < EPS_MACH_LEN_PAR && + abs( m_dStep - pSdata->m_dStep) < EPS_MACH_LEN_PAR && abs( m_dSideStep - pSdata->m_dSideStep) < EPS_MACH_LEN_PAR && m_nSubType == pSdata->m_nSubType && abs( m_dSideAngle - pSdata->m_dSideAngle) < EPS_MACH_ANG_PAR && @@ -215,7 +219,7 @@ FindSurfRoughingKey( const string& sKey) { auto TheRange = equal_range( sSurfRoughingKey.cbegin(), sSurfRoughingKey.cend(), sKey) ; if ( TheRange.first == TheRange.second) - return - 1 ; + return -1 ; return int( TheRange.first - sSurfRoughingKey.cbegin()) ; } @@ -290,8 +294,8 @@ SurfRoughingData::FromString( const string& sString, int& nKey) case KEY_OR : bOk = ::FromString( sVal, m_dOffsR) ; break ; - case KEY_OVL : - bOk = ::FromString( sVal, m_dOverlap) ; + case KEY_OL : + bOk = ::FromString( sVal, m_dOffsL) ; break ; case KEY_PS : bOk = ::FromString( sVal, m_dStartPos) ; @@ -308,6 +312,9 @@ SurfRoughingData::FromString( const string& sString, int& nKey) case KEY_SS : bOk = ::FromString( sVal, m_dSideStep) ; break ; + case KEY_ST : + bOk = ::FromString( sVal, m_dStep) ; + break ; case KEY_SUBTYPE : bOk = ::FromString( sVal, m_nSubType) ; break ; @@ -350,13 +357,14 @@ SurfRoughingData::ToString( int nInd) const case KEY_NAME : return ( sSurfRoughingKey[KEY_NAME] + "=" + m_sName) ; case KEY_NNS : return ( sSurfRoughingKey[KEY_NNS] + "=" + m_sSysNotes) ; case KEY_NNU : return ( sSurfRoughingKey[KEY_NNU] + "=" + m_sUserNotes) ; + case KEY_OL : return ( sSurfRoughingKey[KEY_OL] + "=" + ::ToString( m_dOffsL)) ; case KEY_OR : return ( sSurfRoughingKey[KEY_OR] + "=" + ::ToString( m_dOffsR)) ; - case KEY_OVL : return ( sSurfRoughingKey[KEY_OVL] + "=" + ::ToString( m_dOverlap)) ; case KEY_PS : return ( sSurfRoughingKey[KEY_PS] + "=" + ::ToString( m_dStartPos)) ; case KEY_S : return ( sSurfRoughingKey[KEY_S] + "=" + ::ToString( m_dSpeed)) ; case KEY_SA : return ( sSurfRoughingKey[KEY_SA] + "=" + ::ToString( m_dSideAngle)) ; case KEY_SCC : return ( sSurfRoughingKey[KEY_SCC] + "=" + ::ToString( m_nSolCh)) ; case KEY_SS : return ( sSurfRoughingKey[KEY_SS] + "=" + ::ToString( m_dSideStep)) ; + case KEY_ST : return ( sSurfRoughingKey[KEY_ST] + "=" + ::ToString( m_dStep)) ; case KEY_SUBTYPE : return ( sSurfRoughingKey[KEY_SUBTYPE] + "=" + ::ToString( m_nSubType)) ; case KEY_TNAME : return ( sSurfRoughingKey[KEY_TNAME] + "=" + m_sToolName) ; case KEY_TUUID : return ( sSurfRoughingKey[KEY_TUUID] + "=" + ::ToString( m_ToolUuid)) ; @@ -490,14 +498,17 @@ SurfRoughingData::SetParam( int nType, double dVal) case MPA_OFFSR : m_dOffsR = dVal ; return true ; + case MPA_OFFSL : + m_dOffsL = dVal ; + return true ; case MPA_DEPTH : m_sDepth = ::ToString( dVal) ; return true ; case MPA_STARTPOS : m_dStartPos = dVal ; return true ; - case MPA_OVERL : - m_dOverlap = dVal ; + case MPA_STEP : + m_dStep = dVal ; return true ; case MPA_SIDESTEP : m_dSideStep = dVal ; @@ -628,11 +639,14 @@ SurfRoughingData::GetParam( int nType, double& dVal) const case MPA_OFFSR : dVal = m_dOffsR ; return true ; + case MPA_OFFSL : + dVal = m_dOffsL ; + return true ; case MPA_STARTPOS : dVal = m_dStartPos ; return true ; - case MPA_OVERL : - dVal = m_dOverlap ; + case MPA_STEP : + dVal = m_dStep ; return true ; case MPA_SIDESTEP : dVal = m_dSideStep ; diff --git a/SurfRoughingData.h b/SurfRoughingData.h index 4ce696f..87687c5 100644 --- a/SurfRoughingData.h +++ b/SurfRoughingData.h @@ -29,10 +29,11 @@ struct SurfRoughingData : public MachiningData double m_dEndFeed ; // velocità di lavorazione finale ( se 0 da utensile) double m_dTipFeed ; // velocità di lavorazione di testa ( se 0 da utensile) double m_dOffsR ; // offset radiale ( se UNKNOWN_PAR da utensile) + double m_dOffsL ; // offset longitudinale ( se UNKNOWN_PAR da utensile) bool m_bInvert ; // flag di inversione direzione lavorazione std::string m_sDepth ; // affondamento massimo (espressione numerica) double m_dStartPos ; // quota di inizio lavorazione (sempre >= 0) - double m_dOverlap ; // distanza di sovrapposizione con il contorno + double m_dStep ; // passo di affondamento (0=nessun passo) double m_dSideStep ; // distanza tra le passate int m_nSubType ; // tipo di lavorazione ( ZigZag, OneWay, SpiralIn, SpiralOut) double m_dSideAngle ; // angolo dello ZigZag da X+ locale @@ -48,8 +49,8 @@ struct SurfRoughingData : public MachiningData SurfRoughingData( void) : m_ToolUuid(), m_nSolCh( 0), m_dSpeed( 0), m_dFeed( 0), m_dStartFeed( 0), m_dEndFeed( 0), m_dTipFeed( 0), - m_dOffsR( UNKNOWN_PAR), m_bInvert( false), - m_dStartPos( 0), m_dOverlap(0), m_dSideStep( 0), m_nSubType( 0), m_dSideAngle( 0), + m_dOffsR( UNKNOWN_PAR), m_dOffsL( UNKNOWN_PAR), m_bInvert( false), + m_dStartPos( 0), m_dStep( 0), m_dSideStep( 0), m_nSubType( 0), m_dSideAngle( 0), m_nLeadInType( 0), m_dLiTang( 0), m_dLiPerp( 0), m_nLeadOutType( 0), m_dLoTang( 0), m_dLoPerp( 0), m_dApprox( 0) {} SurfRoughingData* Clone( void) const override ;