From 57acbc93b4f7040193228fdb5876a6ded7cf0c83 Mon Sep 17 00:00:00 2001 From: Riccardo Elitropi Date: Mon, 5 May 2025 09:13:02 +0200 Subject: [PATCH 1/2] EgtMachKernel : - piccola miglioria ad Apply in PocketingNT. --- PocketingNT.cpp | 29 ++++++++++++++++++++++------- PocketingNT.h | 2 ++ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/PocketingNT.cpp b/PocketingNT.cpp index 645f949..6d3badd 100644 --- a/PocketingNT.cpp +++ b/PocketingNT.cpp @@ -106,7 +106,7 @@ const string UN_OPENEXTENSION = "OpenExtension" ; // _debug #define DEBUG_OPEN_EDGE_EXTENSION 0 #define DEBUG_FLATREGIONS 0 -#if DEBUG_OPEN_EDGE_EXTENSION || DEBUG_FLATREGIONS +#if DEBUG_OPEN_EDGE_EXTENSION || DEBUG_FLATREGIONS #include "EgtDev/Include/EGkGeoPoint3d.h" #include "EgtDev/Include/EGkFrame3d.h" #endif @@ -280,6 +280,7 @@ PocketingNT::PocketingNT( void) m_bAggrBottom = false ; m_bOpenOutRaw = false ; m_dOpenMinSafe = 0 ; + m_bRunning = false ; } //---------------------------------------------------------------------------- @@ -602,7 +603,7 @@ PocketingNT::Preview( bool bRecalc) m_pGeomDB->GetInfo( nToolId, TTH_DIAM, m_dTHoldDiam) ; // se necessario, eseguo concatenamento ed inserisco i percorsi sotto la geometria ausiliaria - if ( bChain && ! Chain( nAuxId)) { + if ( bChain && ! Chain( nAuxId)) { m_pMchMgr->SetLastError( 2421, "Error in PocketingNT : Chaining failed") ; return false ; } @@ -634,6 +635,21 @@ PocketingNT::Preview( bool bRecalc) //---------------------------------------------------------------------------- bool PocketingNT::Apply( bool bRecalc, bool bPostApply) +{ + // se calcoli già in corso, esco + if ( m_bRunning) { + LOG_DBG_INFO( GetEMkLogger(), "PocketingNT::Apply already running") ; + return true ; + } + m_bRunning = true ; + bool bOk = MyApply( bRecalc, bPostApply) ; + m_bRunning = false ; + return bOk ; +} + +//---------------------------------------------------------------------------- +bool +PocketingNT::MyApply( bool bRecalc, bool bPostApply) { // reset numero percorsi di svuotatura generati int nCurrPockets = m_nPockets ; @@ -1214,7 +1230,7 @@ PocketingNT::GetCurves( SelData Id, ICURVEPLIST& lstPC) } // se altrimenti superficie else if ( pGObj->GetType() == SRF_TRIMESH) { - // recupero la trimesh + // recupero la trimesh const ISurfTriMesh* pSurf = ::GetSurfTriMesh( pGObj) ; if ( pSurf == nullptr) return false ; @@ -1385,7 +1401,6 @@ PocketingNT::SetSfrLoopsAllTempProp( int nSfrId, ISurfFlatRegion* pSfr) for ( int& i : vOpen) pSfr->SetCurveTempProp( 0, nCount, i, TEMP_PROP_OPEN_EDGE, 0) ; } ; - return true ; } @@ -1399,7 +1414,7 @@ PocketingNT::ResetCurveAllTempProp( ICurve* pCurve) ICurveComposite* pCC = GetCurveComposite( pCurve) ; if ( pCC != nullptr) { for ( int i = 0 ; i < pCC->GetCurveCount() ; ++ i) - pCC->SetCurveTempProp( i, 0) ; + pCC->SetCurveTempProp( i, TEMP_PROP_CLOSE_EDGE) ; } return true ; } @@ -1493,7 +1508,7 @@ PocketingNT::Chain( int nGrpDestId) if ( pCrvCompo->GetCurveCount() == 0) continue ; // se la curva non è chiusa, errore - if ( ! pCrvCompo->IsClosed()) { + if ( ! pCrvCompo->IsClosed()) { m_pMchMgr->SetLastError( 2402, "Error in PocketingNT : Open Contour") ; return false ; } @@ -1890,7 +1905,7 @@ PocketingNT::ExtendOpenEdgesToRaw( ICurveComposite* pCompo, const Vector3d& vtEx m_pGeomDB->SetMaterial( a, Color( 0.2, 0.2, 0.8, .65)) ; #endif - // recupero il Box del grezzo definito dal frame implito dal piano + // recupero il Box del grezzo definito dal frame implicito dal piano Frame3d frCut ; if ( ! frCut.Set( ptC, vtExtr)) return false ; diff --git a/PocketingNT.h b/PocketingNT.h index a9464d3..3649fd7 100644 --- a/PocketingNT.h +++ b/PocketingNT.h @@ -93,6 +93,7 @@ class PocketingNT : public Machining PocketingNT( void) ; private : + bool MyApply( bool bRecalc, bool bPostApply) ; bool VerifyGeometry( SelData Id, int& nSubs, int& nType) ; bool GetCurves( SelData Id, ICURVEPLIST& lstPC) ; bool SetCurveAllTempProp( int nCrvId, bool bForcedClose, ICurve* pCurve, bool* pbSomeOpen = nullptr) ; @@ -200,4 +201,5 @@ class PocketingNT : public Machining double m_dOpenMinSafe ; // minima distanza di sicurezza di attacco su lato aperto double m_dOpenExtension ; // estensione dei tratti aperti dentro al grezzo bool m_bAllClose ; // flag per forzare i lati come tutti chiusi + bool m_bRunning ; // flag di calcoli in corso } ; \ No newline at end of file From 77bd37f9f7b28be9ad29558503b1a4a00b945f29 Mon Sep 17 00:00:00 2001 From: Riccardo Elitropi Date: Mon, 5 May 2025 12:24:19 +0200 Subject: [PATCH 2/2] EgtMachKernel : - in PocketingNT aggiunto controllo per AddApproach. --- PocketingNT.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/PocketingNT.cpp b/PocketingNT.cpp index 5edb485..b7c884f 100644 --- a/PocketingNT.cpp +++ b/PocketingNT.cpp @@ -2806,8 +2806,8 @@ PocketingNT::CalcPaths( STEPINFOPOVECTOR& vStepInfo) if ( vCrvPaths.empty()) continue ; // sistemo gli archi per massimo angolo al centro - for ( int i = 0 ; i < int( vCrvPaths.size()) ; ++ i) - VerifyArcs( vCrvPaths[i]) ; + for ( int j = 0 ; j < int( vCrvPaths.size()) ; ++ j) + VerifyArcs( vCrvPaths[j]) ; // recupero il punto finale del percorso per lo step successivo vCrvPaths.back()->GetEndPoint( ptEndLastPath) ; // inserisco i percorsi nel vettore dei Paths @@ -2954,14 +2954,16 @@ PocketingNT::AddPocket( STEPINFOPOVECTOR& vStepInfo, const Vector3d& vtTool, dou else if ( ! currPath.bOutStart) ptP1 += vtTool * ( - currStep.dRelativeDepth + dMyLIO_ELEV_TOL) ; } - // approccio al punto iniziale + // approccio al punto iniziale ( se punti non allineati lungo vtTool) double dMySafeZ = ( bAbsFirst ? dSafeZ : 0.) ; Point3d ptMyPos ; GetCurrPos( ptMyPos) ; double dMyElev = ( bAbsFirst ? dCurrElev : ( ptMyPos - ptP1) * vtTool) ; double dMyAppr = ( bAbsFirst ? dAppr : 0.) ; - if ( ! AddApproach( ptP1, vtTool, dMySafeZ, dSafeAggrBottZ, dMyElev, dMyAppr, bSplitArcs, currPath.bOutStart)) { - m_pMchMgr->SetLastError( 3011, "Error in PocketingNT : Approach not computable") ; - return false ; + if ( bAbsFirst || ! OrthoCompo( ptMyPos - ptP1, vtTool).IsSmall()) { + if ( ! AddApproach( ptP1, vtTool, dMySafeZ, dSafeAggrBottZ, dMyElev, dMyAppr, bSplitArcs, currPath.bOutStart)) { + m_pMchMgr->SetLastError( 3011, "Error in PocketingNT : Approach not computable") ; + return false ; + } } // aggiungo attacco SetFeed( GetStartFeed()) ; @@ -3064,9 +3066,12 @@ PocketingNT::AddPocket( STEPINFOPOVECTOR& vStepInfo, const Vector3d& vtTool, dou } // tratto lineare sopra al punto corrente SetFeed( GetEndFeed()) ; - AddLinearMove( ptEnd + vtTool * dCurrElev, bSplitArcs) ; + Point3d ptCheck ; + if ( GetCurrPos( ptCheck) && ! AreSamePointApprox( ptCheck, ptEnd + vtTool * dCurrElev)) + AddLinearMove( ptEnd + vtTool * dCurrElev, bSplitArcs) ; // tratto lineare sopra a ptDest - AddLinearMove( ptDest + vtTool * dNextElev, bSplitArcs) ; + if ( GetCurrPos( ptCheck) && ! AreSamePointApprox( ptCheck, ptDest + vtTool * dNextElev)) + AddLinearMove( ptDest + vtTool * dNextElev, bSplitArcs) ; // aggiorno le elevazioni dCurrElev = dNextElev ; }