update.c 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /**
  2. * \file update.c
  3. *
  4. * \brief Vector library - update topology (lower level functions)
  5. *
  6. * Lower level functions for reading/writing/manipulating vectors.
  7. *
  8. * (C) 2001 by the GRASS Development Team
  9. *
  10. * This program is free software under the GNU General Public License
  11. * (>=v2). Read the file COPYING that comes with GRASS for details.
  12. *
  13. * \author Radim Blazek
  14. */
  15. #include <stdlib.h>
  16. #include <grass/vector.h>
  17. /*!
  18. \brief Reset number of updated lines
  19. \param Plus pointer to Plus_head structure
  20. */
  21. void dig_line_reset_updated(struct Plus_head *Plus)
  22. {
  23. Plus->uplist.n_uplines = 0;
  24. }
  25. /*!
  26. \brief Add new line to updated
  27. \param Plus pointer to Plus_head structure
  28. \param line line id
  29. */
  30. void dig_line_add_updated(struct Plus_head *Plus, int line)
  31. {
  32. G_debug(3, "dig_line_add_updated(): line = %d", line);
  33. /* Check if already in list
  34. for (i = 0; i < Plus->uplist.n_uplines; i++)
  35. if (Plus->uplist.uplines[i] == line)
  36. return;
  37. */
  38. /* Alloc space if needed */
  39. if (Plus->uplist.n_uplines == Plus->uplist.alloc_uplines) {
  40. Plus->uplist.alloc_uplines += 1000;
  41. Plus->uplist.uplines =
  42. (int *)G_realloc(Plus->uplist.uplines,
  43. Plus->uplist.alloc_uplines * sizeof(int));
  44. Plus->uplist.uplines_offset =
  45. (off_t *)G_realloc(Plus->uplist.uplines_offset,
  46. Plus->uplist.alloc_uplines * sizeof(off_t));
  47. }
  48. Plus->uplist.uplines[Plus->uplist.n_uplines] = line;
  49. Plus->uplist.n_uplines++;
  50. }
  51. /*!
  52. \brief Reset number of updated nodes
  53. \param Plus pointer to Plus_head structure
  54. */
  55. void dig_node_reset_updated(struct Plus_head *Plus)
  56. {
  57. Plus->uplist.n_upnodes = 0;
  58. }
  59. /*!
  60. \brief Add node to updated
  61. \param Plus pointer to Plus_head structure
  62. \param node node id
  63. */
  64. void dig_node_add_updated(struct Plus_head *Plus, int node)
  65. {
  66. int i;
  67. G_debug(3, "dig_node_add_updated(): node = %d", node);
  68. /* Check if already in list */
  69. for (i = 0; i < Plus->uplist.n_upnodes; i++)
  70. if (Plus->uplist.upnodes[i] == node)
  71. return;
  72. /* Alloc space if needed */
  73. if (Plus->uplist.n_upnodes == Plus->uplist.alloc_upnodes) {
  74. Plus->uplist.alloc_upnodes += 1000;
  75. Plus->uplist.upnodes =
  76. (int *)G_realloc(Plus->uplist.upnodes,
  77. Plus->uplist.alloc_upnodes * sizeof(int));
  78. }
  79. Plus->uplist.upnodes[Plus->uplist.n_upnodes] = node;
  80. Plus->uplist.n_upnodes++;
  81. }