GRASS GIS 8 Programmer's Manual
8.5.0dev(2024)-36359e2344
|
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <grass/dataquad.h>
#include <grass/qtree.h>
Go to the source code of this file.
Functions | |
struct multfunc * | MT_functions_new (int(*compare)(struct triple *, struct quaddata *), struct quaddata **(*divide_data)(struct quaddata *, int, double), int(*add_data)(struct triple *, struct quaddata *, double), int(*intersect)(struct quaddata *, struct quaddata *), int(*division_check)(struct quaddata *, int), int(*get_points)(struct quaddata *, struct quaddata *, int)) |
struct tree_info * | MT_tree_info_new (struct multtree *root, struct multfunc *functions, double dmin, int kmax) |
struct multtree * | MT_tree_new (struct quaddata *data, struct multtree **leafs, struct multtree *parent, int multant) |
int | MT_insert (struct triple *point, struct tree_info *info, struct multtree *tree, int n_leafs) |
int | MT_divide (struct tree_info *info, struct multtree *tree, int n_leafs) |
int | MT_region_data (struct tree_info *info, struct multtree *tree, struct quaddata *data, int MAX, int n_leafs) |
Definition in file qtree.c.
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().
struct multfunc* MT_functions_new | ( | int(*)(struct triple *, struct quaddata *) | compare, |
struct quaddata **(*)(struct quaddata *, int, double) | divide_data, | ||
int(*)(struct triple *, struct quaddata *, double) | add_data, | ||
int(*)(struct quaddata *, struct quaddata *) | intersect, | ||
int(*)(struct quaddata *, int) | division_check, | ||
int(*)(struct quaddata *, struct quaddata *, int) | get_points | ||
) |
Initializes multfunc structure with given arguments
Definition at line 32 of file qtree.c.
References multfunc::add_data, compare(), multfunc::compare, multfunc::divide_data, multfunc::division_check, multfunc::get_points, multfunc::intersect, malloc(), and NULL.
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.
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.
MAX | max number of points we can add (KMAX2) |
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.