20 #include <grass/gis.h>
21 #include <grass/Vect.h>
22 #include <grass/glocale.h>
35 Plus->Version_Major = 0;
36 Plus->Version_Minor = 0;
48 Plus->built = GV_BUILD_NONE;
63 Plus->alloc_nodes = 0;
64 Plus->alloc_edges = 0;
65 Plus->alloc_lines = 0;
66 Plus->alloc_areas = 0;
67 Plus->alloc_isles = 0;
68 Plus->alloc_volumes = 0;
69 Plus->alloc_holes = 0;
78 Plus->Node_offset = 0L;
79 Plus->Edge_offset = 0L;
80 Plus->Line_offset = 0L;
81 Plus->Area_offset = 0L;
82 Plus->Isle_offset = 0L;
83 Plus->Volume_offset = 0L;
84 Plus->Hole_offset = 0L;
86 Plus->Node_spidx_offset = 0L;
87 Plus->Edge_spidx_offset = 0L;
88 Plus->Line_spidx_offset = 0L;
89 Plus->Area_spidx_offset = 0L;
90 Plus->Isle_spidx_offset = 0L;
91 Plus->Volume_spidx_offset = 0L;
92 Plus->Hole_spidx_offset = 0L;
110 G_debug(2,
"dig_free_plus_nodes()");
114 for (i = 1; i <= Plus->n_nodes; i++) {
115 Node = Plus->Node[i];
119 if (Node->alloc_lines > 0) {
129 Plus->alloc_nodes = 0;
142 G_debug(2,
"dig_free_plus_lines()");
146 for (i = 1; i <= Plus->n_lines; i++) {
147 Line = Plus->Line[i];
158 Plus->alloc_lines = 0;
178 G_debug(2,
"dig_free_plus_areas()");
182 for (i = 1; i <= Plus->n_areas; i++) {
183 Area = Plus->Area[i];
187 if (Area->alloc_lines > 0)
190 if (Area->alloc_isles > 0)
199 Plus->alloc_areas = 0;
212 G_debug(2,
"dig_free_plus_isles()");
216 for (i = 1; i <= Plus->n_isles; i++) {
217 Isle = Plus->Isle[i];
221 if (Isle->alloc_lines > 0)
231 Plus->alloc_isles = 0;
287 if (
dig_fseek(plus, Plus->Node_offset, 0) == -1)
291 for (i = 1; i <= Plus->n_nodes; i++) {
297 if (
dig_fseek(plus, Plus->Line_offset, 0) == -1)
301 for (i = 1; i <= Plus->n_lines; i++) {
307 if (
dig_fseek(plus, Plus->Area_offset, 0) == -1)
311 for (i = 1; i <= Plus->n_areas; i++) {
317 if (
dig_fseek(plus, Plus->Isle_offset, 0) == -1)
321 for (i = 1; i <= Plus->n_isles; i++) {
345 G_warning(_(
"Unable to write head to plus file"));
350 G_warning(_(
"Unable to write nodes to plus file"));
355 G_warning(_(
"Unable to write lines to plus file"));
360 G_warning(_(
"Unable to write areas to plus file"));
365 G_warning(_(
"Unable to write isles to plus file"));
371 G_warning(_(
"Unable to write head to plus file"));
395 for (i = 1; i <= Plus->n_nodes; i++) {
419 for (i = 1; i <= Plus->n_lines; i++) {
444 for (i = 1; i <= Plus->n_areas; i++) {
469 for (i = 1; i <= Plus->n_isles; i++) {
int dig_alloc_nodes(struct Plus_head *Plus, int add)
void dig_free_plus_lines(struct Plus_head *Plus)
Free Plus->Line structure.
int dig_init_plus(struct Plus_head *Plus)
Init head structure.
void G_free(void *buf)
Free allocated memory.
int dig_Wr_Plus_head(GVFILE *fp, struct Plus_head *ptr)
int dig_set_cur_port(struct Port_info *port)
int dig_spidx_init(struct Plus_head *Plus)
Initit spatial index (nodes, lines, areas, isles)
int dig_alloc_areas(struct Plus_head *Plus, int add)
int dig_write_plus_file(GVFILE *fp_plus, struct Plus_head *Plus)
Writes topo structure to topo file.
int dig_Rd_P_area(struct Plus_head *Plus, int n, GVFILE *fp)
int dig_Wr_P_line(struct Plus_head *Plus, int n, GVFILE *fp)
int dig_Rd_P_node(struct Plus_head *Plus, int n, GVFILE *fp)
void dig_free_plus_areas(struct Plus_head *Plus)
Free Plus->Area structure.
int dig_write_areas(GVFILE *plus, struct Plus_head *Plus)
Writes topo structure (areas) to topo file.
int dig_Wr_P_isle(struct Plus_head *Plus, int n, GVFILE *fp)
int dig_Rd_Plus_head(GVFILE *fp, struct Plus_head *ptr)
int dig_fseek(GVFILE *file, long offset, int whence)
Set GVFILE position.
int dig_Rd_P_isle(struct Plus_head *Plus, int n, GVFILE *fp)
int dig_alloc_isles(struct Plus_head *Plus, int add)
void dig_cidx_free(struct Plus_head *Plus)
void dig_free_plus_isles(struct Plus_head *Plus)
Free Plus->Isle structure.
void dig_free_plus(struct Plus_head *Plus)
Free Plus structure.
int dig_write_nodes(GVFILE *plus, struct Plus_head *Plus)
Writes topo structure (nodes) to topo file.
int dig_cidx_init(struct Plus_head *Plus)
int dig_fflush(GVFILE *file)
Flush GVFILE.
G_warning("category support for [%s] in mapset [%s] %s", name, mapset, type)
int dig_write_isles(GVFILE *plus, struct Plus_head *Plus)
Writes topo structure (isles) to topo file.
int dig_Rd_P_line(struct Plus_head *Plus, int n, GVFILE *fp)
int G_debug(int level, const char *msg,...)
Print debugging message.
void dig_rewind(GVFILE *file)
Rewind GVFILE position.
int dig_alloc_lines(struct Plus_head *Plus, int add)
int dig_write_lines(GVFILE *plus, struct Plus_head *Plus)
Writes topo structure (lines) to topo file.
int G_fatal_error(const char *msg,...)
Print a fatal error message to stderr.
long dig_ftell(GVFILE *file)
Get GVFILE position.
int dig_Wr_P_node(struct Plus_head *Plus, int n, GVFILE *fp)
int dig_Wr_P_area(struct Plus_head *Plus, int n, GVFILE *fp)
void dig_free_plus_nodes(struct Plus_head *Plus)
Free Plus->Node structure.
int dig_load_plus(struct Plus_head *Plus, GVFILE *plus, int head_only)
Reads topo file to topo structure.