From da24353a116c80e4548c82b6f0c92eceae73f66f Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 1 Feb 2016 07:44:24 +0000 Subject: [PATCH] EgtMachKernel : - migliorati test su tolleranza fori - piccole correzioni per lavorazioni vuote o disabilitate. --- Drilling.cpp | 17 ++++++++++++++--- Drilling.h | 1 + Generator.cpp | 4 ++++ Machining.cpp | 12 ++++++++++-- MachiningsMgr.cpp | 10 +++++----- Simulator.cpp | 22 ++++++++++++++++++---- 6 files changed, 52 insertions(+), 14 deletions(-) diff --git a/Drilling.cpp b/Drilling.cpp index 7028a3a..8159336 100644 --- a/Drilling.cpp +++ b/Drilling.cpp @@ -321,7 +321,7 @@ Drilling::SetGeometry( const SELVECTOR& vIds) for ( int i = 0 ; i < int( vIds.size()) ; ++ i) { // recupero i dati del foro Hole hole ; - if ( ! GetHoleData( vIds[i], hole) || fabs( hole.dDiam - m_TParams.m_dDiam) > dDiamTol) { + if ( ! GetHoleData( vIds[i], hole) || ! VerifyDiameter( hole.dDiam, m_TParams.m_dDiam, dDiamTol)) { string sOut = "Entity " + ToString( vIds[i].nId) + " skipped by Drilling" ; LOG_INFO( GetEMkLogger(), sOut.c_str()) ; continue ; @@ -730,7 +730,7 @@ Drilling::GenerateHolePv( int nInd, const SelData& nCircId, const string& sPName double dDiamTol = m_pMchMgr->GetCurrMachiningsMgr()->GetHoleDiamToler() ; // recupero i dati del foro Hole hole ; - if ( ! GetHoleData( nCircId, hole) || fabs( hole.dDiam - m_TParams.m_dDiam) > dDiamTol) { + if ( ! GetHoleData( nCircId, hole) || ! VerifyDiameter( hole.dDiam, m_TParams.m_dDiam, dDiamTol)) { m_pGeomDB->Erase( nPathId) ; string sOut = "Entity " + ToString( nCircId) + " skipped by Drilling" ; LOG_INFO( GetEMkLogger(), sOut.c_str()) ; @@ -774,7 +774,7 @@ Drilling::GenerateHoleCl( int nInd, const SelData& nCircId, const string& sPName double dDiamTol = m_pMchMgr->GetCurrMachiningsMgr()->GetHoleDiamToler() ; // recupero i dati del foro Hole hole ; - if ( ! GetHoleData( nCircId, hole) || fabs( hole.dDiam - m_TParams.m_dDiam) > dDiamTol) { + if ( ! GetHoleData( nCircId, hole) || ! VerifyDiameter( hole.dDiam, m_TParams.m_dDiam, dDiamTol)) { m_pGeomDB->Erase( nPathId) ; string sOut = "Entity " + ToString( nCircId) + " skipped by Drilling" ; LOG_INFO( GetEMkLogger(), sOut.c_str()) ; @@ -874,6 +874,17 @@ Drilling::GenerateHoleRegionPv( int nFirstId, int nCount, int nPvId) return true ; } +//---------------------------------------------------------------------------- +bool +Drilling::VerifyDiameter( double dHdiam, double dTdiam, double dDiamTol) +{ + // se tolleranza in più o in meno + if ( dDiamTol > 0) + return ( abs( dHdiam - dTdiam) < dDiamTol) ; + // altrimenti tolleranza solo in meno + return ( dTdiam < dHdiam + 10 * EPS_SMALL && dTdiam > dHdiam + dDiamTol - EPS_SMALL) ; +} + //---------------------------------------------------------------------------- bool Drilling::GetParam( int nType, bool& bVal) const diff --git a/Drilling.h b/Drilling.h index 993c7fa..7534321 100644 --- a/Drilling.h +++ b/Drilling.h @@ -64,6 +64,7 @@ class Drilling : public Machining bool GenerateHolePv( int nInd, const SelData& nCircId, const string& sPName, int nPvId) ; bool GenerateHoleCl( int nInd, const SelData& nCircId, const string& sPName, int nClId) ; bool GenerateHoleRegionPv( int nFirstId, int nCount, int nPvId) ; + bool VerifyDiameter( double dHdiam, double dTdiam, double ddiamTol) ; bool DoStandardDrilling( const Hole& hole, SelData Id, int nPathId) ; bool DoPeckDrilling( const Hole& hole, SelData Id, int nPathId) ; diff --git a/Generator.cpp b/Generator.cpp index febf1c8..3e0557a 100644 --- a/Generator.cpp +++ b/Generator.cpp @@ -279,6 +279,10 @@ Generator::ProcessMachining( int nOpId, int nOpInd) if ( ! m_pMchMgr->SetCurrMachining( nOpId)) return false ; + // Verifico non sia vuota + if ( ! m_pMchMgr->IsNotEmpty()) + return true ; + // Recupero l'utensile della lavorazione corrente string sTool ; if ( ! m_pMchMgr->GetMachiningParam( MPA_TOOL, sTool)) diff --git a/Machining.cpp b/Machining.cpp index 2473008..05cfb91 100644 --- a/Machining.cpp +++ b/Machining.cpp @@ -530,9 +530,17 @@ Machining::CalculateAxesValues( void) { if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) return false ; - // recupero la lavorazione precedente - int nPrevOpId = m_pMchMgr->GetPrevOperation( GetOwner()) ; + // recupero la lavorazione precedente non vuota + int nPrevOpId = m_pMchMgr->GetPrevActiveOperation( m_nOwnerId) ; Machining* pPrevMch = dynamic_cast( m_pGeomDB->GetUserObj( nPrevOpId)) ; + while ( pPrevMch != nullptr) { + if ( pPrevMch->IsNotEmpty()) + break ; + else { + nPrevOpId = m_pMchMgr->GetPrevActiveOperation( nPrevOpId) ; + pPrevMch = dynamic_cast( m_pGeomDB->GetUserObj( nPrevOpId)) ; + } + } // recupero l'utensile precedente string sPrevTool ; if ( pPrevMch != nullptr) diff --git a/MachiningsMgr.cpp b/MachiningsMgr.cpp index 166d680..dcdbc61 100644 --- a/MachiningsMgr.cpp +++ b/MachiningsMgr.cpp @@ -828,11 +828,11 @@ MachiningsMgr::SetExtraROnDrillRegion( double dExtraR) bool MachiningsMgr::SetHoleDiamToler( double dToler) { - // deve essere un valore positivo o nullo - if ( dToler < - EPS_SMALL) - return false ; - // minimo EPS_SMALL - dToler = max( dToler, EPS_SMALL) ; + // Tolleranza > 0 -> la punta può essere uguale, più piccola o più grande + // Tolleranza < 0 -> la punta può essere solo uguale o più piccola + // minimo valore assoluto EPS_SMALL + if ( abs( dToler) < EPS_SMALL) + dToler = EPS_SMALL ; // se cambiato, salvo e setto modifica if ( fabs( dToler - m_dHoleDiamToler) > EPS_SMALL) { m_dHoleDiamToler = dToler ; diff --git a/Simulator.cpp b/Simulator.cpp index 25fee2a..bfefbdb 100644 --- a/Simulator.cpp +++ b/Simulator.cpp @@ -68,10 +68,16 @@ Simulator::Start( void) int nOpId = m_pMchMgr->GetFirstActiveOperation() ; if ( m_pMchMgr->GetOperationType( nOpId) != OPER_DISP) return false ; - // cerco la prima lavorazione + // cerco la prima lavorazione valida nOpId = m_pMchMgr->GetNextActiveOperation( nOpId) ; - while ( nOpId != GDB_ID_NULL && ! IsValidMachiningType( m_pMchMgr->GetOperationType( nOpId))) - nOpId = m_pMchMgr->GetNextActiveOperation( nOpId) ; + Machining* pMch = dynamic_cast( m_pGeomDB->GetUserObj( nOpId)) ; + while ( nOpId != GDB_ID_NULL) { + if ( IsValidMachiningType( m_pMchMgr->GetOperationType( nOpId)) && + pMch != nullptr && pMch->IsNotEmpty()) + break ; + nOpId = m_pMchMgr->GetNextActiveOperation( m_nOpId) ; + pMch = dynamic_cast( m_pGeomDB->GetUserObj( nOpId)) ; + } if ( nOpId == GDB_ID_NULL) return false ; m_nOpId = nOpId ; @@ -116,9 +122,17 @@ Simulator::Move( int& nStatus) m_nEntId = m_pGeomDB->GetFirstInGroup( m_nCLPathId) ; m_dCoeff = 0 ; } - // Se arrivato alla fine di una lavorazione, recupero la successiva + // Se arrivato alla fine di una lavorazione, recupero la successiva valida while ( m_nCLPathId == GDB_ID_NULL) { m_nOpId = m_pMchMgr->GetNextActiveOperation( m_nOpId) ; + Machining* pMch = dynamic_cast( m_pGeomDB->GetUserObj( m_nOpId)) ; + while ( m_nOpId != GDB_ID_NULL) { + if ( IsValidMachiningType( m_pMchMgr->GetOperationType( m_nOpId)) && + pMch != nullptr && pMch->IsNotEmpty()) + break ; + m_nOpId = m_pMchMgr->GetNextActiveOperation( m_nOpId) ; + pMch = dynamic_cast( m_pGeomDB->GetUserObj( m_nOpId)) ; + } // se non ce ne sono altre, sono alla fine if ( m_nOpId == GDB_ID_NULL) { nStatus = MCH_SIM_END ;