From 6f60e2d7113687eecfe29e0ed2beb18d99e865ca Mon Sep 17 00:00:00 2001 From: LorenzoM Date: Tue, 11 Jan 2022 16:51:54 +0100 Subject: [PATCH] Correzione errori vmill additivo --- VolZmapVolume.cpp | 77 ++++++++++++++++++++++++----------------------- 1 file changed, 40 insertions(+), 37 deletions(-) diff --git a/VolZmapVolume.cpp b/VolZmapVolume.cpp index 931e7fd..2a0379c 100644 --- a/VolZmapVolume.cpp +++ b/VolZmapVolume.cpp @@ -255,15 +255,7 @@ bool VolZmap::AddIntervals( int nGrid, int nI, int nJ, double dMin, double dMax, const Vector3d& vtNMin, const Vector3d& vtNMax) { - // Restringo minimo e massimo entro i limiti della mappa - dMin = Clamp( dMin, m_dMinZ[nGrid], m_dMaxZ[nGrid]) ; - dMax = Clamp( dMax, m_dMinZ[nGrid], m_dMaxZ[nGrid]) ; - - // Controllo che dMin e dMax non siano quasi coincidenti - if ( abs( dMax - dMin) < EPS_SMALL) - return true ; - - // Controllo che il numero di griglia sia entro i limiti + // Controllo che il numero di griglia sia entro i limiti if ( nGrid < 0 || nGrid > 2) return false ; @@ -280,9 +272,29 @@ VolZmap::AddIntervals( int nGrid, int nI, int nJ, swap( vtNmi, vtNma) ; } + // Restringo minimo e massimo entro i limiti della mappa + if ( dMin < m_dMinZ[nGrid]) { + dMin = m_dMinZ[nGrid] ; + vtNmi = - Z_AX ; + } + else if ( dMin > m_dMaxZ[nGrid]) { + dMin = m_dMaxZ[nGrid] ; + vtNmi = - Z_AX ; + } + if ( dMax < m_dMinZ[nGrid]) { + dMax = m_dMinZ[nGrid] ; + vtNma = Z_AX ; + } + else if ( dMax > m_dMaxZ[nGrid]) { + dMax = m_dMaxZ[nGrid] ; + vtNma = Z_AX ; + } + + // Controllo che dMin e dMax non siano quasi coincidenti + if ( abs( dMax - dMin) < EPS_SMALL) + return true ; + // Riporto le coordinate cicliche nell'ordine di partenza - /*Vector3d vtNmi = vtNMin ; - Vector3d vtNma = vtNMax ;*/ if ( nGrid == 1) { swap( vtNmi.x, vtNmi.z) ; swap( vtNmi.y, vtNmi.z) ; @@ -313,12 +325,6 @@ VolZmap::AddIntervals( int nGrid, int nI, int nJ, vDexel.back().vtMaxN = vtNma ; vDexel.back().nToolMax = m_vTool[m_nCurrTool].GetCurrentToolNum() ; - /*if ( dMax > m_dMaxZ[nGrid]) - m_dMaxZ[nGrid] = dMax ; - - if ( dMin < m_dMinZ[nGrid]) - m_dMinZ[nGrid] = dMin ;*/ - m_OGrMgr.Reset() ; bModified = true ; @@ -364,7 +370,7 @@ VolZmap::AddIntervals( int nGrid, int nI, int nJ, NewSegment.vtMinN = vtNmi ; NewSegment.vtMaxN = vtNma ; NewSegment.nToolMin = m_vTool[m_nCurrTool].GetCurrentToolNum() ; - NewSegment.nToolMin = m_vTool[m_nCurrTool].GetCurrentToolNum() ; + NewSegment.nToolMax = m_vTool[m_nCurrTool].GetCurrentToolNum() ; //NewSegment.nCompo = ; vDexel.insert( itFirstRight, NewSegment) ; bModified = true ; @@ -444,7 +450,7 @@ VolZmap::AddIntervals( int nGrid, int nI, int nJ, NewSegment.vtMinN = vtNmi ; NewSegment.vtMaxN = vtNma ; NewSegment.nToolMin = m_vTool[m_nCurrTool].GetCurrentToolNum() ; - NewSegment.nToolMin = m_vTool[m_nCurrTool].GetCurrentToolNum() ; + NewSegment.nToolMax = m_vTool[m_nCurrTool].GetCurrentToolNum() ; //NewSegment.nCompo = ; vDexel.insert( vDexel.begin(), NewSegment) ; bModified = true ; @@ -730,25 +736,22 @@ VolZmap::MillingTranslationStep( const Point3d& ptPs, const Point3d& ptPe, const Vector3d vtLs[N_MAPS] ; Vector3d vtALs[N_MAPS] ; InitializePointsAndVectors( ptPs, ptPe, vtD, vtA, ptLs, ptLe, vtLs, vtALs) ; - for ( int i = 0 ; i < m_nMapNum ; ++ i) { - SelectMotion( i, ptLs[i], ptLe[i], vtLs[i], vtALs[i]) ; - } // Ciclo sulle mappe - //vector< future> vRes ; - //vRes.resize( m_nMapNum) ; - //for ( int i = 0 ; i < m_nMapNum ; ++ i) { - // vRes[i] = async( launch::async, &VolZmap::SelectMotion, this, i, cref( ptLs[i]), cref( ptLe[i]), cref( vtLs[i]), cref( vtALs[i])) ; - //} - //bool bOk = true ; - //int nTerminated = 0 ; - //while ( nTerminated < m_nMapNum) { - // for ( int i = 0 ; i < m_nMapNum ; ++ i) { - // if ( vRes[i].valid() && vRes[i].wait_for( chrono::nanoseconds{ 1}) == future_status::ready) { - // bOk = vRes[i].get() && bOk ; - // ++ nTerminated ; - // } - // } - //} + vector< future> vRes ; + vRes.resize( m_nMapNum) ; + for ( int i = 0 ; i < m_nMapNum ; ++ i) { + vRes[i] = async( launch::async, &VolZmap::SelectMotion, this, i, cref( ptLs[i]), cref( ptLe[i]), cref( vtLs[i]), cref( vtALs[i])) ; + } + bool bOk = true ; + int nTerminated = 0 ; + while ( nTerminated < m_nMapNum) { + for ( int i = 0 ; i < m_nMapNum ; ++ i) { + if ( vRes[i].valid() && vRes[i].wait_for( chrono::nanoseconds{ 1}) == future_status::ready) { + bOk = vRes[i].get() && bOk ; + ++ nTerminated ; + } + } + } return true ; }