diff --git a/EgtMachKernel.rc b/EgtMachKernel.rc index e39bef3..6c2f568 100644 Binary files a/EgtMachKernel.rc and b/EgtMachKernel.rc differ diff --git a/Machine.cpp b/Machine.cpp index 3d026c7..771353c 100644 --- a/Machine.cpp +++ b/Machine.cpp @@ -695,7 +695,7 @@ Machine::EnableHeadInSet( const string& sHead) int nH = GetGroup( vsHSet[i]) ; bool bShow = ( vsHSet[i] == sHead) ; m_pGeomDB->SetMode( nH, ( bShow ? GDB_MD_STD : GDB_MD_HIDDEN)) ; - //m_pGeomDB->SetStatus( nH, ( bShow ? GDB_ST_ON : GDB_ST_OFF)) ; + m_pGeomDB->SetStatus( nH, ( bShow ? GDB_ST_ON : GDB_ST_OFF)) ; } return true ; } diff --git a/MachineCalc.cpp b/MachineCalc.cpp index cae781a..281cb61 100644 --- a/MachineCalc.cpp +++ b/MachineCalc.cpp @@ -211,6 +211,9 @@ Machine::SetCurrTool( const string& sTool, const string& sHead, int nExit) double dTOvDiam = 0 ; // se definito if ( ! sTool.empty()) { + // carico anche gli utensili su eventuali altre uscite della testa + LoadTools( sHead) ; + // carico l'utensile (si sostituisce ad altro già presente sulla stessa uscita) if ( ! LoadTool( sHead, nExit, sTool)) { string sOut = "Missing tool " + sTool ; LOG_INFO( GetEMkLogger(), sOut.c_str()) @@ -225,8 +228,6 @@ Machine::SetCurrTool( const string& sTool, const string& sHead, int nExit) ! m_pMchMgr->TdbGetCurrToolParam( TPA_TOTLEN, dTOvLen) || ! m_pMchMgr->TdbGetCurrToolParam( TPA_TOTDIAM, dTOvDiam)) return false ; - // carico anche gli utensili su eventuali altre uscite della testa - LoadTools( sHead) ; } // altrimenti casi speciali senza utensile else { diff --git a/Milling.cpp b/Milling.cpp index 1ca28ae..6cede52 100644 --- a/Milling.cpp +++ b/Milling.cpp @@ -23,6 +23,7 @@ #include "/EgtDev/Include/EGkArcSpecial.h" #include "/EgtDev/Include/EGkChainCurves.h" #include "/EgtDev/Include/EGkOffsetCurve.h" +#include "/EgtDev/Include/EGkCurveAux.h" #include "/EgtDev/Include/EGkSfrCreate.h" #include "/EgtDev/Include/EGkSurfTriMesh.h" #include "/EgtDev/Include/EGkUserObjFactory.h" @@ -1601,7 +1602,7 @@ Milling::AddStandardMilling( const ICurveComposite* pCompo, const Vector3d& vtTo dStElev = dElev ; // determino inizio attacco Point3d ptP1 ; - if ( ! CalcLeadInStart( ptStart, vtStart, vtExtr, dStElev, false, ptP1)) + if ( ! CalcLeadInStart( ptStart, vtStart, vtExtr, dStElev, false, pCompo, ptP1)) return false ; // determino se l'inizio dell'attacco è fuori dal grezzo bool bOutStart = GetPointOutOfRaw( ptP1, vtTool) ; @@ -1609,10 +1610,10 @@ Milling::AddStandardMilling( const ICurveComposite* pCompo, const Vector3d& vtTo if ( ( m_TParams.m_nType & TF_SAWBLADE) == 0) { // correggo elevazione iniziale con punto inizio attacco dStElev -= ( ptP1 - ptStart) * vtExtr ; - // se attacco a zigzag o a spirale o a scivolo, l'elevazione va nell'attacco - if ( IsLeadInHelixZigzagGlide()) { - ptP1 += vtExtr * dStElev ; - dStElev = 0 ; + // se attacco a zigzag o a spirale, l'elevazione va nell'attacco + if ( IsLeadInHelixOrZigzag()) { + ptP1 += vtExtr * ( dStElev + LIO_ELEV_TOL) ; + dStElev = - LIO_ELEV_TOL ; } // approccio al punto iniziale if ( ! AddApproach( ptP1, vtTool, dSafeZ, dStElev, dAppr, bOutStart)) @@ -1632,7 +1633,7 @@ Milling::AddStandardMilling( const ICurveComposite* pCompo, const Vector3d& vtTo } // aggiungo attacco SetFeed( GetStartFeed()) ; - if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtExtr, false, bSplitArcs)) { + if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtExtr, false, pCompo, bSplitArcs)) { m_pMchMgr->SetLastError( 2309, "Error in Milling : LeadIn not computable") ; return false ; } @@ -1670,7 +1671,7 @@ Milling::AddStandardMilling( const ICurveComposite* pCompo, const Vector3d& vtTo // aggiungo uscita Point3d ptP1 ; SetFeed( GetStartFeed()) ; - if ( ! AddLeadOut( ptEnd, vtEnd, vtExtr, dEndElev, false, bSplitArcs, ptP1)) { + if ( ! AddLeadOut( ptEnd, vtEnd, vtExtr, dEndElev, false, pCompo, bSplitArcs, ptP1)) { m_pMchMgr->SetLastError( 2310, "Error in Milling : LeadOut not computable") ; return false ; } @@ -1738,7 +1739,7 @@ Milling::AddZigZagMilling( const ICurveComposite* pCompo, const Vector3d& vtTool dStElev = dStep - LIO_ELEV_TOL - 10 * EPS_SMALL ; // determino inizio attacco Point3d ptP1 ; - if ( ! CalcLeadInStart( ptStart, vtStart, vtExtr, dStElev, bInvert, ptP1)) + if ( ! CalcLeadInStart( ptStart, vtStart, vtExtr, dStElev, bInvert, pCompo, ptP1)) return false ; // determino se l'inizio dell'attacco è fuori dal grezzo bool bOutStart = GetPointOutOfRaw( ptP1, vtTool) ; @@ -1779,7 +1780,7 @@ Milling::AddZigZagMilling( const ICurveComposite* pCompo, const Vector3d& vtTool } // aggiungo attacco SetFeed( GetStartFeed()) ; - if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtExtr, bInvert, bSplitArcs)) { + if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtExtr, bInvert, pCompo, bSplitArcs)) { m_pMchMgr->SetLastError( 2309, "Error in Milling : LeadIn not computable") ; return false ; } @@ -1821,7 +1822,7 @@ Milling::AddZigZagMilling( const ICurveComposite* pCompo, const Vector3d& vtTool // aggiungo uscita Point3d ptP1 ; SetFeed( GetStartFeed()) ; - if ( ! AddLeadOut( ptEnd, vtEnd, vtExtr, dEndElev, bInvert, bSplitArcs, ptP1)) { + if ( ! AddLeadOut( ptEnd, vtEnd, vtExtr, dEndElev, bInvert, pCompo, bSplitArcs, ptP1)) { m_pMchMgr->SetLastError( 2310, "Error in Milling : LeadOut not computable") ; return false ; } @@ -1850,17 +1851,15 @@ Milling::AddOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtTool // lunghezza di approccio/retrazione double dAppr = m_Params.m_dStartPos ; + // percorso speciale : chiuso e con attacco a spirale o zigzag + bool bSpecial = pCompo->IsClosed() && IsLeadInHelixOrZigzag() ; + // determino numero e affondamento degli step int nStep = max( 1, static_cast( ceil( dElev / dOkStep))) ; double dStep = dElev / nStep ; - bool bClosed = pCompo->IsClosed() ; - int nMaxInd = pCompo->GetCurveCount() - 1 ; - - // percorso speciale : chiuso e con attacco a spirale o zigzag - bool bSpecial = bClosed && ( GetLeadInType() == MILL_LI_HELIX || GetLeadInType() == MILL_LI_ZIGZAG) ; - // ciclo sugli step + int nMaxInd = pCompo->GetCurveCount() - 1 ; for ( int j = 1 ; j <= nStep ; ++ j) { // ciclo sulle curve elementari for ( int i = 0 ; i <= nMaxInd ; ++ i) { @@ -1892,7 +1891,7 @@ Milling::AddOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtTool if ( ! GetElevation( m_nPhase, ptStart - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), dStElev)) dStElev = dElev ; // determino inizio attacco - if ( ! CalcLeadInStart( ptStart, vtStart, vtExtr, dStElev, false, ptP1)) + if ( ! CalcLeadInStart( ptStart, vtStart, vtExtr, dStElev, false, pCompo, ptP1)) return false ; // determino se l'inizio dell'attacco è fuori dal grezzo bool bOutStart = GetPointOutOfRaw( ptP1, vtTool) ; @@ -1900,8 +1899,8 @@ Milling::AddOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtTool if ( ( m_TParams.m_nType & TF_SAWBLADE) == 0) { // correggo elevazione iniziale con punto inizio attacco dStElev -= ( ptP1 - ptStart) * vtExtr ; - // se attacco a zigzag o a spirale o a scivolo, l'elevazione va nell'attacco - if ( IsLeadInHelixZigzagGlide()) { + // se attacco a zigzag o a spirale, l'elevazione va nell'attacco + if ( IsLeadInHelixOrZigzag()) { ptP1 += vtExtr * ( dStElev - ( j - 1) * dStep) ; dStElev = ( j - 1) * dStep ; } @@ -1924,7 +1923,7 @@ Milling::AddOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtTool } // aggiungo attacco SetFeed( GetStartFeed()) ; - if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtExtr, false, bSplitArcs)) { + if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtExtr, false, pCompo, bSplitArcs)) { m_pMchMgr->SetLastError( 2309, "Error in Milling : LeadIn not computable") ; return false ; } @@ -1965,7 +1964,7 @@ Milling::AddOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtTool // aggiungo uscita Point3d ptP1 ; SetFeed( GetStartFeed()) ; - if ( ! AddLeadOut( ptEnd, vtEnd, vtExtr, dEndElev, false, bSplitArcs, ptP1)) { + if ( ! AddLeadOut( ptEnd, vtEnd, vtExtr, dEndElev, false, pCompo, bSplitArcs, ptP1)) { m_pMchMgr->SetLastError( 2310, "Error in Milling : LeadOut not computable") ; return false ; } @@ -2036,7 +2035,7 @@ Milling::AddSpiralMilling( const ICurveComposite* pCompo, const Vector3d& vtTool dStElev = 0 ; // determino inizio attacco Point3d ptP1 ; - if ( ! CalcLeadInStart( ptStart, vtStart, vtExtr, dStElev, false, ptP1)) + if ( ! CalcLeadInStart( ptStart, vtStart, vtExtr, dStElev, false, pCompo, ptP1)) return false ; // determino se l'inizio dell'attacco è fuori dal grezzo bool bOutStart = GetPointOutOfRaw( ptP1, vtTool) ; @@ -2062,7 +2061,7 @@ Milling::AddSpiralMilling( const ICurveComposite* pCompo, const Vector3d& vtTool } // aggiungo attacco SetFeed( GetStartFeed()) ; - if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtExtr, false, bSplitArcs)) { + if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtExtr, false, pCompo, bSplitArcs)) { m_pMchMgr->SetLastError( 2309, "Error in Milling : LeadIn not computable") ; return false ; } @@ -2104,7 +2103,7 @@ Milling::AddSpiralMilling( const ICurveComposite* pCompo, const Vector3d& vtTool // aggiungo uscita Point3d ptP1 ; SetFeed( GetStartFeed()) ; - if ( ! AddLeadOut( ptEnd, vtEnd, vtExtr, dEndElev, false, bSplitArcs, ptP1)) { + if ( ! AddLeadOut( ptEnd, vtEnd, vtExtr, dEndElev, false, pCompo, bSplitArcs, ptP1)) { m_pMchMgr->SetLastError( 2310, "Error in Milling : LeadOut not computable") ; return false ; } @@ -2158,7 +2157,7 @@ Milling::AddSpiralMilling( const ICurveComposite* pCompo, const Vector3d& vtTool dStElev = dElev ; // determino inizio attacco Point3d ptP1 ; - if ( ! CalcLeadInStart( ptStart, vtStart, vtExtr, dStElev, bInvert, ptP1)) + if ( ! CalcLeadInStart( ptStart, vtStart, vtExtr, dStElev, bInvert, pCompo, ptP1)) return false ; // aggiungo approccio per frese normali if ( ( m_TParams.m_nType & TF_SAWBLADE) == 0) { @@ -2178,7 +2177,7 @@ Milling::AddSpiralMilling( const ICurveComposite* pCompo, const Vector3d& vtTool } // aggiungo attacco SetFeed( GetStartFeed()) ; - if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtExtr, bInvert, bSplitArcs)) { + if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtExtr, bInvert, pCompo, bSplitArcs)) { m_pMchMgr->SetLastError( 2309, "Error in Milling : LeadIn not computable") ; return false ; } @@ -2220,7 +2219,7 @@ Milling::AddSpiralMilling( const ICurveComposite* pCompo, const Vector3d& vtTool // aggiungo uscita Point3d ptP1 ; SetFeed( GetStartFeed()) ; - if ( ! AddLeadOut( ptEnd, vtEnd, vtExtr, dEndElev, bInvert, bSplitArcs, ptP1)) { + if ( ! AddLeadOut( ptEnd, vtEnd, vtExtr, dEndElev, bInvert, pCompo, bSplitArcs, ptP1)) { m_pMchMgr->SetLastError( 2310, "Error in Milling : LeadOut not computable") ; return false ; } @@ -2376,11 +2375,11 @@ Milling::GetLeadInType( void) const if ( ( m_Params.m_nLeadInType == MILL_LI_HELIX || m_Params.m_nLeadInType == MILL_LI_ZIGZAG) && ( m_Params.m_dLiTang < min( 0.1 * m_TParams.m_dDiam, 1.0) || m_Params.m_dLiElev < 10 * EPS_SMALL)) return MILL_LI_NONE ; - if ( ( m_Params.m_nLeadInType == MILL_LI_HELIX || m_Params.m_nLeadInType == MILL_LI_ZIGZAG || - m_Params.m_nLeadInType == MILL_LI_GLIDE) && m_Params.m_nStepType == MILL_ST_ZIGZAG) + if ( ( m_Params.m_nLeadInType == MILL_LI_HELIX || m_Params.m_nLeadInType == MILL_LI_ZIGZAG) && + m_Params.m_nStepType == MILL_ST_ZIGZAG) return MILL_LI_NONE ; - if ( ( m_Params.m_nLeadInType == MILL_LI_HELIX || m_Params.m_nLeadInType == MILL_LI_ZIGZAG || - m_Params.m_nLeadInType == MILL_LI_GLIDE) && m_Params.m_nStepType == MILL_ST_SPIRAL) + if ( ( m_Params.m_nLeadInType == MILL_LI_HELIX || m_Params.m_nLeadInType == MILL_LI_ZIGZAG) && + m_Params.m_nStepType == MILL_ST_SPIRAL) return MILL_LI_NONE ; if ( ( m_Params.m_nLeadInType == MILL_LI_HELIX || m_Params.m_nLeadInType == MILL_LI_ZIGZAG) && ( m_TParams.m_nType & TF_SAWBLADE) != 0) @@ -2391,7 +2390,7 @@ Milling::GetLeadInType( void) const //---------------------------------------------------------------------------- bool Milling::CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtN, - double dStElev, bool bInvert, Point3d& ptP1) + double dStElev, bool bInvert, const ICurveComposite* pCompo, Point3d& ptP1) { // Assegno tipo e parametri int nType = GetLeadInType() ; @@ -2416,8 +2415,8 @@ Milling::CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart, const // senso di rotazione da dir tg a dir esterna bool bCcwRot = (( ! bInvert && m_Params.m_nWorkSide == MILL_WS_LEFT) || ( bInvert && m_Params.m_nWorkSide != MILL_WS_LEFT)) ; - // !!! provvisorio : GLIDE -> NONE !!! - if ( nType == MILL_LI_GLIDE) + // verifico di poter fare l'ingresso a inseguimento + if ( nType == MILL_LI_GLIDE && ! pCompo->IsClosed()) nType = MILL_LI_NONE ; // Calcolo punto iniziale switch ( nType) { @@ -2432,8 +2431,26 @@ Milling::CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart, const return true ; } case MILL_LI_GLIDE : - // !!! DA FARE !!! - return false ; + { + if ( ! bInvert) { + double dLen, dU ; + if ( ! pCompo->GetLength( dLen) || ! pCompo->GetParamAtLength( dLen - dTang, dU) || + ! pCompo->GetPointD1D2( dU, ICurve::FROM_MINUS, ptP1)) { + if ( ! pCompo->GetStartPoint( ptP1)) + return false ; + } + } + else { + double dU ; + if ( ! pCompo->GetParamAtLength( dTang, dU) || + ! pCompo->GetPointD1D2( dU, ICurve::FROM_MINUS, ptP1)) { + if ( ! pCompo->GetEndPoint( ptP1)) + return false ; + } + } + ptP1 += vtN * ( vtN * ( ptStart - ptP1)) + vtN * dElev ; + return true ; + } case MILL_LI_ZIGZAG : ptP1 = ptStart ; return true ; @@ -2448,10 +2465,11 @@ Milling::CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart, const //---------------------------------------------------------------------------- bool Milling::AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d& vtStart, - const Vector3d& vtN, bool bInvert, bool bSplitArcs) + const Vector3d& vtN, bool bInvert, const ICurveComposite* pCompo, bool bSplitArcs) { // Assegno il tipo int nType = GetLeadInType() ; + double dTang = m_Params.m_dLiTang ; // se step invertito if ( bInvert) { switch ( GetLeadOutType()) { @@ -2461,9 +2479,11 @@ Milling::AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d& 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 ; } - // !!! provvisorio : GLIDE -> NONE !!! - if ( nType == MILL_LI_GLIDE) + // verifico di poter fare l'ingresso a inseguimento + if ( nType == MILL_LI_GLIDE && ! pCompo->IsClosed()) nType = MILL_LI_NONE ; // Eseguo a seconda del tipo switch ( nType) { @@ -2480,8 +2500,49 @@ Milling::AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d& return ( AddCurveMove( pCrv, MCH_CL_LEADIN) != GDB_ID_NULL) ; } case MILL_LI_GLIDE : - // !!! DA FARE !!! - return false ; + { + // recupero la parte richiesta della curva + PtrOwner pCrv ; + if ( ! bInvert) { + double dLen, dU ; + if ( pCompo->GetLength( dLen) && pCompo->GetParamAtLength( dLen - dTang, dU)) { + double dParS, dParE ; + pCompo->GetDomain( dParS, dParE) ; + if ( ! pCrv.Set( CreateCurveComposite()) || ! pCrv->AddCurve( pCompo->CopyParamRange( dU, dParE))) + return false ; + } + else { + if ( ! pCrv.Set( pCompo->Clone())) + return false ; + } + } + else { + double dU ; + if ( pCompo->GetParamAtLength( dTang, dU)) { + if ( ! pCrv.Set( CreateCurveComposite()) || ! pCrv->AddCurve( pCompo->CopyParamRange( 0, dU))) + return false ; + } + else { + if ( ! pCrv.Set( pCompo->Clone())) + return false ; + } + pCrv->Invert() ; + } + pCrv->SetExtrusion( vtN) ; + // la porto alla giusta quota + Point3d ptFin ; pCrv->GetEndPoint( ptFin) ; + Vector3d vtMove = ptStart - ptFin ; + pCrv->Translate( vtMove) ; + // assegno la corretta pendenza + double dNini = ( ptP1 - ORIG) * vtN ; + double dNfin = ( ptStart - ORIG) * vtN ; + AdjustCurveSlope( pCrv, dNini, dNfin) ; + // eventuale spezzatura + if ( bSplitArcs && ! ApproxWithLines( pCrv)) + return false ; + // emetto + return ( AddCurveMove( pCrv) != GDB_ID_NULL) ; + } case MILL_LI_ZIGZAG : { double dDeltaN = ( ptStart - ptP1) * vtN ; @@ -2534,15 +2595,16 @@ int Milling::GetLeadOutType( void) const { if ( abs( m_Params.m_dLoTang) < min( 0.1 * m_TParams.m_dDiam, 0.1) && - abs( m_Params.m_dLoPerp) < min( 0.1 * m_TParams.m_dDiam, 0.1)) + abs( m_Params.m_dLoPerp) < min( 0.1 * m_TParams.m_dDiam, 0.1) && + m_Params.m_nLeadOutType != MILL_LO_AS_LI) return MILL_LO_NONE ; return m_Params.m_nLeadOutType ; } //---------------------------------------------------------------------------- bool -Milling::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d& vtN, - double dEndElev, bool bInvert, bool bSplitArcs, Point3d& ptP1) +Milling::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d& vtN, double dEndElev, + bool bInvert, const ICurveComposite* pCompo, bool bSplitArcs, Point3d& ptP1) { // assegno i parametri int nType = GetLeadOutType() ; @@ -2566,8 +2628,8 @@ Milling::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d // senso di rotazione da dir tg a dir esterna bool bCcwRot = (( ! bInvert && m_Params.m_nWorkSide == MILL_WS_LEFT) || ( bInvert && m_Params.m_nWorkSide != MILL_WS_LEFT)) ; - // !!! provvisorio : GLIDE -> NONE !!! - if ( nType == MILL_LO_GLIDE) + // verifico di poter fare l'uscita a inseguimento + if ( nType == MILL_LO_GLIDE && ! pCompo->IsClosed()) nType = MILL_LO_NONE ; // eseguo a seconda del tipo switch ( nType) { @@ -2594,8 +2656,51 @@ Milling::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d return ( AddCurveMove( pCrv, MCH_CL_LEADOUT) != GDB_ID_NULL) ; } case MILL_LO_GLIDE : - // !!! DA FARE !!! - return false ; + { + // recupero la parte richiesta della curva di ritorno + PtrOwner pCrv ; + if ( ! bInvert) { + double dU ; + if ( pCompo->GetParamAtLength( dTang, dU)) { + if ( ! pCrv.Set( CreateCurveComposite()) || ! pCrv->AddCurve( pCompo->CopyParamRange( 0, dU))) + return false ; + } + else { + if ( ! pCrv.Set( pCompo->Clone())) + return false ; + } + } + else { + double dLen, dU ; + if ( pCompo->GetLength( dLen) && pCompo->GetParamAtLength( dLen - dTang, dU)) { + double dParS, dParE ; + pCompo->GetDomain( dParS, dParE) ; + if ( ! pCrv.Set( CreateCurveComposite()) || ! pCrv->AddCurve( pCompo->CopyParamRange( dU, dParE))) + return false ; + } + else { + if ( ! pCrv.Set( pCompo->Clone())) + return false ; + } + pCrv->Invert() ; + } + pCrv->SetExtrusion( vtN) ; + // la porto alla giusta quota + Point3d ptIni ; pCrv->GetStartPoint( ptIni) ; + Vector3d vtMove = ptEnd - ptIni ; + pCrv->Translate( vtMove) ; + // assegno la corretta pendenza + double dNini = ( ptEnd - ORIG) * vtN ; + AdjustCurveSlope( pCrv, dNini, dNini + dElev) ; + // eventuale spezzatura + if ( bSplitArcs && ! ApproxWithLines( pCrv)) + return false ; + // emetto + AddCurveMove( pCrv) ; + // assegno punto finale dell'uscita + pCrv->GetEndPoint( ptP1) ; + return true ; + } default : return false ; } diff --git a/Milling.h b/Milling.h index bf09976..5c79a71 100644 --- a/Milling.h +++ b/Milling.h @@ -81,11 +81,11 @@ class Milling : public Machining bool AddApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dElev, double dAppr, bool bOutStart) ; bool AddRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dElev, double dAppr) ; bool CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtN, - double dStElev, bool bInvert, Point3d& ptP1) ; + double dStElev, bool bInvert, const ICurveComposite* pCompo, Point3d& ptP1) ; bool AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d& vtStart, - const Vector3d& vtN, bool bInvert, bool bSplitArcs) ; - bool AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d& vtN, - double dEndElev, bool bInvert, bool bSplitArcs, Point3d& ptP1) ; + const Vector3d& vtN, bool bInvert, const ICurveComposite* pCompo, bool bSplitArcs) ; + bool AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d& vtN, double dEndElev, + bool bInvert, const ICurveComposite* pCompo, bool bSplitArcs, Point3d& ptP1) ; double GetRadiusForStartEndElevation( void) ; bool GetPointOutOfRaw( const Point3d& ptP, const Vector3d& vtTool) ; @@ -106,9 +106,9 @@ class Milling : public Machining { return ( abs( m_Params.m_dOffsR - UNKNOWN_PAR) < EPS_MACH_LEN_PAR ? m_TParams.m_dOffsR : m_Params.m_dOffsR) ; } int GetLeadInType( void) const ; int GetLeadOutType( void) const ; - bool IsLeadInHelixZigzagGlide() + bool IsLeadInHelixOrZigzag() { int nType = GetLeadInType() ; - return ( nType == MILL_LI_ZIGZAG || nType == MILL_LI_HELIX || nType == MILL_LI_GLIDE) ; } + return ( nType == MILL_LI_ZIGZAG || nType == MILL_LI_HELIX) ; } private : SELVECTOR m_vId ; // identificativi entità geometriche da lavorare diff --git a/Pocketing.cpp b/Pocketing.cpp index 96490d7..84946f7 100644 --- a/Pocketing.cpp +++ b/Pocketing.cpp @@ -23,6 +23,7 @@ #include "/EgtDev/Include/EGkArcSpecial.h" #include "/EgtDev/Include/EGkChainCurves.h" #include "/EgtDev/Include/EGkOffsetCurve.h" +#include "/EgtDev/Include/EGkCurveAux.h" #include "/EgtDev/Include/EGkSfrCreate.h" #include "/EgtDev/Include/EGkSurfTriMesh.h" #include "/EgtDev/Include/EGkUserObjFactory.h" @@ -2061,34 +2062,21 @@ Pocketing::AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3 if ( ! pCrv.Set( pRCrv->Clone())) return false ; } + pCrv->SetExtrusion( vtN) ; // la porto alla giusta quota Point3d ptFin ; pCrv->GetEndPoint( ptFin) ; Vector3d vtMove = ptStart - ptFin ; pCrv->Translate( vtMove) ; - // sposto il punto iniziale e rendo uniforme la pendenza - double dDeltaN = ( ptP1 - ptStart) * vtN ; - int i = 0 ; - double dCurrLen = 0 ; - const ICurve* pSCrv = pCrv->GetFirstCurve() ; - while ( pSCrv != nullptr) { - double dCrvLen ; - pSCrv->GetLength( dCrvLen) ; - double dCurrDeltaN = dDeltaN * ( 1.0 - dCurrLen / dLen) ; - Point3d ptJoin ; - pSCrv->GetStartPoint( ptJoin) ; - pCrv->ModifyJoint( i, ptJoin + vtN * dCurrDeltaN) ; - // passo al successivo - dCurrLen += dCrvLen ; - pSCrv = pCrv->GetNextCurve() ; - ++ i ; - } + // assegno la corretta pendenza + double dNini = ( ptP1 - ORIG) * vtN ; + double dNfin = ( ptStart - ORIG) * vtN ; + AdjustCurveSlope( pCrv, dNini, dNfin) ; // eventuale spezzatura if ( bSplitArcs && ! ApproxWithLines( pCrv)) return false ; // emetto return ( AddCurveMove( pCrv) != GDB_ID_NULL) ; } - return false ; case POCKET_LI_ZIGZAG : { double dDeltaN = ( ptStart - ptP1) * vtN ; diff --git a/Simulator.cpp b/Simulator.cpp index b69ab5e..92ca40d 100644 --- a/Simulator.cpp +++ b/Simulator.cpp @@ -317,8 +317,6 @@ Simulator::UpdateTool( bool bForced) // se forzato, pulisco la testa if ( bForced) m_pMchMgr->ResetHeadSet( sHead) ; - // carico tutti gli utensili attrezzati - m_pMachine->LoadTools( sHead) ; // carico l'utensile (e lo rendo corrente) if ( ! m_pMchMgr->SetCalcTool( sTool, sHead, nExit)) return false ;