GRASS GIS 7 Programmer's Manual  7.5.svn(2017)-r71806
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
dataquad.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <grass/dataquad.h>
Include dependency graph for dataquad.c:

Go to the source code of this file.

Functions

struct triplequad_point_new (double x, double y, double z, double sm)
 
struct quaddataquad_data_new (double x_or, double y_or, double xmax, double ymax, int rows, int cols, int n_points, int kmax)
 
int quad_compare (struct triple *point, struct quaddata *data)
 
int quad_add_data (struct triple *point, struct quaddata *data, double dmin)
 
int quad_intersect (struct quaddata *data_inter, struct quaddata *data)
 
int quad_division_check (struct quaddata *data, int kmax)
 
struct quaddata ** quad_divide_data (struct quaddata *data, int kmax, double dmin)
 
int quad_get_points (struct quaddata *data_inter, struct quaddata *data, int MAX)
 

Function Documentation

int quad_add_data ( struct triple point,
struct quaddata data,
double  dmin 
)

Add point to a given data.

Definition at line 143 of file dataquad.c.

References quaddata::n_points, NULL, quaddata::points, r, triple::sm, triple::x, triple::y, and triple::z.

Referenced by quad_divide_data().

int quad_compare ( struct triple point,
struct quaddata data 
)

Return the quadrant the point should be inserted in

Definition at line 98 of file dataquad.c.

References int, quaddata::n_cols, quaddata::n_rows, NE, NULL, NW, SE, SW, triple::x, quaddata::x_orig, quaddata::xmax, triple::y, quaddata::y_orig, and quaddata::ymax.

Referenced by quad_divide_data().

struct quaddata* quad_data_new ( double  x_or,
double  y_or,
double  xmax,
double  ymax,
int  rows,
int  cols,
int  n_points,
int  kmax 
)

Initialize quaddata structure with given arguments

This is a constructor of the quaddata structure and it allocates memory. It also creates (and allocates memory for) the given number of points (given by kmax). The point attributes are set to zero.

Definition at line 62 of file dataquad.c.

References malloc(), quaddata::n_cols, quaddata::n_points, quaddata::n_rows, NULL, quaddata::points, triple::sm, triple::x, quaddata::x_orig, quaddata::xmax, triple::y, quaddata::y_orig, quaddata::ymax, and triple::z.

Referenced by IL_interp_segments_2d(), IL_interp_segments_2d_parallel(), IL_resample_interp_segments_2d(), and quad_divide_data().

struct quaddata** quad_divide_data ( struct quaddata data,
int  kmax,
double  dmin 
)

Divide data into four new ones

Divides data into 4 new datas reinserting data->points in them by calling data function quad_compare() to determine were to insert. Returns array of 4 new datas (allocates memory).

Definition at line 237 of file dataquad.c.

References int, malloc(), quaddata::n_cols, quaddata::n_points, quaddata::n_rows, NE, NULL, NW, quaddata::points, quad_add_data(), quad_compare(), quad_data_new(), SE, SW, quaddata::x_orig, quaddata::xmax, quaddata::y_orig, and quaddata::ymax.

int quad_division_check ( struct quaddata data,
int  kmax 
)

Check if data needs to be divided

Checks if data needs to be divided. If data->points is empty, returns -1; if its not empty but there aren't enough points in data for division returns 0. Otherwise (if its not empty and there are too many points) returns 1.

Returns
1 if division is needed
0 if division is not needed
-1 if there are no points

Definition at line 219 of file dataquad.c.

References quaddata::n_points, NULL, and quaddata::points.

int quad_get_points ( struct quaddata data_inter,
struct quaddata data,
int  MAX 
)

Gets such points from data that lie within region determined by data_inter. Called by tree function region_data().

Definition at line 323 of file dataquad.c.

References l, quaddata::n_points, quaddata::points, triple::sm, triple::x, quaddata::x_orig, quaddata::xmax, triple::y, quaddata::y_orig, quaddata::ymax, and triple::z.

int quad_intersect ( struct quaddata data_inter,
struct quaddata data 
)

Check intersection of two quaddata structures

Checks if region defined by data intersects the region defined by data_inter.

Definition at line 180 of file dataquad.c.

References quaddata::x_orig, quaddata::xmax, quaddata::y_orig, and quaddata::ymax.

struct triple* quad_point_new ( double  x,
double  y,
double  z,
double  sm 
)

Initialize point structure with given arguments

This is a constructor of the point structure and it allocates memory.

Note
Smoothing is part of the point structure

Definition at line 38 of file dataquad.c.

References malloc(), NULL, triple::sm, triple::x, x, triple::y, and triple::z.

Referenced by process_point().