20static int debug_level = -1;
63 if (debug_level == -1) {
72 G_debug(3,
"dig_build_area_with_line(): first_line = %d, side = %d",
85 G_debug(3,
"First line degenerated");
107 G_debug(3,
"next_line = %d", next_line);
109 if (next_line == 0) {
110 G_debug(3,
"Cannot build area, no next line for line %d",
118 "Cannot build area, a neighbour of the line %d has the "
119 "same angle at the node",
131 if (debug_level > 2) {
132 for (i = 0; i < n_lines; i++) {
133 G_debug(3,
" area line (%d) = %d", i, array[i]);
150 for (i = 0; i < n_lines; i++)
151 if (
abs(next_line) ==
abs(array[i])) {
165 array[n_lines++] = next_line;
191 register int area, line;
206 G_debug(3,
" new area = %d", area);
216 for (i = 0; i < n_lines; i++) {
218 Area->
lines[i] = line;
222 if (topo->
left != 0) {
223 G_warning(
_(
"Line %d already has area/isle %d to left"), line,
229 G_debug(3,
" Line %d left set to %d.", line, area);
233 if (topo->
right != 0) {
234 G_warning(
_(
"Line %d already has area/isle %d to right"), line,
240 G_debug(3,
" Line %d right set to %d.", line, area);
247 plus->
Area[area] = Area;
270 G_debug(3,
"dig_area_add_isle(): area = %d isle = %d", area,
isle);
272 if (debug_level == -1) {
281 Area = plus->
Area[area];
285 if (debug_level > 0) {
286 for (i = 0; i < Area->
n_isles; i++) {
289 G_warning(
_(
"Isle already registered in area"));
319 G_debug(3,
"dig_area_del_isle(): area = %d isle = %d", area,
isle);
321 Area = plus->
Area[area];
332 _(
"Attempt to delete not registered isle %d from area %d"),
isle,
387 for (i = 0; i < Area->
n_lines; i++) {
388 line = Area->
lines[i];
393 G_debug(3,
" Set line %d right side to 0", line);
397 G_debug(3,
" Set line %d left side to 0", line);
417 Line = plus->
Line[line];
419 G_warning(
_(
"Dead centroid %d registered for area (bug in the "
440 for (i = 0; i < Area->
n_isles; i++) {
443 G_fatal_error(
_(
"Attempt to delete area %d info from dead isle %d"),
475 int type,
float *
angle)
483 if (debug_level == -1) {
492 G_debug(3,
"dig__angle_next_line: line = %d, side = %d, type = %d",
529 G_debug(3,
" node = %d", node);
531 Node = plus->
Node[node];
534 if (debug_level > 2) {
537 for (i = 0; i < Node->
n_lines; i++) {
538 G_debug(3,
" i = %d line = %d angle = %f", i, Node->
lines[i],
552 "dig_angle_next_line(): line %d not found at its own node %d",
559 G_debug(3,
" current position = %d", next);
573 G_debug(3,
" next = %d line = %d angle = %f", next, Node->
lines[next],
576 if (Node->
angles[next] == -9.) {
577 G_debug(3,
" point/degenerated -> skip");
585 line = Node->
lines[next];
588 if (Line->
type & type) {
629 G_debug(3,
"dig_node_angle_check: line = %d, type = %d", line,
type);
668 " The line to the right has the same angle: node = %d, line = %d",
679 " The line to the left has the same angle: node = %d, line = %d",
707 register int isle, line;
733 for (i = 0; i < n_lines; i++) {
735 G_debug(3,
" i = %d line = %d", i, line);
736 Isle->
lines[i] = line;
740 if (topo->
left != 0) {
741 G_warning(
_(
"Line %d already has area/isle %d to left"), line,
749 if (topo->
right != 0) {
750 G_warning(
_(
"Line %d already has area/isle %d to right"), line,
794 for (i = 0; i < Isle->
n_lines; i++) {
795 line = Isle->
lines[i];
807 if (Isle->
area > 0) {
809 G_fatal_error(
_(
"Attempt to delete isle %d info from dead area %d"),
const char * G_getenv_nofatal(const char *)
Get environment variable.
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
void G_warning(const char *,...) __attribute__((format(printf
int G_debug(int, const char *,...) __attribute__((format(printf
#define GV_LEFT
Boundary side indicator left/right.
void * dig__falloc(int, int)
int dig_spidx_add_isle(struct Plus_head *, int, const struct bound_box *)
Add new island to spatial index.
float dig_node_line_angle(struct Plus_head *, int, int)
Return line angle.
int dig_spidx_del_area(struct Plus_head *, int)
Delete area from spatial index.
int dig_spidx_add_area(struct Plus_head *, int, const struct bound_box *)
Add new area to spatial index.
int dig_alloc_areas(struct Plus_head *, int)
Reallocate array of pointers to areas.
int dig_alloc_isles(struct Plus_head *, int)
Reallocate array of pointers to isles.
int dig_area_alloc_isle(struct P_area *, int)
Allocate space in P_area for add new isles.
int dig_spidx_del_isle(struct Plus_head *, int)
Delete isle from spatial index.
void * dig__frealloc(void *, int, int, int)
void dig_free_area(struct P_area *)
Free area structure.
struct P_isle * dig_alloc_isle(void)
Allocate new isle structure.
struct P_area * dig_alloc_area(void)
Allocate new area structure.
int dig_isle_alloc_line(struct P_isle *, int)
Allocate space in P_isle for add new lines.
int dig_area_alloc_line(struct P_area *, int)
allocate space in P_area for add new lines
void dig_free_isle(struct P_isle *)
Free isle structure.
int dig_out_of_memory(void)
For now just print message and return error code.
int dig_angle_next_line(struct Plus_head *plus, plus_t current_line, int side, int type, float *angle)
Find line number of next angle to follow a line.
int dig_add_area(struct Plus_head *plus, int n_lines, plus_t *lines, struct bound_box *box)
Allocate space for new area and create boundary info from array.
int dig_area_add_isle(struct Plus_head *plus, int area, int isle)
Add isle to area if does not exist yet.
int dig_node_angle_check(struct Plus_head *plus, plus_t line, int type)
Check if angles of adjacent lines differ.
int dig_add_isle(struct Plus_head *plus, int n_lines, plus_t *lines, struct bound_box *box)
Allocate space for new island and create boundary info from array.
int dig_area_del_isle(struct Plus_head *plus, int area, int isle)
Delete isle from area.
int dig_del_area(struct Plus_head *plus, int area)
Delete area from Plus_head structure.
int dig_build_area_with_line(struct Plus_head *plus, plus_t first_line, int side, plus_t **lines)
Build topo for area from lines.
int dig_del_isle(struct Plus_head *plus, int isle)
Delete island from Plus_head structure.
plus_t n_isles
Number of islands inside.
plus_t * isles
1st generation interior islands
plus_t n_lines
Number of boundary lines.
plus_t * lines
List of boundary lines.
plus_t centroid
Number of first centroid within area.
plus_t alloc_isles
Allocated space for isles.
plus_t * lines
List of boundary lines.
plus_t n_lines
Number of boundary lines.
plus_t area
Area it exists w/in, if any.
void * topo
Topology info.
Topological feature - node.
plus_t n_lines
Number of attached lines (size of lines, angle)
float * angles
List of angles of connected lines.
plus_t * lines
List of connected lines.
plus_t left
Area number to the left, negative for isle.
plus_t right
Area number to the right, negative for isle.
plus_t area
Area number, negative for duplicate centroid.
Basic topology-related info.
struct P_line ** Line
Array of vector geometries.
plus_t alloc_areas
Number of allocated areas.
struct P_area ** Area
Array of areas.
plus_t alloc_isles
Number of allocated isles.
plus_t n_isles
Current number of isles.
struct P_isle ** Isle
Array of isles.
struct P_node ** Node
Array of nodes.
plus_t n_areas
Current number of areas.