From 0722c496ac3adc43c171219216933d69acb780bc Mon Sep 17 00:00:00 2001 From: Riccardo Elitropi Date: Fri, 3 Apr 2026 11:07:27 +0200 Subject: [PATCH 1/6] EgtMachKernel : - in PocketingNT corretto parametro SideStep per Lucidature. --- PocketingNT.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/PocketingNT.cpp b/PocketingNT.cpp index 4181aff..994eaaf 100644 --- a/PocketingNT.cpp +++ b/PocketingNT.cpp @@ -4341,11 +4341,14 @@ PocketingNT::CalcPaths( STEPINFOPOVECTOR& vStepInfo) } } + // determino il SideStep + double dSideStep = ( ! bPolishing ? GetSideStep() : m_Params.m_dSideStep) ; + // scorro gli indici delle superfici for ( int i = 0 ; i < int( vStepInfo.size()) ; ++ i) { // calcolo i percorsi di Pocketing ( o di lucidatura se richiesto) ICRVCOMPOPOVECTOR vCrvPaths ; - if ( ! CalcPocketing( vStepInfo[i].pSfrPock, m_TParams.m_dDiam / 2, GetOffsR(), GetSideStep(), + if ( ! CalcPocketing( vStepInfo[i].pSfrPock, m_TParams.m_dDiam / 2, GetOffsR(), dSideStep, m_Params.m_dSideAngle, m_dOpenMinSafe, m_Params.m_nSubType, true, true, m_Params.m_bInvert, false, true, bAdjustFeed, ptStartRef, vStepInfo[i].pSfrLimit, bAllOffset, dMaxOptSize, GetLeadInType(), m_Params.m_dLiTang, m_Params.m_dLiElev, GetLeadOutType(), m_Params.m_dLoTang, From 79e1e9fefd4ab77bc83a80c396fce488d61d6d47 Mon Sep 17 00:00:00 2001 From: Riccardo Elitropi Date: Fri, 3 Apr 2026 16:21:53 +0200 Subject: [PATCH 2/6] EgtMachKernel : - in Preview utensile piccole modifiche e migliorie. --- Machining.cpp | 95 ++++++++++++++++++++++++++++++++++++++++++++------- Machining.h | 9 +++-- 2 files changed, 88 insertions(+), 16 deletions(-) diff --git a/Machining.cpp b/Machining.cpp index ec6d97e..f6eabfa 100644 --- a/Machining.cpp +++ b/Machining.cpp @@ -47,10 +47,12 @@ Machining::Machining( void) m_nLookFlag = MCH_LOOK_TAB_HEAD ; m_nPreviewHeadId = GDB_ID_NULL ; m_nPreviewHeadIdDBL = GDB_ID_NULL ; + m_nPreviewExitId = GDB_ID_NULL ; + m_nPreviewExitIdDBL = GDB_ID_NULL ; m_nPreviewToolTip = GDB_ID_NULL ; m_nPreviewToolTipDBL = GDB_ID_NULL ; m_vPreviewAxisIds = {} ; - m_vPreviewAxisIdsBBL = {} ; + m_vPreviewAxisIdsDBL = {} ; } //---------------------------------------------------------------------------- @@ -59,10 +61,12 @@ Machining::~Machining( void) m_nLookFlag = MCH_LOOK_NONE ; m_nPreviewHeadId = GDB_ID_NULL ; m_nPreviewHeadIdDBL = GDB_ID_NULL ; + m_nPreviewExitId = GDB_ID_NULL ; + m_nPreviewExitIdDBL = GDB_ID_NULL ; m_nPreviewToolTip = GDB_ID_NULL ; m_nPreviewToolTipDBL = GDB_ID_NULL ; m_vPreviewAxisIds.clear() ; - m_vPreviewAxisIdsBBL.clear() ; + m_vPreviewAxisIdsDBL.clear() ; } //---------------------------------------------------------------------------- @@ -165,17 +169,20 @@ Machining::MyChangeToolPreviewShow( int nLookFlag, bool bDouble) // se non esiste il gruppo di Preview, errore int nCurrStdId = GDB_ID_NULL ; int nCurrHeadId = GDB_ID_NULL ; + int nCurrExitId = GDB_ID_NULL ; if ( ! bDouble) { nCurrStdId = m_pGeomDB->GetFirstNameInGroup( GetOwner(), MCH_ST) ; if ( nCurrStdId == GDB_ID_NULL || m_nPreviewHeadId == GDB_ID_NULL) return false ; nCurrHeadId = m_nPreviewHeadId ; + nCurrExitId = m_nPreviewExitId ; } else { nCurrStdId = m_pGeomDB->GetFirstNameInGroup( GetOwner(), MCH_ST_DBL) ; if ( nCurrStdId == GDB_ID_NULL || m_nPreviewHeadIdDBL == GDB_ID_NULL) return false ; nCurrHeadId = m_nPreviewHeadIdDBL ; + nCurrExitId = m_nPreviewExitIdDBL ; } // recupero la macchina corrente @@ -198,8 +205,14 @@ Machining::MyChangeToolPreviewShow( int nLookFlag, bool bDouble) int nIter = 0 ; // se devo visualizzare solamente il gruppo della testa corrente if ( nLookFlag == MCH_LOOK_TAB_TOOL) { - // la testa diventa visibile + // la testa diventa visibile ( solamente il gruppo dell'uscita corrente) m_pGeomDB->SetStatus( nCurrHeadId, GDB_ST_ON) ; + int nHeadChildId = m_pGeomDB->GetFirstGroupInGroup( nCurrHeadId) ; + while ( nHeadChildId != GDB_ID_NULL) { + if ( nHeadChildId != nCurrExitId) + m_pGeomDB->SetStatus( nHeadChildId, GDB_ST_OFF) ; + nHeadChildId = m_pGeomDB->GetNext( nHeadChildId) ; + } // tutti i gruppi che contengono la testa diventano visibili fino a "ST", l'unico loro // figlio visibile deve essere quello che contiene la testa corrente int nCurrId = nCurrHeadId ; @@ -249,10 +262,17 @@ Machining::MyChangeToolPreviewShow( int nLookFlag, bool bDouble) } } else { + // visualizzo tutti i gruppi in coda for ( auto Iter = dqHierarchy.begin() ; Iter != dqHierarchy.end() ; ++ Iter) { if ( m_pGeomDB->GetGdbType( *Iter) == GDB_TY_GROUP) m_pGeomDB->SetStatus( *Iter, GDB_ST_ON) ; } + // visualizzo tutti i sottogruppi della testa + int nHeadChild = m_pGeomDB->GetFirstGroupInGroup( nCurrHeadId) ; + while ( nHeadChild != GDB_ID_NULL) { + m_pGeomDB->SetStatus( nHeadChild, GDB_ST_ON) ; + nHeadChild = m_pGeomDB->GetNextGroup( nHeadChild) ; + } } ++ nIter ; } @@ -379,7 +399,7 @@ Machining::MyPrepareToolPreview( bool bDouble) if ( ! bDouble) m_vPreviewAxisIds.push_back( nNewTabRotAxisId) ; else - m_vPreviewAxisIdsBBL.push_back( nNewTabRotAxisId) ; + m_vPreviewAxisIdsDBL.push_back( nNewTabRotAxisId) ; // aggiungo il versore invertito int nChildId = m_pGeomDB->GetFirstInGroup( nParentId) ; while ( nChildId != GDB_ID_NULL) { @@ -478,7 +498,7 @@ Machining::MyPrepareToolPreview( bool bDouble) if ( ! bDouble) m_vPreviewAxisIds.push_back( nNewParentId) ; else - m_vPreviewAxisIdsBBL.push_back( nNewParentId) ; + m_vPreviewAxisIdsDBL.push_back( nNewParentId) ; // memorizzo la sua posizione iniziale double dAxisPos = 0. ; bOk = bOk && pMch->GetAxisPos( sParentName, dAxisPos) && @@ -551,10 +571,14 @@ Machining::MyPrepareToolPreview( bool bDouble) bOk = bOk && m_pGeomDB->GetName( nExitGrpId, sExitGrpName) ; int nFrId = GDB_ID_NULL ; if ( bOk) { - if ( ! bDouble) + if ( ! bDouble) { nFrId = m_pGeomDB->GetFirstNameInGroup( m_nPreviewHeadId, "_" + sExitGrpName) ; - else + m_nPreviewExitId = m_pGeomDB->GetFirstNameInGroup( m_nPreviewHeadId, sExitGrpName) ; + } + else { nFrId = m_pGeomDB->GetFirstNameInGroup( m_nPreviewHeadIdDBL, "_" + sExitGrpName) ; + m_nPreviewExitIdDBL = m_pGeomDB->GetFirstNameInGroup( m_nPreviewHeadIdDBL, sExitGrpName) ; + } } bOk = bOk && ( nFrId != GDB_ID_NULL) ; const IGeoFrame3d* frExit = ( bOk ? GetGeoFrame3d( m_pGeomDB->GetGeoObj( nFrId)) : nullptr) ; @@ -631,7 +655,7 @@ Machining::PrepareToolPreview( void) m_nPreviewToolTip = GDB_ID_NULL ; m_nPreviewToolTipDBL = GDB_ID_NULL ; m_vPreviewAxisIds.clear() ; - m_vPreviewAxisIdsBBL.clear() ; + m_vPreviewAxisIdsDBL.clear() ; // preparo l'anteprima per il gruppo ST bool bOk = true ; @@ -680,10 +704,12 @@ Machining::RemoveToolPreview( void) // reset delle variabili membro m_nPreviewHeadId = GDB_ID_NULL ; m_nPreviewHeadIdDBL = GDB_ID_NULL ; + m_nPreviewExitId = GDB_ID_NULL ; + m_nPreviewExitIdDBL = GDB_ID_NULL ; m_nPreviewToolTip = GDB_ID_NULL ; m_nPreviewToolTipDBL = GDB_ID_NULL ; m_vPreviewAxisIds.clear() ; - m_vPreviewAxisIdsBBL.clear() ; + m_vPreviewAxisIdsDBL.clear() ; return true ; } @@ -750,8 +776,10 @@ Machining::GetToolPreviewNext( int nEntId, int nParentId, int nStId) const // se prima entità, eventuale attivazione uscite di gruppo a forare if ( nEntId == GDB_ID_NULL && m_pGeomDB->ExistsInfo( nNewParentId, KEY_DRACEX)) { INTVECTOR vActExit ; - if ( m_pGeomDB->GetInfo( nNewParentId, KEY_DRACEX, vActExit)) + if ( m_pGeomDB->GetInfo( nNewParentId, KEY_DRACEX, vActExit)) { ActivateDrillingUnit( m_nPreviewHeadId, vActExit) ; + MyShowMultiDrillingTool( vActExit) ; + } } return nNewId ; } @@ -760,8 +788,10 @@ Machining::GetToolPreviewNext( int nEntId, int nParentId, int nStId) const // eventuale attivazione uscite di gruppo a forare if ( m_pGeomDB->ExistsInfo( nNewParentId, KEY_DRACEX)) { INTVECTOR vActExit ; - if ( m_pGeomDB->GetInfo( nNewParentId, KEY_DRACEX, vActExit)) + if ( m_pGeomDB->GetInfo( nNewParentId, KEY_DRACEX, vActExit)) { ActivateDrillingUnit( m_nPreviewHeadId, vActExit) ; + MyShowMultiDrillingTool( vActExit) ; + } } // recupero la prima entità del successivo gruppo nNewId = m_pGeomDB->GetFirstInGroup( nNewParentId) ; @@ -793,8 +823,10 @@ Machining::GetToolPreviewPrev( int nEntId, int nParentId, int nStId) const // eventuale attivazione uscite di gruppo a forare if ( m_pGeomDB->ExistsInfo( nNewParentId, KEY_DRACEX)) { INTVECTOR vActExit ; - if ( m_pGeomDB->GetInfo( nNewParentId, KEY_DRACEX, vActExit)) + if ( m_pGeomDB->GetInfo( nNewParentId, KEY_DRACEX, vActExit)) { ActivateDrillingUnit( m_nPreviewHeadId, vActExit) ; + MyShowMultiDrillingTool( vActExit) ; + } } // recupero l'ultima entità del precedente gruppo nNewId = m_pGeomDB->GetLastInGroup( nNewParentId) ; @@ -852,7 +884,7 @@ Machining::MyToolPreview( int nEntId, bool bDouble) const } // scorro gli assi dentro al gruppo "ST" ( considero solo quelli rotativi) - const INTVECTOR& vCurrPreviewAxisIds = ( ! bDouble ? m_vPreviewAxisIds : m_vPreviewAxisIdsBBL) ; + const INTVECTOR& vCurrPreviewAxisIds = ( ! bDouble ? m_vPreviewAxisIds : m_vPreviewAxisIdsDBL) ; for ( auto Iter = vCurrPreviewAxisIds.begin() ; Iter != vCurrPreviewAxisIds.end() ; ++ Iter) { // recupero l'Id dell'asse corrente int nAxisId = *Iter ; @@ -1169,6 +1201,43 @@ Machining::CalcMirrorByDouble( int nClId, const string& sUserNotes) return true ; } +//---------------------------------------------------------------------------- +bool +Machining::MyShowMultiDrillingTool( const INTVECTOR& vActExit) const +{ + // verifico validità del Flag + if ( m_nLookFlag != MCH_LOOK_NONE && m_nLookFlag != MCH_LOOK_TAB_TOOL && m_nLookFlag != MCH_LOOK_TAB_HEAD) + return false ; + // se non ho visibilità solo utensile, non faccio nulla + if ( m_nLookFlag != MCH_LOOK_TAB_TOOL) + return false ; + + // verifico che il gruppo di preview della testa sia valido + if ( m_nPreviewHeadId == GDB_ID_NULL) + return false ; + + // recupero i nomi delle uscite da visualizzare nella preview + STRVECTOR vsExit ; vsExit.resize( vActExit.size()) ; + for ( int i = 0 ; i < ssize( vActExit) ; ++ i) + vsExit[i] = MCH_EXIT + ToString( vActExit[i]) ; + + // rendo visibili solo i gruppi nella preview inerenti + int nChildHeadId = m_pGeomDB->GetFirstInGroup( m_nPreviewHeadId) ; + while ( nChildHeadId != GDB_ID_NULL) { + // recupero il nome del gruppo corrente + string sName ; + m_pGeomDB->GetName( nChildHeadId, sName) ; + // verifico se attivare o meno il gruppo corrente + bool bStatusOn = ( find_if( vsExit.begin(), vsExit.end(), [&]( const string& sExitName) { + return EqualNoCase( sExitName, sName) ; }) != vsExit.end()) ; + m_pGeomDB->SetStatus( nChildHeadId, bStatusOn ? GDB_ST_ON : GDB_ST_OFF) ; + // passo al gruppo successivo + nChildHeadId = m_pGeomDB->GetNextGroup( nChildHeadId) ; + } + + return true ; +} + //---------------------------------------------------------------------------- bool Machining::ActivateDrillingUnit( int nHeadId, const INTVECTOR& vActExit) const diff --git a/Machining.h b/Machining.h index ea81632..c944a9b 100644 --- a/Machining.h +++ b/Machining.h @@ -72,17 +72,20 @@ class Machining : public Operation bool MyPrepareToolPreview( bool bDouble) ; bool MyChangeToolPreviewShow( int nLookFlag, bool bDouble) ; bool MyToolPreview( int nEntId, bool bDouble) const ; + bool MyShowMultiDrillingTool( const INTVECTOR& vActExit) const ; private : int m_nLookFlag ; // flag di Visualizzazione per Preview // lavorazione singola - int m_nPreviewHeadId ; // Id del gruppo testa di Preview + int m_nPreviewHeadId ; // Id del gruppo della testa di Preview + int m_nPreviewExitId ; // Id del gruppo dell'uscita di Preview int m_nPreviewToolTip ; // Id del gruppo contenente il punto ToolTip INTVECTOR m_vPreviewAxisIds ; // indici degli assi di Preview // lavorazione in doppio - int m_nPreviewHeadIdDBL ; // Id della testa di Preview + int m_nPreviewHeadIdDBL ; // Id del gruppo della testa di Preview + int m_nPreviewExitIdDBL ; // Id del gruppo dell'uscita di Preview int m_nPreviewToolTipDBL ; // Id del gruppo contenente il punto di ToolTip - INTVECTOR m_vPreviewAxisIdsBBL ; // indici degli assi di Preview + INTVECTOR m_vPreviewAxisIdsDBL ; // indici degli assi di Preview } ; //---------------------------------------------------------------------------- From 624bc499a20c953d47837fb901fe364e0d975eab Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 6 Apr 2026 09:59:00 +0200 Subject: [PATCH 3/6] EgtMachKernel : - in fresatura e taglio di lama portate info di Start, End, Extr e Elev anche nei gruppi P1, P2, ... di Preview - in simulazione migliorato nascondere della traccia utensile. --- Milling.cpp | 9 +++++++++ Sawing.cpp | 26 ++++++++++++++++++++++++++ SimulatorSP.cpp | 6 ++++-- SimulatorSP.h | 1 + 4 files changed, 40 insertions(+), 2 deletions(-) diff --git a/Milling.cpp b/Milling.cpp index 744366c..78c94aa 100644 --- a/Milling.cpp +++ b/Milling.cpp @@ -2037,6 +2037,15 @@ Milling::ProcessPath( int nPathId, int nPvId, int nClId) return false ; m_pGeomDB->SetName( nPxId, sPathName) ; m_pGeomDB->SetMaterial( nPxId, GREEN) ; + + // assegno il vettore estrazione al gruppo del percorso + m_pGeomDB->SetInfo( nPxId, KEY_EXTR, vtTool) ; + // assegno i punti di inizio e fine al gruppo del percorso + m_pGeomDB->SetInfo( nPxId, KEY_START, ptStart) ; + m_pGeomDB->SetInfo( nPxId, KEY_END, ptEnd) ; + // assegno l'elevazione massima + m_pGeomDB->SetInfo( nPxId, KEY_ELEV, dElev) ; + // creo l'anteprima del percorso if ( ! GenerateMillingPv( nPxId, pCompo, dRbDist, dDepth)) return false ; diff --git a/Sawing.cpp b/Sawing.cpp index 8ba3d86..183c96b 100644 --- a/Sawing.cpp +++ b/Sawing.cpp @@ -1953,6 +1953,14 @@ Sawing::GenerateLinePv( const ICurveLine* pLine, const Vector3d& vtTool, const V return false ; m_pGeomDB->SetName( nPxId, sName) ; m_pGeomDB->SetMaterial( nPxId, BLUE) ; + // assegno il vettore estrazione al gruppo del percorso + m_pGeomDB->SetInfo( nPxId, KEY_EXTR, Z_AX) ; + // assegno i punti di inizio e fine al gruppo del percorso (tenendo conto degli allungamenti in vera lavorazione) + Vector3d vtMidDir ; pLine->GetMidDir( vtMidDir) ; + m_pGeomDB->SetInfo( nPxId, KEY_START, pLine->GetStart() - dStartWhiskExt * vtMidDir) ; + m_pGeomDB->SetInfo( nPxId, KEY_END, pLine->GetEnd() + dEndWhiskExt * vtMidDir) ; + // assegno l'elevazione massima + m_pGeomDB->SetInfo( nPxId, KEY_ELEV, dElev) ; // punti notevoli Point3d ptIni = pLine->GetStart() + dElev * vtCorr ; @@ -2576,6 +2584,15 @@ Sawing::GenerateExtCurvePv( const ICurveComposite* pCrv, double dOffs, return false ; m_pGeomDB->SetName( nPxId, sName) ; m_pGeomDB->SetMaterial( nPxId, BLUE) ; + // assegno il vettore estrusione al gruppo del percorso + m_pGeomDB->SetInfo( nPxId, KEY_EXTR, Z_AX) ; + // assegno i punti di inizio e fine al gruppo del percorso + Point3d ptStart ; pCrv->GetStartPoint( ptStart) ; + m_pGeomDB->SetInfo( nPxId, KEY_START, ptStart) ; + Point3d ptEnd ; pCrv->GetEndPoint( ptEnd) ; + m_pGeomDB->SetInfo( nPxId, KEY_END, ptEnd) ; + // assegno l'elevazione massima + m_pGeomDB->SetInfo( nPxId, KEY_ELEV, dElev) ; // disabilito eventuale registrazione comandi EXE (riabilitazione automatica) CmdLogOff cmdLogOff ; @@ -3358,6 +3375,15 @@ Sawing::GenerateIntArcPv( const ICurveArc* pArc, return false ; m_pGeomDB->SetName( nPxId, sName) ; m_pGeomDB->SetMaterial( nPxId, BLUE) ; + // assegno il vettore estrazione al gruppo del percorso + m_pGeomDB->SetInfo( nPxId, KEY_EXTR, Z_AX) ; + // assegno i punti di inizio e fine al gruppo del percorso + Point3d ptStart ; pArc->GetStartPoint( ptStart) ; + m_pGeomDB->SetInfo( nPxId, KEY_START, ptStart) ; + Point3d ptEnd ; pArc->GetEndPoint( ptEnd) ; + m_pGeomDB->SetInfo( nPxId, KEY_END, ptEnd) ; + // assegno l'elevazione massima + m_pGeomDB->SetInfo( nPxId, KEY_ELEV, dElev) ; // disabilito eventuale registrazione comandi EXE (riabilitazione automatica) CmdLogOff cmdLogOff ; diff --git a/SimulatorSP.cpp b/SimulatorSP.cpp index d86904d..f97a7f6 100644 --- a/SimulatorSP.cpp +++ b/SimulatorSP.cpp @@ -97,6 +97,7 @@ SimulatorSP::SimulatorSP( void) m_bEnableVm = false ; m_dSafeDist = SAFEDIST_STD ; m_bEnableTrace = false ; + m_nTraceGroup = GDB_ID_NULL ; m_nCurrTrace = GDB_ID_NULL ; m_nAxesMask = 0 ; m_bEnabAxes = true ; @@ -1685,10 +1686,10 @@ SimulatorSP::EnableToolTipTrace( bool bEnable) ; } else { - int nTraceCrvId = m_nCurrTrace ; + int nTraceCrvId = m_pGeomDB->GetFirstInGroup( m_nTraceGroup) ; while ( nTraceCrvId != GDB_ID_NULL) { m_pGeomDB->SetStatus( nTraceCrvId, GDB_ST_OFF) ; - nTraceCrvId = m_pGeomDB->GetPrev( nTraceCrvId) ; + nTraceCrvId = m_pGeomDB->GetNext( nTraceCrvId) ; } m_nCurrTrace = GDB_ID_NULL ; } @@ -1708,6 +1709,7 @@ SimulatorSP::TraceToolTipMove( int nMoveType) int nTraceGrpId ; if ( ! m_pMachine->LuaGetGlobVar( GLOB_VAR + GVAR_TOOLTRACE, nTraceGrpId)) return false ; + m_nTraceGroup = nTraceGrpId ; // recupero posizione utensile corrente int nExitId = m_pMachine->GetExitId( m_sHead, m_nExit) ; Frame3d frExit ; diff --git a/SimulatorSP.h b/SimulatorSP.h index ae54298..d8ea59c 100644 --- a/SimulatorSP.h +++ b/SimulatorSP.h @@ -177,6 +177,7 @@ class SimulatorSP : public ISimulator double m_dSafeDist ; // distanza di sicurezza per verifica collisioni INTVECTOR m_nCollMarkId ; // elenco oggetti marcati per visualizzare meglio la collisione rilevata bool m_bEnableTrace ; // flag abilitazione tool tip trace + int m_nTraceGroup ; // Id del gruppo in cui si inceriscono le curve di tracciatura int m_nCurrTrace ; // Id della curva composita corrente di trace int m_nAxesMask ; // maschera a bit di abilitazione movimento assi (solo se rapido) bool m_bEnabAxes ; // flag abilitazione movimento assi attivi From b577dfe86b93985f6533390a1f912980356fd2f1 Mon Sep 17 00:00:00 2001 From: Riccardo Elitropi Date: Tue, 7 Apr 2026 14:49:34 +0200 Subject: [PATCH 4/6] EgtMachKernel : - modifica nomi gruppi Paths per Sgrossature e PocketingNT sotto al gruppo CL. In Sgrossature e Finiture migliorati i controlli sulla semplificazione delle curve mediante frame Locale. --- PocketingNT.cpp | 10 +++---- SurfFinishing.cpp | 60 ++++++++++++++++++++++------------------ SurfFinishing.h | 2 +- SurfRoughing.cpp | 70 +++++++++++++++++++++++++++++------------------ SurfRoughing.h | 2 +- 5 files changed, 85 insertions(+), 59 deletions(-) diff --git a/PocketingNT.cpp b/PocketingNT.cpp index 994eaaf..ca499f4 100644 --- a/PocketingNT.cpp +++ b/PocketingNT.cpp @@ -1938,7 +1938,7 @@ PocketingNT::Chain( int nGrpDestId) } // scorro le regioni piane ricavate dalle curve - int nGroupName = -1 ; + int nGroupName = 0 ; PtrOwner pSfrCurr( SfrByC.GetSurf()) ; while ( ! IsNull( pSfrCurr) && pSfrCurr->IsValid()) { // per ogni Chunk @@ -1982,7 +1982,7 @@ PocketingNT::Chain( int nGrpDestId) PtrOwner pCrvLoop( CreateCurveComposite()) ; if ( IsNull( pCrvLoop) || ! pCrvLoop.Set( ConvertCurveToComposite( pSfrChunk->GetLoop( 0, nL))) || - ! pCrvLoop->IsValid()) + ! pCrvLoop->IsValid()) return false ; // se loop esterno, aggiungo la superfifice al gruppo con le relative informazioni if ( nL == 0) { @@ -2165,7 +2165,7 @@ ISurfFlatRegion* PocketingNT::GetSfrByStmIntersection( const IntersParPlanesSurfTm& IPPStm, double dDist, double dSmallOffs) { // interseco la superficie alla quota corrente - PNTVECTOR vPnt ; + PNTVECTOR vPnt ; BIPNTVECTOR vBpt ; TRIA3DVECTOR vTria ; if ( ! IPPStm.GetInters( dDist, vPnt, vBpt, vTria)) @@ -2855,8 +2855,8 @@ PocketingNT::ChooseCloseOrOpenEdge( ISurfFlatRegion* pSfr, const ISurfTriMesh* p return false ; // recupero i NUM_POINTS punti bool bIsOnStm = true ; - for ( int p = 0 ; p < NUM_POINTS + 1 && bIsOnStm ; ++ p) { - double dPar = ( 1. / ( 1. * NUM_POINTS)) * p ; + for ( int nP = 0 ; nP < NUM_POINTS + 1 && bIsOnStm ; ++ nP) { + double dPar = ( 1. / ( 1. * NUM_POINTS)) * nP ; Point3d ptPar ; if ( ! pCrv->GetPointD1D2( dPar, ICurve::FROM_PLUS, ptPar)) return false ; diff --git a/SurfFinishing.cpp b/SurfFinishing.cpp index fa54e5b..11062b3 100644 --- a/SurfFinishing.cpp +++ b/SurfFinishing.cpp @@ -2093,7 +2093,7 @@ SurfFinishing::ProcessSfr( int nPathId, int nPvId, int nClId) //---------------------------------------------------------------------------- bool -SurfFinishing::SimplifyCurve( ICurveComposite* pCompo, double dMergeLinTol, double dMergeAndTolDeg, +SurfFinishing::SimplifyCurve( ICurveComposite* pCompo, const Frame3d& frLocXY, double dMergeLinTol, double dMergeAndTolDeg, double dSmallDefLinTol, double dSmallDefAngTolDeg, double dArcApproxLinTol, double dArcApproxAngTolDeg) const { @@ -2101,35 +2101,38 @@ SurfFinishing::SimplifyCurve( ICurveComposite* pCompo, double dMergeLinTol, doub if ( pCompo == nullptr || ! pCompo->IsValid()) return false ; - // ricavo il punto iniziale e finale - Point3d ptStart ; pCompo->GetStartPoint( ptStart) ; - Point3d ptEnd ; pCompo->GetEndPoint( ptEnd) ; - - // eseguo le modifiche su una copia della curva originale - PtrOwner pCompoCL( CloneCurveComposite( pCompo)) ; - if ( IsNull( pCompoCL)) + // eseguo le modifiche su una copia della curva originale in locale al frame XY + PtrOwner pCompoLoc( CloneCurveComposite( pCompo)) ; + if ( IsNull( pCompoLoc)) return false ; + pCompoLoc->ToLoc( frLocXY) ; + + // ricavo il punto iniziale e finale + Point3d ptStart ; pCompoLoc->GetStartPoint( ptStart) ; + Point3d ptEnd ; pCompoLoc->GetEndPoint( ptEnd) ; // merge per uniformità - bool bOk = pCompoCL->MergeCurves( dMergeLinTol, dMergeAndTolDeg, false) ; + bool bOk = pCompoLoc->MergeCurves( dMergeLinTol, dMergeAndTolDeg, false) ; // rimozione Spikes o Curve Z - bOk = bOk && pCompoCL->RemoveSmallDefects( dSmallDefLinTol, dSmallDefAngTolDeg, true) ; + bOk = bOk && pCompoLoc->RemoveSmallDefects( dSmallDefLinTol, dSmallDefAngTolDeg, true) ; // interpolazione mediante linee ed archi PolyArc PA ; - bOk = bOk && pCompoCL->ApproxWithArcsEx( dArcApproxLinTol, dArcApproxAngTolDeg, LIN_FEA_STD, PA) && - pCompoCL->Clear() && pCompoCL->FromPolyArc( PA) ; + bOk = bOk && pCompoLoc->ApproxWithArcsEx( dArcApproxLinTol, dArcApproxAngTolDeg, LIN_FEA_STD, PA) && + pCompoLoc->Clear() && pCompoLoc->FromPolyArc( PA) ; // controllo aggiuntivo sui punti iniziali e finali che siano gli stessi Point3d ptNewStart, ptNewEnd ; - bOk = bOk && pCompoCL->GetStartPoint( ptNewStart) && pCompoCL->GetEndPoint( ptNewEnd) && + bOk = bOk && pCompoLoc->GetStartPoint( ptNewStart) && pCompoLoc->GetEndPoint( ptNewEnd) && AreSamePointApprox( ptNewStart, ptStart) && AreSamePointApprox( ptNewEnd, ptEnd) ; // controllo che non si siano create auto-intersezioni - SelfIntersCurve SIC( *pCompoCL) ; + SelfIntersCurve SIC( *pCompoLoc) ; bOk = bOk && ( SIC.GetCrossIntersCount() == 0) ; // se tutto bene, sostiuisco la curva originale con la modificata - if ( bOk) - pCompo->CopyFrom( pCompoCL) ; + if ( bOk) { + pCompoLoc->ToGlob( frLocXY) ; + pCompo->CopyFrom( pCompoLoc) ; + } return true ; } @@ -2502,6 +2505,11 @@ SurfFinishing::CalcZConstSilCrv( ICAvParSilhouettesSurfTm* pCavParSilh, const SU if ( pSfrClass == nullptr || ! pSfrClass->IsValid()) return false ; + // definisco un frame implicito rispetto alla superficie di classificazione + Frame3d frLocXY ; + Point3d ptC ; pSfrClass->GetCentroid( ptC) ; + frLocXY.Set( ptC, pSfrClass->GetNormVersor()) ; + // NB. Essendo una finitura a Z costante, devo controllare che i piani di finitura non facciano // overlap con facce delle TriMesh selezionate con normale simile a vtTool set setZAmbiguos ; @@ -2530,32 +2538,32 @@ SurfFinishing::CalcZConstSilCrv( ICAvParSilhouettesSurfTm* pCavParSilh, const SU if ( ! pCavParSilh->GetSilhouette( dZLoc, vPL)) return false ; // classifico le PolyLine in base alla regione - POLYLINEVECTOR vPL_InsideSfr ; + POLYLINEVECTOR vPLInsideSfr ; for ( auto& PL : vPL) { // porto la PolyLine a contatto con la regione PL.Translate( - dZLoc * pSfrClass->GetNormVersor()) ; // converto in curva composita - PtrOwner pCrv_PL( CreateCurveComposite()) ; - if ( IsNull( pCrv_PL) || ! pCrv_PL->FromPolyLine( PL)) + PtrOwner pCrvPL( CreateCurveComposite()) ; + if ( IsNull( pCrvPL) || ! pCrvPL->FromPolyLine( PL)) return false ; // classifico la curva con la superficie CRVCVECTOR ccClass ; - if ( ! pSfrClass->GetCurveClassification( *pCrv_PL, EPS_SMALL, ccClass)) + if ( ! pSfrClass->GetCurveClassification( *pCrvPL, EPS_SMALL, ccClass)) return false ; // tengo tutti i tratti non esterni alla superficie for ( int i = 0 ; i < int( ccClass.size()) ; ++ i) { if ( ccClass[i].nClass != CRVC_OUT) { - PtrOwner pCrvCompoPartIn( ConvertCurveToComposite( pCrv_PL->CopyParamRange( ccClass[i].dParS, ccClass[i].dParE))) ; + PtrOwner pCrvCompoPartIn( ConvertCurveToComposite( pCrvPL->CopyParamRange( ccClass[i].dParS, ccClass[i].dParE))) ; if ( ! IsNull( pCrvCompoPartIn) && pCrvCompoPartIn->IsValid()) { - vPL_InsideSfr.emplace_back( PolyLine()) ; + vPLInsideSfr.emplace_back( PolyLine()) ; // riporto la curva alla quota giusta pCrvCompoPartIn->Translate( dZLoc * pSfrClass->GetNormVersor()) ; - pCrvCompoPartIn->ApproxWithLines( 0, 0, ICurve::APL_SPECIAL, vPL_InsideSfr.back()) ; + pCrvCompoPartIn->ApproxWithLines( 0, 0, ICurve::APL_SPECIAL, vPLInsideSfr.back()) ; } } } } - swap( vPL, vPL_InsideSfr) ; + swap( vPL, vPLInsideSfr) ; for ( auto& PL : vPL) { // recupero la curva dalla silhouette PtrOwner pSilCrv( CreateCurveComposite()) ; @@ -2574,7 +2582,7 @@ SurfFinishing::CalcZConstSilCrv( ICAvParSilhouettesSurfTm* pCavParSilh, const SU pTempCrv->MergeCurves( SILH_ARC_TOL / 2., ANG_TOL_STD_DEG)) pSilCrv.Set( pTempCrv) ; } - SimplifyCurve( pSilCrv) ; + SimplifyCurve( pSilCrv, frLocXY) ; vCrvCompo.back().emplace_back( Release( pSilCrv)) ; } // controllo validità delle curve @@ -5807,7 +5815,7 @@ SurfFinishing::CalcOptimalZConstCurves( const ISurfFlatRegion* pSfrLoc, const SU PtrOwner pNewCrvCompo( CreateCurveComposite()) ; if ( IsNull( pNewCrvCompo) || ! pNewCrvCompo->FromPolyLine( PL)) continue ; - SimplifyCurve( pNewCrvCompo) ; + SimplifyCurve( pNewCrvCompo, frSfr) ; vvCrvCompo[i].emplace_back( Release( pNewCrvCompo)) ; // memorizzo come primo TempParam la distanza della superficie ( per coerenza) vvCrvCompo[i].back()->SetTempParam( dSfrDist, 0) ; diff --git a/SurfFinishing.h b/SurfFinishing.h index 377dbc0..cf21044 100644 --- a/SurfFinishing.h +++ b/SurfFinishing.h @@ -115,7 +115,7 @@ class SurfFinishing : public Machining double dDepth, ISurfFlatRegion* pSfrCnt) ; bool ProcessCrvCompo( int nPathId, int nPvId, int nClId) ; bool ProcessSfr( int nPathId, int nPvId, int nClId) ; - bool SimplifyCurve( ICurveComposite* pCompo, + bool SimplifyCurve( ICurveComposite* pCompo, const Frame3d& frLocXY, double dMergeLinTol = 200. * EPS_SMALL, double dMergeAndTolDeg = 200. * EPS_ANG_SMALL, double dSmallDefLinTol = 150. * EPS_SMALL, double dSmallDefAngTolDeg = 2. * ANG_TOL_STD_DEG, double dArcApproxLinTol = 50. * EPS_SMALL, double dArcApproxAngTolDeg = ANG_TOL_STD_DEG) const ; diff --git a/SurfRoughing.cpp b/SurfRoughing.cpp index b16bbf1..d261184 100644 --- a/SurfRoughing.cpp +++ b/SurfRoughing.cpp @@ -1236,7 +1236,7 @@ SurfRoughing::Chain( int nGrpDestId) } // scorro le regioni piane ricavate dalle curve - int nGroupName = -1 ; + int nGroupName = 0 ; PtrOwner pSfrCurr( SfrByC.GetSurf()) ; while ( ! IsNull( pSfrCurr) && pSfrCurr->IsValid()) { // la normale del Chunk deve essere coerente con l'estrusione ricavata @@ -4281,52 +4281,60 @@ SurfRoughing::ResetCurveAllTempProp( ICurve* pCurve) const //---------------------------------------------------------------------------- bool -SurfRoughing::SimplifyCurve( ICurveComposite* pCompo, const ICRVCOMPOPOVECTOR& vCrvCheck) const +SurfRoughing::SimplifyCurve( ICurveComposite* pCompo, const ICRVCOMPOPOVECTOR& vCrvCheck, const Frame3d& frLocXY) const { // controllo dei parametri if ( pCompo == nullptr || ! pCompo->IsValid()) return false ; - // ricavo il punto iniziale e finale - Point3d ptStart ; pCompo->GetStartPoint( ptStart) ; - Point3d ptEnd ; pCompo->GetEndPoint( ptEnd) ; - - // eseguo le modifiche su una copia della curva originale - PtrOwner pCompoCL( CloneCurveComposite( pCompo)) ; - if ( IsNull( pCompoCL)) + // eseguo le modifiche su una copia della curva originale in locale al frameXY + PtrOwner pCompoLoc( CloneCurveComposite( pCompo)) ; + if ( IsNull( pCompoLoc)) return false ; + pCompoLoc->ToLoc( frLocXY) ; + + // ricavo il punto iniziale e finale + Point3d ptStart ; pCompoLoc->GetStartPoint( ptStart) ; + Point3d ptEnd ; pCompoLoc->GetEndPoint( ptEnd) ; // merge per uniformità - bool bOk = pCompoCL->MergeCurves( 200 * EPS_SMALL, 200 * EPS_ANG_SMALL, false) ; + bool bOk = pCompoLoc->MergeCurves( 200. * EPS_SMALL, 200. * EPS_ANG_SMALL, false) ; // rimozione Spikes o Curve Z - bOk = bOk && pCompoCL->RemoveSmallDefects( 150 * EPS_SMALL, 2 * ANG_TOL_STD_DEG, true) ; + bOk = bOk && pCompoLoc->RemoveSmallDefects( 150. * EPS_SMALL, 2. * ANG_TOL_STD_DEG, true) ; // interpolazione mediante linee ed archi PolyArc PA ; - bOk = bOk && pCompoCL->ApproxWithArcsEx( 50 * EPS_SMALL, ANG_TOL_STD_DEG, LIN_FEA_STD, PA) && - pCompoCL->Clear() && pCompoCL->FromPolyArc( PA) ; + bOk = bOk && pCompoLoc->ApproxWithArcsEx( 50. * EPS_SMALL, ANG_TOL_STD_DEG, LIN_FEA_STD, PA) && + pCompoLoc->Clear() && pCompoLoc->FromPolyArc( PA) ; // controllo aggiuntivo sui punti iniziali e finali che siano gli stessi Point3d ptNewStart, ptNewEnd ; - bOk = bOk && pCompoCL->GetStartPoint( ptNewStart) && pCompoCL->GetEndPoint( ptNewEnd) && + bOk = bOk && pCompoLoc->GetStartPoint( ptNewStart) && pCompoLoc->GetEndPoint( ptNewEnd) && AreSamePointApprox( ptNewStart, ptStart) && AreSamePointApprox( ptNewEnd, ptEnd) ; // controllo che non si siano create auto-intersezioni - SelfIntersCurve SIC( *pCompoCL) ; + SelfIntersCurve SIC( *pCompoLoc) ; bOk = bOk && ( SIC.GetCrossIntersCount() == 0) ; // controllo che non si siano create intersezioni con le altre curve in punti interni - for ( int i = 0 ; i < int( vCrvCheck.size()) && bOk ; ++ i) { - IntersCurveCurve ICC( *vCrvCheck[i], *pCompoCL) ; - for ( int j = 0 ; j < int( ICC.GetIntersCount()) && bOk ; ++ j) { - IntCrvCrvInfo aInfo ; - bOk = bOk && ICC.GetIntCrvCrvInfo( j, aInfo) ; - bOk = bOk && ( AreSamePointApprox( ptStart, aInfo.IciA[0].ptI) || - AreSamePointApprox( ptEnd, aInfo.IciA[0].ptI)) ; + for ( int i = 0 ; i < ssize( vCrvCheck) && bOk ; ++ i) { + PtrOwner pCrvCheckLocXY( CloneCurveComposite( vCrvCheck[i])) ; + bOk = bOk && ( ! IsNull( pCrvCheckLocXY)) && pCrvCheckLocXY->IsValid() ; + if ( bOk) { + pCrvCheckLocXY->ToLoc( frLocXY) ; + IntersCurveCurve ICC( *pCrvCheckLocXY, *pCompoLoc) ; + for ( int j = 0 ; j < ICC.GetIntersCount() && bOk ; ++ j) { + IntCrvCrvInfo aInfo ; + bOk = ICC.GetIntCrvCrvInfo( j, aInfo) ; + bOk = bOk && ( AreSamePointApprox( ptStart, aInfo.IciA[0].ptI) || + AreSamePointApprox( ptEnd, aInfo.IciA[0].ptI)) ; + } } } // se tutto bene, sostiuisco la curva originale con la modificata - if ( bOk) - pCompo->CopyFrom( pCompoCL) ; + if ( bOk) { + pCompoLoc->ToGlob( frLocXY) ; + pCompo->CopyFrom( pCompoLoc) ; + } return true ; } @@ -4345,12 +4353,17 @@ SurfRoughing::SimplyfySfr( ISurfFlatRegion* pSfr) const return false ; ICRVCOMPOPOVECTOR vCrvEmpty ; + // recupero il frame localeXY della regione piana + Frame3d frLoc ; + Point3d ptC ; pSfr->GetCentroid( ptC) ; + frLoc.Set( ptC, pSfr->GetNormVersor()) ; + // scorro tutti i loops di tutte le parti for ( int nC = 0 ; nC < pSfr->GetChunkCount() ; ++ nC) { for ( int nL = 0 ; nL < pSfr->GetLoopCount( nC) ; ++ nL) { // recupero la curva di Loop e la semplifico PtrOwner pCompoLoop( ConvertCurveToComposite( pSfr->GetLoop( nC, nL))) ; - if ( IsNull( pCompoLoop) || ! SimplifyCurve( pCompoLoop, vCrvEmpty)) + if ( IsNull( pCompoLoop) || ! SimplifyCurve( pCompoLoop, vCrvEmpty, frLoc)) return false ; // inserisco le curve nella nuova regione (il primo loop di ogni parte è esterno) if ( nL == 0) { @@ -4458,6 +4471,11 @@ SurfRoughing::CloseOpenEdgesUnderTolerance( ISurfFlatRegion* pSfr, double dToler if ( IsNull( pSfrRegular)) return false ; + // recupero il frame locale XY della superficie + Frame3d frLoc ; + Point3d ptC ; pSfr->GetCentroid( ptC) ; + frLoc.Set( ptC, pSfr->GetNormVersor()) ; + // scorro tutti i chunk della superficie for ( int nC = 0 ; nC < pSfr->GetChunkCount() ; ++ nC) { // creo una superficie di test @@ -4488,7 +4506,7 @@ SurfRoughing::CloseOpenEdgesUnderTolerance( ISurfFlatRegion* pSfr, double dToler // se tratto aperto e non coincidente con tutta la curva if ( vpCrvs[i]->GetTempProp( 0) == TEMP_PROP_OPEN_EDGE && int( vpCrvs.size()) != 1) { // semplifico il loop per avere curve più uniformi - SimplifyCurve( vpCrvs[i], vCrvClose) ; + SimplifyCurve( vpCrvs[i], vCrvClose, frLoc) ; // riporto le proprietà vpCrvs[i]->SetTempProp( TEMP_PROP_OPEN_EDGE) ; for ( int j = 0 ; j < vpCrvs[i]->GetCurveCount() ; ++ j) diff --git a/SurfRoughing.h b/SurfRoughing.h index 887593c..2906f22 100644 --- a/SurfRoughing.h +++ b/SurfRoughing.h @@ -222,7 +222,7 @@ class SurfRoughing : public Machining bool CloseOpenEdgesUnderTolerance( ISurfFlatRegion* pSfr, double dToler) ; bool ModifySurfForOpenCloseEdges( ISurfFlatRegion* pSfr, const Vector3d& vtTool, const ICurveComposite* pCrvCompo) const ; bool ChooseCloseOrOpenEdge( ISurfFlatRegion* pSfr, const ISurfFlatRegion* pSfrRef) const ; - bool SimplifyCurve( ICurveComposite* pCompo, const ICRVCOMPOPOVECTOR& vCrvCheck) const ; + bool SimplifyCurve( ICurveComposite* pCompo, const ICRVCOMPOPOVECTOR& vCrvCheck, const Frame3d& frLocXY) const ; bool SimplyfySfr( ISurfFlatRegion* pSfr) const ; bool CheckSafetyLinearLink( const Point3d& ptCurr, const Point3d& ptDest, const ISurfFlatRegion* pSfrCheck, const Vector3d& vtTool, bool& bSafe) const ; From 83c83fb5f0fb6201b92ac38808c95b46b126938f Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Tue, 7 Apr 2026 17:50:13 +0200 Subject: [PATCH 5/6] =?UTF-8?q?EgtMacheKernel=20:=20-=20aggiunta=20gestion?= =?UTF-8?q?e=20calcolo=20angoli=20di=20macchine=20con=20tre=20assi=20rotan?= =?UTF-8?q?ti=20liberi=20(di=20tipo=20ZYZ=20o=20equivalenti)=20purch=C3=A8?= =?UTF-8?q?=20fornito=20versore=20ausiliario=20-=20aggiunta=20possibilit?= =?UTF-8?q?=C3=A0=20di=20impostare=20versore=20ausiliario=20tramite=20User?= =?UTF-8?q?Notes=20(VtAuxDir=3DVx,Vy,Vz)=20in=20fresature,=20svuotature=20?= =?UTF-8?q?e=20forature=20con=20punta=20singola.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Drilling.cpp | 9 +- Machine.h | 6 +- MachineCalc.cpp | 238 +++++++++++++++++++++++++++++++------------ Milling.cpp | 16 ++- OperUserNotesConst.h | 1 + Pocketing.cpp | 9 ++ PocketingNT.cpp | 9 ++ 7 files changed, 217 insertions(+), 71 deletions(-) diff --git a/Drilling.cpp b/Drilling.cpp index 26f9370..c60aeeb 100644 --- a/Drilling.cpp +++ b/Drilling.cpp @@ -27,6 +27,7 @@ #include "/EgtDev/Include/EGkCurveComposite.h" #include "/EgtDev/Include/EGkChainCurves.h" #include "/EgtDev/Include/EGkSfrCreate.h" +#include "/EgtDev/Include/EGkStringUtils3d.h" #include "/EgtDev/Include/EGkUserObjFactory.h" #include "/EgtDev/Include/EGnStringKeyVal.h" #include "/EgtDev/Include/EgtPointerOwner.h" @@ -867,7 +868,11 @@ Drilling::StandardProcess( bool bRecalc, int nPvId, int nClId) // eseguo la lavorazione richiesta switch ( nDrillType) { case DRILL_TYPE_STD : - { // elaboro i singoli fori + { // se vtAux impostato come parametro di lavorazione nelle UserNotes + Vector3d vtAux ; + if ( GetValInNotes( m_Params.m_sUserNotes, UN_VTAUXDIR, vtAux)) + vtAux.Normalize() ; + // elaboro i singoli fori for ( int i = 0 ; i < int( m_vId.size()) ; ++ i) { const auto& vId = m_vId[i] ; // se richiesto preview @@ -880,7 +885,7 @@ Drilling::StandardProcess( bool bRecalc, int nPvId, int nClId) } // se richiesta lavorazione if ( nClId != GDB_ID_NULL) { - if ( ! GenerateHoleCl( i, vId, MCH_PATH, nClId)) + if ( ! GenerateHoleCl( i, vId, MCH_PATH, nClId, 0, vtAux)) return false ; } } diff --git a/Machine.h b/Machine.h index 52b991e..bd2e6f6 100644 --- a/Machine.h +++ b/Machine.h @@ -169,8 +169,6 @@ class Machine { return m_frLinAx ; } int GetCurrKinematicChainType( void) const { return m_nCalcChainType ; } - bool GetAngles( const Vector3d& vtDirT, const Vector3d& vtDirA, - int& nStat, double& dAngA1, double& dAngB1, double& dAngA2, double& dAngB2) const ; bool GetAngles( const Vector3d& vtDirT, const Vector3d& vtDirA, int& nStat, DBLVECTOR& vAng1, DBLVECTOR& vAng2) const ; bool GetPositions( const Point3d& ptP, const DBLVECTOR& vAng, @@ -281,6 +279,10 @@ class Machine const Vector3d& vtDirH, const Vector3d& vtDirI, int nNumRotAx, const KinAxis& RotAx1, const KinAxis& RotAx2, int& nStat, double& dAngA1, double& dAngB1, double& dAngA2, double& dAngB2) const ; + bool GetMyAngles( const Vector3d& vtDirT, const Vector3d& vtDirA, + const Vector3d& vtDirH, const Vector3d& vtDirI, + const KinAxis& RotAx1, const KinAxis& RotAx2, const KinAxis& RotAx3, + int& nStat, double& dAngA1, double& dAngB1, double& dAngC1, double& dAngA2, double& dAngB2, double& dAngC2) const ; bool GetDirection( const Vector3d& vtDir, const DBLVECTOR& vAng, Vector3d& vtNew) const ; bool GetBackDirection( const Vector3d& vtDir, const DBLVECTOR& vAng, Vector3d& vtNew) const ; bool GetSccDir( int nSolCh, const Vector3d& vtDirA, Vector3d& vtDirScc) const ; diff --git a/MachineCalc.cpp b/MachineCalc.cpp index 41bd8f2..5d2bf1a 100644 --- a/MachineCalc.cpp +++ b/MachineCalc.cpp @@ -660,7 +660,7 @@ Machine::CalculateKinematicChain( void) // verifiche sugli assi lineari : // aggiusto gli indici di ordine sulla sua catena cinematica (1-based) - for ( int i = 0 ; i < int( m_vCalcLinAx.size()) ; ++ i) { + for ( int i = 0 ; i < ssize( m_vCalcLinAx) ; ++ i) { if ( m_vCalcLinAx[i].bHead) m_vCalcLinAx[i].nInd += m_nHeadLinAxes + m_nHeadRotAxes + 1 ; else @@ -891,7 +891,7 @@ Machine::BlockKinematicRotAxis( int nId, double dVal) if ( nId == GDB_ID_NULL) return false ; // cerco l'asse rotante di calcolo con questo identificativo - for ( size_t i = 0 ; i < m_vCalcRotAx.size() ; ++ i) { + for ( int i = 0 ; i < ssize( m_vCalcRotAx) ; ++ i) { if ( m_vCalcRotAx[i].nGrpId == nId) { if ( dVal < m_vCalcRotAx[i].stroke.Min || dVal > m_vCalcRotAx[i].stroke.Max) { m_vCalcRotAx[i].bFixed = false ; @@ -920,7 +920,7 @@ Machine::FreeKinematicRotAxis( int nId) if ( nId == GDB_ID_NULL) return false ; // cerco l'asse rotante di calcolo con questo identificativo - for ( size_t i = 0 ; i < m_vCalcRotAx.size() ; ++ i) { + for ( int i = 0 ; i < ssize( m_vCalcRotAx) ; ++ i) { if ( m_vCalcRotAx[i].nGrpId == nId) { m_vCalcRotAx[i].bFixed = false ; return true ; @@ -994,31 +994,6 @@ Machine::SetSolCh( int nScc, bool bExact) return false ; } -//---------------------------------------------------------------------------- -bool -Machine::GetAngles( const Vector3d& vtDirT, const Vector3d& vtDirA, - int& nStat, double& dAngA1, double& dAngB1, double& dAngA2, double& dAngB2) const -{ - // assegno dati - Vector3d vtDirH = m_vtCalcDir ; - Vector3d vtDirI = m_vtCalcADir ; - int nNumRotAx = 0 ; - KinAxis RotAx1 ; - if ( m_vCalcRotAx.size() >= 1) { - ++ nNumRotAx ; - RotAx1 = m_vCalcRotAx[0] ; - } - KinAxis RotAx2 ; - if ( m_vCalcRotAx.size() >= 2) { - ++ nNumRotAx ; - RotAx2 = m_vCalcRotAx[1] ; - } - - // eseguo calcolo - return GetMyAngles( vtDirT, vtDirA, vtDirH, vtDirI, nNumRotAx, RotAx1, RotAx2, - nStat, dAngA1, dAngB1, dAngA2, dAngB2) ; -} - //---------------------------------------------------------------------------- bool Machine::GetAngles( const Vector3d& vtDirT, const Vector3d& vtDirA, @@ -1030,19 +1005,19 @@ Machine::GetAngles( const Vector3d& vtDirT, const Vector3d& vtDirA, Vector3d vtDirH = m_vtCalcDir ; Vector3d vtDirI = m_vtCalcADir ; int nNumRotAx = 0 ; - KinAxis RotAx[2] ; + KinAxis RotAx[3] ; INTVECTOR vBloHeAx ; - for ( size_t i = 0 ; i < m_vCalcRotAx.size() ; ++ i) { + for ( int i = 0 ; i < ssize( m_vCalcRotAx) ; ++ i) { // se asse libero if ( ! m_vCalcRotAx[i].bFixed) { // verifico di non superare il limite - if ( nNumRotAx >= 2) + if ( nNumRotAx >= 3) return false ; // assegno l'asse RotAx[nNumRotAx] = m_vCalcRotAx[i] ; // se asse di testa, lo aggiorno con precedenti bloccati di testa (applicati in ordine contrario) if ( RotAx[nNumRotAx].bHead) { - for ( size_t k = vBloHeAx.size() ; k >= 1 ; -- k) { + for ( int k = ssize( vBloHeAx) ; k >= 1 ; -- k) { int nA = vBloHeAx[k-1] ; RotAx[nNumRotAx].ptPos.Rotate( m_vCalcRotAx[nA].ptPos, m_vCalcRotAx[nA].vtDir, m_vCalcRotAx[nA].dFixVal) ; RotAx[nNumRotAx].vtDir.Rotate( m_vCalcRotAx[nA].vtDir, m_vCalcRotAx[nA].dFixVal) ; @@ -1059,7 +1034,7 @@ Machine::GetAngles( const Vector3d& vtDirT, const Vector3d& vtDirA, vtDirTm.Rotate( m_vCalcRotAx[i].vtDir, m_vCalcRotAx[i].dFixVal) ; vtDirAm.Rotate( m_vCalcRotAx[i].vtDir, m_vCalcRotAx[i].dFixVal) ; // aggiorno eventuali assi già inseriti (sicuramente di tavola) - for ( size_t j = 0 ; int( j) < nNumRotAx ; ++ j) { + for ( int j = 0 ; j < nNumRotAx ; ++ j) { RotAx[j].ptPos.Rotate( m_vCalcRotAx[i].ptPos, m_vCalcRotAx[i].vtDir, m_vCalcRotAx[i].dFixVal) ; RotAx[j].vtDir.Rotate( m_vCalcRotAx[i].vtDir, m_vCalcRotAx[i].dFixVal) ; } @@ -1070,42 +1045,83 @@ Machine::GetAngles( const Vector3d& vtDirT, const Vector3d& vtDirA, vBloHeAx.push_back( int( i)) ; } } - } // aggiorno direzioni utensile e ausiliaria su testa con eventuali assi bloccati di testa (applico in ordine contrario) - for ( size_t k = vBloHeAx.size() ; k >= 1 ; -- k) { + for ( int k = ssize( vBloHeAx) ; k >= 1 ; -- k) { int nA = vBloHeAx[k-1] ; vtDirH.Rotate( m_vCalcRotAx[nA].vtDir, m_vCalcRotAx[nA].dFixVal) ; vtDirI.Rotate( m_vCalcRotAx[nA].vtDir, m_vCalcRotAx[nA].dFixVal) ; } - // eseguo calcolo - double dAngA1, dAngB1, dAngA2, dAngB2 ; - if ( ! GetMyAngles( vtDirTm, vtDirAm, vtDirH, vtDirI, nNumRotAx, RotAx[0], RotAx[1], - nStat, dAngA1, dAngB1, dAngA2, dAngB2)) - return false ; - // assegno gli angoli - int nRotAxInd = 1 ; - for ( size_t i = 0 ; i < m_vCalcRotAx.size() ; ++i) { - if ( m_vCalcRotAx[i].bFixed) { - vAng1.push_back( m_vCalcRotAx[i].dFixVal) ; - vAng2.push_back( m_vCalcRotAx[i].dFixVal) ; - } - else { - if ( nRotAxInd == 1) { - vAng1.push_back( dAngA1) ; - vAng2.push_back( dAngA2) ; + // fino a due assi rotanti liberi + if ( nNumRotAx <= 2) { + // eseguo calcolo + double dAngA1, dAngB1, dAngA2, dAngB2 ; + if ( ! GetMyAngles( vtDirTm, vtDirAm, vtDirH, vtDirI, nNumRotAx, RotAx[0], RotAx[1], + nStat, dAngA1, dAngB1, dAngA2, dAngB2)) + return false ; + // assegno gli angoli + int nRotAxInd = 1 ; + for ( int i = 0 ; i < ssize( m_vCalcRotAx) ; ++i) { + if ( m_vCalcRotAx[i].bFixed) { + vAng1.push_back( m_vCalcRotAx[i].dFixVal) ; + vAng2.push_back( m_vCalcRotAx[i].dFixVal) ; } - else if ( nRotAxInd == 2) { - vAng1.push_back( dAngB1) ; - vAng2.push_back( dAngB2) ; + else { + if ( nRotAxInd == 1) { + vAng1.push_back( dAngA1) ; + vAng2.push_back( dAngA2) ; + } + else if ( nRotAxInd == 2) { + vAng1.push_back( dAngB1) ; + vAng2.push_back( dAngB2) ; + } + else + return false ; + ++ nRotAxInd ; } - else - return false ; - ++ nRotAxInd ; - } + } + return true ; + } + + // altrimenti tre assi rotanti liberi + else { + // verifico siano del tipo XYX (primo e terzo paralleli, secondo ortogonale a questi) + if ( ! AreSameOrOppositeVectorApprox( RotAx[0].vtDir, RotAx[2].vtDir) || + ! AreOrthoApprox( RotAx[0].vtDir, RotAx[1].vtDir)) + return false ; + // eseguo calcolo + double dAngA1, dAngB1, dAngC1, dAngA2, dAngB2, dAngC2 ; + if ( ! GetMyAngles( vtDirTm, vtDirAm, vtDirH, vtDirI, RotAx[0], RotAx[1], RotAx[2], + nStat, dAngA1, dAngB1, dAngC1, dAngA2, dAngB2, dAngC2)) + return false ; + // assegno gli angoli + int nRotAxInd = 1 ; + for ( int i = 0 ; i < ssize( m_vCalcRotAx) ; ++i) { + if ( m_vCalcRotAx[i].bFixed) { + vAng1.push_back( m_vCalcRotAx[i].dFixVal) ; + vAng2.push_back( m_vCalcRotAx[i].dFixVal) ; + } + else { + if ( nRotAxInd == 1) { + vAng1.push_back( dAngA1) ; + vAng2.push_back( dAngA2) ; + } + else if ( nRotAxInd == 2) { + vAng1.push_back( dAngB1) ; + vAng2.push_back( dAngB2) ; + } + else if ( nRotAxInd == 3) { + vAng1.push_back( dAngC1) ; + vAng2.push_back( dAngC2) ; + } + else + return false ; + ++ nRotAxInd ; + } + } + return true ; } - return true ; } //---------------------------------------------------------------------------- @@ -1318,6 +1334,98 @@ Machine::GetMyAngles( const Vector3d& vtDirT, const Vector3d& vtDirA, return true ; } +//---------------------------------------------------------------------------- +bool +Machine::GetMyAngles( const Vector3d& vtDirT, const Vector3d& vtDirA, + const Vector3d& vtDirH, const Vector3d& vtDirI, + const KinAxis& RotAx1, const KinAxis& RotAx2, const KinAxis& RotAx3, + int& nStat, double& dAngA1, double& dAngB1, double& dAngC1, double& dAngA2, double& dAngB2, double& dAngC2) const +{ + // annullo tutti gli angoli + nStat = 0 ; dAngA1 = 0 ; dAngB1 = 0 ; dAngC1 = 0 ; dAngA2 = 0 ; dAngB2 = 0 ; dAngC2 = 0 ; + + // direzione fresa normalizzata + Vector3d vtDirTn = vtDirT ; + if ( ! vtDirTn.Normalize()) + return false ; + // direzione ausiliaria normalizzata + Vector3d vtDirAn = vtDirA ; + if ( ! vtDirAn.Normalize()) + return false ; + + // riferimento fresa su testa a riposo + Frame3d frTzero ; + frTzero.Set( ORIG, vtDirH, vtDirI) ; + // riferimento fresa richiesto + Frame3d frTool ; + frTool.Set( ORIG, vtDirTn, vtDirAn) ; + // riferimento intrinseco primi due assi rotanti + Frame3d frWrist ; + frWrist.Set( ORIG, RotAx1.vtDir, RotAx2.vtDir ^ RotAx1.vtDir) ; + + // direzione terzo asse rotante con testa a riposo + Vector3d vtCzero = GetToLoc( RotAx3.vtDir, frTzero) ; + // direzione richiesta terzo asse rotante + Vector3d vtCen = GetToGlob( vtCzero, frTool) ; + + // calcolo primi due assi rotanti + Vector3d vtCenL = GetToLoc( vtCen, frWrist) ; + vtCenL.ToSpherical( nullptr, &dAngB1, &dAngA1) ; + if ( dAngA1 > ANG_STRAIGHT) + dAngA1 -= ANG_FULL ; + if ( dAngA1 > ANG_RIGHT) { + dAngA1 -= ANG_STRAIGHT ; + dAngB1 = -dAngB1 ; + } + else if ( dAngA1 < -ANG_RIGHT) { + dAngA1 += ANG_STRAIGHT ; + dAngB1 = -dAngB1 ; + } + dAngA2 = dAngA1 + ( dAngA1 > EPS_ANG_ZERO ? -ANG_STRAIGHT : ANG_STRAIGHT) ; + dAngB2 = -dAngB1 ; + + // calcolo il terzo asse rotante del polso + Vector3d vtR3 = RotAx3.vtDir ; + vtR3.Rotate( RotAx2.vtDir, dAngB1) ; + vtR3.Rotate( RotAx1.vtDir, dAngA1) ; + Vector3d vtTool = vtDirH ; + vtTool.Rotate( RotAx2.vtDir, dAngB1) ; + vtTool.Rotate( RotAx1.vtDir, dAngA1) ; + bool bDetC1 ; + if ( ! vtTool.GetRotation( vtDirTn, vtR3, EPS_SMALL, dAngC1, bDetC1) || ! bDetC1) { + Vector3d vtAux = vtDirI ; + vtAux.Rotate( RotAx2.vtDir, dAngB1) ; + vtAux.Rotate( RotAx1.vtDir, dAngA1) ; + if ( ! vtAux.GetRotation( vtDirAn, vtR3, EPS_SMALL, dAngC1, bDetC1) || ! bDetC1) { + LOG_ERROR( GetEMkLogger(), "Error : R3 not calculable (machine)") + return false ; + } + } + dAngC2 = dAngC1 + ( dAngC1 > EPS_ANG_ZERO ? -ANG_STRAIGHT : ANG_STRAIGHT) ; + + // verifiche dei limiti di corsa + nStat = 2 ; + // se non riesco ad aggiustare, elimino + if ( ! AdjustAngleInStroke( RotAx1.stroke, dAngA2) || + ! AdjustAngleInStroke( RotAx2.stroke, dAngB2) || + ! AdjustAngleInStroke( RotAx3.stroke, dAngC2)) + -- nStat ; + // se non riesco ad aggiustare, elimino + if ( ! AdjustAngleInStroke( RotAx1.stroke, dAngA1) || + ! AdjustAngleInStroke( RotAx2.stroke, dAngB1) || + ! AdjustAngleInStroke( RotAx3.stroke, dAngC1)) { + -- nStat ; + // riloco eventuale soluzione rimasta + if ( nStat >= 1) { + dAngA1 = dAngA2 ; + dAngB1 = dAngB2 ; + dAngC1 = dAngC2 ; + } + } + + return true ; +} + //---------------------------------------------------------------------------- bool Machine::GetPositions( const Point3d& ptP, const DBLVECTOR& vAng, @@ -1399,7 +1507,7 @@ Machine::GetDirection( const Vector3d& vtDir, const DBLVECTOR& vAng, Vector3d& v vtNew = vtDir ; // ciclo sugli assi di testa dall'ultimo (prima assi di tavola, poi di testa) - for ( size_t i = m_vCalcRotAx.size() ; i >= 1 ; -- i) { + for ( int i = ssize( m_vCalcRotAx) ; i >= 1 ; -- i) { // se asse di testa if ( m_vCalcRotAx[i-1].bHead) vtNew.Rotate( m_vCalcRotAx[i-1].vtDir, vAng[i-1]) ; @@ -1426,7 +1534,7 @@ Machine::GetBackDirection( const Vector3d& vtDir, const DBLVECTOR& vAng, Vector3 vtNew = vtDir ; // ciclo sugli assi dall'ultimo (prima assi di tavola, poi di testa) - for ( size_t i = m_vCalcRotAx.size() ; i >= 1 ; -- i) { + for ( int i = ssize( m_vCalcRotAx) ; i >= 1 ; -- i) { // se asse di testa if ( m_vCalcRotAx[i-1].bHead) vtNew.Rotate( m_vCalcRotAx[i-1].vtDir, vAng[i-1]) ; @@ -1617,7 +1725,7 @@ Machine::GetPartDirFromAngles( const Vector3d& vtPart, const DBLVECTOR& vAng, Ve vtDir = vtPart ; // ciclo sugli assi dal primo (solo assi di tavola) - for ( size_t i = 1 ; i <= m_vCalcRotAx.size() ; ++ i) { + for ( int i = 1 ; i <= ssize( m_vCalcRotAx) ; ++ i) { // se asse di tavola if ( ! m_vCalcRotAx[i-1].bHead) vtDir.Rotate( m_vCalcRotAx[i-1].vtDir, vAng[i-1]) ; @@ -1625,7 +1733,7 @@ Machine::GetPartDirFromAngles( const Vector3d& vtPart, const DBLVECTOR& vAng, Ve // eseguo rotazione inversa eventuale asse rotante speciale di testa if ( m_nHeadSpecRotAxis != -1) { - if ( m_nHeadSpecRotAxis < 0 || m_nHeadSpecRotAxis >= int( m_vCalcRotAx.size())) + if ( m_nHeadSpecRotAxis < 0 || m_nHeadSpecRotAxis >= ssize( m_vCalcRotAx)) return false ; int i = m_nHeadSpecRotAxis ; vtDir.Rotate( m_vCalcRotAx[i].vtDir, -vAng[i]) ; @@ -1814,7 +1922,7 @@ Machine::VerifyOutstroke( double dX, double dY, double dZ, const DBLVECTOR& vAng m_OutstrokeInfo.Clear() ; // verifica degli assi lineari DBLVECTOR vLin( 3) ; vLin[0] = dX ; vLin[1] = dY ; vLin[2] = dZ ; - for ( size_t i = 0 ; i < m_vCalcLinAx.size() && i < vLin.size() ; ++ i) { + for ( int i = 0 ; i < ssize( m_vCalcLinAx) && i < ssize( vLin) ; ++ i) { if ( vLin[i] < m_vCalcLinAx[i].stroke.Min) { if ( nStat == 0) { m_OutstrokeInfo.sAxName = GetAxis( m_vCalcLinAx[i].nGrpId)->GetName() ; @@ -1837,7 +1945,7 @@ Machine::VerifyOutstroke( double dX, double dY, double dZ, const DBLVECTOR& vAng } } // verifica degli assi rotanti - for ( size_t i = 0 ; i < m_vCalcRotAx.size() && i < vAng.size() ; ++ i) { + for ( int i = 0 ; i < ssize(m_vCalcRotAx) && i < ssize( vAng) ; ++ i) { if ( vAng[i] < m_vCalcRotAx[i].stroke.Min) { if ( nStat == 0) { m_OutstrokeInfo.sAxName = GetAxis( m_vCalcRotAx[i].nGrpId)->GetName() ; diff --git a/Milling.cpp b/Milling.cpp index 78c94aa..dd8af72 100644 --- a/Milling.cpp +++ b/Milling.cpp @@ -6521,14 +6521,26 @@ Milling::CalcAndSetCorrAuxDir( const ICurveComposite* pCompo, double dU, bool bI if ( m_bAggrBottom) return true ; // se impostato uso direttamente da lavorazione, imposto anche come versore aux - if ( m_Params.m_nSolCh == MCH_SCC_ADIR_NEAR || m_Params.m_nSolCh == MCH_SCC_ADIR_FAR) + if ( m_Params.m_nSolCh == MCH_SCC_ADIR_NEAR || m_Params.m_nSolCh == MCH_SCC_ADIR_FAR) { SetAuxDir( vtCorr) ; + return true ; + } // se standard o nullo o suo opposto if ( m_Params.m_nSolCh == MCH_SCC_STD || m_Params.m_nSolCh == MCH_SCC_NONE || m_Params.m_nSolCh == MCH_SCC_OPPOSITE) { // verifico se richiesto dalla testa - if ( m_nHeadSolCh == MCH_SCC_ADIR_NEAR || m_nHeadSolCh == MCH_SCC_ADIR_FAR) + if ( m_nHeadSolCh == MCH_SCC_ADIR_NEAR || m_nHeadSolCh == MCH_SCC_ADIR_FAR) { SetAuxDir( vtCorr) ; + return true ; + } } + // se impostato come parametro di lavorazione nelle UserNotes + Vector3d vtAux ; + if ( GetValInNotes( m_Params.m_sUserNotes, UN_VTAUXDIR, vtAux)) { + vtAux.Normalize() ; + SetAuxDir( vtAux) ; + return true ; + } + return true ; } diff --git a/OperUserNotesConst.h b/OperUserNotesConst.h index 28b8239..1dbe54a 100644 --- a/OperUserNotesConst.h +++ b/OperUserNotesConst.h @@ -25,6 +25,7 @@ static const std::string UN_LINTOL = "LinTol" ; static const std::string UN_DOUBLE = "DOUBLE" ; static const std::string UN_MIRRORAX = "MirrorAx" ; static const std::string UN_DELTAZ = "DeltaZ" ; +static const std::string UN_VTAUXDIR = "VtAuxDir" ; // Solo per Drilling static const std::string UN_LASTSTEP = "LastStep" ; diff --git a/Pocketing.cpp b/Pocketing.cpp index 517f0a6..a78414d 100644 --- a/Pocketing.cpp +++ b/Pocketing.cpp @@ -5165,6 +5165,15 @@ Pocketing::AddApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafe SetFlag( 0) ; } } + // altrimenti + else { + // se impostato come parametro di lavorazione nelle UserNotes + Vector3d vtAux ; + if ( GetValInNotes( m_Params.m_sUserNotes, UN_VTAUXDIR, vtAux)) { + vtAux.Normalize() ; + SetAuxDir( vtAux) ; + } + } // se sopra attacco c'è spazio per sicurezza o approccio double dSafeDist = ( m_bAggrBottom ? dSafeAggrBottZ : dSafeZ) ; if ( ! bBottomOutStart && dElev + max( dSafeDist, dAppr) > 10 * EPS_SMALL) { diff --git a/PocketingNT.cpp b/PocketingNT.cpp index ca499f4..1fbcdd1 100644 --- a/PocketingNT.cpp +++ b/PocketingNT.cpp @@ -5223,6 +5223,15 @@ PocketingNT::AddApproach( const Point3d& ptP, const Vector3d& vtTool, double dSa SetFlag( 0) ; } } + // altrimenti + else { + // se impostato come parametro di lavorazione nelle UserNotes + Vector3d vtAux ; + if ( GetValInNotes( m_Params.m_sUserNotes, UN_VTAUXDIR, vtAux)) { + vtAux.Normalize() ; + SetAuxDir( vtAux) ; + } + } // se sopra attacco c'è spazio per sicurezza o approccio double dSafeDist = ( m_bAggrBottom ? dSafeAggrBottZ : dSafeZ) ; if ( ! bBottomOutStart && dElev + max( dSafeDist, dAppr) > 10 * EPS_SMALL) { From 083f896d50e8f859d8aa77b41586a87f9fd7ddb6 Mon Sep 17 00:00:00 2001 From: Riccardo Elitropi Date: Wed, 8 Apr 2026 09:45:36 +0200 Subject: [PATCH 6/6] EgtMachKernel : - in pocketingNT aggiunta memorizzazione SelId al gruppo PathId corrente. --- PocketingNT.cpp | 64 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 49 insertions(+), 15 deletions(-) diff --git a/PocketingNT.cpp b/PocketingNT.cpp index 1fbcdd1..c34052c 100644 --- a/PocketingNT.cpp +++ b/PocketingNT.cpp @@ -1796,11 +1796,6 @@ PocketingNT::ResetCurveAllTempProp( ICurve* pCurve) bool PocketingNT::Chain( int nGrpDestId) { - // vettore puntatori alle curve - ICURVEPOVECTOR vpCrvs ; - vpCrvs.reserve( m_vId.size()) ; - // vettore selettori delle curve originali - SELVECTOR vInds ; // flag per imposizione lati chiusi m_bAllClose = GetForcedClosed() ; @@ -1814,8 +1809,21 @@ PocketingNT::Chain( int nGrpDestId) // recupero la superficie di Trim in globale [nullptr se non presente] PtrOwner pStmTrim( GetStmTrim()) ; + // struct per informazioni da salvare sul gruppo Aux come su chiave KEY_IDS + struct InfoCrvSel { + Point3d ptOnCrv ; // per determinare a quale curva si riferisce nella regione piana + bool bFound ; // per ottimizzare la ricerca + SELVECTOR vIds ; // SELVECTOR originario + InfoCrvSel( const Point3d& ptOC, const SELVECTOR& vI) + : ptOnCrv( ptOC), bFound( false), vIds( vI) {} ; + } ; + vector vInfoCrvSel ; + + // vettore puntatori e selettori alle curve + ICURVEPOVECTOR vpCrvs ; vpCrvs.reserve( m_vId.size()) ; + SELVECTOR vInds ; vInds.reserve( m_vId.size()) ; // recupero tutte le curve e le porto in globale - for ( const auto& Id : m_vId) { + for ( const SelData& Id : m_vId) { // prendo le curve ICURVEPLIST lstPC ; if ( ! GetCurves( Id, pStmRaw, pStmTrim, lstPC)) { @@ -1830,10 +1838,10 @@ PocketingNT::Chain( int nGrpDestId) // preparo i dati per il concatenamento bool bFirst = true ; Point3d ptNear = ORIG ; - double dToler = 10 * EPS_SMALL ; + double dToler = 10. * EPS_SMALL ; ChainCurves chainC ; - chainC.Init( true, dToler, int( vpCrvs.size())) ; - for ( size_t i = 0 ; i < vpCrvs.size() ; ++ i) { + chainC.Init( true, dToler, ssize( vpCrvs)) ; + for ( int i = 0 ; i < ssize( vpCrvs) ; ++ i) { // recupero la curva e il suo riferimento ICurve* pCrv = vpCrvs[i] ; if ( pCrv == nullptr) @@ -1844,11 +1852,11 @@ PocketingNT::Chain( int nGrpDestId) if ( ! pCrv->GetStartPoint( ptStart) || ! pCrv->GetStartDir( vtStart) || ! pCrv->GetEndPoint( ptEnd) || ! pCrv->GetEndDir( vtEnd)) return false ; - if ( ! chainC.AddCurve( int( i + 1), ptStart, vtStart, ptEnd, vtEnd)) + if ( ! chainC.AddCurve( i + 1, ptStart, vtStart, ptEnd, vtEnd)) return false ; // se prima curva, assegno inizio della ricerca if ( bFirst) { - ptNear = ptStart + 10 * EPS_SMALL * vtStart ; + ptNear = ptStart + 10. * EPS_SMALL * vtStart ; bFirst = false ; } } @@ -1867,7 +1875,7 @@ PocketingNT::Chain( int nGrpDestId) SELVECTOR vId2 ; vId2.reserve( vnId2.size()) ; // recupero le curve semplici e le inserisco nella curva composita - for ( size_t i = 0 ; i < vnId2.size() ; ++ i) { + for ( int i = 0 ; i < ssize( vnId2) ; ++ i) { int nId = abs( vnId2[i]) - 1 ; bool bInvert = ( vnId2[i] < 0) ; vId2.emplace_back( vInds[nId]) ; @@ -1927,11 +1935,14 @@ PocketingNT::Chain( int nGrpDestId) vCrvCompo.back()->SetExtrusion( vtExtr) ; // salvo la thickness come seconda temp prop ( la Sfr rimuove la thick delle curve) vCrvCompo.back()->SetTempParam( dThick, 1) ; + // salvo le Info della curva corrente + Point3d ptStart ; vCrvCompo.back()->GetStartPoint( ptStart) ; + vInfoCrvSel.emplace_back( ptStart, vId2) ; } // ordino le curve creando una regione piana SurfFlatRegionByContours SfrByC ; - for ( int i = 0 ; i < int( vCrvCompo.size()) ; ++ i) { + for ( int i = 0 ; i < ssize( vCrvCompo) ; ++ i) { // memorizzo la Thickness nei TempParams vCrvCompo[i]->SetTempParam( vCrvCompo[i]->GetTempParam( 1), 1) ; SfrByC.AddCurve( Release( vCrvCompo[i])) ; @@ -1948,17 +1959,40 @@ PocketingNT::Chain( int nGrpDestId) if ( nPathId == GDB_ID_NULL) return false ; m_pGeomDB->SetName( nPathId, MCH_PATH + ToString( ++ nGroupName)) ; - m_pGeomDB->SetInfo( nPathId, KEY_IDS, ToString( nGroupName)) ; // recupero il Chunk corrente PtrOwner pSfrChunk( pSfrCurr->CloneChunk( nC)) ; if ( IsNull( pSfrChunk) || ! pSfrChunk->IsValid()) return false ; - // recupero la ThickNess e l'Estrusione dal Loop esterno + // recupero la Thickness e l'Estrusione dal Loop esterno PtrOwner pCrvInfo( ConvertCurveToComposite( pSfrChunk->GetLoop( 0, 0))) ; if ( IsNull( pCrvInfo) || ! pCrvInfo->IsValid()) return false ; double dThick = pCrvInfo->GetTempParam( 1) ; Vector3d vtExtr ; pCrvInfo->GetExtrusion( vtExtr) ; + // assegno come proprietà del gruppo le Info di selezione delle entità selezionate originarie + string sInfo ; + for ( int nInfo = 0 ; nInfo < ssize( vInfoCrvSel) ; ++ nInfo) { + if ( ! vInfoCrvSel[nInfo].bFound) { + if ( pCrvInfo->IsPointOn( vInfoCrvSel[nInfo].ptOnCrv, 5. * EPS_SMALL)) { + sInfo += ToString( vInfoCrvSel[nInfo].vIds) ; + vInfoCrvSel[nInfo].bFound = true ; + } + } + } + for ( int nL = 1 ; nL < pSfrChunk->GetLoopCount( 0) ; ++ nL) { + PtrOwner pCrvLoop( pSfrChunk->GetLoop( 0, nL)) ; + if ( IsNull( pCrvLoop) || ! pCrvLoop->IsValid()) + continue ; + for ( int nInfo = 0 ; nInfo < ssize( vInfoCrvSel) ; ++ nInfo) { + if ( ! vInfoCrvSel[nInfo].bFound) { + if ( pCrvLoop->IsPointOn( vInfoCrvSel[nInfo].ptOnCrv, 5. * EPS_SMALL)) { + sInfo += ToString( vInfoCrvSel[nInfo].vIds) ; + vInfoCrvSel[nInfo].bFound = true ; + } + } + } + } + m_pGeomDB->SetInfo( nPathId, KEY_IDS, sInfo) ; // -------------- Verifico quale part del Grezzo bisogna considerare ---------------- if ( ! ChooseRawPart( pSfrChunk, ( pStmTrim == nullptr ? pStmRaw : pStmTrim))) { m_pMchMgr->SetLastError( 2436, "Error in PocketingNT : not valid Raw") ;