TheBoussinesqModel  3.2.1
 All Data Structures Files Functions Variables Typedefs Macros Pages
geometry_io.c File Reference
#include "turtle.h"
#include "geometry.h"
#include "additional_read_functions.h"
#include "geometry_utilities.h"
#include "geometry_io.h"
#include "geometry_freememory.h"

Go to the source code of this file.

Macros

#define DELIMITERS   ";"
 
#define MAX_POINTS   20
 
#define NULL_VALUE   -99
 
#define NO_ELEVATION   0.0
 
#define NO_COLS_LINEVECTOR_DOUBLEMATRIX   8
 

Functions

LINEget_line (DOUBLEVECTOR *vertex_x_coord, DOUBLEVECTOR *vertex_y_coord, long line_index, char *number_strings, short print)
 
LINEVECTORget_linevector (DOUBLEVECTOR *vertex_x_coord, DOUBLEVECTOR *vertex_y_coord, STRINGBIN *line_strings, short print)
 
LINEVECTORextract_linvector_from_linevector (LONGVECTOR *nlines, LINEVECTOR *lines)
 
POLYGONget_polygon (long index, double x, double y, double z, char *edge_index_string, LINEVECTOR *all_lines, short print)
 
POLYGONVECTORget_polygonvector (DOUBLEVECTOR *centroid_x_coord, DOUBLEVECTOR *centroid_y_coord, STRINGBIN *polygon_strings, LINEVECTOR *all_lines, short print)
 
int write_linevector (char *filename, LINEVECTOR *lines)
 
int write_polygonvector (char *filename, POLYGONVECTOR *polygons)
 
int fprint_linevector (char *filename, LINEVECTOR *lines)
 
int fprint_polygonvector (char *filename, POLYGONVECTOR *polygons)
 

Macro Definition Documentation

#define DELIMITERS   ";"
BGEOMETRY BUILDS THE MESH FROM A RASTER FOR THE BOUSSINESQ MODEL

KeyPalette Version 0.9375 KMackenzie

file geometry_io.c

Copyright, 2009 Emanuele Cordano and Riccardo Rigon

This file is part of BGEOMETRY. BGEOMETRY is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

BGEOMETRY is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition at line 32 of file geometry_io.c.

Referenced by get_line(), and get_polygon().

#define MAX_POINTS   20

Definition at line 33 of file geometry_io.c.

Referenced by get_line(), and get_polygon().

#define NO_COLS_LINEVECTOR_DOUBLEMATRIX   8

Definition at line 37 of file geometry_io.c.

Referenced by write_linevector().

#define NO_ELEVATION   0.0

Definition at line 35 of file geometry_io.c.

Referenced by get_line(), and get_polygonvector().

#define NULL_VALUE   -99

Definition at line 34 of file geometry_io.c.

Referenced by fprint_polygonvector(), and write_polygonvector().

Function Documentation

LINEVECTOR* extract_linvector_from_linevector ( LONGVECTOR nlines,
LINEVECTOR lines 
)
Author
Emanuele Cordano
Date
November 2008
Parameters
nlines- (LONGVECTOR *) numbers of lines to be extracted
lines- (LINEVECTOR *) vector of all lines
Returns
a reduced linevoctor with the lines extracted

Definition at line 125 of file geometry_io.c.

References LINE::begin, LINEVECTOR::element, LINE::end, new_line_from_points(), new_linevector(), LONGVECTOR::nh, and LINEVECTOR::nl.

Referenced by get_polygon(), and new_pixel_from_raster().

int fprint_linevector ( char *  filename,
LINEVECTOR lines 
)
Author
Emanuele Cordano November 2008
Parameters
name- (char *)name of file where to write the linevector properties
linevector- (LINEVECTOR *) the linevector to be printed
Returns
0 if the linevector is written correctly, -1 otherwise

Definition at line 341 of file geometry_io.c.

References LINE::begin, LINEVECTOR::element, LINE::end, LINE::index, LINE::length2d, LINEVECTOR::nl, POINT::x, and POINT::y.

int fprint_polygonvector ( char *  filename,
POLYGONVECTOR polygons 
)
Author
Emanuele Cordano November 2008
Parameters
name- (char *)name of file where to write the linevector properties
polygons- (POLYGONVECTOR *) the polygonvector to be printed
Returns
0 if the polygonvector is written correctly, -1 otherwise

PRINT HEADER

end print header

Definition at line 392 of file geometry_io.c.

References POLYGON::area2D, POLYGON::centroid, POLYGON::edge_indices, POLYGONVECTOR::element, POLYGON::index, LONGVECTOR::nh, NL, POLYGONVECTOR::nl, LONGVECTOR::nl, NULL_VALUE, POINT::x, and POINT::y.

