From 029ed15541dcfec1cde901ab33ed4fe4d62f7e19 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Tue, 25 Mar 2025 11:22:53 +0100 Subject: [PATCH] =?UTF-8?q?EgtMachKernel=20:=20-=20i=20punti=20intermedi?= =?UTF-8?q?=20aggiunti=20per=20garantire=20movimento=20punta=20utensile=20?= =?UTF-8?q?al=20cambio=20di=20orientamento=20sono=20ora=20basati=20su=20pu?= =?UTF-8?q?nti=20e=20non=20pi=C3=B9=20su=20linee=20(potrebbero=20essere=20?= =?UTF-8?q?estremamente=20vicini).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Operation.cpp | 60 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 21 deletions(-) diff --git a/Operation.cpp b/Operation.cpp index b89e409..0bf574b 100644 --- a/Operation.cpp +++ b/Operation.cpp @@ -1901,6 +1901,7 @@ Operation::CalculateClPathAxesValues( int nClPathId, int nLinAxes, int nRotAxes, Vector3d vtAuxPrec ; Vector3d vtCorrPrec ; DBLVECTOR vAxPrec ; + int nFlag2Prec = 0 ; // ciclo su tutte le entità del percorso CL nOutStrC = 0 ; bool bOk = true ; @@ -1988,19 +1989,23 @@ Operation::CalculateClPathAxesValues( int nClPathId, int nLinAxes, int nRotAxes, int nMoveType = pCamData->GetMoveType() ; // se punto finale di linea if ( ! bFirst && pCamData->IsLine()) { - // Verifica ricorsiva del punto medio - bool bMidAdded ; - bool bAxesError ; - if ( ! VerifyLineMidPoint( ptPrec, vtDirPrec, vtAuxPrec, vtCorrPrec, vAxPrec, - ptP, vtDir, vtAux, vtCorr, vAxVal, - 0, nEntId, dRot1W, nMoveType, bMidAdded, bAxesError)) { - string sOut = "Error : VerifyLineMidPoint of CalculateClPathAxesValues failed (EntId=" + ToString( nEntId) + ")" ; - LOG_ERROR( GetEMkLogger(), sOut.c_str()) - return false ; - } - if ( bAxesError) { - bOk = false ; - continue ; + // Verifica ricorsiva del punto medio (se non già fatta) + bool bMidAdded = false ; + if ( nFlag2Prec == -1 || pCamData->GetFlag2() == -1) + bMidAdded = true ; + else { + bool bAxesError ; + if ( ! VerifyLineMidPoint( ptPrec, vtDirPrec, vtAuxPrec, vtCorrPrec, vAxPrec, + ptP, vtDir, vtAux, vtCorr, vAxVal, + 1, nEntId, dRot1W, nMoveType, bMidAdded, bAxesError)) { + string sOut = "Error : VerifyLineMidPoint of CalculateClPathAxesValues failed (EntId=" + ToString( nEntId) + ")" ; + LOG_ERROR( GetEMkLogger(), sOut.c_str()) + return false ; + } + if ( bAxesError) { + bOk = false ; + continue ; + } } // Se esistono aree protette, devo comunque verificare i punti intermedi if ( ! bMidAdded && m_pMchMgr->ExistProtectedAreas()) { @@ -2145,6 +2150,7 @@ Operation::CalculateClPathAxesValues( int nClPathId, int nLinAxes, int nRotAxes, vtCorrPrec = vtCorr ; vAxPrec = vAxVal ; vAxRotPrec = vAxRot ; + nFlag2Prec = pCamData->GetFlag2() ; } return bOk ; @@ -2316,7 +2322,7 @@ Operation::VerifyLineMidPoint( const Point3d& ptPrec, const Vector3d& vtDirPrec, return true ; // se superato il limite di ricursioni, non devo fare alcunché - const int MAX_RECURSION = 6 ; + const int MAX_RECURSION = 8 ; if ( nCnt > MAX_RECURSION) return true ; @@ -2379,16 +2385,27 @@ Operation::VerifyLineMidPoint( const Point3d& ptPrec, const Vector3d& vtDirPrec, vtCorrMid.ToGlob( refMid) ; } } - // inserisco nuova entità e modifico vecchia - int nMidEntId = m_pGeomDB->Copy( nEntId, GDB_ID_NULL, nEntId, GDB_BEFORE) ; + // inserisco nuova entità punto (per evitare problemi di lunghezza linea) + // creo oggetto punto per DB geometrico + PtrOwner pGP( CreateGeoPoint3d()) ; + if ( IsNull( pGP)) + return false ; + // assegno le coordinate del punto + pGP->Set( ptP) ; + // inserisco l'oggetto nel DB geometrico + int nMidEntId = m_pGeomDB->InsertGeoObj( GDB_ID_NULL, nEntId, GDB_BEFORE, Release( pGP)) ; if ( nMidEntId == GDB_ID_NULL) return false ; - ICurve* pCurve = GetCurve( m_pGeomDB->GetGeoObj( nEntId)) ; - if ( pCurve == nullptr || ! pCurve->ModifyStart( ptMid)) + // creo oggetto dati Cam + const CamData* pEntCam = GetCamData( m_pGeomDB->GetUserObj( nEntId)) ; + if ( pEntCam == nullptr) return false ; - ICurve* pMidCurve = GetCurve( m_pGeomDB->GetGeoObj( nMidEntId)) ; - if ( pMidCurve == nullptr || ! pMidCurve->ModifyEnd( ptMid)) + PtrOwner pCam( pEntCam->Clone()) ; + if ( IsNull( pCam)) return false ; + // associo questo oggetto a quello geometrico + m_pGeomDB->SetUserObj( nMidEntId, Release( pCam)) ; + // assegno valori CamData* pMidCamData = GetCamData( m_pGeomDB->GetUserObj( nMidEntId)) ; if ( pMidCamData == nullptr) return false ; @@ -2397,6 +2414,7 @@ Operation::VerifyLineMidPoint( const Point3d& ptPrec, const Vector3d& vtDirPrec, pMidCamData->SetAuxDir( vtAuxMid) ; pMidCamData->SetCorrDir( vtCorrMid) ; pMidCamData->SetFlag2( -1) ; + pMidCamData->SetToolShow( nCnt < 4) ; // calcolo gli assi rotanti per il punto medio DBLVECTOR vAxRotHome( int( vAxVal.size() - 3)) ; DBLVECTOR vAxRotPrec( int( vAxVal.size() - 3)) ; @@ -2435,7 +2453,7 @@ Operation::VerifyLineMidPoint( const Point3d& ptPrec, const Vector3d& vtDirPrec, pMidCamData->SetBackAuxDir( vtBackAux) ; // devo verificare le due nuove parti - nCnt ++ ; + ++ nCnt ; bool bAdded1, bAxError1, bAdded2, bAxError2 ; if ( ! VerifyLineMidPoint( ptPrec, vtDirPrec, vtAuxPrec, vtCorrPrec, vAxPrec, ptMid, vtDirMid, vtAuxMid, vtCorrMid, vAxMid,