![]() |
OGS
|
A quadtree is a rooted tree in which every internal node has four children. Every node corresponds to a square. (see Computational Geometry - Algorithms and Applications [Mark de Berg, Otfried Cheong, Marc van Kreveld, Mark Overmars] - Chapter 14)
One can instantiate the class template with a point type and a value for the maximal number of points per node. The point-type have to provide the access to its coordinates via operator[] and for debugging purposes operator<<)
Definition at line 38 of file QuadTree.h.
#include <QuadTree.h>
Public Types | |
enum class | Quadrant { NE = 0 , NW , SW , SE } |
Public Member Functions | |
QuadTree (POINT ll, POINT ur, std::size_t max_points_per_leaf) | |
~QuadTree () | |
bool | addPoint (POINT const *pnt) |
void | balance () |
void | getLeafs (std::list< QuadTree< POINT > * > &leaf_list) |
const std::vector< POINT const * > & | getPoints () const |
void | getSquarePoints (POINT &ll, POINT &ur) const |
void | getLeaf (const POINT &pnt, POINT &ll, POINT &ur) |
QuadTree< POINT > const * | getFather () const |
QuadTree< POINT > const * | getChild (Quadrant quadrant) const |
void | getMaxDepth (std::size_t &max_depth) const |
std::size_t | getDepth () const |
Private Member Functions | |
QuadTree< POINT > * | getChild (Quadrant quadrant) |
bool | isLeaf () const |
bool | isChild (QuadTree< POINT > const *const tree, Quadrant quadrant) const |
QuadTree< POINT > * | getNorthNeighbor () const |
QuadTree< POINT > * | getSouthNeighbor () const |
QuadTree< POINT > * | getEastNeighbor () const |
QuadTree< POINT > * | getWestNeighbor () const |
QuadTree (POINT ll, POINT ur, QuadTree *father, std::size_t depth, std::size_t max_points_per_leaf) | |
void | splitNode () |
Static Private Member Functions | |
static bool | needToRefine (QuadTree< POINT > const *const node) |
Private Attributes | |
QuadTree< POINT > * | _father |
std::array< QuadTree< POINT > *, 4 > | _children |
POINT | _ll |
POINT | _ur |
std::size_t | _depth = 0 |
std::vector< POINT const * > | _pnts |
bool | _is_leaf = true |
const std::size_t | _max_points_per_leaf |
|
strong |
Enumerator | |
---|---|
NE | north east |
NW | north west |
SW | south west |
SE | south east |
Definition at line 41 of file QuadTree.h.
|
inline |
This is the constructor for class QuadTree. It takes two points (lower left and the upper right points).
ll | lower left point of the square |
ur | upper right point of the square |
max_points_per_leaf | maximum number of points per leaf |
Definition at line 55 of file QuadTree.h.
References _depth, _father, _ll, _max_points_per_leaf, _ur, DBUG(), and GeoLib::POINT.
Referenced by QuadTree(), balance(), getChild(), getChild(), getEastNeighbor(), getFather(), getLeafs(), getNorthNeighbor(), getSouthNeighbor(), getWestNeighbor(), isChild(), needToRefine(), and splitNode().
|
inline |
|
inlineprivate |
private constructor
ll | lower left point |
ur | upper right point |
father | father in the tree |
depth | depth of the node |
max_points_per_leaf | maximum number of points per leaf |
Definition at line 495 of file QuadTree.h.
References QuadTree(), _depth, _father, _ll, _max_points_per_leaf, _ur, and GeoLib::POINT.
|
inline |
This method adds the given point to the quadtree. If necessary, the quadtree will be extended.
pnt | the point |
Definition at line 101 of file QuadTree.h.
References _children, _is_leaf, _ll, _max_points_per_leaf, _pnts, _ur, GeoLib::POINT, and splitNode().
Referenced by splitNode().
|
inline |
This method balances the quadtree, i.e., it will be inserted nodes such that the depth between neighbored leafs is at most one. If you want to create a mesh (for instance with GMSH) you can use this method to improve the mesh quality. The balance method should be used after inserting all points.
Definition at line 162 of file QuadTree.h.
References QuadTree(), getChild(), getDepth(), getEastNeighbor(), getLeafs(), getNorthNeighbor(), getSouthNeighbor(), getWestNeighbor(), isLeaf(), NE, needToRefine(), NW, SE, splitNode(), and SW.
|
inlineprivate |
Definition at line 339 of file QuadTree.h.
References QuadTree(), and _children.
|
inline |
Definition at line 305 of file QuadTree.h.
References QuadTree(), and _children.
Referenced by balance(), getEastNeighbor(), getNorthNeighbor(), getSouthNeighbor(), getWestNeighbor(), and needToRefine().
|
inline |
Method returns the depth of the current QuadTree node.
Definition at line 336 of file QuadTree.h.
References _depth.
Referenced by balance(), and needToRefine().
|
inlineprivate |
Definition at line 419 of file QuadTree.h.
References QuadTree(), _father, getChild(), isLeaf(), NE, NW, SE, and SW.
Referenced by balance(), and needToRefine().
|
inline |
|
inline |
Definition at line 265 of file QuadTree.h.
References _children, _ll, _ur, getLeaf(), isLeaf(), NE, NW, GeoLib::POINT, SE, and SW.
Referenced by getLeaf().
|
inline |
add all leafs of the quadtree to the list
leaf_list | list of leafs |
Definition at line 242 of file QuadTree.h.
References QuadTree(), _children, and _is_leaf.
Referenced by balance().
|
inline |
Method calculates the maximum depth of the QuadTree instance. It is used within the method GMSHAdaptiveMeshDensity::getSteinerPoints().
max_depth | (input/output) at the entry max_depth contains the maximum depth up to now |
Definition at line 316 of file QuadTree.h.
|
inlineprivate |
Definition at line 351 of file QuadTree.h.
References QuadTree(), _father, getChild(), isLeaf(), NE, NW, SE, and SW.
Referenced by balance(), and needToRefine().
|
inline |
|
inlineprivate |
Definition at line 385 of file QuadTree.h.
References QuadTree(), _father, getChild(), isLeaf(), NE, NW, SE, and SW.
Referenced by balance(), and needToRefine().
|
inline |
Definition at line 259 of file QuadTree.h.
References _ll, _ur, and GeoLib::POINT.
|
inlineprivate |
Definition at line 453 of file QuadTree.h.
References QuadTree(), _father, getChild(), isLeaf(), NE, NW, SE, and SW.
Referenced by balance(), and needToRefine().
|
inlineprivate |
Definition at line 346 of file QuadTree.h.
References QuadTree(), and _children.
|
inlineprivate |
Definition at line 344 of file QuadTree.h.
References _is_leaf.
Referenced by balance(), getEastNeighbor(), getLeaf(), getNorthNeighbor(), getSouthNeighbor(), getWestNeighbor(), and needToRefine().
|
inlinestaticprivate |
Definition at line 550 of file QuadTree.h.
References QuadTree(), getChild(), getDepth(), getEastNeighbor(), getNorthNeighbor(), getSouthNeighbor(), getWestNeighbor(), isLeaf(), NE, NW, SE, and SW.
Referenced by balance().
|
inlineprivate |
Definition at line 508 of file QuadTree.h.
References QuadTree(), _children, _depth, _is_leaf, _ll, _max_points_per_leaf, _pnts, _ur, addPoint(), and GeoLib::POINT.
Referenced by addPoint(), and balance().
|
private |
children are sorted: _children[0] is north east child _children[1] is north west child _children[2] is south west child _children[3] is south east child
Definition at line 638 of file QuadTree.h.
Referenced by ~QuadTree(), addPoint(), getChild(), getChild(), getLeaf(), getLeafs(), getMaxDepth(), isChild(), and splitNode().
|
private |
Definition at line 648 of file QuadTree.h.
Referenced by QuadTree(), QuadTree(), getDepth(), getMaxDepth(), and splitNode().
|
private |
Definition at line 630 of file QuadTree.h.
Referenced by QuadTree(), QuadTree(), getEastNeighbor(), getFather(), getNorthNeighbor(), getSouthNeighbor(), and getWestNeighbor().
|
private |
Definition at line 650 of file QuadTree.h.
Referenced by addPoint(), getLeafs(), isLeaf(), and splitNode().
|
private |
lower left point of the square
Definition at line 643 of file QuadTree.h.
Referenced by QuadTree(), QuadTree(), addPoint(), getLeaf(), getSquarePoints(), and splitNode().
|
private |
maximum number of points per leaf
Definition at line 654 of file QuadTree.h.
Referenced by QuadTree(), QuadTree(), addPoint(), and splitNode().
|
private |
Definition at line 649 of file QuadTree.h.
Referenced by addPoint(), getPoints(), and splitNode().
|
private |
upper right point of the square
Definition at line 647 of file QuadTree.h.
Referenced by QuadTree(), QuadTree(), addPoint(), getLeaf(), getSquarePoints(), and splitNode().