LINE* get_line ( DOUBLEVECTOR vertex_x_coord,
DOUBLEVECTOR vertex_y_coord,
long  line_index,
char *  number_strings,
short  print 
)
Parameters
vertex_x_coord- (DOUBLEVECTOR *) vector of x coordinates
vertex_y_coord- (DOUBLEVECTOR *) vector of y coordinates
line_index- (long int) index of the line
number_string- (char *) string containing the number of two vertex points
print- (short) if activated it prints error or warning messages
Author
Emanuele Cordano
Date
November 2008

Definition at line 39 of file geometry_io.c.

References DELIMITERS, free_longvector(), free_point(), POINT::index, MAX_POINTS, new_line_from_points(), new_point(), LONGVECTOR::nh, DOUBLEVECTOR::nh, LONGVECTOR::nl, NO_ELEVATION, read_longarray_from_string(), POINT::x, and POINT::y.

Referenced by get_linevector().

LINEVECTOR* get_linevector ( DOUBLEVECTOR vertex_x_coord,
DOUBLEVECTOR vertex_y_coord,
STRINGBIN line_strings,
short  print 
)
Author
Emanuele Cordano
Date
November 2008
Parameters
vertex_x_coord- (DOUBLEVECTOR *) vector of x coordinates
vertex_y_coord- (DOUBLEVECTOR *) vector of y coordinates
line_strings- (STRINGBIN *) string array containing line information
print- (short int)

Definition at line 90 of file geometry_io.c.

References LINEVECTOR::element, get_line(), st::index, new_linevector(), LONGVECTOR::nh, and LINEVECTOR::nl.

POLYGON* get_polygon ( long  index,
double  x,
double  y,
double  z,
char *  edge_index_string,
LINEVECTOR all_lines,
short  print 
)
Author
Emanuele Cordano
Date
November 2008
Parameters
index- (long) index of the centroid and the polygons
x- (double) x of the centroid
y- (double) y of the centroid
z- (double) z of the centroid
edge_line_index- (char *) string containing the edge indices
all_lines- (LINEVECTOR *) vector of all lines
print- (short)
Returns
a polygon (Attributes are not allocated!!)

Definition at line 153 of file geometry_io.c.

References DELIMITERS, extract_linvector_from_linevector(), free_linevector(), free_longvector(), free_point(), MAX_POINTS, new_point(), new_polygon_from_a_linevector(), and read_longarray_from_string().

Referenced by get_polygonvector().

POLYGONVECTOR* get_polygonvector ( DOUBLEVECTOR centroid_x_coord,
DOUBLEVECTOR centroid_y_coord,
STRINGBIN polygon_strings,
LINEVECTOR all_lines,
short  print 
)
Author
Emanuele Cordano
Date
November 2008
Parameters
centroid_x_coord- (DOUBLEVECTOR*) vector of centroid x coordinates
centroid_y_coord- (DOUBLEVECTOR*) vector of centroid y coordinates
polygon_strings- (STRINGBIN *) string containing polygon information
lines- (LINEVECTOR *) vector containing all the lines
print- (short)

Definition at line 191 of file geometry_io.c.

References POLYGONVECTOR::element, get_polygon(), st::index, new_polygonvector(), LONGVECTOR::nh, DOUBLEVECTOR::nh, POLYGONVECTOR::nl, and NO_ELEVATION.

int write_linevector ( char *  filename,
LINEVECTOR lines 
)
Author
Emanuele Cordano November 2008
Parameters
name- (char *)name of file where to write the linevector properties
linevector- (LINEVECTOR *) the linevector to be printed

write a linevecto in a fluidturtle formalism.

Returns
0 if the linevector is written correctly, -1 otherwise

Definition at line 219 of file geometry_io.c.

References LINE::begin, LINEVECTOR::element, LINE::end, LINE::index, LINE::length2d, LINEVECTOR::nh, LINEVECTOR::nl, NO_COLS_LINEVECTOR_DOUBLEMATRIX, POINT::x, and POINT::y.

Referenced by write_grid().

int write_polygonvector ( char *  filename,
POLYGONVECTOR polygons 
)
Author
Emanuele Cordano May 2009
Parameters
name- (char *)name of file where to write the linevector properties
polygons- (POLYGONVECTOR *) the polygonvector to be printed

This functions writes a polygonvector in an ascii files with fluidturle formalism

Returns
0 if the polygonvector is written correctly, -1 otherwise

PRINT HEADER

end print header

Definition at line 271 of file geometry_io.c.

References POLYGON::area2D, POLYGON::centroid, POLYGON::edge_indices, POLYGONVECTOR::element, POLYGON::index, POLYGONVECTOR::nh, LONGVECTOR::nh, NL, POLYGONVECTOR::nl, LONGVECTOR::nl, NULL_VALUE, POINT::x, and POINT::y.

Referenced by write_grid().