update.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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->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. int i;
  33. G_debug(3, "dig_line_add_updated(): line = %d", line);
  34. /* Check if already in list */
  35. for (i = 0; i < Plus->n_uplines; i++)
  36. if (Plus->uplines[i] == line)
  37. return;
  38. /* Alloc space if needed */
  39. if (Plus->n_uplines == Plus->alloc_uplines) {
  40. Plus->alloc_uplines += 1000;
  41. Plus->uplines =
  42. (int *)G_realloc(Plus->uplines,
  43. Plus->alloc_uplines * sizeof(int));
  44. }
  45. Plus->uplines[Plus->n_uplines] = line;
  46. Plus->n_uplines++;
  47. }
  48. /*!
  49. \brief Reset number of updated nodes
  50. \param Plus pointer to Plus_head structure
  51. */
  52. void dig_node_reset_updated(struct Plus_head *Plus)
  53. {
  54. Plus->n_upnodes = 0;
  55. }
  56. /*!
  57. \brief Add node to updated
  58. \param Plus pointer to Plus_head structure
  59. \param node node id
  60. */
  61. void dig_node_add_updated(struct Plus_head *Plus, int node)
  62. {
  63. int i;
  64. G_debug(3, "dig_node_add_updated(): node = %d", node);
  65. /* Check if already in list */
  66. for (i = 0; i < Plus->n_upnodes; i++)
  67. if (Plus->upnodes[i] == node)
  68. return;
  69. /* Alloc space if needed */
  70. if (Plus->n_upnodes == Plus->alloc_upnodes) {
  71. Plus->alloc_upnodes += 1000;
  72. Plus->upnodes =
  73. (int *)G_realloc(Plus->upnodes,
  74. Plus->alloc_upnodes * sizeof(int));
  75. }
  76. Plus->upnodes[Plus->n_upnodes] = node;
  77. Plus->n_upnodes++;
  78. }