diff --git a/EgtNumKernel.rc b/EgtNumKernel.rc index ca9885d..0a05743 100644 Binary files a/EgtNumKernel.rc and b/EgtNumKernel.rc differ diff --git a/ShortestPath.h b/ShortestPath.h index 050ef00..1f06c8f 100644 --- a/ShortestPath.h +++ b/ShortestPath.h @@ -17,7 +17,7 @@ //---------------------------------------------------------------------------- -#define MAXCARD 1048576 // 2^20 per evitare overflow con int e 1024 somme +#define MAXDIST 1048576U // 2^20 per evitare overflow con int e 1024 somme //---------------------------------------------------------------------------- struct SpPoint { diff --git a/ShortestPathTsp.cpp b/ShortestPathTsp.cpp index 871ac3d..840a783 100644 --- a/ShortestPathTsp.cpp +++ b/ShortestPathTsp.cpp @@ -297,7 +297,7 @@ ShortestPath::CalcDistances( void) nDist = 0 ; break ; } - m_Dists[ Index( m_nNumPnts - 1, i)] = nDist ; + m_Dists[ Index( m_nNumPnts - 1, i)] = min( nDist, MAXDIST) ; // verifico se nuovo minimo di linea if ( nDist < nRowMinDist) nRowMinDist = nDist ; @@ -333,10 +333,10 @@ ShortestPath::CalcDistances( void) nDist = 0 ; break ; } - m_Dists[ Index( i, m_nNumPnts - 1)] = nDist ; + m_Dists[ Index( i, m_nNumPnts - 1)] = min( nDist, MAXDIST) ; } // punto su diagonale principale - m_Dists[ Index( m_nNumPnts - 1, m_nNumPnts - 1)] = MAXCARD ; + m_Dists[ Index( m_nNumPnts - 1, m_nNumPnts - 1)] = MAXDIST ; // devo ancora calcolare le righe/colonne precedenti nLimit = m_nNumPnts - 1 ; } @@ -352,14 +352,14 @@ ShortestPath::CalcDistances( void) float dDz = float( m_Points[i].dZf - m_Points[j].dZi) ; float dDh = float( m_Points[i].dHf - m_Points[j].dHi) ; float dDv = float( m_Points[i].dVf - m_Points[j].dVi) ; - unsigned nDist = GetDistance( dDx, dDy, dDz, dDh, dDv) ; + unsigned nDist = min( GetDistance( dDx, dDy, dDz, dDh, dDv), MAXDIST) ; m_Dists[ Index( i, j)] = nDist ; // verifico se nuovo minimo di linea if ( nDist < nRowMinDist) nRowMinDist = nDist ; } else - m_Dists[ Index( i, j)] = MAXCARD ; + m_Dists[ Index( i, j)] = MAXDIST ; } // aggiorno il totale delle minime distanze m_nTotMin += nRowMinDist ;