EgtGeomKernel :
- in VolZmap migliorata la funzione RemoveFins.
This commit is contained in:
+120
-4
@@ -847,7 +847,7 @@ VolZmap::UniformIntervalsInVoxel( int nGrid, int nI, int nJ, double dZMin,
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::AddStripInterval( int nGrid, int nI, int nJ, double dZMin, double dZMax)
|
||||
VolZmap::AddStripInterval( int nGrid, int nI, int nJ, double dZMin, double dZMax, int nToolNum)
|
||||
{
|
||||
// Se non Tridex, esco
|
||||
if ( ! IsTriDexel())
|
||||
@@ -880,7 +880,7 @@ VolZmap::AddStripInterval( int nGrid, int nI, int nJ, double dZMin, double dZMax
|
||||
nMyGrid == 1 ? m_MapFrame.VersX() :
|
||||
m_MapFrame.VersY()) ;
|
||||
Vector3d vtMyMinN = - vtMyMaxN ;
|
||||
AddIntervals( nMyGrid, nMyI, nMyJ, dMyMinZ - EPS_SMALL, dMyMaxZ + EPS_SMALL, vtMyMinN, vtMyMaxN, 2, true) ;
|
||||
AddIntervals( nMyGrid, nMyI, nMyJ, dMyMinZ - EPS_SMALL, dMyMaxZ + EPS_SMALL, vtMyMinN, vtMyMaxN, nToolNum, true) ;
|
||||
// Recupero gli indici della griglia precedente
|
||||
nMyGrid = ( nGrid + 2) % 3 ;
|
||||
nMyI = nVox ;
|
||||
@@ -892,7 +892,7 @@ VolZmap::AddStripInterval( int nGrid, int nI, int nJ, double dZMin, double dZMax
|
||||
nMyGrid == 1 ? m_MapFrame.VersX() :
|
||||
m_MapFrame.VersY()) ;
|
||||
vtMyMinN = - vtMyMaxN ;
|
||||
AddIntervals( nMyGrid, nMyI, nMyJ, dMyMinZ, dMyMaxZ, vtMyMinN, vtMyMaxN, 2, true) ;
|
||||
AddIntervals( nMyGrid, nMyI, nMyJ, dMyMinZ - EPS_SMALL, dMyMaxZ + EPS_SMALL, vtMyMinN, vtMyMaxN, nToolNum, true) ;
|
||||
}
|
||||
}
|
||||
// Aggiungo l'intervallo corrente
|
||||
@@ -900,11 +900,127 @@ VolZmap::AddStripInterval( int nGrid, int nI, int nJ, double dZMin, double dZMax
|
||||
nGrid == 1 ? m_MapFrame.VersX() :
|
||||
m_MapFrame.VersY()) ;
|
||||
Vector3d vtMyMinN = - vtMyMaxN ;
|
||||
AddIntervals( nGrid, nI, nJ, dZMin, dZMax, vtMyMaxN, vtMyMinN, 2, true) ;
|
||||
AddIntervals( nGrid, nI, nJ, dZMin, dZMax, vtMyMinN, vtMyMaxN, nToolNum, true) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::GetLocalPoint( int nGrid, int nI, int nJ, double dZ, Point3d& ptLoc)
|
||||
{
|
||||
// Verifico che lo ZMap corrente sia valido
|
||||
if ( ! IsValid())
|
||||
return false ;
|
||||
|
||||
// Controllo che il numero di griglia sia entro i limiti
|
||||
if ( nGrid < 0 || nGrid > 2)
|
||||
return false ;
|
||||
|
||||
// Controllo che indici nI, nJ siano entro i limiti
|
||||
if ( nI < 0 && nI >= m_nNx[nGrid] && nJ < 0 && nJ >= m_nNy[nGrid])
|
||||
return false ;
|
||||
|
||||
// Calcolo il punto
|
||||
ptLoc = m_MapFrame.Orig() ;
|
||||
if ( nGrid == 0)
|
||||
ptLoc += ( ( nI + 0.5) * m_dStep * m_MapFrame.VersX() + ( nJ + 0.5) * m_dStep * m_MapFrame.VersY() + dZ * m_MapFrame.VersZ()) ;
|
||||
else if ( nGrid == 1)
|
||||
ptLoc += ( ( nI + 0.5) * m_dStep * m_MapFrame.VersY() + ( nJ + 0.5) * m_dStep * m_MapFrame.VersZ() + dZ * m_MapFrame.VersX()) ;
|
||||
else
|
||||
ptLoc += ( ( nI + 0.5) * m_dStep * m_MapFrame.VersZ() + ( nJ + 0.5) * m_dStep * m_MapFrame.VersX() + dZ * m_MapFrame.VersY()) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::ComputePointAndNormalForRemovingFins( int nGrid, int nI, int nJ, double dZ,
|
||||
const Vector3d& vtDir, double dThick, bool bMinVsMax, int nTool,
|
||||
Vector3d& vtN, double& dNewZ)
|
||||
{
|
||||
// Verifico che lo ZMap corrente sia valido
|
||||
if ( ! IsValid())
|
||||
return false ;
|
||||
|
||||
// Controllo che il numero di griglia sia entro i limiti
|
||||
if ( nGrid < 0 || nGrid > 2)
|
||||
return false ;
|
||||
|
||||
// Inizializzo il vettore da restituire
|
||||
vtN = V_NULL ;
|
||||
dNewZ = INFINITO ;
|
||||
|
||||
// Proietto la direzione lungo la mappa della griglia corrente
|
||||
Vector3d vtDirProj = OrthoCompo( vtDir, ( nGrid == 0 ? m_MapFrame.VersZ() :
|
||||
nGrid == 1 ? m_MapFrame.VersX() :
|
||||
m_MapFrame.VersY())) ;
|
||||
// Sposto il punto corrente nella direzione opposta a quella trovata
|
||||
Point3d ptLoc ;
|
||||
if ( ! GetLocalPoint( nGrid, nI, nJ, dZ, ptLoc))
|
||||
return false ;
|
||||
Point3d ptCenterLoc = ptLoc ;
|
||||
ptCenterLoc.Translate( - vtDirProj * dThick) ;
|
||||
|
||||
// Recupero il Box nel punto
|
||||
BBox3d BBoxLoc ; BBoxLoc.Add( ptCenterLoc) ;
|
||||
double dExpandX = ( m_MapFrame.VersX() * X_AX) * dThick * ( vtDirProj * X_AX) ;
|
||||
double dExpandY = ( m_MapFrame.VersY() * Y_AX) * dThick * ( vtDirProj * Y_AX) ;
|
||||
double dExpandZ = ( m_MapFrame.VersZ() * Z_AX) * dThick * ( vtDirProj * Z_AX) ;
|
||||
BBoxLoc.Expand( max( ( m_dStep + EPS_SMALL), dExpandX),
|
||||
max( ( m_dStep + EPS_SMALL), dExpandY),
|
||||
max( ( m_dStep + EPS_SMALL), dExpandZ)) ;
|
||||
|
||||
// Porto il Box nel Frame della Mappa corrente
|
||||
BBox3d BBoxInGrid = GetToLoc( BBoxLoc, m_MapFrame) ;
|
||||
// Recupero i suoi estremi
|
||||
Point3d ptBoxLocMax = BBoxInGrid.GetMax() ;
|
||||
Point3d ptBoxLocMin = BBoxInGrid.GetMin() ;
|
||||
// Determino gli intervalli locali in X e Y locali alla Griglia correnti
|
||||
double dMinXLoc = ( nGrid == 0 ? ptBoxLocMin.x : nGrid == 1 ? ptBoxLocMin.y : ptBoxLocMin.z) ;
|
||||
double dMinYLoc = ( nGrid == 0 ? ptBoxLocMin.y : nGrid == 1 ? ptBoxLocMin.z : ptBoxLocMin.x) ;
|
||||
double dMaxXLoc = ( nGrid == 0 ? ptBoxLocMax.x : nGrid == 1 ? ptBoxLocMax.y : ptBoxLocMax.z) ;
|
||||
double dMaxYLoc = ( nGrid == 0 ? ptBoxLocMax.y : nGrid == 1 ? ptBoxLocMax.z : ptBoxLocMax.x) ;
|
||||
|
||||
// Recupero gli Spilloni coinvolti nel Box
|
||||
int nStartI = max( 0, int( dMinXLoc / m_dStep)) ;
|
||||
int nEndI = min( m_nNx[nGrid] - 1, int( dMaxXLoc / m_dStep)) ;
|
||||
int nStartJ = max( 0, int( dMinYLoc / m_dStep)) ;
|
||||
int nEndJ = min( m_nNy[nGrid] - 1, int( dMaxYLoc / m_dStep)) ;
|
||||
double dSqMinDist = INFINITO ;
|
||||
for ( int i = nStartI ; i <= nEndI ; ++ i) {
|
||||
for ( int j = nStartJ ; j <= nEndJ ; ++ j) {
|
||||
// Determino la posizione corrente dello Spillone
|
||||
int nPos = j * m_nNx[nGrid] + i ;
|
||||
vector<Data>& vDexel = m_Values[nGrid][nPos] ;
|
||||
// Scorro i suoi Intervalli
|
||||
for ( int nInterval = 0 ; nInterval < ssize( vDexel) ; ++ nInterval) {
|
||||
// Se l'Intervallo presenta un indice del Tool da evitare, passo al successivo
|
||||
if ( ( bMinVsMax && vDexel[nInterval].nToolMin != nTool) ||
|
||||
( ! bMinVsMax && vDexel[nInterval].nToolMax != nTool))
|
||||
continue ;
|
||||
// Recupero l'estremo da analizzare
|
||||
double dZInterval = ( bMinVsMax ? vDexel[nInterval].dMin : vDexel[nInterval].dMax) ;
|
||||
// Recupero il punto associato
|
||||
Point3d ptInterval ;
|
||||
if ( ! GetLocalPoint( nGrid, i, j, dZInterval, ptInterval))
|
||||
return false ;
|
||||
// Se il punto è dentro nel Box, aggiungo il contributo della normale presente
|
||||
if ( BBoxLoc.Encloses( ptInterval)) {
|
||||
double dCurrSqDist = ( SqDist( ptInterval, ptLoc)) ;
|
||||
if ( dCurrSqDist < dSqMinDist) {
|
||||
dSqMinDist = dCurrSqDist ;
|
||||
vtN = ( bMinVsMax ? vDexel[nInterval].vtMinN : vDexel[nInterval].vtMaxN) ;
|
||||
dNewZ = dZInterval ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ( ! vtN.IsSmall() && dZ < INFINITO - 1) ;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------- BOUNDING BOX --------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user