From 662241c8e1560612c1a74185bbf415707a9bdb71 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 12 May 2025 09:47:18 +0200 Subject: [PATCH] EgtMachKernel 2.7e2 : - modifiche per gestione lavorazioni con percorsi vuoti. --- Chiseling.h | 10 ++- Disposition.h | 2 +- Drilling.h | 10 ++- EgtMachKernel.rc | Bin 11774 -> 11774 bytes FiveAxisMilling.h | 10 ++- GenMachining.h | 10 ++- MachMgr.h | 12 +-- MachMgrOperations.cpp | 28 +++--- Milling.h | 10 ++- Mortising.h | 10 ++- Operation.cpp | 200 +++++++++++++++++++++++++++--------------- Operation.h | 41 +++++---- Pocketing.cpp | 1 - Pocketing.h | 10 ++- PocketingNT.cpp | 59 +++---------- PocketingNT.h | 11 ++- Processor.cpp | 2 +- SawFinishing.h | 10 ++- SawRoughing.h | 10 ++- Sawing.h | 10 ++- SimulatorMP.cpp | 2 - SimulatorSP.cpp | 4 +- SurfFinishing.h | 10 ++- SurfRoughing.h | 10 ++- WaterJetting.h | 10 ++- 25 files changed, 302 insertions(+), 190 deletions(-) diff --git a/Chiseling.h b/Chiseling.h index e713dec..c3c31df 100644 --- a/Chiseling.h +++ b/Chiseling.h @@ -37,8 +37,14 @@ class Chiseling : public Machining public : // Operation int GetType( void) const override { return OPER_CHISELING ; } - bool IsEmpty( void) const override - { return ( m_nChisels == 0) ; } + bool IsEmpty( int nEmptyType = NEED_GEOM) const override + { if ( m_nChisels == 0) + return true ; + if ( nEmptyType == NEED_ONE_TP_OK) + return ( ! IsAtLeastOnePathOk()) ; + if ( nEmptyType == NEED_ALL_TP_OK) + return ( ! AreAllPathsOk()) ; + return false ; } bool UpdateStatus( int nModif) override { m_nStatus |= nModif ; return true ; } diff --git a/Disposition.h b/Disposition.h index ec95c91..3a606e6 100644 --- a/Disposition.h +++ b/Disposition.h @@ -73,7 +73,7 @@ class Disposition : public Operation public : // Operation int GetType( void) const override { return OPER_DISP ; } - bool IsEmpty( void) const override + bool IsEmpty( int nEmptyType = NEED_GEOM) const override { return ( m_nShifts == 0) ; } bool UpdateStatus( int nModif) override { m_nStatus |= nModif ; return true ; } diff --git a/Drilling.h b/Drilling.h index fef90f1..a699be6 100644 --- a/Drilling.h +++ b/Drilling.h @@ -51,8 +51,14 @@ class Drilling : public Machining public : // Operation int GetType( void) const override { return OPER_DRILLING ; } - bool IsEmpty( void) const override - { return ( m_nDrillings == 0) ; } + bool IsEmpty( int nEmptyType = NEED_GEOM) const override + { if ( m_nDrillings == 0) + return true ; + if ( nEmptyType == NEED_ONE_TP_OK) + return ( ! IsAtLeastOnePathOk()) ; + if ( nEmptyType == NEED_ALL_TP_OK) + return ( ! AreAllPathsOk()) ; + return false ; } bool UpdateStatus( int nModif) override { m_nStatus |= nModif ; return true ; } diff --git a/EgtMachKernel.rc b/EgtMachKernel.rc index ae520d7c0022518528a753e560d5c8ed82676d27..f60d4f3730d1f46c82614f1ac8e6e75836633626 100644 GIT binary patch delta 97 zcmewt{V#gMFE&P_&A-`fnHh~HKa|wnoW?bQ1uSxrY4Qod0+^@}R1`^_2jk{d(jGv4 NK<#LXK~l;gTmU8!BZvS1 delta 97 zcmewt{V#gMFE&QQ&A-`fnHdcyKa|wnoW?bQ1uSxrY4Qod0+^@}R1`^_2jk{d(jGv4 NK<#LXK~l;gTmU3rBY*$^ diff --git a/FiveAxisMilling.h b/FiveAxisMilling.h index c7c5c4d..c93c230 100644 --- a/FiveAxisMilling.h +++ b/FiveAxisMilling.h @@ -35,8 +35,14 @@ class FiveAxisMilling : public Machining public : // Operation int GetType( void) const override { return OPER_FIVEAXISMILLING ; } - bool IsEmpty( void) const override - { return ( m_nMills == 0) ; } + bool IsEmpty( int nEmptyType = NEED_GEOM) const override + { if ( m_nMills == 0) + return true ; + if ( nEmptyType == NEED_ONE_TP_OK) + return ( ! IsAtLeastOnePathOk()) ; + if ( nEmptyType == NEED_ALL_TP_OK) + return ( ! AreAllPathsOk()) ; + return false ; } bool UpdateStatus( int nModif) override { m_nStatus |= nModif ; return true ; } diff --git a/GenMachining.h b/GenMachining.h index 23c6c97..6d89977 100644 --- a/GenMachining.h +++ b/GenMachining.h @@ -35,8 +35,14 @@ class GenMachining : public Machining public : // Operation int GetType( void) const override { return OPER_GENMACHINING ; } - bool IsEmpty( void) const override - { return ( m_nMills == 0) ; } + bool IsEmpty( int nEmptyType = NEED_GEOM) const override + { if ( m_nMills == 0) + return true ; + if ( nEmptyType == NEED_ONE_TP_OK) + return ( ! IsAtLeastOnePathOk()) ; + if ( nEmptyType == NEED_ALL_TP_OK) + return ( ! AreAllPathsOk()) ; + return false ; } bool UpdateStatus( int nModif) override { m_nStatus |= nModif ; return true ; } diff --git a/MachMgr.h b/MachMgr.h index 63ed2db..7cf0bee 100644 --- a/MachMgr.h +++ b/MachMgr.h @@ -258,16 +258,16 @@ class MachMgr : public IMachMgr int GetNextOperation( int nId) const override ; int GetLastOperation( void) const override ; int GetPrevOperation( int nId) const override ; - int GetFirstActiveOperation( void) const override ; - int GetNextActiveOperation( int nId) const override ; - int GetLastActiveOperation( void) const override ; - int GetPrevActiveOperation( int nId) const override ; + int GetFirstActiveOperation( bool bNeedMachNotEmpty = false) const override ; + int GetNextActiveOperation( int nId, bool bNeedMachNotEmpty = false) const override ; + int GetLastActiveOperation( bool bNeedMachNotEmpty = false) const override ; + int GetPrevActiveOperation( int nId, bool bNeedMachNotEmpty = false) const override ; int GetOperationType( int nId) const override ; int GetOperationPhase( int nId) const override ; bool SetOperationName( int nId, const std::string& sName) override ; std::string GetOperationName( int nId) const override ; int GetOperationId( const std::string& sName) const override ; - bool IsOperationEmpty( int nId) const override ; + bool IsOperationEmpty( int nId, int nEmptyType = 0) const override ; bool RemoveOperation( int nId) override ; bool RemoveAllPhaseOperations( int nPhase) override ; bool RemoveAllOperations( void) override ; @@ -313,7 +313,7 @@ class MachMgr : public IMachMgr bool GetMachiningParam( int nType, std::string& sVal) const override ; bool GetMachiningGeometry( SELVECTOR& vIds) const override ; bool GetMachiningSkippedGeometry( SELVECTOR& vIds) const override ; - bool IsMachiningEmpty( void) const override ; + bool IsMachiningEmpty( int nEmptyType = 0) const override ; bool GetMachiningStartPoint( Point3d& ptStart) const override ; bool GetMachiningEndPoint( Point3d& ptEnd) const override ; // CL Entities Interrogations diff --git a/MachMgrOperations.cpp b/MachMgrOperations.cpp index bb386b6..ecfa662 100644 --- a/MachMgrOperations.cpp +++ b/MachMgrOperations.cpp @@ -100,48 +100,52 @@ MachMgr::GetPrevOperation( int nId) const //---------------------------------------------------------------------------- int -MachMgr::GetFirstActiveOperation( void) const +MachMgr::GetFirstActiveOperation( bool bNeedMachNotEmpty) const { int nId = GetFirstOperation() ; int nMode ; while ( nId != GDB_ID_NULL && - m_pGeomDB->GetCalcMode( nId, nMode) && nMode == GDB_MD_HIDDEN) + (( m_pGeomDB->GetCalcMode( nId, nMode) && nMode == GDB_MD_HIDDEN) || + ( bNeedMachNotEmpty && IsValidMachiningType( GetOperationType( nId)) && IsOperationEmpty( nId, NEED_ONE_TP_OK)))) nId = GetNextOperation( nId) ; return nId ; } //---------------------------------------------------------------------------- int -MachMgr::GetNextActiveOperation( int nId) const +MachMgr::GetNextActiveOperation( int nId, bool bNeedMachNotEmpty) const { int nNextId = GetNextOperation( nId) ; int nMode ; while ( nNextId != GDB_ID_NULL && - m_pGeomDB->GetCalcMode( nNextId, nMode) && nMode == GDB_MD_HIDDEN) + (( m_pGeomDB->GetCalcMode( nNextId, nMode) && nMode == GDB_MD_HIDDEN) || + ( bNeedMachNotEmpty && IsValidMachiningType( GetOperationType( nNextId)) && IsOperationEmpty( nNextId, NEED_ONE_TP_OK)))) nNextId = GetNextOperation( nNextId) ; return nNextId ; } //---------------------------------------------------------------------------- int -MachMgr::GetLastActiveOperation( void) const +MachMgr::GetLastActiveOperation( bool bNeedMachNotEmpty) const { int nId = GetLastOperation() ; int nMode ; while ( nId != GDB_ID_NULL && - m_pGeomDB->GetCalcMode( nId, nMode) && nMode == GDB_MD_HIDDEN) + (( m_pGeomDB->GetCalcMode( nId, nMode) && nMode == GDB_MD_HIDDEN) || + ( bNeedMachNotEmpty && IsValidMachiningType( GetOperationType( nId)) && IsOperationEmpty( nId, NEED_ONE_TP_OK)))) nId = GetPrevOperation( nId) ; return nId ; } //---------------------------------------------------------------------------- int -MachMgr::GetPrevActiveOperation( int nId) const +MachMgr::GetPrevActiveOperation( int nId, bool bNeedMachNotEmpty) const { int nPrevId = GetPrevOperation( nId) ; int nMode ; while ( nPrevId != GDB_ID_NULL && - m_pGeomDB->GetCalcMode( nPrevId, nMode) && nMode == GDB_MD_HIDDEN) + (( m_pGeomDB->GetCalcMode( nPrevId, nMode) && nMode == GDB_MD_HIDDEN) || + ( bNeedMachNotEmpty && IsValidMachiningType( GetOperationType( nPrevId)) && IsOperationEmpty( nPrevId, NEED_ONE_TP_OK)))) nPrevId = GetPrevOperation( nPrevId) ; return nPrevId ; } @@ -263,7 +267,7 @@ MachMgr::GetOperationId( const string& sName) const //---------------------------------------------------------------------------- bool -MachMgr::IsOperationEmpty( int nId) const +MachMgr::IsOperationEmpty( int nId, int nEmptyType) const { // verifiche if ( m_pGeomDB == nullptr || m_pGeomDB->GetParentId( nId) != GetCurrOperId()) @@ -273,7 +277,7 @@ MachMgr::IsOperationEmpty( int nId) const if ( pOpe == nullptr) return true ; // restituisco se vuota - return pOpe->IsEmpty() ; + return pOpe->IsEmpty( nEmptyType) ; } //---------------------------------------------------------------------------- @@ -1279,7 +1283,7 @@ MachMgr::GetMachiningSkippedGeometry( SELVECTOR& vIds) const //---------------------------------------------------------------------------- bool -MachMgr::IsMachiningEmpty( void) const +MachMgr::IsMachiningEmpty( int nEmptyType) const { // recupero la lavorazione corrente int nCurrMchId = GetCurrMachining() ; @@ -1290,7 +1294,7 @@ MachMgr::IsMachiningEmpty( void) const if ( pMch == nullptr) return true ; // restituisco lo stato - return pMch->IsEmpty() ; + return pMch->IsEmpty( nEmptyType) ; } //---------------------------------------------------------------------------- diff --git a/Milling.h b/Milling.h index 78e153f..4098cf4 100644 --- a/Milling.h +++ b/Milling.h @@ -37,8 +37,14 @@ class Milling : public Machining public : // Operation int GetType( void) const override { return OPER_MILLING ; } - bool IsEmpty( void) const override - { return ( m_nMills == 0) ; } + bool IsEmpty( int nEmptyType = NEED_GEOM) const override + { if ( m_nMills == 0) + return true ; + if ( nEmptyType == NEED_ONE_TP_OK) + return ( ! IsAtLeastOnePathOk()) ; + if ( nEmptyType == NEED_ALL_TP_OK) + return ( ! AreAllPathsOk()) ; + return false ; } bool UpdateStatus( int nModif) override { m_nStatus |= nModif ; return true ; } diff --git a/Mortising.h b/Mortising.h index f4f345a..8ce3420 100644 --- a/Mortising.h +++ b/Mortising.h @@ -36,8 +36,14 @@ class Mortising : public Machining public : // Operation int GetType( void) const override { return OPER_MORTISING ; } - bool IsEmpty( void) const override - { return ( m_nMortises == 0) ; } + bool IsEmpty( int nEmptyType = NEED_GEOM) const override + { if ( m_nMortises == 0) + return true ; + if ( nEmptyType == NEED_ONE_TP_OK) + return ( ! IsAtLeastOnePathOk()) ; + if ( nEmptyType == NEED_ALL_TP_OK) + return ( ! AreAllPathsOk()) ; + return false ; } bool UpdateStatus( int nModif) override { m_nStatus |= nModif ; return true ; } diff --git a/Operation.cpp b/Operation.cpp index 0fa8852..7ed7da4 100644 --- a/Operation.cpp +++ b/Operation.cpp @@ -140,6 +140,87 @@ Operation::Operation( void) } //---------------------------------------------------------------------------- +bool +Operation::IsAtLeastOnePathOk( void) const +{ + int nCnt ; int nEmpty ; + if ( ! GetToolpathsStatus( nCnt, nEmpty)) + return false ; + return ( nCnt > 0 && nEmpty < nCnt) ; +} + +//---------------------------------------------------------------------------- +bool +Operation::AreAllPathsOk( void) const +{ + int nCnt ; int nEmpty ; + if ( ! GetToolpathsStatus( nCnt, nEmpty)) + return false ; + return ( nCnt > 0 && nEmpty == 0) ; +} + +//---------------------------------------------------------------------------- +bool +Operation::GetToolpathsStatus( int& nCnt, int& nEmpty) const +{ + nCnt = 0 ; + nEmpty = 0 ; + if ( m_pGeomDB == nullptr) + return false ; + int nClPath = m_pGeomDB->GetFirstGroupInGroup( m_pGeomDB->GetFirstNameInGroup( m_nOwnerId, MCH_CL)) ; + while ( nClPath != GDB_ID_NULL) { + ++ nCnt ; + if ( m_pGeomDB->GetFirstInGroup( nClPath) == GDB_ID_NULL) + ++ nEmpty ; + nClPath = m_pGeomDB->GetNextGroup( nClPath) ; + } + return true ; +} + +//---------------------------------------------------------------------------- +int +Operation::GetFirstFullToolpath( void) const +{ + if ( m_pGeomDB == nullptr) + return GDB_ID_NULL ; + int nClPath = m_pGeomDB->GetFirstGroupInGroup( m_pGeomDB->GetFirstNameInGroup( m_nOwnerId, MCH_CL)) ; + while ( nClPath != GDB_ID_NULL && m_pGeomDB->GetFirstInGroup( nClPath) == GDB_ID_NULL) + nClPath = m_pGeomDB->GetNextGroup( nClPath) ; + return nClPath ; +} + +//---------------------------------------------------------------------------- +int +Operation::GetNextFullToolpath( int nClPathId) const +{ + do { + nClPathId = m_pGeomDB->GetNextGroup( nClPathId) ; + } while ( nClPathId != GDB_ID_NULL && m_pGeomDB->GetFirstInGroup( nClPathId) == GDB_ID_NULL) ; + return nClPathId ; +} + +//---------------------------------------------------------------------------- +int +Operation::GetLastFullToolpath( void) const +{ + if ( m_pGeomDB == nullptr) + return GDB_ID_NULL ; + int nClPath = m_pGeomDB->GetLastGroupInGroup( m_pGeomDB->GetFirstNameInGroup( m_nOwnerId, MCH_CL)) ; + while ( nClPath != GDB_ID_NULL && m_pGeomDB->GetFirstInGroup( nClPath) == GDB_ID_NULL) + nClPath = m_pGeomDB->GetPrevGroup( nClPath) ; + return nClPath ; +} + +//---------------------------------------------------------------------------- +int +Operation::GetPrevFullToolpath( int nClPathId) const +{ + do { + nClPathId = m_pGeomDB->GetPrevGroup( nClPathId) ; + } while ( nClPathId != GDB_ID_NULL && m_pGeomDB->GetFirstInGroup( nClPathId) == GDB_ID_NULL) ; + return nClPathId ; +} + //---------------------------------------------------------------------------- bool Operation::UpdateFollowingOperationsStatus(int nModif) @@ -1601,14 +1682,10 @@ Operation::GetClPathFinalToolDir( int nClPathId, bool bSkipRise, Vector3d& vtToo const CamData* Operation::GetInitialCamData( bool bSkipClimb) const { - if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) + // recupero il primo percorso CL non vuoto + int nClPathId = GetFirstFullToolpath() ; + if ( nClPathId == GDB_ID_NULL) return nullptr ; - // recupero gruppo per geometria di lavorazione (Cutter Location) - int nClId = m_pGeomDB->GetFirstNameInGroup( GetOwner(), MCH_CL) ; - if ( nClId == GDB_ID_NULL) - return nullptr ; - // recupero il primo percorso CL - int nClPathId = m_pGeomDB->GetFirstGroupInGroup( nClId) ; // recupero i dati Cam della prima entità del percorso return GetClPathInitialCamData( nClPathId, bSkipClimb) ; } @@ -1638,14 +1715,10 @@ Operation::GetClPathInitialCamData( int nClPathId, bool bSkipClimb) const const CamData* Operation::GetFinalCamData( bool bSkipRise) const { - if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) + // recupero l'ultimo percorso CL non vuoto + int nClPathId = GetLastFullToolpath() ; + if ( nClPathId == GDB_ID_NULL) return nullptr ; - // recupero gruppo per geometria di lavorazione (Cutter Location) - int nClId = m_pGeomDB->GetFirstNameInGroup( GetOwner(), MCH_CL) ; - if ( nClId == GDB_ID_NULL) - return nullptr ; - // recupero l'ultimo percorso CL - int nClPathId = m_pGeomDB->GetLastGroupInGroup( nClId) ; // recupero i dati Cam dell'ultima entità del percorso return GetClPathFinalCamData( nClPathId, bSkipRise) ; } @@ -2645,16 +2718,15 @@ Operation::AdjustStartEndMovements( bool bVerifyPreviousLink) if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr || m_pMchMgr->GetCurrMachine() == nullptr) return false ; - // recupero gruppo della geometria di lavorazione (Cutter Location) - int nClId = m_pGeomDB->GetFirstNameInGroup( m_nOwnerId, MCH_CL) ; - if ( nClId == GDB_ID_NULL) - return false ; + // se lavorazione completamente vuota, non devo fare alcunché + if ( ! IsAtLeastOnePathOk()) + return true ; // recupero ultima operazione precedente non vuota o che richiede home precedente int nPrevOpId = m_pMchMgr->GetPrevActiveOperation( m_nOwnerId) ; Operation* pPrevOp = GetOperation( m_pGeomDB->GetUserObj( nPrevOpId)) ; while ( pPrevOp != nullptr) { - if ( ! pPrevOp->IsEmpty() || pPrevOp->NeedPrevHome()) + if ( pPrevOp->IsAtLeastOnePathOk() || pPrevOp->NeedPrevHome()) break ; else { nPrevOpId = m_pMchMgr->GetPrevActiveOperation( nPrevOpId) ; @@ -2663,7 +2735,7 @@ Operation::AdjustStartEndMovements( bool bVerifyPreviousLink) } // recupero l'utensile precedente e i dati della sua testa string sPrevTool ; - if ( pPrevOp != nullptr && ! pPrevOp->IsEmpty()) + if ( pPrevOp != nullptr && pPrevOp->IsAtLeastOnePathOk()) sPrevTool = pPrevOp->GetToolName() ; // flag nuova gestione collegamenti tra lavorazioni @@ -2964,7 +3036,7 @@ Operation::AdjustStartEndMovements( bool bVerifyPreviousLink) // aggiusto l'inizio di ogni percorso di lavoro bool bOk = true ; int nPrevClPathId = GDB_ID_NULL ; - int nClPathId = m_pGeomDB->GetFirstGroupInGroup( nClId) ; + int nClPathId = GetFirstFullToolpath() ; while ( bOk && nClPathId != GDB_ID_NULL) { // se richiesta verifica collegamento con lavorazione precedente, sistemo inizio if ( bVerifyPreviousLink && ( ! bClimbDone || nPrevClPathId != GDB_ID_NULL)) { @@ -2978,7 +3050,7 @@ Operation::AdjustStartEndMovements( bool bVerifyPreviousLink) bOk = false ; // passo al successivo nPrevClPathId = nClPathId ; - nClPathId = m_pGeomDB->GetNextGroup( nClPathId) ; + nClPathId = GetNextFullToolpath( nClPathId) ; pPrevOp = nullptr ; } @@ -3000,7 +3072,8 @@ Operation::AdjustStartEndMovements( bool bVerifyPreviousLink) // se ultima operazione o la successiva lo richiede, vado in home int nNextOpId = m_pMchMgr->GetNextActiveOperation( m_nOwnerId) ; Operation* pNextOp = GetOperation( m_pGeomDB->GetUserObj( nNextOpId)) ; - if ( pNextOp == nullptr || pNextOp->NeedPrevHome()) + if ( pNextOp == nullptr || pNextOp->NeedPrevHome() || + ( IsValidMachiningType( pNextOp->GetType()) && ! pNextOp->IsAtLeastOnePathOk())) bOk = bOk && AddHome() ; return bOk ; @@ -3503,18 +3576,15 @@ Operation::AddSpecialClimb( const DBLVECTOR& vAxVal, bool bOk, int nClPathId, { if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) return false ; - // recupero gruppo per geometria di lavorazione (Cutter Location) - int nClId = m_pGeomDB->GetFirstNameInGroup( GetOwner(), MCH_CL) ; - if ( nClId == GDB_ID_NULL) - return false ; - // se percorso CL specificato, verifico appartenga al gruppo sopra ricavato + // se percorso CL specificato, verifico appartenga al gruppo della geometria di lavorazione (Cutter Location) if ( nClPathId != GDB_ID_NULL) { - if ( m_pGeomDB->GetParentId( nClPathId) != nClId) + int nClId = m_pGeomDB->GetFirstNameInGroup( GetOwner(), MCH_CL) ; + if ( nClId == GDB_ID_NULL || m_pGeomDB->GetParentId( nClPathId) != nClId) return false ; } - // altrimenti, recupero il primo percorso CL della operazione + // altrimenti, recupero il primo percorso CL non vuoto della operazione else { - nClPathId = m_pGeomDB->GetFirstGroupInGroup( nClId) ; + nClPathId = GetFirstFullToolpath() ; if ( nClPathId == GDB_ID_NULL) return false ; } @@ -3574,18 +3644,15 @@ Operation::RemoveClimb( int nClPathId) { if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) return false ; - // recupero gruppo per geometria di lavorazione (Cutter Location) - int nClId = m_pGeomDB->GetFirstNameInGroup( GetOwner(), MCH_CL) ; - if ( nClId == GDB_ID_NULL) - return false ; - // se percorso CL specificato, verifico appartenga al gruppo sopra ricavato + // se percorso CL specificato, verifico appartenga al gruppo della geometria di lavorazione (Cutter Location) if ( nClPathId != GDB_ID_NULL) { - if ( m_pGeomDB->GetParentId( nClPathId) != nClId) + int nClId = m_pGeomDB->GetFirstNameInGroup( GetOwner(), MCH_CL) ; + if ( nClId == GDB_ID_NULL || m_pGeomDB->GetParentId( nClPathId) != nClId) return false ; } - // altrimenti, recupero il primo percorso CL della operazione + // altrimenti, recupero il primo percorso CL non vuoto della operazione else { - nClPathId = m_pGeomDB->GetFirstGroupInGroup( nClId) ; + nClPathId = GetFirstFullToolpath() ; if ( nClPathId == GDB_ID_NULL) return false ; } @@ -3605,18 +3672,15 @@ Operation::AddRise( DBLVECTOR& vAxVal, double dDelta, int nClPathId, int nToMinM { if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) return false ; - // recupero gruppo per geometria di lavorazione (Cutter Location) - int nClId = m_pGeomDB->GetFirstNameInGroup( GetOwner(), MCH_CL) ; - if ( nClId == GDB_ID_NULL) - return false ; - // se percorso CL specificato, verifico appartenga al gruppo sopra ricavato + // se percorso CL specificato, verifico appartenga al gruppo della geometria di lavorazione (Cutter Location) if ( nClPathId != GDB_ID_NULL) { - if ( m_pGeomDB->GetParentId( nClPathId) != nClId) + int nClId = m_pGeomDB->GetFirstNameInGroup( GetOwner(), MCH_CL) ; + if ( nClId == GDB_ID_NULL || m_pGeomDB->GetParentId( nClPathId) != nClId) return false ; } - // altrimenti, recupero l'ultimo percorso CL della operazione + // altrimenti, recupero l'ultimo percorso CL non vuoto della operazione else { - nClPathId = m_pGeomDB->GetLastGroupInGroup( nClId) ; + nClPathId = GetLastFullToolpath() ; if ( nClPathId == GDB_ID_NULL) return false ; } @@ -3770,18 +3834,15 @@ Operation::AddSpecialRise( const DBLVECTOR& vAxVal, bool bOk, int nClPathId, { if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) return false ; - // recupero gruppo per geometria di lavorazione (Cutter Location) - int nClId = m_pGeomDB->GetFirstNameInGroup( GetOwner(), MCH_CL) ; - if ( nClId == GDB_ID_NULL) - return false ; - // se percorso CL specificato, verifico appartenga al gruppo sopra ricavato + // se percorso CL specificato, verifico appartenga al gruppo della geometria di lavorazione (Cutter Location) if ( nClPathId != GDB_ID_NULL) { - if ( m_pGeomDB->GetParentId( nClPathId) != nClId) + int nClId = m_pGeomDB->GetFirstNameInGroup( GetOwner(), MCH_CL) ; + if ( nClId == GDB_ID_NULL || m_pGeomDB->GetParentId( nClPathId) != nClId) return false ; } - // altrimenti, recupero l'ultimo percorso CL della operazione + // altrimenti, recupero l'ultimo percorso CL non vuoto della operazione else { - nClPathId = m_pGeomDB->GetLastGroupInGroup( nClId) ; + nClPathId = GetLastFullToolpath() ; if ( nClPathId == GDB_ID_NULL) return false ; } @@ -3842,18 +3903,15 @@ Operation::RemoveRise( int nClPathId) { if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) return false ; - // recupero gruppo per geometria di lavorazione (Cutter Location) - int nClId = m_pGeomDB->GetFirstNameInGroup( GetOwner(), MCH_CL) ; - if ( nClId == GDB_ID_NULL) - return false ; - // se percorso CL specificato, verifico appartenga al gruppo sopra ricavato + // se percorso CL specificato, verifico appartenga al gruppo della geometria di lavorazione (Cutter Location) if ( nClPathId != GDB_ID_NULL) { - if ( m_pGeomDB->GetParentId( nClPathId) != nClId) + int nClId = m_pGeomDB->GetFirstNameInGroup( GetOwner(), MCH_CL) ; + if ( nClId == GDB_ID_NULL || m_pGeomDB->GetParentId( nClPathId) != nClId) return false ; } - // altrimenti, recupero l'ultimo percorso CL della operazione + // altrimenti, recupero l'ultimo percorso CL non vuoto della operazione else { - nClPathId = m_pGeomDB->GetLastGroupInGroup( nClId) ; + nClPathId = GetLastFullToolpath() ; if ( nClPathId == GDB_ID_NULL) return false ; } @@ -3879,12 +3937,10 @@ Operation::AddHome( void) { if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) return false ; - // recupero gruppo per geometria di lavorazione (Cutter Location) - int nClId = m_pGeomDB->GetFirstNameInGroup( GetOwner(), MCH_CL) ; - if ( nClId == GDB_ID_NULL) + // recupero l'ultimo percorso CL non vuoto + int nLastPxClId = GetLastFullToolpath() ; + if ( nLastPxClId == GDB_ID_NULL) return false ; - // recupero l'ultimo percorso - int nLastPxClId = m_pGeomDB->GetLastGroupInGroup( nClId) ; // recupero l'ultima entità del percorso di nome RISE int nEntId = m_pGeomDB->GetLastNameInGroup( nLastPxClId, MCH_CL_RISE) ; if ( nEntId == GDB_ID_NULL) @@ -3930,12 +3986,10 @@ Operation::RemoveHome( void) { if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) return false ; - // recupero gruppo per geometria di lavorazione (Cutter Location) - int nClId = m_pGeomDB->GetFirstNameInGroup( GetOwner(), MCH_CL) ; - if ( nClId == GDB_ID_NULL) + // recupero l'ultimo percorso CL non vuoto + int nClPathId = GetLastFullToolpath() ; + if ( nClPathId == GDB_ID_NULL) return false ; - // recupero l'ultimo percorso CL - int nClPathId = m_pGeomDB->GetLastGroupInGroup( nClId) ; // elimino tutte le entità HOME alla fine del percorso int nId = m_pGeomDB->GetFirstNameInGroup( nClPathId, MCH_CL_HOME) ; while ( nId != GDB_ID_NULL) { diff --git a/Operation.h b/Operation.h index 0400781..82d7092 100644 --- a/Operation.h +++ b/Operation.h @@ -1,14 +1,14 @@ //---------------------------------------------------------------------------- -// EgalTech 2016-2019 +// EgalTech 2016-2025 //---------------------------------------------------------------------------- -// File : Operation.h Data : 17.06.19 Versione : 2.1f2 +// File : Operation.h Data : 09.05.25 Versione : 2.7e2 // Contenuto : Dichiarazione della classe Operation da cui derivano // Disposition e Machining. // // // // Modifiche : 29.04.16 DS Creazione modulo. -// +// 09.05.25 DS Generalizzazionee funzione IsEmpty con tipo (EMPTY_*). // //---------------------------------------------------------------------------- @@ -48,7 +48,7 @@ class Operation : public IUserObj public : virtual int GetType( void) const = 0 ; - virtual bool IsEmpty( void) const = 0 ; + virtual bool IsEmpty( int nEmptyType = 0) const = 0 ; virtual bool UpdateStatus( int nModif) = 0 ; protected : @@ -115,18 +115,13 @@ class Operation : public IUserObj Operation( void) ; protected : - struct Position { - int nSide ; - DBLVECTOR vAxis ; - int nFlag ; - int nFlag2 ; - int nMask ; - std::string sInfo ; - Position() : nSide( 0), nFlag( 0), nFlag2( 0), nMask( -1) {} - } ; - typedef std::vector POSVECTOR ; - - protected : + bool IsAtLeastOnePathOk( void) const ; + bool AreAllPathsOk( void) const ; + bool GetToolpathsStatus( int& nCnt, int& nEmpty) const ; + int GetFirstFullToolpath( void) const ; + int GetNextFullToolpath( int nClPathId) const ; + int GetLastFullToolpath( void) const ; + int GetPrevFullToolpath( int nClPathId) const ; bool UpdateFollowingOperationsStatus( int nModif) ; bool GetElevation( int nPhase, const Point3d& ptP, const Vector3d& vtDir, double& dElev) const ; @@ -189,6 +184,18 @@ class Operation : public IUserObj bool GetAggrBottomData( const std::string& sHead, AggrBottom& agbData) const ; bool IsAggrBottom( const std::string& sHead) const ; + private : + struct Position { + int nSide ; + DBLVECTOR vAxis ; + int nFlag ; + int nFlag2 ; + int nMask ; + std::string sInfo ; + Position() : nSide( 0), nFlag( 0), nFlag2( 0), nMask( -1) {} + } ; + typedef std::vector POSVECTOR ; + private : bool GetInitialAxesValues( bool bSkipClimb, DBLVECTOR& vAxVal) const ; bool GetClPathInitialAxesValues( int nClPathId, bool bSkipClimb, DBLVECTOR& vAxVal) const ; @@ -323,6 +330,8 @@ inline Operation* GetOperation( IUserObj* pUserObj) { return dynamic_cast< Operation*>( pUserObj) ; } //---------------------------------------------------------------------------- +// Tipo di controllo per lavorazione vuota +enum { NEED_GEOM = 0, NEED_ONE_TP_OK = 1, NEED_ALL_TP_OK = 2} ; // tipo posizione utensile enum { TOOL_PARAL = 1, TOOL_ORTHO = 2, TOOL_ORTUP = 3, TOOL_PAR_SLANT= 4} ; // tipo di utilizzo contorno faccia diff --git a/Pocketing.cpp b/Pocketing.cpp index 9f1a55b..15fa5f8 100644 --- a/Pocketing.cpp +++ b/Pocketing.cpp @@ -89,7 +89,6 @@ const string UN_MAXOPTSIZE = "MaxOptSize" ; // 2452 = "Warning in Pocketing : No machinable pocket" // 2453 = "Warning in Pocketing : Tool name changed (xx)" // 2454 = "Warning in Pocketing : Tool data changed (xx)" -// 2455 = "Warning in Pocketing : skipped Path too short" // 2456 = "Warning in Pocketing : machining step too small (xx)" // 2457 = "Warning in Pocketing : machining step (xxx) bigger than MaxMaterial (yyy)" // 2458 = "Warning in Pocketing : machining depth (xxx) bigger than MaxMaterial (yyy)" diff --git a/Pocketing.h b/Pocketing.h index eaa18a5..c52f304 100644 --- a/Pocketing.h +++ b/Pocketing.h @@ -35,8 +35,14 @@ class Pocketing : public Machining public : // Operation int GetType( void) const override { return OPER_POCKETING ; } - bool IsEmpty( void) const override - { return ( m_nPockets == 0) ; } + bool IsEmpty( int nEmptyType = NEED_GEOM) const override + { if ( m_nPockets == 0) + return true ; + if ( nEmptyType == NEED_ONE_TP_OK) + return ( ! IsAtLeastOnePathOk()) ; + if ( nEmptyType == NEED_ALL_TP_OK) + return ( ! AreAllPathsOk()) ; + return false ; } bool UpdateStatus( int nModif) override { m_nStatus |= nModif ; return true ; } diff --git a/PocketingNT.cpp b/PocketingNT.cpp index 015521f..c014c9a 100644 --- a/PocketingNT.cpp +++ b/PocketingNT.cpp @@ -96,10 +96,10 @@ const string UN_OPENMINSAFE = "OpenMinSafe" ; // 2434 = "Error in PocketingNT : Managing Open Edges inside Raw failed" // 2435 = "Error in PocketingNT : Managing Open Edges on Raw failed" // 2451 = "Warning in PocketingNT : Skipped entity (xx)" -// 2452 = "Warning in PocketingNT : No machinable pocket" +// 2452 = "Warning in PocketingNT : No pocket" // 2453 = "Warning in PocketingNT : Tool name changed (xx)" // 2454 = "Warning in PocketingNT : Tool data changed (xx)" -// 2455 = "Warning in PocketingNT : skipped Path too short" +// 2455 = "Warning in PocketingNT : No machinable pocket" // 2456 = "Warning in PocketingNT : machining step too small (xx)" // 2457 = "Warning in PocketingNT : machining step (xxx) bigger than MaxMaterial (yyy)" // 2458 = "Warning in PocketingNT : machining depth (xxx) bigger than MaxMaterial (yyy)" @@ -745,8 +745,10 @@ PocketingNT::MyApply( bool bRecalc, bool bPostApply) } // 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 ; + } // lavoro ogni singola catena bool bOk = true ; @@ -790,9 +792,14 @@ PocketingNT::Update( bool bPostApply) if ( m_pGeomDB == nullptr || ! m_pGeomDB->ExistsObj( m_nOwnerId)) return false ; + // se geometria di lavorazione vuota, esco + if ( m_nPockets == 0 ) { + m_pMchMgr->SetWarning( 2452, "Warning in PocketingNT : No pocket") ; + return true ; + } // se lavorazione vuota, esco - if ( m_nPockets == 0) { - m_pMchMgr->SetWarning( 2452, "Warning in PocketingNT : No machinable pocket") ; + if ( ! IsAtLeastOnePathOk()) { + m_pMchMgr->SetWarning( 2455, "Warning in PocketingNT : No machinable pocket") ; return true ; } @@ -1670,48 +1677,6 @@ PocketingNT::GetRaw( void) return ( ( pStmRaw->IsValid() && pStmRaw->GetTriangleCount() > 0) ? Release( pStmRaw) : nullptr) ; } -//---------------------------------------------------------------------------- -ISurfTriMesh* -PocketingNT::GetRawPart( void) -{ - // controllo MachManager e database geometrico - if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) - return nullptr ; - - // creo Stm del grezzo - PtrOwner pStmRaw( CreateSurfTriMesh()) ; - if ( IsNull( pStmRaw)) - return nullptr ; - pStmRaw->AdjustTopology() ; - - // Id prima RawPart - int nRawId = m_pMchMgr->GetFirstRawPart() ; - - while ( nRawId != GDB_ID_NULL) { - // verifico che il grezzo compaia nella fase - if ( m_pMchMgr->VerifyRawPartPhase( nRawId, m_nPhase)) { - // recupero l'oggetto dal database con tale Id - int nRawSolidId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ; - const IGeoObj* pGObj = m_pGeomDB->GetGeoObj( nRawSolidId) ; - if ( pGObj == nullptr) - return nullptr ; - // recupero il frame in cui si trova - Frame3d frRaw ; - m_pGeomDB->GetGlobFrame( nRawSolidId, frRaw) ; - // controllo che sia una Trimesh - if ( pGObj->GetType() == SRF_TRIMESH) { - SurfLocal StmRawPart( GetSurfTriMesh( pGObj), frRaw, GLOB_FRM) ; - // lo aggiungo alla Trimesh complessiva - pStmRaw->Add( *GetSurfTriMesh( StmRawPart)) ; - } - } - // passo al grezzo successivo - nRawId = m_pMchMgr->GetNextRawPart( nRawId) ; - } - - return ( ( pStmRaw->IsValid() && pStmRaw->GetTriangleCount() > 0) ? Release( pStmRaw) : nullptr) ; -} - //---------------------------------------------------------------------------- ISurfTriMesh* PocketingNT::GetExtrusionStm( const ISurfFlatRegion* pSfr, const Vector3d& vtTrasl, const Vector3d& vtExtr) diff --git a/PocketingNT.h b/PocketingNT.h index 182eb2c..cf393e8 100644 --- a/PocketingNT.h +++ b/PocketingNT.h @@ -62,8 +62,14 @@ class PocketingNT : public Machining public : // Operation int GetType( void) const override { return OPER_POCKETING ; } - bool IsEmpty( void) const override - { return ( m_nPockets == 0) ; } + bool IsEmpty( int nEmptyType = NEED_GEOM) const override + { if ( m_nPockets == 0) + return true ; + if ( nEmptyType == NEED_ONE_TP_OK) + return ( ! IsAtLeastOnePathOk()) ; + if ( nEmptyType == NEED_ALL_TP_OK) + return ( ! AreAllPathsOk()) ; + return false ; } bool UpdateStatus( int nModif) override { m_nStatus |= nModif ; return true ; } @@ -101,7 +107,6 @@ class PocketingNT : public Machining bool ResetCurveAllTempProp( ICurve* pCurve) ; bool Chain( int nGrpDestId) ; ISurfTriMesh* GetRaw( void) ; - ISurfTriMesh* GetRawPart( void) ; ISurfTriMesh* GetExtrusionStm( const ISurfFlatRegion* pSfr, const Vector3d& vtTrasl, const Vector3d& vtExtr) ; ISurfFlatRegion* GetSfrByStmIntersection( const IntersParPlanesSurfTm& IPPStm, double dDist, double dSmallOffs = 0) ; bool ManageOpenEdges( ISurfFlatRegion* pSfr, const ISurfTriMesh* pStmPart) ; diff --git a/Processor.cpp b/Processor.cpp index aa26bbc..a716c7e 100644 --- a/Processor.cpp +++ b/Processor.cpp @@ -318,7 +318,7 @@ Processor::ProcessMachining( int nOpId, int nOpInd) return false ; // Verifico non sia vuota - if ( m_pMchMgr->IsMachiningEmpty()) + if ( m_pMchMgr->IsMachiningEmpty( NEED_ONE_TP_OK)) return true ; // Recupero l'utensile della lavorazione corrente diff --git a/SawFinishing.h b/SawFinishing.h index 9e00e2b..e038a3b 100644 --- a/SawFinishing.h +++ b/SawFinishing.h @@ -38,8 +38,14 @@ class SawFinishing : public Machining public : // Operation int GetType( void) const override { return OPER_SAWFINISHING ; } - bool IsEmpty( void) const override - { return ( m_nCuts == 0) ; } + bool IsEmpty( int nEmptyType = NEED_GEOM) const override + { if ( m_nCuts == 0) + return true ; + if ( nEmptyType == NEED_ONE_TP_OK) + return ( ! IsAtLeastOnePathOk()) ; + if ( nEmptyType == NEED_ALL_TP_OK) + return ( ! AreAllPathsOk()) ; + return false ; } bool UpdateStatus( int nModif) override { m_nStatus |= nModif ; return true ; } diff --git a/SawRoughing.h b/SawRoughing.h index f4e6eba..4d32b4e 100644 --- a/SawRoughing.h +++ b/SawRoughing.h @@ -38,8 +38,14 @@ class SawRoughing : public Machining public : // Operation int GetType( void) const override { return OPER_SAWROUGHING ; } - bool IsEmpty( void) const override - { return ( m_nCuts == 0) ; } + bool IsEmpty( int nEmptyType = NEED_GEOM) const override + { if ( m_nCuts == 0) + return true ; + if ( nEmptyType == NEED_ONE_TP_OK) + return ( ! IsAtLeastOnePathOk()) ; + if ( nEmptyType == NEED_ALL_TP_OK) + return ( ! AreAllPathsOk()) ; + return false ; } bool UpdateStatus( int nModif) override { m_nStatus |= nModif ; return true ; } diff --git a/Sawing.h b/Sawing.h index a44fc58..ff9df3c 100644 --- a/Sawing.h +++ b/Sawing.h @@ -39,8 +39,14 @@ class Sawing : public Machining public : // Operation int GetType( void) const override { return OPER_SAWING ; } - bool IsEmpty( void) const override - { return ( m_nCuts == 0) ; } + bool IsEmpty( int nEmptyType = NEED_GEOM) const override + { if ( m_nCuts == 0) + return true ; + if ( nEmptyType == NEED_ONE_TP_OK) + return ( ! IsAtLeastOnePathOk()) ; + if ( nEmptyType == NEED_ALL_TP_OK) + return ( ! AreAllPathsOk()) ; + return false ; } bool UpdateStatus( int nModif) override { m_nStatus |= nModif ; return true ; } diff --git a/SimulatorMP.cpp b/SimulatorMP.cpp index 763196d..0db5b69 100644 --- a/SimulatorMP.cpp +++ b/SimulatorMP.cpp @@ -792,12 +792,10 @@ SimulatorMP::FindAndManageOperationStart( bool bStart, bool bFirst, int& nChange // recupero la nuova operazione if ( nChangeTool == 0) { if ( bStart) { - //m_nOpId = m_pMchMgr->GetFirstActiveOperation() ; m_nOpInd = 0 ; m_nOpId = ( m_nOpInd < int( m_vOperId.size()) ? m_vOperId[m_nOpInd] : GDB_ID_NULL) ; } else { - // m_nOpId = m_pMchMgr->GetNextActiveOperation( m_nOpId) ; ++ m_nOpInd ; m_nOpId = ( m_nOpInd < int( m_vOperId.size()) ? m_vOperId[m_nOpInd] : GDB_ID_NULL) ; } diff --git a/SimulatorSP.cpp b/SimulatorSP.cpp index 21b5bb8..4b1b4e0 100644 --- a/SimulatorSP.cpp +++ b/SimulatorSP.cpp @@ -725,11 +725,11 @@ SimulatorSP::FindAndManageOperationStart( bool bStart, bool bFirst, int& nStatus bFirst = false ; // recupero la nuova operazione if ( bStart) { - m_nOpId = m_pMchMgr->GetFirstActiveOperation() ; + m_nOpId = m_pMchMgr->GetFirstActiveOperation( true) ; m_nOpInd = 0 ; } else - m_nOpId = m_pMchMgr->GetNextActiveOperation( m_nOpId) ; + m_nOpId = m_pMchMgr->GetNextActiveOperation( m_nOpId, true) ; // ciclo sulle successive operazioni while ( m_nOpId != GDB_ID_NULL) { // se lavorazione valida diff --git a/SurfFinishing.h b/SurfFinishing.h index 9799736..8a911e3 100644 --- a/SurfFinishing.h +++ b/SurfFinishing.h @@ -62,8 +62,14 @@ class SurfFinishing : public Machining public : // Operation int GetType( void) const override { return OPER_SAWFINISHING ; } - bool IsEmpty( void) const override - { return ( m_nPaths == 0) ; } + bool IsEmpty( int nEmptyType = NEED_GEOM) const override + { if ( m_nPaths == 0) + return true ; + if ( nEmptyType == NEED_ONE_TP_OK) + return ( ! IsAtLeastOnePathOk()) ; + if ( nEmptyType == NEED_ALL_TP_OK) + return ( ! AreAllPathsOk()) ; + return false ; } bool UpdateStatus( int nModif) override { m_nStatus |= nModif ; return true ; } diff --git a/SurfRoughing.h b/SurfRoughing.h index 6d418a5..d6eb165 100644 --- a/SurfRoughing.h +++ b/SurfRoughing.h @@ -71,8 +71,14 @@ class SurfRoughing : public Machining public : // Operation int GetType( void) const override { return OPER_SURFROUGHING ; } - bool IsEmpty( void) const override - { return ( m_nPaths == 0) ; } + bool IsEmpty( int nEmptyType = NEED_GEOM) const override + { if ( m_nPaths == 0) + return true ; + if ( nEmptyType == NEED_ONE_TP_OK) + return ( ! IsAtLeastOnePathOk()) ; + if ( nEmptyType == NEED_ALL_TP_OK) + return ( ! AreAllPathsOk()) ; + return false ; } bool UpdateStatus( int nModif) override { m_nStatus |= nModif ; return true ; } diff --git a/WaterJetting.h b/WaterJetting.h index 667d3ca..8399ba9 100644 --- a/WaterJetting.h +++ b/WaterJetting.h @@ -36,8 +36,14 @@ class WaterJetting : public Machining public : // Operation int GetType( void) const override { return OPER_WATERJETTING ; } - bool IsEmpty( void) const override - { return ( m_nMills == 0) ; } + bool IsEmpty( int nEmptyType = NEED_GEOM) const override + { if ( m_nMills == 0) + return true ; + if ( nEmptyType == NEED_ONE_TP_OK) + return ( ! IsAtLeastOnePathOk()) ; + if ( nEmptyType == NEED_ALL_TP_OK) + return ( ! AreAllPathsOk()) ; + return false ; } bool UpdateStatus( int nModif) override { m_nStatus |= nModif ; return true ; }