update.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 <grass/config.h>
  16. #include <stdlib.h>
  17. #include <grass/gis.h>
  18. #include <grass/vector.h>
  19. /*!
  20. \brief Reset number of updated lines
  21. \param Plus pointer to Plus_head structure
  22. */
  23. void dig_line_reset_updated(struct Plus_head *Plus)
  24. {
  25. Plus->n_uplines = 0;
  26. }
  27. /*!
  28. \brief Add new line to updated
  29. \param Plus pointer to Plus_head structure
  30. \param line line id
  31. */
  32. void dig_line_add_updated(struct Plus_head *Plus, int line)
  33. {
  34. int i;
  35. G_debug(3, "dig_line_add_updated(): line = %d", line);
  36. /* Check if already in list */
  37. for (i = 0; i < Plus->n_uplines; i++)
  38. if (Plus->uplines[i] == line)
  39. return;
  40. /* Alloc space if needed */
  41. if (Plus->n_uplines == Plus->alloc_uplines) {
  42. Plus->alloc_uplines += 1000;
  43. Plus->uplines =
  44. (int *)G_realloc(Plus->uplines,
  45. Plus->alloc_uplines * sizeof(int));
  46. }
  47. Plus->uplines[Plus->n_uplines] = line;
  48. Plus->n_uplines++;
  49. }
  50. /*!
  51. \brief Reset number of updated nodes
  52. \param Plus pointer to Plus_head structure
  53. */
  54. void dig_node_reset_updated(struct Plus_head *Plus)
  55. {
  56. Plus->n_upnodes = 0;
  57. }
  58. /*!
  59. \brief Add node to updated
  60. \param Plus pointer to Plus_head structure
  61. \param node node id
  62. */
  63. void dig_node_add_updated(struct Plus_head *Plus, int node)
  64. {
  65. int i;
  66. G_debug(3, "dig_node_add_updated(): node = %d", node);
  67. /* Check if already in list */
  68. for (i = 0; i < Plus->n_upnodes; i++)
  69. if (Plus->upnodes[i] == node)
  70. return;
  71. /* Alloc space if needed */
  72. if (Plus->n_upnodes == Plus->alloc_upnodes) {
  73. Plus->alloc_upnodes += 1000;
  74. Plus->upnodes =
  75. (int *)G_realloc(Plus->upnodes,
  76. Plus->alloc_upnodes * sizeof(int));
  77. }
  78. Plus->upnodes[Plus->n_upnodes] = node;
  79. Plus->n_upnodes++;
  80. }