From 7fbce2b5936cf61f2d82cdce311b91c36cf24624 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Tue, 19 Mar 2024 18:11:50 +0100 Subject: [PATCH] EgtMachKernel : - aggiunta gestione oggetti per verifica collisioni nei link tra lavorazioni anche nelle tavole - in fresatura standard migliorati approcci e retrazioni per frese che non lavorano di testa - in simulazione migliorata gestione comandi ausiliari di start in Disposizioni senza movimenti. --- Head.cpp | 2 ++ Machine.cpp | 4 +-- Machine.h | 3 +- MachineCalc.cpp | 25 +++++++++++++ MachineLua.cpp | 6 +++- Milling.cpp | 94 +++++++++++++++++++++++++++++-------------------- Operation.cpp | 43 ++++++++++++++++++++-- Simulator.cpp | 8 ++--- Table.cpp | 13 ++++--- Table.h | 5 ++- 10 files changed, 149 insertions(+), 54 deletions(-) diff --git a/Head.cpp b/Head.cpp index 1fb614f..3760f36 100644 --- a/Head.cpp +++ b/Head.cpp @@ -52,6 +52,7 @@ Head::Clone( void) const pHead->m_bMaxDeltaR2On1 = m_bMaxDeltaR2On1 ; pHead->m_Rot2Stroke = m_Rot2Stroke ; pHead->m_nSolCh = m_nSolCh ; + pHead->m_vsOtherColl = m_vsOtherColl ; } catch( ...) { delete pHead ; @@ -73,6 +74,7 @@ Head::Dump( string& sOut, bool bMM, const char* szNewLine) const sOut += "ExitCount=" + ToString( m_nExitCount) + szNewLine ; sOut += "HSet=" + ToString( m_vsHSet) + szNewLine ; sOut += "ADir=" + ToString( m_vtADir) + szNewLine ; + sOut += "OtherColl=" + ToString( m_vsOtherColl) + szNewLine ; return true ; } diff --git a/Machine.cpp b/Machine.cpp index 91ff2d7..629ce9a 100644 --- a/Machine.cpp +++ b/Machine.cpp @@ -212,7 +212,7 @@ Machine::AdjustAuxGeometry( const STRVECTOR& vsAux, int nLay) bool Machine::LoadMachineTable( const string& sName, const string& sParent, int nType, const Point3d& ptRef1, double dCoeffX, double dCoeffY, double dCoeffZ, - const string& sGeo, const STRVECTOR& vsAux) + const STRVECTOR& vsColl, const string& sGeo, const STRVECTOR& vsAux) { // recupero pezzo e layer della geometria originale della tavola string sPart, sLay ; @@ -251,7 +251,7 @@ Machine::LoadMachineTable( const string& sName, const string& sParent, int nType Table* pTab = new(nothrow) Table ; if ( pTab == nullptr) return false ; - pTab->Set( sName, nType, ptRef1, b3Area1) ; + pTab->Set( sName, nType, ptRef1, b3Area1, vsColl) ; m_pGeomDB->SetUserObj( nLay, pTab) ; // lo inserisco nel dizionario dei gruppi della macchina return m_mapGroups.emplace( sName, nLay).second ; diff --git a/Machine.h b/Machine.h index b2ac0d4..561905e 100644 --- a/Machine.h +++ b/Machine.h @@ -97,6 +97,7 @@ class Machine bool GetCurrTableArea1( BBox3d& b3Area1) const ; bool GetCurrTableDeltaRef1( Vector3d& vtDelta1) const ; bool GetCurrTableIsTilting( bool& bTilting, Vector3d& vtTiltingAx) const ; + bool GetCurrTableCollGroups( INTVECTOR& vIds) const ; bool SetCurrTool( const std::string& sTool, const std::string& sHead, int nExit) ; bool ResetCurrTool( void) ; int GetCurrTool( void) const ; @@ -197,7 +198,7 @@ class Machine bool AdjustAuxGeometry( const STRVECTOR& vsAux, int nLay) ; bool LoadMachineTable( const std::string& sName, const std::string& sParent, int nType, const Point3d& ptRef1, double dCoeffX, double dCoeffY, double dCoeffZ, - const std::string& sGeo, const STRVECTOR& vsAux) ; + const STRVECTOR& vsColl, const std::string& sGeo, const STRVECTOR& vsAux) ; bool AdjustTable( int nLay, const Point3d& ptRef1) ; bool LoadMachineAxis( const std::string& sName, const std::string& sParent, const std::string& sToken, bool bInvert, double dOffset, int nType, const Point3d& ptPos, const Vector3d& vtDir, const STROKE& Stroke, diff --git a/MachineCalc.cpp b/MachineCalc.cpp index cb5e6d7..9eb9f90 100644 --- a/MachineCalc.cpp +++ b/MachineCalc.cpp @@ -214,6 +214,31 @@ Machine::GetCurrTableIsTilting( bool& bTilting, Vector3d& vtTiltingAx) const return true ; } +//---------------------------------------------------------------------------- +bool +Machine::GetCurrTableCollGroups( INTVECTOR& vIds) const +{ + // controllo GeomDB + if ( m_pGeomDB == nullptr) + return false ; + // recupero la tavola corrente + Table* pTab = GetTable( m_nCalcTabId) ; + if ( pTab == nullptr) + return false ; + // recupero stringhe con gruppi ausiliari di collisione + const STRVECTOR& vsColl = pTab->GetCollGroups() ; + for ( const auto& sColl : vsColl) { + string sGrp, sSub ; + Split( sColl, "/", true, sGrp, sSub) ; + int nId = GetGroup( sGrp) ; + if ( ! sSub.empty() && nId != GDB_ID_NULL) + nId = m_pGeomDB->GetFirstNameInGroup( nId, sSub) ; + if ( nId != GDB_ID_NULL) + vIds.push_back( nId) ; + } + return true ; +} + //---------------------------------------------------------------------------- bool Machine::SetCurrTool( const string& sTool, const string& sHead, int nExit) diff --git a/MachineLua.cpp b/MachineLua.cpp index 0117a62..2fab700 100644 --- a/MachineLua.cpp +++ b/MachineLua.cpp @@ -59,6 +59,7 @@ static const string FLD_MAXDELTAR2ON1 = "MaxDeltaR2OnFirst" ; static const string FLD_ROT2STROKE = "Rot2Stroke" ; static const string FLD_SOLCH = "SolCh" ; static const string FLD_OTHCOLL = "OthColl" ; +static const string FLD_COLL = "Coll" ; //---------------------------------------------------------------------------- Machine* Machine::m_pMchLua = nullptr ; @@ -452,6 +453,9 @@ Machine::LuaEmtTable( lua_State* L) // lettura eventuale campo 'Scale' dalla tabella double vScale[3] = {1.0, 1.0, 1.0} ; LuaGetTabFieldParam( L, 1, FLD_SCALE, vScale) ; + // lettura eventuale campo 'Coll' dalla tabella + STRVECTOR vsColl ; + LuaGetTabFieldParam( L, 1, FLD_COLL, vsColl) ; // lettura campo 'Geo' dalla tabella string sGeo ; LuaCheckTabFieldParam( L, 1, FLD_GEO, sGeo) @@ -469,7 +473,7 @@ Machine::LuaEmtTable( lua_State* L) return luaL_error( L, " Unknown Machine") ; // carico i dati della tavola - if ( ! m_pMchLua->LoadMachineTable( sName, sParent, nType, Ref1, vScale[0], vScale[1], vScale[2], sGeo, vsAux)) + if ( ! m_pMchLua->LoadMachineTable( sName, sParent, nType, Ref1, vScale[0], vScale[1], vScale[2], vsColl, sGeo, vsAux)) return luaL_error( L, " Load Machine Table failed") ; // restituisco l'indice della tavola diff --git a/Milling.cpp b/Milling.cpp index a19e33a..c98520b 100644 --- a/Milling.cpp +++ b/Milling.cpp @@ -2267,6 +2267,8 @@ Milling::AddStandardMilling( const ICurveComposite* pCompo, const Vector3d& vtTo // lunghezza di approccio/retrazione double dAppr = m_Params.m_dStartPos ; double dExtrAppr = dAppr + max( 0.0, m_TParams.m_dTLen - m_TParams.m_dLen) ; + // delta da punto lavoro a punto tip + Vector3d vtWkTip = vtTool * ( m_TParams.m_dLen - m_TParams.m_dTLen) ; // in caso di tabs ne aggiusto i parametri secondo il percorso TabData tdTabs ; @@ -2302,7 +2304,7 @@ Milling::AddStandardMilling( const ICurveComposite* pCompo, const Vector3d& vtTo pCurve->GetStartDir( vtStart) ; // determino elevazione su inizio percorso di lavoro double dStElev ; - if ( ! GetElevation( m_nPhase, ptStart, vtTool, GetRadiusForStartEndElevation(), vtTool, dStElev)) + if ( ! GetElevation( m_nPhase, ptStart + vtWkTip, vtTool, GetRadiusForStartEndElevation(), vtTool, dStElev)) dStElev = dElev ; // determino inizio attacco Point3d ptP1 ; @@ -2314,9 +2316,9 @@ Milling::AddStandardMilling( const ICurveComposite* pCompo, const Vector3d& vtTo Vector3d vtAppr( vtTool.x, vtTool.y, 0) ; if ( ! vtAppr.Normalize()) vtAppr = FromNearestHorizontalOrtho( vtTool, vtDir1) ; - bool bOutStart = GetPointOutOfRaw( ptP1, vtTool, vtAppr, dStElev, dSafeZ) ; + bool bOutStart = GetPointOutOfRaw( ptP1 + vtWkTip, vtTool, vtAppr, dStElev, dSafeZ) ; // determino se l'inizio dell'attacco è sopra il grezzo - bool bGeomAboveStart = GetPointAboveRaw( ptP1, vtTool) ; + bool bGeomAboveStart = GetPointAboveRaw( ptP1 + vtWkTip, vtTool) ; bool bAboveStart = false ; if ( m_bAboveHead) { if ( ! m_bTiltingTab) @@ -2330,7 +2332,7 @@ Milling::AddStandardMilling( const ICurveComposite* pCompo, const Vector3d& vtTo CalcAndSetCorrAuxDir( pCompo, i) ; // aggiungo approccio per frese normali e frese che non lavorano di testa con attacco opportuno oppure fuori if ( ( m_TParams.m_nType & TF_MILL) != 0 && - ( m_TParams.m_nType != TT_MILL_NOTIP || LeadInRawIsOk() || m_bStartOutRaw || bOutStart)) { + ( m_TParams.m_nType != TT_MILL_NOTIP || LeadInRawIsOk() || m_bStartOutRaw)) { // correggo elevazione iniziale per punto inizio attacco (se testa da sopra senza aggregato approccio mai Z-) Vector3d vtEscape = vtTool ; if ( ( m_bAboveHead && ! m_bAggrBottom && ! m_bTiltingTab && vtTool.z < -EPS_SMALL) || @@ -2339,13 +2341,13 @@ Milling::AddStandardMilling( const ICurveComposite* pCompo, const Vector3d& vtTo vtEscape.Normalize() ; } double dNewStElev ; - if ( GetElevation( m_nPhase, ptP1, vtTool, GetRadiusForStartEndElevation(), vtEscape, dNewStElev)) + if ( GetElevation( m_nPhase, ptP1 + vtWkTip, vtTool, GetRadiusForStartEndElevation(), vtEscape, dNewStElev)) dStElev = min( dStElev, dNewStElev) ; // se testa sopra, determino se l'inizio dell'attacco è esattamente sotto il grezzo, nel qual caso ricalcolo l'elevazione - bool bAhUnderStart = m_bAboveHead && GetAhPointUnderRaw( ptP1, vtTool, 0, GetRadiusForStartEndElevation(), + bool bAhUnderStart = m_bAboveHead && GetAhPointUnderRaw( ptP1 + vtWkTip, vtTool, 0, GetRadiusForStartEndElevation(), m_TParams.m_dLen, false, dSafeZ, vtEscape, dStElev) ; // se testa sotto, determino se l'inizio dell'attacco è esattamente sopra il grezzo, nel qual caso ricalcolo l'elevazione - bool bUhAboveStart = ! m_bAboveHead && GetUhPointAboveRaw( ptP1, vtTool, 0, GetRadiusForStartEndElevation(), + bool bUhAboveStart = ! m_bAboveHead && GetUhPointAboveRaw( ptP1 + vtWkTip, vtTool, 0, GetRadiusForStartEndElevation(), m_TParams.m_dLen, false, dSafeZ, vtEscape, dStElev) ; // se attacco a zigzag o a spirale, l'elevazione va nell'attacco if ( IsLeadInHelixOrZigzag()) { @@ -2364,15 +2366,21 @@ Milling::AddStandardMilling( const ICurveComposite* pCompo, const Vector3d& vtTo if ( ! bOutStart) { // verifico se sono sotto double dSawStartElev = 0 ; - bool bUnderStart = false ; + bool bAhUnderStart = false ; + bool bUhAboveStart = false ; bool bSideStart = false ; if ( ! bGeomAboveStart) { - bUnderStart = m_bAboveHead && GetAhPointUnderRaw( ptP1, vtTool, m_TParams.m_dTDiam / 2, - GetRadiusForStartEndElevation( false), - m_TParams.m_dLen, true, dSafeZ, vtAppr, dSawStartElev) ; + bAhUnderStart = m_bAboveHead && GetAhPointUnderRaw( ptP1 + vtWkTip, vtTool, m_TParams.m_dTDiam / 2, + GetRadiusForStartEndElevation( false), + m_TParams.m_dLen, true, dSafeZ, vtAppr, dSawStartElev) ; + } + else { + bUhAboveStart = ! m_bAboveHead && GetUhPointAboveRaw( ptP1 + vtWkTip, vtTool, m_TParams.m_dTDiam / 2, + GetRadiusForStartEndElevation( false), + m_TParams.m_dLen, true, dSafeZ, vtAppr, dSawStartElev) ; } // se non sono sotto, verifico se posso allontanarmi nel piano lama (meglio se in orizzontale) - if ( ! bUnderStart) { + if ( ! bAhUnderStart && ! bUhAboveStart) { Point3d ptTest = ptP1 - MIN_SAFEDIST * ( m_bAboveHead ? Z_AX : -Z_AX) - DELTA_ELEV_RAD * vtTool ; Point3d ptTestU = ptTest + m_TParams.m_dDiam * ( m_bAboveHead ? Z_AX : -Z_AX) ; Vector3d vtAppr1 = FromNearestHorizontalOrtho( vtTool, vtDir1) ; @@ -2381,9 +2389,9 @@ Milling::AddStandardMilling( const ICurveComposite* pCompo, const Vector3d& vtTo vtAppr2 = ( m_TParams.m_nType == TT_MILL_NOTIP ? -vtStart : CalcCorrDir( pCompo, i)) ; double dThick = ( m_TParams.m_nType == TT_MILL_NOTIP ? m_TParams.m_dMaxMat : m_TParams.m_dThick) + 2 * DELTA_ELEV_RAD ; double dSawStartElev1, dSawStartElev2 ; - bool bOk1 = GetElevation( m_nPhase, ptTest, ptTestU, vtTool, GetRadiusForStartEndElevation(), dThick, vtAppr1, dSawStartElev1) ; + bool bOk1 = GetElevation( m_nPhase, ptTest + vtWkTip, ptTestU + vtWkTip, vtTool, GetRadiusForStartEndElevation(), dThick, vtAppr1, dSawStartElev1) ; bool bOk2 = ! AreSameVectorApprox( vtAppr2, vtAppr1) && - GetElevation( m_nPhase, ptTest, ptTestU, vtTool, GetRadiusForStartEndElevation(), dThick, vtAppr2, dSawStartElev2) ; + GetElevation( m_nPhase, ptTest + vtWkTip, ptTestU + vtWkTip, vtTool, GetRadiusForStartEndElevation(), dThick, vtAppr2, dSawStartElev2) ; if ( bOk1 && bOk2) { bool bFirst = ( dSawStartElev1 < 1.3 * dSawStartElev2) ; vtAppr = ( bFirst ? vtAppr1 : vtAppr2) ; @@ -2401,7 +2409,7 @@ Milling::AddStandardMilling( const ICurveComposite* pCompo, const Vector3d& vtTo bSideStart = true ; } } - if ( ! bGeomAboveStart && ! bUnderStart && ! bSideStart && bOk) { + if ( ! bGeomAboveStart && ! bAhUnderStart && ! bUhAboveStart && ! bSideStart && bOk) { m_pMchMgr->SetLastError( 2314, "Error in Milling : LeadIn must be out of rawpart") ; bOk = false ; } @@ -2474,7 +2482,7 @@ Milling::AddStandardMilling( const ICurveComposite* pCompo, const Vector3d& vtTo pCurve->GetEndDir( vtEnd) ; // elevazione sul punto finale double dEndElev ; - if ( ! GetElevation( m_nPhase, ptEnd, vtTool, GetRadiusForStartEndElevation(), vtTool, dEndElev)) + if ( ! GetElevation( m_nPhase, ptEnd + vtWkTip, vtTool, GetRadiusForStartEndElevation(), vtTool, dEndElev)) dEndElev = dElev ; // aggiungo uscita Point3d ptP1 ; @@ -2488,18 +2496,18 @@ Milling::AddStandardMilling( const ICurveComposite* pCompo, const Vector3d& vtTo Vector3d vtRetr( vtTool.x, vtTool.y, 0) ; if ( ! vtRetr.Normalize()) vtRetr = FromNearestHorizontalOrtho( vtTool, vtDir1) ; - bool bOutEnd = GetPointOutOfRaw( ptP1, vtTool, vtRetr, dEndElev, dSafeZ) ; + bool bOutEnd = GetPointOutOfRaw( ptP1 + vtWkTip, vtTool, vtRetr, dEndElev, dSafeZ) ; // aggiungo retrazione per frese normali e frese che non lavorano di testa già fuori if ( ( m_TParams.m_nType & TF_MILL) != 0 && - ( m_TParams.m_nType != TT_MILL_NOTIP || m_bEndOutRaw || bOutEnd)) { + ( m_TParams.m_nType != TT_MILL_NOTIP || m_bEndOutRaw)) { // determino se la fine dell'uscita è sopra il grezzo bool bAboveEnd = false ; if ( m_bAboveHead) { if ( ! m_bTiltingTab) - bAboveEnd = GetPointAboveRaw( ptP1, vtTool) ; + bAboveEnd = GetPointAboveRaw( ptP1 + vtWkTip, vtTool) ; else { Vector3d vtCorr = CalcCorrDir( pCompo, nMaxInd + 1) ; - if ( GetPointOutOfRaw( ptP1, vtTool, vtCorr, dEndElev, dSafeZ)) + if ( GetPointOutOfRaw( ptP1 + vtWkTip, vtTool, vtCorr, dEndElev, dSafeZ)) dEndElev = min( dEndElev, dElev) ; } } @@ -2511,13 +2519,13 @@ Milling::AddStandardMilling( const ICurveComposite* pCompo, const Vector3d& vtTo vtEscape.Normalize() ; } double dNewEndElev ; - if ( GetElevation( m_nPhase, ptP1, vtTool, GetRadiusForStartEndElevation(), vtEscape, dNewEndElev)) + if ( GetElevation( m_nPhase, ptP1 + vtWkTip, vtTool, GetRadiusForStartEndElevation(), vtEscape, dNewEndElev)) dEndElev = min( dEndElev, dNewEndElev) ; // se testa sopra, determino se l'inizio dell'uscita è esattamente sotto il grezzo, nel qual caso ricalcolo l'elevazione - bool bAhUnderEnd = m_bAboveHead && GetAhPointUnderRaw( ptP1, vtTool, 0, GetRadiusForStartEndElevation(), + bool bAhUnderEnd = m_bAboveHead && GetAhPointUnderRaw( ptP1 + vtWkTip, vtTool, 0, GetRadiusForStartEndElevation(), m_TParams.m_dLen, false, dSafeZ, vtEscape, dEndElev) ; // se testa sotto, determino se l'inizio dell'uscita è esattamente sopra il grezzo, nel qual caso ricalcolo l'elevazione - bool bUhAboveEnd = ! m_bAboveHead && GetUhPointAboveRaw( ptP1, vtTool, 0, GetRadiusForStartEndElevation(), + bool bUhAboveEnd = ! m_bAboveHead && GetUhPointAboveRaw( ptP1 + vtWkTip, vtTool, 0, GetRadiusForStartEndElevation(), m_TParams.m_dLen, false, dSafeZ, vtEscape, dEndElev) ; // aggiungo retrazione if ( ! AddRetract( ptP1, vtTool, dSafeZ, dSafeAggrBottZ, dEndElev, dExtrAppr, bAboveEnd)) { @@ -2529,17 +2537,23 @@ Milling::AddStandardMilling( const ICurveComposite* pCompo, const Vector3d& vtTo else { if ( ! bOutEnd) { // verifico se sono sopra - bool bGeomAboveEnd = GetPointAboveRaw( ptP1, vtTool) ; + bool bGeomAboveEnd = GetPointAboveRaw( ptP1 + vtWkTip, vtTool) ; // verifico se sono sotto double dSawEndElev = 0 ; - bool bUnderEnd = false ; + bool bAhUnderEnd = false ; + bool bUhAboveEnd = false ; bool bSideEnd = false ; if ( ! bGeomAboveEnd) { - bUnderEnd = m_bAboveHead && GetAhPointUnderRaw( ptP1, vtTool, m_TParams.m_dTDiam / 2, - GetRadiusForStartEndElevation( true), - m_TParams.m_dLen, true, dSafeZ, vtRetr, dSawEndElev) ; + bAhUnderEnd = m_bAboveHead && GetAhPointUnderRaw( ptP1 + vtWkTip, vtTool, m_TParams.m_dTDiam / 2, + GetRadiusForStartEndElevation( true), + m_TParams.m_dLen, true, dSafeZ, vtRetr, dSawEndElev) ; } - if ( ! bUnderEnd) { + else { + bUhAboveEnd = ! m_bAboveHead && GetUhPointAboveRaw( ptP1 + vtWkTip, vtTool, m_TParams.m_dTDiam / 2, + GetRadiusForStartEndElevation( true), + m_TParams.m_dLen, true, dSafeZ, vtRetr, dSawEndElev) ; + } + if ( ! bAhUnderEnd && ! bUhAboveEnd) { Point3d ptTest = ptP1 - MIN_SAFEDIST * ( m_bAboveHead ? Z_AX : -Z_AX) - DELTA_ELEV_RAD * vtTool ; Point3d ptTestU = ptTest + m_TParams.m_dDiam * ( m_bAboveHead ? Z_AX : -Z_AX) ; Vector3d vtRetr1 = FromNearestHorizontalOrtho( vtTool, vtDir1) ; @@ -2548,9 +2562,9 @@ Milling::AddStandardMilling( const ICurveComposite* pCompo, const Vector3d& vtTo vtRetr2 = ( m_TParams.m_nType == TT_MILL_NOTIP ? vtEnd : CalcCorrDir( pCompo, i + 1)) ; double dThick = ( m_TParams.m_nType == TT_MILL_NOTIP ? m_TParams.m_dMaxMat : m_TParams.m_dThick) + 2 * DELTA_ELEV_RAD ; double dSawEndElev1, dSawEndElev2 ; - bool bOk1 = GetElevation( m_nPhase, ptTest, ptTestU, vtTool, GetRadiusForStartEndElevation(), dThick, vtRetr1, dSawEndElev1) ; + bool bOk1 = GetElevation( m_nPhase, ptTest + vtWkTip, ptTestU + vtWkTip, vtTool, GetRadiusForStartEndElevation(), dThick, vtRetr1, dSawEndElev1) ; bool bOk2 = ! AreSameVectorApprox( vtRetr2, vtRetr1) && - GetElevation( m_nPhase, ptTest, ptTestU, vtTool, GetRadiusForStartEndElevation(), dThick, vtRetr2, dSawEndElev2) ; + GetElevation( m_nPhase, ptTest + vtWkTip, ptTestU + vtWkTip, vtTool, GetRadiusForStartEndElevation(), dThick, vtRetr2, dSawEndElev2) ; if ( bOk1 && bOk2) { bool bFirst = ( dSawEndElev1 < 1.3 * dSawEndElev2) ; vtRetr = ( bFirst ? vtRetr1 : vtRetr2) ; @@ -2568,7 +2582,7 @@ Milling::AddStandardMilling( const ICurveComposite* pCompo, const Vector3d& vtTo bSideEnd = true ; } } - if ( ! bGeomAboveEnd && ! bUnderEnd && ! bSideEnd && bOk) { + if ( ! bGeomAboveEnd && ! bAhUnderEnd && ! bUhAboveEnd && ! bSideEnd && bOk) { m_pMchMgr->SetLastError( 2324, "Error in Milling : LeadOut must be out of rawpart") ; bOk = false ; } @@ -5121,12 +5135,16 @@ Milling::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d Vector3d vtRot = OrthoCompo( vtTool, vtEnd) ; vtPerp.Rotate( vtRot, 0, ( bCcwRot ? 1 : - 1)) ; ptP1 = ptEnd + vtEnd * dTang + vtPerp * dPerp + vtTool * dElev ; + vtDir1 = ptP1 - ptEnd ; + if ( ! vtDir1.Normalize()) + return false ; // inserisco uscita PtrOwner pCrv( GetArc2PVN( ptEnd, ptP1, vtEnd, vtTool)) ; if ( IsNull( pCrv)) return false ; // assegno direzione finale dell'uscita - if ( ! pCrv->GetEndDir( vtDir1)) + Vector3d vtDirF ; + if ( ! pCrv->GetEndDir( vtDirF)) return false ; bool bOk = true ; // eventuale spezzatura @@ -5141,7 +5159,7 @@ Milling::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d } // eventuale movimento ortogonale (estensione di inserimento compensazione raggio utensile) if ( m_Params.m_dLoCompLen > 10 * EPS_SMALL) { - vtDir1 = OrthoCompo( vtDir1, vtTool) ; + vtDir1 = OrthoCompo( vtDirF, vtTool) ; bOk = bOk && vtDir1.Normalize() ; vtDir1.Rotate( vtRot, 0, ( bCcwRot ? 1 : - 1)) ; ptP1 += vtDir1 * m_Params.m_dLoCompLen ; @@ -6130,16 +6148,16 @@ bool Milling::GetPointOutOfRaw( const Point3d& ptP, const Vector3d& vtTool, const Vector3d& vtCorr, double dElev, double dSafeZ) const { // per frese normali - if ( ( m_TParams.m_nType & TF_SAWBLADE) == 0) { + if ( m_TParams.m_nType == TT_MILL_STD) { // determino se l'inizio dell'attacco è fuori dal grezzo (considero movimento fresa lungo il suo asse) double dTemp ; - if ( ! GetElevation( m_nPhase, ptP, vtTool, m_TParams.m_dDiam / 2, vtTool, dTemp)) + if ( ! GetElevation( m_nPhase, ptP, vtTool, m_TParams.m_dTDiam / 2, vtTool, dTemp)) return false ; return ( dTemp < 10 * EPS_SMALL || dTemp > dElev + 10 * EPS_SMALL) ; } - // per lame + // per lame e frese che non lavorano di testa else { - // determino se l'inizio dell'attacco è fuori dal grezzo (considero movimento lama in +/- Z) + // determino se l'inizio dell'attacco è fuori dal grezzo (considero movimento utensile in +/- Z) double dTemp ; Vector3d vtMove = ( m_bAboveHead ? Z_AX : -Z_AX) ; Vector3d vtSafe = vtCorr ; vtSafe.z = 0 ; vtSafe.Normalize() ; diff --git a/Operation.cpp b/Operation.cpp index 418bc23..2ff83c3 100644 --- a/Operation.cpp +++ b/Operation.cpp @@ -3780,9 +3780,12 @@ Operation::TestCollisionAvoid( const DBLVECTOR& vAxStart, const DBLVECTOR& vAxEn // Aggancio bloccaggi alla tavola corrente for ( const auto nFxtId : vFxtId) pMch->LinkFixtureToGroup( nFxtId, sTable) ; + // Parti di tavola da considerare per la collisione + INTVECTOR vTabCollId ; + pMch->GetCurrTableCollGroups( vTabCollId) ; // Parti di testa e collegati da considerare per la collisione - INTVECTOR vCollId ; - pMch->GetCurrHeadCollGroups( vCollId) ; + INTVECTOR vHeadCollId ; + pMch->GetCurrHeadCollGroups( vHeadCollId) ; // Lancio la verifica custom int nRes = SpecialTestCollisionAvoid( vAxStart, vAxEnd) ; @@ -3819,7 +3822,7 @@ Operation::TestCollisionAvoid( const DBLVECTOR& vAxStart, const DBLVECTOR& vAxEn // Determino sottobox e box della testa e degli altri oggetti da considerare per la collisione BOXIVECTOR vbiSH ; BBox3d b3Head ; - for ( int nCId : vCollId) { + for ( int nCId : vHeadCollId) { int nHId = m_pGeomDB->GetFirstInGroup( nCId) ; while ( nHId != GDB_ID_NULL) { BBox3d b3Tmp ; @@ -3911,6 +3914,40 @@ Operation::TestCollisionAvoid( const DBLVECTOR& vAxStart, const DBLVECTOR& vAxEn if ( ExeGetDebugLevel() >= 5) { LOG_DBG_INFO( GetEMkLogger(), ( bCollide ? " COLLIDE" : " avoid")) ; } + // Se non trovata collisione, li confronto con oggetti da verificare della tavola + if ( ! bCollide) { + for ( const auto nTabCollId : vTabCollId) { + // verifico i box + BBox3d b3TabColl ; + int nFlag = BBF_ONLY_VISIBLE | BBF_IGNORE_TEXT | BBF_IGNORE_DIM ; + m_pGeomDB->GetGlobalBBox( nTabCollId, b3TabColl, nFlag) ; + // eventuale emissione Log + if ( ExeGetDebugLevel() >= 5) { + string sBox = " TabColl : " + ( b3TabColl.IsEmpty() ? string( "Empty Box") : ToString( b3TabColl, 1)) ; + LOG_DBG_INFO( GetEMkLogger(), sBox.c_str()) ; + } + // se i box interferiscono + if ( ! b3TabColl.IsEmpty() && b3Head.Overlaps( b3TabColl)) { + // eventuale emissione Log + if ( ExeGetDebugLevel() >= 5) { + LOG_DBG_INFO( GetEMkLogger(), " Can collide -->") ; + } + // verifico i sottobox + for ( const auto& biSH : vbiSH) { + if ( biSH.first.Overlaps( b3TabColl)) { + bCollide = true ; + break ; + } + } + if ( bCollide) + break ; + } + } + // eventuale emissione Log + if ( ExeGetDebugLevel() >= 5) { + LOG_DBG_INFO( GetEMkLogger(), ( bCollide ? " COLLIDE" : " avoid")) ; + } + } // Se non trovata collisione, li confronto con i bloccaggi if ( ! bCollide) { for ( const auto nFxtId : vFxtId) { diff --git a/Simulator.cpp b/Simulator.cpp index dbb0cb6..a84fc62 100644 --- a/Simulator.cpp +++ b/Simulator.cpp @@ -282,15 +282,15 @@ Simulator::Move( int& nStatus) m_dCoeff = 0 ; } - // Se appena arrivato alla fine di un percorso di lavoro - if ( m_nEntId == GDB_ID_NULL && m_nAuxEInd == 0 && m_nCLPathInd > 0) { + // Se appena arrivato alla fine di un percorso di lavoro (verifico anche completamento dei comandi aux di start per path vuote) + if ( m_nEntId == GDB_ID_NULL && m_nAuxEInd == 0 && m_nCLPathInd > 0 && m_nAuxSInd >= m_nAuxSTot) { // gestione fine percorso di lavoro if ( ! ManagePathEnd( nStatus)) return false ; } - // Se alla fine del percorso dopo esecuzione azioni ausiliarie - if ( m_nEntId == GDB_ID_NULL && m_nAuxEInd >= m_nAuxETot) { + // Se alla fine del percorso dopo esecuzione azioni ausiliarie (verifico anche completamento dei comandi aux di start per path vuote) + if ( m_nEntId == GDB_ID_NULL && m_nAuxEInd >= m_nAuxETot && m_nAuxSInd >= m_nAuxSTot) { // ricerca e gestione inizio percorso di lavoro if ( ! FindAndManagePathStart( nStatus)) return false ; diff --git a/Table.cpp b/Table.cpp index 7d476bf..39ad6ce 100644 --- a/Table.cpp +++ b/Table.cpp @@ -1,7 +1,7 @@ //---------------------------------------------------------------------------- -// EgalTech 2015-2015 +// EgalTech 2015-2024 //---------------------------------------------------------------------------- -// File : Table.cpp Data : 25.05.15 Versione : 1.6e7 +// File : Table.cpp Data : 19.03.24 Versione : 2.6c2 // Contenuto : Oggetto tavola per gruppo tavola di macchina. // // @@ -45,6 +45,7 @@ Table::Clone( void) const pTab->m_sName = m_sName ; pTab->m_nType = m_nType ; pTab->m_ptRef1 = m_ptRef1 ; + pTab->m_vsColl = m_vsColl ; } catch( ...) { delete pTab ; @@ -63,7 +64,10 @@ Table::Dump( string& sOut, bool bMM, const char* szNewLine) const sOut += "Id=" + ToString( m_nOwnerId) + szNewLine ; sOut += "Name=" + m_sName + szNewLine ; sOut += "Type=" + ToString( m_nType) + szNewLine ; - sOut += "Ref1=(" + ToString( GetInUiUnits(m_ptRef1, bMM), 4) + ")" + szNewLine ; + sOut += "Ref1=(" + ToString( GetInUiUnits( m_ptRef1, bMM), 4) + ")" + szNewLine ; + sOut += "Area1=(" + ToString( GetInUiUnits( m_b3Area1.GetMin(), bMM), 4) + ";" + + ToString( GetInUiUnits( m_b3Area1.GetMax(), bMM), 4) + szNewLine ; + sOut += "Coll=" + ToString( m_vsColl) + szNewLine ; return true ; } @@ -99,11 +103,12 @@ Table::Table( void) //---------------------------------------------------------------------------- bool -Table::Set( const string& sName, int nType, const Point3d& ptRef1, const BBox3d& b3Area1) +Table::Set( const string& sName, int nType, const Point3d& ptRef1, const BBox3d& b3Area1, const STRVECTOR& vsColl) { m_sName = sName ; m_nType = nType ; m_ptRef1 = ptRef1 ; m_b3Area1 = b3Area1 ; + m_vsColl = vsColl ; return true ; } diff --git a/Table.h b/Table.h index 910870b..876159e 100644 --- a/Table.h +++ b/Table.h @@ -30,7 +30,7 @@ class Table : public IUserObj public : Table( void) ; - bool Set( const std::string& sName, int nType, const Point3d& ptRef1, const BBox3d& b3Area1) ; + bool Set( const std::string& sName, int nType, const Point3d& ptRef1, const BBox3d& b3Area1, const STRVECTOR& vsColl) ; const std::string& GetName( void) { return m_sName ; } int GetType( void) @@ -39,6 +39,8 @@ class Table : public IUserObj { return m_ptRef1 ; } const BBox3d& GetArea1( void) { return m_b3Area1 ; } + const STRVECTOR& GetCollGroups( void) const + { return m_vsColl ; } private : int m_nOwnerId ; @@ -47,4 +49,5 @@ class Table : public IUserObj int m_nType ; Point3d m_ptRef1 ; BBox3d m_b3Area1 ; + STRVECTOR m_vsColl ; } ; \ No newline at end of file