diff --git a/EgtMachKernel.rc b/EgtMachKernel.rc index e72f066..c164383 100644 Binary files a/EgtMachKernel.rc and b/EgtMachKernel.rc differ diff --git a/Milling.cpp b/Milling.cpp index faf6cbb..ff8a78a 100644 --- a/Milling.cpp +++ b/Milling.cpp @@ -45,6 +45,7 @@ using namespace std ; // 2311 = "Error in Milling : Linear Approx not computable" // 2312 = "Error in Milling : LeadIn must be out of rawpart" // 2313 = "Error in Milling : Chaining failed" +// 2314 = "Error in Milling : Tool MaxMaterial too small (xx)" //---------------------------------------------------------------------------- USEROBJ_REGISTER( "EMkMilling", Milling) ; @@ -1240,17 +1241,43 @@ Milling::ProcessPath( int nPathId, int nPvId, int nClId) else return false ; + // verifico che lo step dell'utensile sia sensato + double dOkStep = m_Params.m_dStep ; + const double MIN_ZSTEP = 1.0 ; + if ( dOkStep < MIN_ZSTEP) { + dOkStep = MIN_ZSTEP ; + string sInfo = "Warning in Milling : machining step too small (" + + ToString( m_Params.m_dStep, 2) + ")" ; + LOG_INFO( GetEMkLogger(), sInfo.c_str()) ; + } + // per frese normali, verifico di non superare il massimo materiale if ( ( m_TParams.m_nType & TF_SAWBLADE) == 0) { - 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)) { + // verifico che il massimo materiale dell'utensile sia sensato + const double MIN_MAXMAT = 1.0 ; + if ( m_TParams.m_dMaxMat < dElev && m_TParams.m_dMaxMat < MIN_MAXMAT) { + string sInfo = "Error in Milling : Tool MaxMaterial too small (" + + ToString( m_TParams.m_dMaxMat, 2) + ")" ; + m_pMchMgr->SetLastError( 2314, sInfo) ; + return false ; + } + // se lo step supera la capacità dell'utensile + if ( m_Params.m_dStep > m_TParams.m_dMaxMat + EPS_SMALL) { + dOkStep = m_TParams.m_dMaxMat ; + string sInfo = "Warning in Milling : machining step (" + ToString( m_Params.m_dStep, 1) + + ") bigger than MaxMaterial (" + ToString( m_TParams.m_dMaxMat, 1) + ")" ; + LOG_INFO( GetEMkLogger(), sInfo.c_str()) ; + } + // se lavorazione singola e l'elevazione supera la capacità dell'utensile + if ( ( dOkStep < EPS_SMALL || dOkStep > dElev) && dElev > m_TParams.m_dMaxMat + EPS_SMALL) { + // se affondamento riducibile : segnalo, riduco e continuo if ( dDepth + max( dThick, 0.0) > m_TParams.m_dMaxMat) { dDepth = m_TParams.m_dMaxMat - max( dThick, 0.0) ; string sInfo = "Warning in Milling : machining depth (" + ToString( dElev, 1) + ") bigger than MaxMaterial (" + ToString( m_TParams.m_dMaxMat, 1) + ")" ; LOG_INFO( GetEMkLogger(), sInfo.c_str()) ; } + // altrimenti errore else { string sInfo = "Error in Milling : machining depth (" + ToString( dElev, 1) + ") bigger than MaxMaterial (" + ToString( m_TParams.m_dMaxMat, 1) + ")" ; @@ -1298,18 +1325,18 @@ Milling::ProcessPath( int nPathId, int nPvId, int nClId) SetToolDir( vtTool) ; // Se una sola passata - if ( m_Params.m_dStep < EPS_SMALL || dElev <= m_Params.m_dStep) { + if ( dOkStep < EPS_SMALL || dElev <= dOkStep) { if ( ! AddStandardMilling( pCompo, vtTool, vtExtr, dDepth, dElev, bSplitArcs)) return false ; } // se altrimenti passate a zig-zag else if ( m_Params.m_nStepType == MILL_ST_ZIGZAG) { - if ( ! AddZigZagMilling( pCompo, vtTool, vtExtr, dDepth, dElev, bSplitArcs)) + if ( ! AddZigZagMilling( pCompo, vtTool, vtExtr, dDepth, dElev, dOkStep, bSplitArcs)) return false ; } // se altrimenti passate a one-way else if ( m_Params.m_nStepType == MILL_ST_ONEWAY) { - if ( ! AddOneWayMilling( pCompo, vtTool, vtExtr, dDepth, dElev, bSplitArcs)) + if ( ! AddOneWayMilling( pCompo, vtTool, vtExtr, dDepth, dElev, dOkStep, bSplitArcs)) return false ; } // se altrimenti passate a spirale @@ -1321,7 +1348,7 @@ Milling::ProcessPath( int nPathId, int nPvId, int nClId) pCompo->TrimEndAtLen( dLen - m_Params.m_dOverlap) ; } // eseguo - if ( ! AddSpiralMilling( pCompo, vtTool, vtExtr, dDepth, dElev, bSplitArcs)) + if ( ! AddSpiralMilling( pCompo, vtTool, vtExtr, dDepth, dElev, dOkStep, bSplitArcs)) return false ; } @@ -1639,7 +1666,7 @@ Milling::AddStandardMilling( const ICurveComposite* pCompo, const Vector3d& vtTo //---------------------------------------------------------------------------- bool Milling::AddZigZagMilling( const ICurveComposite* pCompo, const Vector3d& vtTool, const Vector3d& vtExtr, - double dDepth, double dElev, bool bSplitArcs) + double dDepth, double dElev, double dOkStep, bool bSplitArcs) { // recupero distanza di sicurezza double dSafeZ = m_pMchMgr->GetCurrMachiningsMgr()->GetSafeZ() ; @@ -1647,7 +1674,7 @@ Milling::AddZigZagMilling( const ICurveComposite* pCompo, const Vector3d& vtTool double dAppr = m_Params.m_dStartPos ; // determino numero e affondamento degli step - int nStep = max( 1, static_cast( ceil( dElev / m_Params.m_dStep))) ; + int nStep = max( 1, static_cast( ceil( dElev / dOkStep))) ; double dStep = dElev / nStep ; bool bClosed = pCompo->IsClosed() ; @@ -1779,7 +1806,7 @@ Milling::AddZigZagMilling( const ICurveComposite* pCompo, const Vector3d& vtTool //---------------------------------------------------------------------------- bool Milling::AddOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtTool, const Vector3d& vtExtr, - double dDepth, double dElev, bool bSplitArcs) + double dDepth, double dElev, double dOkStep, bool bSplitArcs) { // recupero distanza di sicurezza double dSafeZ = m_pMchMgr->GetCurrMachiningsMgr()->GetSafeZ() ; @@ -1787,7 +1814,7 @@ Milling::AddOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtTool double dAppr = m_Params.m_dStartPos ; // determino numero e affondamento degli step - int nStep = max( 1, static_cast( ceil( dElev / m_Params.m_dStep))) ; + int nStep = max( 1, static_cast( ceil( dElev / dOkStep))) ; double dStep = dElev / nStep ; bool bClosed = pCompo->IsClosed() ; @@ -1900,7 +1927,7 @@ Milling::AddOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtTool //---------------------------------------------------------------------------- bool Milling::AddSpiralMilling( const ICurveComposite* pCompo, const Vector3d& vtTool, const Vector3d& vtExtr, - double dDepth, double dElev, bool bSplitArcs) + double dDepth, double dElev, double dOkStep, bool bSplitArcs) { // recupero distanza di sicurezza double dSafeZ = m_pMchMgr->GetCurrMachiningsMgr()->GetSafeZ() ; @@ -1912,7 +1939,7 @@ Milling::AddSpiralMilling( const ICurveComposite* pCompo, const Vector3d& vtTool dStart = m_Params.m_dLiElev ; // determino numero e affondamento degli step - int nStep = max( 1, static_cast( ceil( ( dElev + dStart) / m_Params.m_dStep))) ; + int nStep = max( 1, static_cast( ceil( ( dElev + dStart) / dOkStep))) ; double dStep = ( dElev + dStart) / nStep ; // determino dati del percorso @@ -2299,6 +2326,9 @@ 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, ZIGZAG e HELIX -> NONE !!! + if ( nType == MILL_LI_GLIDE || nType == MILL_LI_ZIGZAG || nType == MILL_LI_HELIX) + nType = MILL_LI_NONE ; // Calcolo punto iniziale switch ( nType) { case MILL_LI_NONE : @@ -2314,6 +2344,12 @@ Milling::CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart, const case MILL_LI_GLIDE : // !!! DA FARE !!! return false ; + case MILL_LI_ZIGZAG : + // !!! DA FARE !!! + return false ; + case MILL_LI_HELIX : + // !!! DA FARE !!! + return false ; default : return false ; } @@ -2346,6 +2382,9 @@ Milling::AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d& // se parametri tg e perp entrambi nulli, allora nessun attacco if ( (( ptStart - ptP1) ^ vtN).IsSmall()) nType = MILL_LI_NONE ; + // !!! provvisorio : GLIDE, ZIGZAG e HELIX -> NONE !!! + if ( nType == MILL_LI_GLIDE || nType == MILL_LI_ZIGZAG || nType == MILL_LI_HELIX) + nType = MILL_LI_NONE ; // Eseguo a seconda del tipo switch ( nType) { case MILL_LI_NONE : @@ -2455,6 +2494,9 @@ 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) + nType = MILL_LO_NONE ; // eseguo a seconda del tipo switch ( nType) { case MILL_LO_NONE : diff --git a/Milling.h b/Milling.h index 9544a3f..799a212 100644 --- a/Milling.h +++ b/Milling.h @@ -73,11 +73,11 @@ class Milling : public Machining bool AddStandardMilling( const ICurveComposite* pCompo, const Vector3d& vtTool, const Vector3d& vtExtr, double dDepth, double dElev, bool bSplitArcs) ; bool AddZigZagMilling( const ICurveComposite* pCompo, const Vector3d& vtTool, const Vector3d& vtExtr, - double dDepth, double dElev, bool bSplitArcs) ; + double dDepth, double dElev, double dOkStep, bool bSplitArcs) ; bool AddOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtTool, const Vector3d& vtExtr, - double dDepth, double dElev, bool bSplitArcs) ; + double dDepth, double dElev, double dOkStep, bool bSplitArcs) ; bool AddSpiralMilling( const ICurveComposite* pCompo, const Vector3d& vtTool, const Vector3d& vtExtr, - double dDepth, double dElev, bool bSplitArcs) ; + double dDepth, double dElev, double dOkStep, bool bSplitArcs) ; 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, bool bInvert, diff --git a/Pocketing.cpp b/Pocketing.cpp index d0c914b..e4b908c 100644 --- a/Pocketing.cpp +++ b/Pocketing.cpp @@ -52,6 +52,7 @@ using namespace std ; // 2417 = "Error in Pocketing : Linear Approx not computable" // 2418 = "Error in Pocketing : Return toolpath not computable" // 2419 = "Error in Pocketing : Chaining failed" +// 2420 = "Error in Pocketing : Tool MaxMaterial too small (xxx)" //---------------------------------------------------------------------------- USEROBJ_REGISTER( "EMkPocketing", Pocketing) ; @@ -1078,10 +1079,35 @@ Pocketing::ProcessPath( int nPathId, int nPvId, int nClId) else return false ; + // verifico che il massimo materiale dell'utensile sia sensato + const double MIN_MAXMAT = 1.0 ; + if ( m_TParams.m_dMaxMat < dElev && m_TParams.m_dMaxMat < MIN_MAXMAT) { + string sInfo = "Error in Pocketing : Tool MaxMaterial too small (" + + ToString( m_TParams.m_dMaxMat, 2) + ")" ; + m_pMchMgr->SetLastError( 2420, sInfo) ; + return false ; + } + + // verifico che lo step dell'utensile sia sensato + double dOkStep = m_Params.m_dStep ; + const double MIN_ZSTEP = 1.0 ; + if ( dOkStep < MIN_ZSTEP) { + dOkStep = MIN_ZSTEP ; + string sInfo = "Warning in Pocketing : machining step too small (" + + ToString( m_Params.m_dStep, 2) + ")" ; + LOG_INFO( GetEMkLogger(), sInfo.c_str()) ; + } + // verifico di non superare il massimo materiale - 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)) { + // se lo step supera la capacità dell'utensile + if ( m_Params.m_dStep > m_TParams.m_dMaxMat + EPS_SMALL) { + dOkStep = m_TParams.m_dMaxMat ; + string sInfo = "Warning in Pocketing : machining step (" + ToString( m_Params.m_dStep, 1) + + ") bigger than MaxMaterial (" + ToString( m_TParams.m_dMaxMat, 1) + ")" ; + LOG_INFO( GetEMkLogger(), sInfo.c_str()) ; + } + // se lavorazione singola e l'elevazione supera la capacità dell'utensile + if ( ( dOkStep < EPS_SMALL || dOkStep > dElev) && dElev > m_TParams.m_dMaxMat + EPS_SMALL) { if ( dDepth + max( dThick, 0.0) > m_TParams.m_dMaxMat) { dDepth = m_TParams.m_dMaxMat - max( dThick, 0.0) ; string sInfo = "Warning in Pocketing : machining depth (" + ToString( dElev, 1) + @@ -1147,11 +1173,11 @@ Pocketing::ProcessPath( int nPathId, int nPvId, int nClId) case POCKET_SUB_ZIGZAG : case POCKET_SUB_ONEWAY : case POCKET_SUB_SPIRALIN : - if ( ! AddSpiralIn( pCompo, vtTool, vtExtr, dDepth, dElev, bSplitArcs)) + if ( ! AddSpiralIn( pCompo, vtTool, vtExtr, dDepth, dElev, dOkStep, bSplitArcs)) return false ; break ; case POCKET_SUB_SPIRALOUT : - if ( ! AddSpiralOut( pCompo, vtTool, vtExtr, dDepth, dElev, bSplitArcs)) + if ( ! AddSpiralOut( pCompo, vtTool, vtExtr, dDepth, dElev, dOkStep, bSplitArcs)) return false ; break ; } @@ -1369,7 +1395,7 @@ GetCurveRadius( const ICurve* pCrv) //---------------------------------------------------------------------------- bool Pocketing::AddSpiralIn( const ICurveComposite* pCompo, const Vector3d& vtTool, const Vector3d& vtExtr, - double dDepth, double dElev, bool bSplitArcs) + double dDepth, double dElev, double dOkStep, bool bSplitArcs) { // recupero distanza di sicurezza double dSafeZ = m_pMchMgr->GetCurrMachiningsMgr()->GetSafeZ() ; @@ -1388,8 +1414,7 @@ Pocketing::AddSpiralIn( const ICurveComposite* pCompo, const Vector3d& vtTool, c // determino numero e affondamento degli step int nStep = 1 ; - if ( m_Params.m_dStep > 100 * EPS_SMALL) - nStep = max( 1, static_cast( ceil( dElev / m_Params.m_dStep))) ; + nStep = max( 1, static_cast( ceil( dElev / dOkStep))) ; double dStep = dElev / nStep ; int nMaxInd = pMCrv->GetCurveCount() - 1 ; @@ -1512,7 +1537,7 @@ Pocketing::AddSpiralIn( const ICurveComposite* pCompo, const Vector3d& vtTool, c //---------------------------------------------------------------------------- bool Pocketing::AddSpiralOut( const ICurveComposite* pCompo, const Vector3d& vtTool, const Vector3d& vtExtr, - double dDepth, double dElev, bool bSplitArcs) + double dDepth, double dElev, double dOkStep, bool bSplitArcs) { // recupero distanza di sicurezza double dSafeZ = m_pMchMgr->GetCurrMachiningsMgr()->GetSafeZ() ; @@ -1533,8 +1558,7 @@ Pocketing::AddSpiralOut( const ICurveComposite* pCompo, const Vector3d& vtTool, // determino numero e affondamento degli step int nStep = 1 ; - if ( m_Params.m_dStep > 100 * EPS_SMALL) - nStep = max( 1, static_cast( ceil( dElev / m_Params.m_dStep))) ; + nStep = max( 1, static_cast( ceil( dElev / dOkStep))) ; double dStep = dElev / nStep ; int nMaxInd = pMCrv->GetCurveCount() - 1 ; @@ -1941,6 +1965,9 @@ Pocketing::CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart, con double dLen= m_Params.m_dLiTang ; // senso di rotazione da dir tg a dir esterna bool bCcwRot = true ; + // !!! provvisorio : GLIDE -> NONE !!! + if ( nType == POCKET_LI_GLIDE) + nType = POCKET_LI_NONE ; // Calcolo punto iniziale switch ( nType) { case POCKET_LI_NONE : @@ -1964,6 +1991,9 @@ Pocketing::AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3 { // Assegno il tipo int nType = GetLeadInType() ; + // !!! provvisorio : GLIDE -> NONE !!! + if ( nType == POCKET_LI_GLIDE) + nType = POCKET_LI_NONE ; // Eseguo a seconda del tipo switch ( nType) { case POCKET_LI_NONE : diff --git a/Pocketing.h b/Pocketing.h index faea029..d00105f 100644 --- a/Pocketing.h +++ b/Pocketing.h @@ -72,9 +72,9 @@ class Pocketing : public Machining bool VerifyPathFromBottom( const ICurveComposite* pCompo, const Vector3d& vtTool) ; bool GenerateMillingPv( int nPathId, const ICurveComposite* pCompo) ; bool AddSpiralIn( const ICurveComposite* pCompo, const Vector3d& vtTool, const Vector3d& vtExtr, - double dDepth, double dElev, bool bSplitArcs) ; + double dDepth, double dElev, double dOkStep, bool bSplitArcs) ; bool AddSpiralOut( const ICurveComposite* pCompo, const Vector3d& vtTool, const Vector3d& vtExtr, - double dDepth, double dElev, bool bSplitArcs) ; + double dDepth, double dElev, double dOkStep, bool bSplitArcs) ; bool CalcSpiral( const ICurveComposite* pCompo, bool bSplitArcs, ICurveComposite* pMCrv, ICurveComposite* pRCrv) ; bool CalcCircleSpiral( const Point3d& ptCen, const Vector3d& vtN, double dOutRad, double dIntRad,