public void updateIndex ( Iterator < Triangle > updatedTriangles ) { // Gather the bounding box of the updated area BoundingBox updatedRegion = new BoundingBox ( ) ; while ( updatedTriangles . hasNext ( ) ) { updatedRegion = updatedRegion . unionWith ( updatedTriangles . next ( ) . getBoundingBox ( ) ) ; } if ( updatedRegion . isNull ( ) ) // No update... return ; // Bad news - the updated region lies outside the indexed region. // The whole index must be recalculated if ( ! indexRegion . contains ( updatedRegion ) ) { init ( indexDelaunay , ( int ) ( indexRegion . getWidth ( ) / x_size ) , ( int ) ( indexRegion . getHeight ( ) / y_size ) , indexRegion . unionWith ( updatedRegion ) ) ; } else { // Find the cell region to be updated Vector2i minInvalidCell = getCellOf ( updatedRegion . getMinPoint ( ) ) ; Vector2i maxInvalidCell = getCellOf ( updatedRegion . getMaxPoint ( ) ) ; // And update it with fresh triangles Triangle adjacentValidTriangle = findValidTriangle ( minInvalidCell ) ; updateCellValues ( minInvalidCell . getX ( ) , minInvalidCell . getY ( ) , maxInvalidCell . getX ( ) , maxInvalidCell . getY ( ) , adjacentValidTriangle ) ; } }
Updates the grid index to reflect changes to the triangulation . Note that added triangles outside the indexed region will force to recompute the whole index with the enlarged region .