diff --git a/EgtMachKernel.rc b/EgtMachKernel.rc index aca4e2e..5dda8ad 100644 Binary files a/EgtMachKernel.rc and b/EgtMachKernel.rc differ diff --git a/Operation.cpp b/Operation.cpp index 8434022..695381f 100644 --- a/Operation.cpp +++ b/Operation.cpp @@ -1107,13 +1107,15 @@ Operation::CalcAndSetBBox( int nClId) Vector3d vtN = pCamData->GetNormDir() ; double dDeltaN = pCamData->GetDeltaN() ; // ricavo i punti - const double ANG_STEP = 15.0 ; + const double ANG_STEP = 4.9 ; int nStep = 1 + int( abs( dAngCen) / ANG_STEP) ; double dCoeff = -1. / nStep ; + double dCosRot = cos( dCoeff * dAngCen * DEGTORAD) ; + double dSinRot = sin( dCoeff * dAngCen * DEGTORAD) ; + Point3d ptT = ptP ; for ( int i = 1 ; i < nStep ; ++ i) { - Point3d ptT = ptP ; - ptT.Rotate( ptCen, vtN, i * dCoeff * dAngCen) ; - ptT.Translate( vtN * ( i * dCoeff * dDeltaN)) ; + ptT.Rotate( ptCen, vtN, dCosRot, dSinRot) ; + ptT.Translate( vtN * ( dCoeff * dDeltaN)) ; b3Grp.Add( ptT) ; } } @@ -1182,14 +1184,16 @@ Operation::CalcAndSetAxesBBox( void) Vector3d vtN = pCamData->GetAxesNormDir() ; double dDeltaN = ( ptAxEnd - ptCen) * vtN ; // ricavo i punti - const double ANG_STEP = 15.0 ; + const double ANG_STEP = 4.9 ; int nStep = 1 + int( abs( dAngCen) / ANG_STEP) ; double dCoeff = -1. / nStep ; + double dCosRot = cos( dCoeff * dAngCen * DEGTORAD) ; + double dSinRot = sin( dCoeff * dAngCen * DEGTORAD) ; + Point3d ptAxT = ptAxEnd ; for ( int i = 1 ; i < nStep ; ++ i) { // assi lineari - Point3d ptAxT = ptAxEnd ; - ptAxT.Rotate( ptCen, vtN, i * dCoeff * dAngCen) ; - ptAxT.Translate( vtN * ( i * dCoeff * dDeltaN)) ; + ptAxT.Rotate( ptCen, vtN, dCosRot, dSinRot) ; + ptAxT.Translate( vtN * ( dCoeff * dDeltaN)) ; for ( int i = 0 ; i < min( nLinAxes, 3) ; ++ i) vMmAxGrp[i].Add( ptAxT.v[i]) ; } diff --git a/Pocketing.cpp b/Pocketing.cpp index 4b9d13c..d1d14a0 100644 --- a/Pocketing.cpp +++ b/Pocketing.cpp @@ -1848,7 +1848,7 @@ Pocketing::VerifyPathFromBottom( const ICurveComposite* pCompo, const Vector3d& dCurrDist = dQDist ; } } - // se la massima distanza trovata è inferiore al minimo, loaggiorno + // se la massima distanza trovata è inferiore al minimo, lo aggiorno if ( dCurrDist < dMinDist) { dMinDist = dCurrDist ; vtMinDir = vtCurrDir ; @@ -5183,7 +5183,7 @@ Pocketing::AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3 double dRad = min( 0.5 * min( m_Params.m_dLiTang, m_TParams.m_dDiam), m_dMaxHelixRad) ; Point3d ptCen = ptP1 + vtCen * dRad ; double dDeltaN = ( ptStart - ptP1) * vtN ; - double dAngCen = ceil( - dDeltaN / ( m_Params.m_dLiElev + 10 * EPS_SMALL)) * ( bAtLeft ? ANG_FULL : - ANG_FULL) ; + double dAngCen = ceil( - dDeltaN / ( m_Params.m_dLiElev + 20 * EPS_SMALL)) * ( bAtLeft ? ANG_FULL : - ANG_FULL) ; // verifico se fattibile if ( bSkipControl || VerifyLeadInHelix( pCompo, ptCen, dRad)) { // creo l'elica @@ -5210,7 +5210,7 @@ Pocketing::AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3 if ( nType == POCKET_LI_ZIGZAG) { // dati dello zigzag double dDeltaN = ( ptStart - ptP1) * vtN ; - int nStep = int( ceil( - dDeltaN / ( m_Params.m_dLiElev + 10 * EPS_SMALL))) ; + int nStep = int( ceil( - dDeltaN / ( m_Params.m_dLiElev + 20 * EPS_SMALL))) ; double dStep = - dDeltaN / nStep ; Point3d ptPa = ptP1 + vtStart * 0.5 * min( m_Params.m_dLiTang, m_TParams.m_dDiam) ; Point3d ptPb = ptP1 - vtStart * 0.5 * min( m_Params.m_dLiTang, m_TParams.m_dDiam) ; @@ -5371,7 +5371,8 @@ Pocketing::GetMidOfLongestOpenSide( const ICurveComposite* pCompo, Point3d& ptMi pMyCrv = pCompo->GetNextCurve() ; } // richiedo lunghezza superiore a diametro utensile più doppio offset radiale - double dMaxLen = ( bAllOpen ? 0 : m_TParams.m_dDiam + 2 * GetOffsR() - EPS_SMALL) ; + double dRefLen = ( bAllOpen ? 0 : m_TParams.m_dDiam + 2 * GetOffsR() - EPS_SMALL) ; + double dMaxLen = dRefLen ; // ciclo sulle singole curve bool bFound = false ; const ICurve* pPrevCrv = pCompo->GetLastCurve() ; @@ -5406,15 +5407,33 @@ Pocketing::GetMidOfLongestOpenSide( const ICurveComposite* pCompo, Point3d& ptMi } // entità corrente double dLen = 0 ; - if ( pCrv->GetLength( dLen) && dLen + dLenAgg > dMaxLen) { - dMaxLen = dLen + dLenAgg ; - pCrv->GetMidPoint( ptMid) ; - // vettore ortogonale verso l'esterno (ruotato -90deg rispetto a estrusione) - pCrv->GetMidDir( vtMidOrt) ; - vtMidOrt.Rotate( vtExtr, 0, -1) ; - bFound = true ; + if ( pCrv->GetLength( dLen)) { + const double LEN_TOL = 1 ; + // se di lunghezza praticamente uguale + if ( bFound && dLen + dLenAgg > dRefLen && abs( dLen + dLenAgg - dMaxLen) < LEN_TOL) { + Point3d ptTest ; + pCrv->GetMidPoint( ptTest) ; + if ( ( m_bAboveHead && ptTest.z > ptMid.z + 100 * EPS_SMALL) || + ( ! m_bAboveHead && ptTest.z < ptMid.z - 100 * EPS_SMALL) || + ( abs( ptTest.z - ptMid.z) < 100 * EPS_SMALL && ptTest.y < ptMid.y - 100 * EPS_SMALL)) { + dMaxLen = max( dMaxLen, dLen + dLenAgg) ; + ptMid = ptTest ; + // vettore ortogonale verso l'esterno (ruotato -90deg attorno a estrusione) + pCrv->GetMidDir( vtMidOrt) ; + vtMidOrt.Rotate( vtExtr, 0, -1) ; + } + } + // se più lunga + else if ( dLen + dLenAgg > dMaxLen) { + dMaxLen = dLen + dLenAgg ; + pCrv->GetMidPoint( ptMid) ; + // vettore ortogonale verso l'esterno (ruotato -90deg attorno a estrusione) + pCrv->GetMidDir( vtMidOrt) ; + vtMidOrt.Rotate( vtExtr, 0, -1) ; + bFound = true ; + } + dLenPrev = dLen ; } - dLenPrev = dLen ; } else dLenPrev = 0 ; diff --git a/stdafx.h b/stdafx.h index d681b8a..33c035f 100644 --- a/stdafx.h +++ b/stdafx.h @@ -33,4 +33,4 @@ #pragma comment(lib, EGTLIBDIR "EgtGeomKernel" EGTLIBVER ".lib") #pragma comment(lib, EGTLIBDIR "EgtExecutor" EGTLIBVER ".lib") #pragma comment(lib, EGTLIBDIR "SEgtLock" EGTLIBVER ".lib") -#pragma comment(lib, EGTEXTDIR "Lua/Lib/Lua53" EGTLIBVER ".lib") +#pragma comment(lib, EGTEXTDIR "Lua/Lib/Lua54" EGTLIBVER ".lib")