From f2b8f25fbda509d4a292779ae5b2b57df8a7e887 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Fri, 22 May 2026 20:18:38 +0200 Subject: [PATCH] EgtMachKernel : - corretto calcolo elevazione per percorso di lavorazione Mortasatura. --- Mortising.cpp | 50 +++++++++++++++++++------------------------------- Mortising.h | 2 +- 2 files changed, 20 insertions(+), 32 deletions(-) diff --git a/Mortising.cpp b/Mortising.cpp index 6c864f5..a10dbfd 100644 --- a/Mortising.cpp +++ b/Mortising.cpp @@ -1250,7 +1250,7 @@ Mortising::ProcessPath( int nPathId, int nPvId, int nClId) return false ; dLen += dStartAddLen ; } - if (dEndAddLen > EPS_SMALL) { + if ( dEndAddLen > EPS_SMALL) { if ( ! pCompo->ExtendEndByLen( dEndAddLen)) return false ; dLen += dEndAddLen ; @@ -1330,7 +1330,7 @@ Mortising::ProcessPath( int nPathId, int nPvId, int nClId) // calcolo l'elevazione massima double dElev ; - if ( CalcPathElevation( pCompo, vtTool, dDepth, GetRadiusForStartEndElevation(), m_TParams.m_dThick, dElev)) { + if ( CalcPathElevation( pCompo, vtTool, vtAux, dDepth, GetRadiusForStartEndElevation(), m_TParams.m_dThick, dElev)) { if ( dElev < EPS_SMALL && AreSameVectorApprox( vtExtr, Z_AX)) { BBox3d b3Crv ; pCompo->GetLocalBBox( b3Crv) ; @@ -1350,7 +1350,7 @@ Mortising::ProcessPath( int nPathId, int nPvId, int nClId) double dCosAng = min( abs( vtTg * vtExtr), cos( 30 * DEGTORAD)) ; double dAddEnc = m_TParams.m_dDiam / 2 * dCosAng / dSinAng ; - // affondamento speciale da note utente (!!! da trasformare in parametro come gli altri !!!) + // affondamento speciale da note utente int nPlunge = 0 ; GetValInNotes( m_Params.m_sUserNotes, UN_PLUNGE, nPlunge) ; @@ -1437,12 +1437,12 @@ Mortising::ProcessPath( int nPathId, int nPvId, int nClId) //---------------------------------------------------------------------------- bool -Mortising::CalcPathElevation( const ICurveComposite* pCompo, const Vector3d& vtTool, double dDepth, double dRad, double dThick, - double& dElev) const +Mortising::CalcPathElevation( const ICurveComposite* pCompo, const Vector3d& vtTool, const Vector3d& vtAux, + double dDepth, double dRad, double dThick, double& dElev) const { dElev = 0 ; - int nMaxInd = pCompo->GetCurveCount() - 1 ; - for ( int i = 0 ; i <= nMaxInd ; ++ i) { + const double DELTA_ELEV_RAD = 20.0 ; + for ( int i = 0 ; i < pCompo->GetCurveCount() ; ++ i) { // curva corrente const ICurve* pCrvC = pCompo->GetCurve( i) ; // calcolo elevazione @@ -1451,17 +1451,16 @@ Mortising::CalcPathElevation( const ICurveComposite* pCompo, const Vector3d& vtT pCrvC->GetStartPoint( ptStart) ; pCrvC->GetMidPoint( ptMid) ; pCrvC->GetEndPoint( ptEnd) ; - Vector3d vtStartPerp, vtEndPerp ; - pCrvC->GetStartDir( vtStartPerp) ; - vtStartPerp *= -dRad ; - pCrvC->GetEndDir( vtEndPerp) ; - vtEndPerp *= dRad ; - Vector3d vtTg ; pCrvC->GetMidDir( vtTg) ; - Vector3d vtOrtho = vtTool ^ vtTg ; - vtOrtho.Normalize() ; - vtOrtho *= dThick ; + Vector3d vtStart, vtEnd ; + pCrvC->GetStartDir( vtStart) ; + pCrvC->GetEndDir( vtEnd) ; + ptStart += -dRad * vtStart + 0.5 * dThick * vtAux ; + ptMid += 0.5 * dThick * vtAux ; + ptEnd += dRad * vtEnd + 0.5 * dThick * vtAux ; + Vector3d vtOrtho = vtAux ; + vtOrtho *= 0.5 * dThick + DELTA_ELEV_RAD ; Vector3d vtDepth = -vtTool * dDepth ; - // linea centro utensile + // in centro utensile if ( GetElevation( m_nPhase, ptStart + vtDepth, ptMid + vtDepth, ptEnd + vtDepth, vtTool, dCurrElev)) { if ( dCurrElev > dElev) dElev = dCurrElev ; @@ -1479,19 +1478,8 @@ Mortising::CalcPathElevation( const ICurveComposite* pCompo, const Vector3d& vtT m_pMchMgr->SetLastError( 2505, "Error in Mortising : Entity GetElevation") ; return false ; } - // da una parte - if ( GetElevation( m_nPhase, ptStart + vtStartPerp + vtDepth, ptMid + vtDepth, - ptEnd + vtEndPerp + vtDepth, vtTool, dCurrElev)) { - if ( dCurrElev > dElev) - dElev = dCurrElev ; - } - else { - m_pMchMgr->SetLastError( 2505, "Error in Mortising : Entity GetElevation") ; - return false ; - } - // dall'altra parte - if ( GetElevation( m_nPhase, ptStart + vtStartPerp + vtDepth, ptMid + vtDepth, - ptEnd + vtEndPerp + vtDepth, vtTool, dCurrElev)) { + // sotto centro utensile + if ( GetElevation( m_nPhase, ptStart + vtDepth - vtOrtho, ptMid + vtDepth - vtOrtho, ptEnd + vtDepth - vtOrtho, vtTool, dCurrElev)) { if ( dCurrElev > dElev) dElev = dCurrElev ; } @@ -1535,7 +1523,7 @@ Mortising::GenerateMortisingCl( const ICurveComposite* pCompo, const Vector3d& v return false ; } - // se alrimenti affondamenti ripetuti da inizio a fine con ritorno basso + // se altrimenti affondamenti ripetuti da inizio a fine con ritorno basso else if ( nPlunge == MORTISE_PLUNGE_START_TO_END) { // distanza e vettore spostamento laterale Vector3d vtDir = ptEnd - ptStart ; diff --git a/Mortising.h b/Mortising.h index 38d4d88..4c5ba67 100644 --- a/Mortising.h +++ b/Mortising.h @@ -78,7 +78,7 @@ class Mortising : public Machining bool Chain( int nGrpDestId) ; bool CalcSurfAuxView( int nAuxId, int nAuxViewId) ; bool ProcessPath( int nPathId, int nPvId, int nClId) ; - bool CalcPathElevation( const ICurveComposite* pCompo, const Vector3d& vtTool, double dDepth, double dRad, double dThick, double& dElev) const ; + bool CalcPathElevation( const ICurveComposite* pCompo, const Vector3d& vtTool, const Vector3d& vtAux, double dDepth, double dRad, double dThick, double& dElev) const ; bool GenerateMortisingPv( int nPathId, const ICurveComposite* pCompo) ; bool GenerateMortisingCl( const ICurveComposite* pCompo, const Vector3d& vtTool, double dDepth, double dElev, double dOkStep, int nPlunge) ; bool GenerateOnePlungeCl( const Point3d& ptStart, const Point3d& ptEnd, const Vector3d& vtTool, double dDepth, double dElev, double dOkStep,