From fde68bd68f9764d1c7604df286bf5245a8eafc08 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 26 Sep 2016 13:51:30 +0000 Subject: [PATCH] EgtMachKernel : - correzione calcolo elevazione fresature. --- Milling.cpp | 45 +++++++++++++++++++++++++++++++++++++++++---- Milling.h | 2 +- 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/Milling.cpp b/Milling.cpp index 300a48c..ab3963e 100644 --- a/Milling.cpp +++ b/Milling.cpp @@ -1041,7 +1041,7 @@ Milling::ProcessPath( int nPathId, int nPvId, int nClId) // calcolo l'elevazione massima double dElev ; - if ( CalcPathElevation( pCompo, vtTool, dDepth, dElev)) { + if ( CalcPathElevation( pCompo, vtTool, dDepth, 0.5 * m_TParams.m_dDiam, dElev)) { if ( dElev < EPS_SMALL && AreSameVectorApprox( vtExtr, Z_AX)) { BBox3d b3Crv ; pCompo->GetLocalBBox( b3Crv) ; @@ -1052,9 +1052,12 @@ Milling::ProcessPath( int nPathId, int nPvId, int nClId) return false ; // verifico di non superare il massimo materiale - if ( ( m_Params.m_dStep < EPS_SMALL && dElev > m_TParams.m_dMaxMat + EPS_SMALL) || + const double MAXMAT_TOL = EPS_SMALL ; + if ( ( m_Params.m_dStep < EPS_SMALL && dElev > m_TParams.m_dMaxMat + MAXMAT_TOL) || ( m_Params.m_dStep > EPS_SMALL && m_Params.m_dStep > m_TParams.m_dMaxMat + EPS_SMALL)) { - LOG_INFO( GetEMkLogger(), "Error in Milling : machining depth bigger than MaxMaterial") ; + string sInfo = "Error in Milling : machining depth (" + ToString( dElev, 1) + + ") bigger than MaxMaterial (" + ToString( m_TParams.m_dMaxMat, 1) + ")" ; + LOG_INFO( GetEMkLogger(), sInfo.c_str()) ; return false ; } @@ -1119,7 +1122,7 @@ Milling::ProcessPath( int nPathId, int nPvId, int nClId) //---------------------------------------------------------------------------- bool -Milling::CalcPathElevation( const ICurveComposite* pCompo, const Vector3d& vtTool, double dDepth, +Milling::CalcPathElevation( const ICurveComposite* pCompo, const Vector3d& vtTool, double dDepth, double dRad, double& dElev) { dElev = 0 ; @@ -1133,7 +1136,21 @@ Milling::CalcPathElevation( const ICurveComposite* pCompo, const Vector3d& vtToo pCrvC->GetStartPoint( ptStart) ; pCrvC->GetMidPoint( ptMid) ; pCrvC->GetEndPoint( ptEnd) ; + Vector3d vtStartPerp, vtMidPerp, vtEndPerp, vtTg ; + pCrvC->GetStartDir( vtTg) ; + vtStartPerp = vtTg ^ vtTool ; + vtStartPerp.Normalize() ; + vtStartPerp *= dRad ; + pCrvC->GetMidDir( vtTg) ; + vtMidPerp = vtTg ^ vtTool ; + vtMidPerp.Normalize() ; + vtMidPerp *= dRad ; + pCrvC->GetEndDir( vtTg) ; + vtEndPerp = vtTg ^ vtTool ; + vtEndPerp.Normalize() ; + vtEndPerp *= dRad ; Vector3d vtDepth = vtTool * dDepth ; + // linea centro utensile if ( GetElevation( m_nPhase, ptStart - vtDepth, ptMid - vtDepth, ptEnd - vtDepth, vtTool, dCurrElev)) { if ( dCurrElev > dElev) dElev = dCurrElev ; @@ -1142,6 +1159,26 @@ Milling::CalcPathElevation( const ICurveComposite* pCompo, const Vector3d& vtToo LOG_INFO( GetEMkLogger(), "Error in Milling : Entity GetElevation") ; return false ; } + // da una parte + if ( GetElevation( m_nPhase, ptStart + vtStartPerp - vtDepth, ptMid + vtMidPerp - vtDepth, + ptEnd + vtEndPerp - vtDepth, vtTool, dCurrElev)) { + if ( dCurrElev > dElev) + dElev = dCurrElev ; + } + else { + LOG_INFO( GetEMkLogger(), "Error in Milling : Entity GetElevation") ; + return false ; + } + // dall'altra parte + if ( GetElevation( m_nPhase, ptStart - vtStartPerp - vtDepth, ptMid - vtMidPerp - vtDepth, + ptEnd - vtEndPerp - vtDepth, vtTool, dCurrElev)) { + if ( dCurrElev > dElev) + dElev = dCurrElev ; + } + else { + LOG_INFO( GetEMkLogger(), "Error in Milling : Entity GetElevation") ; + return false ; + } } return true ; } diff --git a/Milling.h b/Milling.h index 38cd635..f1be6f2 100644 --- a/Milling.h +++ b/Milling.h @@ -66,7 +66,7 @@ class Milling : public Machining ICurve* GetCurve( SelData Id) ; bool Chain( int nGrpDestId) ; bool ProcessPath( int nPathId, int nPvId, int nClId) ; - bool CalcPathElevation( const ICurveComposite* pCompo, const Vector3d& vtTool, double dDepth, double& dElev) ; + bool CalcPathElevation( const ICurveComposite* pCompo, const Vector3d& vtTool, double dDepth, double dRad, double& dElev) ; bool GenerateMillingPv( int nPathId, const ICurveComposite* pCompo) ; bool AddStandardMilling( const ICurveComposite* pCompo, const Vector3d& vtTool, const Vector3d& vtExtr, double dDepth, double dElev, bool bSplitArcs) ;