TopoToolbox / libtopotoolbox

A C library for the analysis of digital elevation models.
https://topotoolbox.github.io/libtopotoolbox/
GNU General Public License v3.0
0 stars 5 forks source link

Restructure the morphological reconstruction loop #21

Closed wkearn closed 6 months ago

wkearn commented 6 months ago

This now uses a for loop with an iteration counter up to a maximum number of iterations, which is declared as a named constant. The loop is ended early if the scans stop changing, which indicates convergence. This ensures that the reconstruction will not run forever even in the presence of NaNs or some other reason why it wouldn't converged.

Note that we do not current signal to the caller that the reconstruction has not converged. A value could be returned from this function to indicate whether it has converged, but it is unclear to me what the caller (namely fillsinks) should do with that information.