18 #include <grass/Vect.h>
20 static int add_line(
struct Plus_head *plus,
int lineid,
int type,
struct line_pnts *Points,
28 line = plus->Line[lineid];
31 G_debug(3,
"Register node: type = %d, %f,%f", type, Points->x[0],
34 node =
dig_find_node(plus, Points->x[0], Points->y[0], Points->z[0]);
37 node =
dig_add_node(plus, Points->x[0], Points->y[0], Points->z[0]);
38 G_debug(3,
"Add new node: %d", node);
41 G_debug(3,
"Old node found: %d", node);
49 lp = Points->n_points - 1;
50 G_debug(3,
"Register node %f,%f", Points->x[lp], Points->y[lp]);
52 dig_find_node(plus, Points->x[lp], Points->y[lp], Points->z[lp]);
58 G_debug(3,
"Add new node: %d", node);
61 G_debug(3,
"Old node found: %d", node);
73 line->offset = offset;
102 dig_add_line(
struct Plus_head *plus,
int type,
struct line_pnts *Points,
109 if (plus->n_lines >= plus->alloc_lines) {
114 ret = add_line(plus, plus->n_lines + 1, type, Points, offset);
158 int type,
struct line_pnts *Points,
161 if (lineid < 1 || lineid > plus->n_lines) {
165 return add_line(plus, lineid, type, Points, offset);
190 G_debug(3,
"dig_del_line() line = %d", line);
192 Line = plus->Line[line];
196 Node = plus->Node[Line->N1];
198 for (i = 0; i < Node->n_lines; i++) {
200 Node->lines[i - 1] = Node->lines[i];
201 Node->angles[i - 1] = Node->angles[i];
204 if (abs(Node->lines[i]) == line)
209 if (Node->n_lines == 0) {
210 G_debug(3,
" node %d has 0 lines -> delete", Line->N1);
212 plus->Node[Line->N1] =
NULL;
219 if (Line->type & GV_LINES) {
220 Node = plus->Node[Line->N2];
222 for (i = 0; i < Node->n_lines; i++) {
224 Node->lines[i - 1] = Node->lines[i];
225 Node->angles[i - 1] = Node->angles[i];
228 if (abs(Node->lines[i]) == line)
233 if (Node->n_lines == 0) {
234 G_debug(3,
" node %d has 0 lines -> delete", Line->N2);
236 plus->Node[Line->N2] =
NULL;
245 plus->Line[line] =
NULL;
265 Line = plus->Line[line];
266 if (side == GV_LEFT) {
268 "dig_line_get_area(): line = %d, side = %d (left), area = %d",
269 line, side, Line->left);
272 if (side == GV_RIGHT) {
274 "dig_line_get_area(): line = %d, side = %d (right), area = %d",
275 line, side, Line->right);
277 return (Line->right);
298 Line = plus->Line[line];
299 if (side == GV_LEFT) {
302 else if (side == GV_RIGHT) {
322 Line = plus->Line[line];
347 Line = plus->Line[line];
int dig_line_box(struct line_pnts *Points, BOUND_BOX *Box)
int dig_spidx_add_line(struct Plus_head *Plus, int line, BOUND_BOX *box)
Add new line to spatial index.
float Box[8][3]
Vertices for box.
int dig_spidx_del_node(struct Plus_head *Plus, int node)
Delete node from spatial index.
int dig_add_line(struct Plus_head *plus, int type, struct line_pnts *Points, long offset)
Add new line to Plus_head structure.
int dig_node_add_line(struct Plus_head *plus, int nodeid, int lineid, struct line_pnts *points, int type)
Add line info to node.
void dig_node_add_updated(struct Plus_head *Plus, int node)
Add node to updated.
int dig_add_node(struct Plus_head *plus, double x, double y, double z)
Add new node to plus structure.
int dig_line_get_box(struct Plus_head *plus, plus_t line, BOUND_BOX *Box)
Get line bounding box saved in topo.
int dig_line_set_area(struct Plus_head *plus, plus_t line, int side, plus_t area)
Set area number on line side.
int dig_del_line(struct Plus_head *plus, int line)
Delete line from Plus_head structure.
int dig_restore_line(struct Plus_head *plus, int lineid, int type, struct line_pnts *Points, long offset)
Restore line in Plus_head structure.
P_LINE * dig_alloc_line()
int G_debug(int level, const char *msg,...)
Print debugging message.
int dig_alloc_lines(struct Plus_head *Plus, int add)
void dig_line_add_updated(struct Plus_head *Plus, int line)
Add new line to updated.
int dig_find_node(struct Plus_head *Plus, double x, double y, double z)
Find one node by coordinates.
plus_t dig_line_get_area(struct Plus_head *plus, plus_t line, int side)
Get area number on line side.
int dig_line_set_box(struct Plus_head *plus, plus_t line, BOUND_BOX *Box)
Set line bounding box.
int dig_spidx_del_line(struct Plus_head *Plus, int line)
Delete line from spatial index.