genericWindow.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /****************************************************************************
  2. *
  3. * MODULE: r.terraflow
  4. *
  5. * COPYRIGHT (C) 2007 Laura Toma
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. *****************************************************************************/
  18. #include "types.h"
  19. #include "genericWindow.h"
  20. /* ********************************************************************** */
  21. /* ********************************************************************** */
  22. /* if center of the wind is a pit, fill it */
  23. void
  24. fillPit(ElevationWindow& win) {
  25. /* find min of the 8 neighbors */
  26. elevation_type min = win.get(0);
  27. for (int k=1; k<9; k++) {
  28. if (k != 4 && win.get(k) < min) {
  29. min = win.get(k);
  30. }
  31. }
  32. if (win.get(4) < min) {
  33. win.set(4, min);
  34. }
  35. };