GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-bea8435a9e
qtree.h File Reference

Go to the source code of this file.

Data Structures

struct  multfunc
 
struct  tree_info
 
struct  multtree
 

Macros

#define VOID_T   char
 

Functions

struct multfuncMT_functions_new (int(*)(struct triple *, struct quaddata *), struct quaddata **(*)(struct quaddata *, int, double), int(*)(struct triple *, struct quaddata *, double), int(*)(struct quaddata *, struct quaddata *), int(*)(struct quaddata *, int), int(*)(struct quaddata *, struct quaddata *, int))
 
struct tree_infoMT_tree_info_new (struct multtree *, struct multfunc *, double, int)
 
struct multtreeMT_tree_new (struct quaddata *, struct multtree **, struct multtree *, int)
 
int MT_insert (struct triple *, struct tree_info *, struct multtree *, int)
 
int MT_divide (struct tree_info *, struct multtree *, int)
 
int MT_region_data (struct tree_info *, struct multtree *, struct quaddata *, int, int)
 

Macro Definition Documentation

◆ VOID_T

#define VOID_T   char

Definition at line 28 of file qtree.h.

Function Documentation

◆ MT_divide()

int MT_divide ( struct tree_info info,
struct multtree tree,
int  n_leafs 
)

Divide a tree

Divides the tree by calling one of tree's functions (divide_data()) and returns the result of divide_data()

Definition at line 154 of file qtree.c.

References multtree::data, multfunc::divide_data, tree_info::dmin, tree_info::functions, tree_info::kmax, multtree::leafs, malloc(), MT_tree_new(), and NULL.

Referenced by MT_insert().

◆ MT_functions_new()

struct multfunc* MT_functions_new ( int(*)(struct triple *, struct quaddata *)  ,
struct quaddata **  *)(struct quaddata *, int, double,
int(*)(struct triple *, struct quaddata *, double)  ,
int(*)(struct quaddata *, struct quaddata *)  ,
int(*)(struct quaddata *, int)  ,
int(*)(struct quaddata *, struct quaddata *, int)   
)

◆ MT_insert()

int MT_insert ( struct triple point,
struct tree_info info,
struct multtree tree,
int  n_leafs 
)

First checks for dividing cond. (if n_points>=KMAX) and tree is a leaf by calling one of tree's functions (division_check()). If tree is not a leaf (is a node) uses function compare to determine into which "son" we need to insert the point and calls MT_insert() with this son as a n argument.

If TREE is a leaf but we don't need to divide it (n_points<KMAX) then calls function add_data(point, ...) to add point to the data of tree and returns the result of add_data() (which returns 1 if the point is inserted and 0 if its ignored (when its too dense)).

If division_check() returns true, calls MT_divide() and then calls MT_insert() to insert the point into divided tree and returns the result of MT_divide().

Definition at line 103 of file qtree.c.

References multfunc::add_data, multfunc::compare, multtree::data, multfunc::division_check, tree_info::dmin, tree_info::functions, tree_info::kmax, multtree::leafs, MT_divide(), and NULL.

◆ MT_region_data()

int MT_region_data ( struct tree_info info,
struct multtree tree,
struct quaddata data,
int  MAX,
int  n_leafs 
)

Get points inside a region from a tree

Gets points inside the region defined by DATA from TREE and adds them to DATA. If the number of eligible point is more than MAX returns MAX+1 otherwise returns number of points added to DATA.

Uses tree's functions intersect() to find leafs that intersect given region and get_points() to get points from such leafs.

Parameters
MAXmax number of points we can add (KMAX2)

Definition at line 186 of file qtree.c.

◆ MT_tree_info_new()

struct tree_info* MT_tree_info_new ( struct multtree root,
struct multfunc functions,
double  dmin,
int  kmax 
)

Initializes tree_info using given arguments

Definition at line 55 of file qtree.c.

References tree_info::dmin, tree_info::functions, tree_info::kmax, malloc(), NULL, and tree_info::root.

◆ MT_tree_new()

struct multtree* MT_tree_new ( struct quaddata data,
struct multtree **  leafs,
struct multtree parent,
int  multant 
)

Initializes multtree using given arguments

Definition at line 72 of file qtree.c.

Referenced by MT_divide().