From dbb19c7bd67a741b02299a1b774bc3e650102504 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 15 Feb 2016 10:54:11 +0000 Subject: [PATCH] EgtMachKernel 1.6n5 : - in simulazione aggiunta breve pausa al cambio fase - aggiunta gestione fase per recupero info grezzi in lavorazione (elevazione, rawbotto,...). --- Drilling.cpp | 2 +- EgtMachKernel.rc | Bin 11782 -> 11782 bytes Machining.cpp | 224 +++++++++++++++++++++++++---------------------- Machining.h | 8 +- Sawing.cpp | 26 +++--- Simulator.cpp | 7 +- 6 files changed, 143 insertions(+), 124 deletions(-) diff --git a/Drilling.cpp b/Drilling.cpp index f20ce43..7966471 100644 --- a/Drilling.cpp +++ b/Drilling.cpp @@ -1040,7 +1040,7 @@ Drilling::GetHoleData( SelData Id, Hole& hole) Vector3d vtExtrG = vtExtr ; vtExtrG.ToGlob( frGlob) ; if ( vtExtrG.IsZplus()) - GetDistanceFromRawBottom( Id.nId, EPS_SMALL, dRbDist) ; + GetDistanceFromRawBottom( m_nPhase, Id.nId, EPS_SMALL, dRbDist) ; // valuto l'espressione dell'affondamento ExeLuaSetGlobNumVar( "TH", - dThick) ; ExeLuaSetGlobNumVar( "RB", dRbDist) ; diff --git a/EgtMachKernel.rc b/EgtMachKernel.rc index 277edae260d7a54b1ce994555d65e30a81e16dbb..facd924345ab7287375128a26ecc93d910134191 100644 GIT binary patch delta 97 zcmZpRX^YwLhmFy6^ItYwW=7M=j>5W|vxM9jH?QON0rG*u7nvrX5iEd9O=7{OSQ@Kh Hr8(RHQiUK= delta 97 zcmZpRX^YwLhmFx>^ItYwW=50Aj>5W|vxM9jH?QON0rG*u7nvrX5iEd9O=7{OSQ@Kh Hr8(RHQ1Kv2 diff --git a/Machining.cpp b/Machining.cpp index ff34a89..019782f 100644 --- a/Machining.cpp +++ b/Machining.cpp @@ -74,7 +74,7 @@ Machining::Machining( void) //---------------------------------------------------------------------------- //---------------------------------------------------------------------------- bool -Machining::GetElevation( const Point3d& ptP, const Vector3d& vtDir, double& dElev) +Machining::GetElevation( int nPhase, const Point3d& ptP, const Vector3d& vtDir, double& dElev) { if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) return false ; @@ -84,111 +84,40 @@ Machining::GetElevation( const Point3d& ptP, const Vector3d& vtDir, double& dEle bool bFound = false ; int nRawId = m_pMchMgr->GetFirstRawPart() ; while ( nRawId != GDB_ID_NULL) { - // intersezione del raggio dal punto alla trimesh del grezzo - const double RAY_LEN = 10000 ; - int nStmId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ; - ISurfTriMesh* pStm = GetSurfTriMesh( m_pGeomDB->GetGeoObj( nStmId)) ; - if ( pStm != nullptr) { - bFound = true ; - // recupero il riferimento della trimesh - Frame3d frStm ; - m_pGeomDB->GetGlobFrame( nStmId, frStm) ; - // porto il raggio in questo riferimento - Point3d ptPL = ptP ; - ptPL.ToLoc( frStm) ; - Vector3d vtDirL = vtDir ; - vtDirL.ToLoc( frStm) ; - ILSIVECTOR vInfo ; - if ( IntersLineSurfTm( ptPL, vtDirL, RAY_LEN, *pStm, vInfo)) { - for ( const auto& Info : vInfo) { - // se tratto di intersezione coincidente, considero la posizione pių lontana, ovvero 2 - if ( Info.nILTT == ILTT_SEGM || Info.nILTT == ILTT_SEGM_ON_EDGE) { - // se prosegue un tratto precedente, non devo controllare sia minimo - if ( fabs( dElev - Info.dU) < EPS_SMALL) - dElev = Info.dU2 ; - else - dElev = min( dElev, Info.dU2) ; - } - // altrimenti intersezione puntuale, verifico che esca (coseno >= 0) - else if ( Info.dCosDN > - COS_ORTO_ANG_ZERO) { - dElev = min( dElev, Info.dU) ; - } - } - } - } - // passo al grezzo successivo - nRawId = m_pMchMgr->GetNextRawPart( nRawId) ; - } - // se non trovate intersezioni, elevazione nulla - if ( dElev > INFINITO - 1) - dElev = 0 ; - return bFound ; -} - -//---------------------------------------------------------------------------- -bool -Machining::GetElevation( const Point3d& ptP1, const Point3d& ptP2, const Vector3d& vtDir, double& dElev) -{ - if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) - return false ; - // inizializzo elevazione - dElev = INFINITO ; - // ciclo sui grezzi - bool bFound = false ; - int nRawId = m_pMchMgr->GetFirstRawPart() ; - while ( nRawId != GDB_ID_NULL) { - // intersezione del raggio dal punto alla trimesh del grezzo - const double RAY_LEN = 10000 ; - int nStmId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ; - ISurfTriMesh* pStm = GetSurfTriMesh( m_pGeomDB->GetGeoObj( nStmId)) ; - if ( pStm != nullptr) { - bFound = true ; - // recupero il riferimento della trimesh - Frame3d frStm ; - m_pGeomDB->GetGlobFrame( nStmId, frStm) ; - // porto il segmento e la direzione in questo riferimento - Point3d ptP1L = ptP1 ; - ptP1L.ToLoc( frStm) ; - Point3d ptP2L = ptP2 ; - ptP2L.ToLoc( frStm) ; - Vector3d vtDirL = vtDir ; - vtDirL.ToLoc( frStm) ; - ILSIVECTOR vInfo ; - // inizializzo elevazione della superficie - double dElevS = 0 ; - // faccio test con un insieme di punti ( !!! sostituire con intersezione tra rettangolo e trimesh !!!) - const double STEP = 50 ; - int nStep = max( (int) ceil( ApproxDist( ptP1L, ptP2L) / STEP), 3) ; - for ( int i = 0 ; i <= nStep ; ++ i) { - // calcolo punto di test - double dFraz = i / (double) nStep ; - Point3d ptPL = Media( ptP1L, ptP2L, dFraz) ; - // inizializzo elevazione del punto - double dElevP = INFINITO ; - // calcolo elevazione sul punto + // verifico che il grezzo compaia nella fase + if ( m_pMchMgr->VerifyRawPartPhase( nRawId, nPhase)) { + // intersezione del raggio dal punto alla trimesh del grezzo + const double RAY_LEN = 10000 ; + int nStmId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ; + ISurfTriMesh* pStm = GetSurfTriMesh( m_pGeomDB->GetGeoObj( nStmId)) ; + if ( pStm != nullptr) { + bFound = true ; + // recupero il riferimento della trimesh + Frame3d frStm ; + m_pGeomDB->GetGlobFrame( nStmId, frStm) ; + // porto il raggio in questo riferimento + Point3d ptPL = ptP ; + ptPL.ToLoc( frStm) ; + Vector3d vtDirL = vtDir ; + vtDirL.ToLoc( frStm) ; + ILSIVECTOR vInfo ; if ( IntersLineSurfTm( ptPL, vtDirL, RAY_LEN, *pStm, vInfo)) { for ( const auto& Info : vInfo) { // se tratto di intersezione coincidente, considero la posizione pių lontana, ovvero 2 if ( Info.nILTT == ILTT_SEGM || Info.nILTT == ILTT_SEGM_ON_EDGE) { // se prosegue un tratto precedente, non devo controllare sia minimo - if ( fabs( dElevP - Info.dU) < EPS_SMALL) - dElevP = Info.dU2 ; + if ( fabs( dElev - Info.dU) < EPS_SMALL) + dElev = Info.dU2 ; else - dElevP = min( dElevP, Info.dU2) ; + dElev = min( dElev, Info.dU2) ; } // altrimenti intersezione puntuale, verifico che esca (coseno >= 0) else if ( Info.dCosDN > - COS_ORTO_ANG_ZERO) { - dElevP = min( dElevP, Info.dU) ; + dElev = min( dElev, Info.dU) ; } } } - // se elevazione calcolata, aggiorno quella della superficie - if ( dElevP < INFINITO - 1) - dElevS = max( dElevS, dElevP) ; } - // aggiorno elevazione complessiva - if ( dElevS > 0) - dElev = min( dElev, dElevS) ; } // passo al grezzo successivo nRawId = m_pMchMgr->GetNextRawPart( nRawId) ; @@ -201,7 +130,84 @@ Machining::GetElevation( const Point3d& ptP1, const Point3d& ptP2, const Vector3 //---------------------------------------------------------------------------- bool -Machining::GetDistanceFromRawSide( const Point3d& ptP, const Vector3d& vtDir, double& dDist) +Machining::GetElevation( int nPhase, const Point3d& ptP1, const Point3d& ptP2, const Vector3d& vtDir, double& dElev) +{ + if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) + return false ; + // inizializzo elevazione + dElev = INFINITO ; + // ciclo sui grezzi + bool bFound = false ; + int nRawId = m_pMchMgr->GetFirstRawPart() ; + while ( nRawId != GDB_ID_NULL) { + // verifico che il grezzo compaia nella fase + if ( m_pMchMgr->VerifyRawPartPhase( nRawId, nPhase)) { + // intersezione del raggio dal punto alla trimesh del grezzo + const double RAY_LEN = 10000 ; + int nStmId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ; + ISurfTriMesh* pStm = GetSurfTriMesh( m_pGeomDB->GetGeoObj( nStmId)) ; + if ( pStm != nullptr) { + bFound = true ; + // recupero il riferimento della trimesh + Frame3d frStm ; + m_pGeomDB->GetGlobFrame( nStmId, frStm) ; + // porto il segmento e la direzione in questo riferimento + Point3d ptP1L = ptP1 ; + ptP1L.ToLoc( frStm) ; + Point3d ptP2L = ptP2 ; + ptP2L.ToLoc( frStm) ; + Vector3d vtDirL = vtDir ; + vtDirL.ToLoc( frStm) ; + ILSIVECTOR vInfo ; + // inizializzo elevazione della superficie + double dElevS = 0 ; + // faccio test con un insieme di punti ( !!! sostituire con intersezione tra rettangolo e trimesh !!!) + const double STEP = 50 ; + int nStep = max( (int) ceil( ApproxDist( ptP1L, ptP2L) / STEP), 3) ; + for ( int i = 0 ; i <= nStep ; ++ i) { + // calcolo punto di test + double dFraz = i / (double) nStep ; + Point3d ptPL = Media( ptP1L, ptP2L, dFraz) ; + // inizializzo elevazione del punto + double dElevP = INFINITO ; + // calcolo elevazione sul punto + if ( IntersLineSurfTm( ptPL, vtDirL, RAY_LEN, *pStm, vInfo)) { + for ( const auto& Info : vInfo) { + // se tratto di intersezione coincidente, considero la posizione pių lontana, ovvero 2 + if ( Info.nILTT == ILTT_SEGM || Info.nILTT == ILTT_SEGM_ON_EDGE) { + // se prosegue un tratto precedente, non devo controllare sia minimo + if ( fabs( dElevP - Info.dU) < EPS_SMALL) + dElevP = Info.dU2 ; + else + dElevP = min( dElevP, Info.dU2) ; + } + // altrimenti intersezione puntuale, verifico che esca (coseno >= 0) + else if ( Info.dCosDN > - COS_ORTO_ANG_ZERO) { + dElevP = min( dElevP, Info.dU) ; + } + } + } + // se elevazione calcolata, aggiorno quella della superficie + if ( dElevP < INFINITO - 1) + dElevS = max( dElevS, dElevP) ; + } + // aggiorno elevazione complessiva + if ( dElevS > 0) + dElev = min( dElev, dElevS) ; + } + } + // passo al grezzo successivo + nRawId = m_pMchMgr->GetNextRawPart( nRawId) ; + } + // se non trovate intersezioni, elevazione nulla + if ( dElev > INFINITO - 1) + dElev = 0 ; + return bFound ; +} + +//---------------------------------------------------------------------------- +bool +Machining::GetDistanceFromRawSide( int nPhase, const Point3d& ptP, const Vector3d& vtDir, double& dDist) { if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) return false ; @@ -210,11 +216,15 @@ Machining::GetDistanceFromRawSide( const Point3d& ptP, const Vector3d& vtDir, do b3Pnt.Expand( 10, 10, 0) ; int nRawId = m_pMchMgr->GetFirstRawPart() ; while ( nRawId != GDB_ID_NULL) { - BBox3d b3Raw ; - int nRawSolidId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ; - if ( m_pGeomDB->GetGlobalBBox( nRawSolidId, b3Raw) && b3Pnt.OverlapsXY( b3Raw)) { - break ; + // verifico che il grezzo compaia nella fase + if ( m_pMchMgr->VerifyRawPartPhase( nRawId, nPhase)) { + BBox3d b3Raw ; + int nRawSolidId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ; + if ( m_pGeomDB->GetGlobalBBox( nRawSolidId, b3Raw) && b3Pnt.OverlapsXY( b3Raw)) { + break ; + } } + // passo al grezzo successivo nRawId = m_pMchMgr->GetNextRawPart( nRawId) ; } // se il punto non č interno ad alcun grezzo, distanza nulla @@ -249,7 +259,7 @@ Machining::GetDistanceFromRawSide( const Point3d& ptP, const Vector3d& vtDir, do //---------------------------------------------------------------------------- bool -Machining::GetDistanceFromRawBottom( int nPathId, double dToler, double& dRbDist) +Machining::GetDistanceFromRawBottom( int nPhase, int nPathId, double dToler, double& dRbDist) { if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) return false ; @@ -261,13 +271,17 @@ Machining::GetDistanceFromRawBottom( int nPathId, double dToler, double& dRbDist b3Compo.Expand( dToler, dToler, 0) ; int nRawId = m_pMchMgr->GetFirstRawPart() ; while ( nRawId != GDB_ID_NULL) { - BBox3d b3Raw ; - int nRawSolidId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ; - if ( m_pGeomDB->GetGlobalBBox( nRawSolidId, b3Raw) && b3Compo.OverlapsXY( b3Raw)) { - double dDist = b3Compo.GetMax().z - b3Raw.GetMin().z ; - if ( dDist > dRbDist) - dRbDist = dDist ; + // verifico che il grezzo compaia nella fase + if ( m_pMchMgr->VerifyRawPartPhase( nRawId, nPhase)) { + BBox3d b3Raw ; + int nRawSolidId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ; + if ( m_pGeomDB->GetGlobalBBox( nRawSolidId, b3Raw) && b3Compo.OverlapsXY( b3Raw)) { + double dDist = b3Compo.GetMax().z - b3Raw.GetMin().z ; + if ( dDist > dRbDist) + dRbDist = dDist ; + } } + // passo al grezzo successivo nRawId = m_pMchMgr->GetNextRawPart( nRawId) ; } return true ; diff --git a/Machining.h b/Machining.h index c4f41b8..6ffd40b 100644 --- a/Machining.h +++ b/Machining.h @@ -58,10 +58,10 @@ class Machining : public IUserObj Machining( void) ; protected : - bool GetElevation( const Point3d& ptP, const Vector3d& vtDir, double& dElev) ; - bool GetElevation( const Point3d& ptP1, const Point3d& ptP2, const Vector3d& vtDir, double& dElev) ; - bool GetDistanceFromRawSide( const Point3d& ptP, const Vector3d& vtDir, double& dDist) ; - bool GetDistanceFromRawBottom( int nPathId, double dToler, double& dRbDist) ; + bool GetElevation( int nPhase, const Point3d& ptP, const Vector3d& vtDir, double& dElev) ; + bool GetElevation( int nPhase, const Point3d& ptP1, const Point3d& ptP2, const Vector3d& vtDir, double& dElev) ; + bool GetDistanceFromRawSide( int nPhase, const Point3d& ptP, const Vector3d& vtDir, double& dDist) ; + bool GetDistanceFromRawBottom( int nPhase, int nPathId, double dToler, double& dRbDist) ; bool GetInitialAxesValues( DBLVECTOR& vAxVal) ; bool GetClPathInitialAxesValues( int nClPathId, DBLVECTOR& vAxVal) ; bool GetFinalAxesValues( DBLVECTOR& vAxVal) ; diff --git a/Sawing.cpp b/Sawing.cpp index 2afaec3..0e04bae 100644 --- a/Sawing.cpp +++ b/Sawing.cpp @@ -969,7 +969,7 @@ Sawing::ProcessPath( int nPathId, int nPvId, int nClId) // recupero distanza da fondo dei grezzi interessati dal percorso double dRbDist ; - if ( ! GetDistanceFromRawBottom( nCopyId, 2 * m_TParams.m_dThick, dRbDist)) + if ( ! GetDistanceFromRawBottom( m_nPhase, nCopyId, 2 * m_TParams.m_dThick, dRbDist)) return false ; // valuto l'espressione dell'affondamento @@ -1051,8 +1051,8 @@ Sawing::ProcessEntity( const ICurve* pCrvP, const ICurve* pCrvC, const ICurve* p // calcolo elevazione (sui due bordi della striscia double dElev, dElev2 ; Vector3d vtThick = vtTool * m_TParams.m_dThick ; - if ( ! GetElevation( pLine->GetStart(), pLine->GetEnd(), vtCorr, dElev) || - ! GetElevation( pLine->GetStart() + vtThick, pLine->GetEnd() + vtThick, vtCorr, dElev2) ) { + if ( ! GetElevation( m_nPhase, pLine->GetStart(), pLine->GetEnd(), vtCorr, dElev) || + ! GetElevation( m_nPhase, pLine->GetStart() + vtThick, pLine->GetEnd() + vtThick, vtCorr, dElev2) ) { LOG_INFO( GetEMkLogger(), "Error in Sawing : Entity GetElevation") ; return false ; } @@ -1456,8 +1456,8 @@ Sawing::AdjustForEdges( ICurveLine* pLine, double dElev, const Vector3d& vtThick pLine->GetStartDir( vtDir) ; // determino la distanza dal bordo del grezzo double dDist = 0, dDist2 = 0 ; - if ( ! GetDistanceFromRawSide( ptP, - vtDir, dDist) && - ! GetDistanceFromRawSide( ptP + vtThick, - vtDir, dDist2)) + if ( ! GetDistanceFromRawSide( m_nPhase, ptP, - vtDir, dDist) && + ! GetDistanceFromRawSide( m_nPhase, ptP + vtThick, - vtDir, dDist2)) return false ; dDeltaI = max( dDist, dDist2) ; } @@ -1470,8 +1470,8 @@ Sawing::AdjustForEdges( ICurveLine* pLine, double dElev, const Vector3d& vtThick pLine->GetStartDir( vtDir) ; // determino la distanza dal bordo del grezzo double dDist = 0, dDist2 = 0 ; - if ( ! GetDistanceFromRawSide( ptP, - vtDir, dDist) || - ! GetDistanceFromRawSide( ptP + vtThick, - vtDir, dDist2)) + if ( ! GetDistanceFromRawSide( m_nPhase, ptP, - vtDir, dDist) || + ! GetDistanceFromRawSide( m_nPhase, ptP + vtThick, - vtDir, dDist2)) return false ; dDeltaI = max( dDist, dDist2) + dDeltaT ; } @@ -1487,8 +1487,8 @@ Sawing::AdjustForEdges( ICurveLine* pLine, double dElev, const Vector3d& vtThick pLine->GetStartDir( vtDir) ; // determino la distanza dal bordo del grezzo double dDist = 0, dDist2 = 0 ; - if ( ! GetDistanceFromRawSide( ptP, - vtDir, dDist) || - ! GetDistanceFromRawSide( ptP + vtThick, - vtDir, dDist2)) + if ( ! GetDistanceFromRawSide( m_nPhase, ptP, - vtDir, dDist) || + ! GetDistanceFromRawSide( m_nPhase, ptP + vtThick, - vtDir, dDist2)) return false ; dDeltaI = max( dDist, dDist2) ; // se LeadIn EXT_OUT vado all'esterno @@ -1512,8 +1512,8 @@ Sawing::AdjustForEdges( ICurveLine* pLine, double dElev, const Vector3d& vtThick pLine->GetEndDir( vtDir) ; // determino la distanza dal bordo del grezzo double dDist = 0, dDist2 = 0 ; - if ( ! GetDistanceFromRawSide( ptP, vtDir, dDist) || - ! GetDistanceFromRawSide( ptP + vtThick, vtDir, dDist2)) + if ( ! GetDistanceFromRawSide( m_nPhase, ptP, vtDir, dDist) || + ! GetDistanceFromRawSide( m_nPhase, ptP + vtThick, vtDir, dDist2)) return false ; dDeltaF = max( dDist, dDist2) ; } @@ -1529,8 +1529,8 @@ Sawing::AdjustForEdges( ICurveLine* pLine, double dElev, const Vector3d& vtThick pLine->GetEndDir( vtDir) ; // determino la distanza dal bordo del grezzo double dDist = 0, dDist2 = 0 ; - if ( ! GetDistanceFromRawSide( ptP, vtDir, dDist) || - ! GetDistanceFromRawSide( ptP + vtThick, vtDir, dDist2)) + if ( ! GetDistanceFromRawSide( m_nPhase, ptP, vtDir, dDist) || + ! GetDistanceFromRawSide( m_nPhase, ptP + vtThick, vtDir, dDist2)) return false ; dDeltaF = max( dDist, dDist2) ; } diff --git a/Simulator.cpp b/Simulator.cpp index 804969e..049d1da 100644 --- a/Simulator.cpp +++ b/Simulator.cpp @@ -133,8 +133,13 @@ Simulator::Move( int& nStatus) // se non č una lavorazione, verifico se disposizione con cambio di fase if ( pMch == nullptr) { Disposition* pDisp = GetDisposition( m_pGeomDB->GetUserObj( m_nOpId)) ; - if ( pDisp != nullptr) + if ( pDisp != nullptr) { + // cambio fase m_pMchMgr->SetCurrPhase( pDisp->GetPhase()) ; + // aggiorno visualizzazione e breve pausa (200 ms) + ExeDraw() ; + Sleep( 200) ; + } } // lavorazione valida else if ( ! pMch->IsEmpty())