grid.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. #ifndef GRID_H
  19. #define GRID_H
  20. #include <grass/iostream/ami.h>
  21. #include "types.h"
  22. #include "plateau.h"
  23. #include "water.h"
  24. /* define to keep i,j values (used in printing) */
  25. /* #define KEEP_COORDS */
  26. struct gridElement {
  27. direction_type dir;
  28. char valid; /* whether part of plateau in grid */
  29. bfs_depth_type depth;
  30. #ifdef KEEP_COORDS
  31. dimension_type i,j;
  32. #endif
  33. };
  34. class grid {
  35. private:
  36. gridElement *data;
  37. dimension_type iMin, jMin;
  38. dimension_type width, height;
  39. cclabel_type label;
  40. long size;
  41. queue<gridElement *> boundaryQueue[2];
  42. public:
  43. grid(dimension_type iMin, dimension_type jMin,
  44. dimension_type iMax, dimension_type jMax,
  45. long size,
  46. cclabel_type label);
  47. ~grid();
  48. void load(AMI_STREAM<plateauType> &str);
  49. void save(AMI_STREAM<waterType> &str);
  50. void print();
  51. void assignDirections(int sfdmode); /* single flow directions */
  52. gridElement *getNeighbour(gridElement *datap, int k);
  53. direction_type getDirection(int);
  54. };
  55. #endif