GRASS 8 Programmer's Manual 8.6.0dev(2026)-55de52a352
Loading...
Searching...
No Matches
vector/diglib/update.c
Go to the documentation of this file.
1/**
2 * \file lib/vector/diglib/update.c
3 *
4 * \brief Vector library - update topology (lower level functions)
5 *
6 * Lower level functions for reading/writing/manipulating vectors.
7 *
8 * SPDX-FileCopyrightText: 2001 GRASS Development Team
9 * SPDX-License-Identifier: GPL-2.0-or-later
10 *
11 * \author Radim Blazek
12 */
13
14#include <stdlib.h>
15#include <grass/vector.h>
16
17/*!
18 \brief Reset number of updated lines
19
20 \param Plus pointer to Plus_head structure
21 */
23{
24 Plus->uplist.n_uplines = 0;
25}
26
27/*!
28 \brief Add new line to updated
29
30 \param Plus pointer to Plus_head structure
31 \param line line id
32 \param offset line offset (negative offset is ignored)
33 */
34void dig_line_add_updated(struct Plus_head *Plus, int line, off_t offset)
35{
36 G_debug(3, "dig_line_add_updated(): line = %d", line);
37
38 /* undo/redo in the digitizer needs all steps,
39 * disable check */
40#if 0
41 int i;
42
43 /* Check if already in list */
44 for (i = 0; i < Plus->uplist.n_uplines; i++) {
45 if (Plus->uplist.uplines[i] == line) {
46 G_debug(3, "\tskipped");
47 return;
48 }
49 }
50#endif
51
52 /* Alloc space if needed */
53 if (Plus->uplist.n_uplines == Plus->uplist.alloc_uplines) {
54 Plus->uplist.alloc_uplines += 1000;
55 Plus->uplist.uplines = (int *)G_realloc(
56 Plus->uplist.uplines, Plus->uplist.alloc_uplines * sizeof(int));
57 Plus->uplist.uplines_offset =
58 (off_t *)G_realloc(Plus->uplist.uplines_offset,
59 Plus->uplist.alloc_uplines * sizeof(off_t));
60 }
61
62 Plus->uplist.uplines[Plus->uplist.n_uplines] = line;
63 Plus->uplist.uplines_offset[Plus->uplist.n_uplines] = offset;
64 Plus->uplist.n_uplines++;
65}
66
67/*!
68 \brief Reset number of updated nodes
69
70 \param Plus pointer to Plus_head structure
71 */
73{
74 Plus->uplist.n_upnodes = 0;
75}
76
77/*!
78 \brief Add node to updated
79
80 \param Plus pointer to Plus_head structure
81 \param node node id
82 */
83void dig_node_add_updated(struct Plus_head *Plus, int node)
84{
85 int i;
86
87 G_debug(3, "dig_node_add_updated(): node = %d", node);
88
89 /* Check if already in list */
90 for (i = 0; i < Plus->uplist.n_upnodes; i++) {
91 if (abs(Plus->uplist.upnodes[i]) == abs(node)) {
92 G_debug(3, "\tskipped");
93 return;
94 }
95 }
96
97 /* Alloc space if needed */
98 if (Plus->uplist.n_upnodes == Plus->uplist.alloc_upnodes) {
99 Plus->uplist.alloc_upnodes += 1000;
100 Plus->uplist.upnodes = (int *)G_realloc(
101 Plus->uplist.upnodes, Plus->uplist.alloc_upnodes * sizeof(int));
102 }
103
104 Plus->uplist.upnodes[Plus->uplist.n_upnodes] = node;
105 Plus->uplist.n_upnodes++;
106}
#define G_realloc(p, n)
Definition defs/gis.h:138
int G_debug(int, const char *,...) __attribute__((format(printf
Basic topology-related info.
void dig_line_add_updated(struct Plus_head *Plus, int line, off_t offset)
Add new line to updated.
void dig_node_reset_updated(struct Plus_head *Plus)
Reset number of updated nodes.
void dig_line_reset_updated(struct Plus_head *Plus)
Reset number of updated lines.
void dig_node_add_updated(struct Plus_head *Plus, int node)
Add node to updated.