![]() |
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 37 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 > *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 40 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 53 of file QuadTree.h.
References GeoLib::QuadTree< POINT >::_depth, GeoLib::QuadTree< POINT >::_ll, GeoLib::QuadTree< POINT >::_max_points_per_leaf, GeoLib::QuadTree< POINT >::_ur, and DBUG().
|
inline |
destructor
Definition at line 85 of file QuadTree.h.
References GeoLib::QuadTree< POINT >::_children.
|
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 494 of file QuadTree.h.
|
inline |
This method adds the given point to the quadtree. If necessary, the quadtree will be extended.
pnt | the point |
Definition at line 99 of file QuadTree.h.
References GeoLib::QuadTree< POINT >::_children, GeoLib::QuadTree< POINT >::_is_leaf, GeoLib::QuadTree< POINT >::_ll, GeoLib::QuadTree< POINT >::_max_points_per_leaf, GeoLib::QuadTree< POINT >::_pnts, GeoLib::QuadTree< POINT >::_ur, and GeoLib::QuadTree< POINT >::splitNode().
Referenced by FileIO::GMSH::GMSHAdaptiveMeshDensity::addPoints(), and GeoLib::QuadTree< POINT >::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 163 of file QuadTree.h.
References GeoLib::QuadTree< POINT >::getChild(), GeoLib::QuadTree< POINT >::getDepth(), GeoLib::QuadTree< POINT >::getEastNeighbor(), GeoLib::QuadTree< POINT >::getLeafs(), GeoLib::QuadTree< POINT >::getNorthNeighbor(), GeoLib::QuadTree< POINT >::getSouthNeighbor(), GeoLib::QuadTree< POINT >::getWestNeighbor(), GeoLib::QuadTree< POINT >::isLeaf(), GeoLib::QuadTree< POINT >::NE, GeoLib::QuadTree< POINT >::needToRefine(), GeoLib::QuadTree< POINT >::NW, GeoLib::QuadTree< POINT >::SE, GeoLib::QuadTree< POINT >::splitNode(), and GeoLib::QuadTree< POINT >::SW.
Referenced by FileIO::GMSH::GMSHAdaptiveMeshDensity::addPoints().
|
inlineprivate |
Definition at line 337 of file QuadTree.h.
References GeoLib::QuadTree< POINT >::_children.
|
inline |
Definition at line 304 of file QuadTree.h.
References GeoLib::QuadTree< POINT >::_children.
Referenced by GeoLib::QuadTree< POINT >::balance(), GeoLib::QuadTree< POINT >::getEastNeighbor(), GeoLib::QuadTree< POINT >::getNorthNeighbor(), GeoLib::QuadTree< POINT >::getSouthNeighbor(), GeoLib::QuadTree< POINT >::getWestNeighbor(), and GeoLib::QuadTree< POINT >::needToRefine().
|
inline |
Method returns the depth of the current QuadTree node.
Definition at line 334 of file QuadTree.h.
References GeoLib::QuadTree< POINT >::_depth.
Referenced by GeoLib::QuadTree< POINT >::balance(), and GeoLib::QuadTree< POINT >::needToRefine().
|
inlineprivate |
Definition at line 417 of file QuadTree.h.
References GeoLib::QuadTree< POINT >::_father, GeoLib::QuadTree< POINT >::getChild(), GeoLib::QuadTree< POINT >::isLeaf(), GeoLib::QuadTree< POINT >::NE, GeoLib::QuadTree< POINT >::NW, GeoLib::QuadTree< POINT >::SE, and GeoLib::QuadTree< POINT >::SW.
Referenced by GeoLib::QuadTree< POINT >::balance(), and GeoLib::QuadTree< POINT >::needToRefine().
|
inline |
|
inline |
Definition at line 266 of file QuadTree.h.
References GeoLib::QuadTree< POINT >::_children, GeoLib::QuadTree< POINT >::_ll, GeoLib::QuadTree< POINT >::_ur, GeoLib::QuadTree< POINT >::isLeaf(), GeoLib::QuadTree< POINT >::NE, GeoLib::QuadTree< POINT >::NW, GeoLib::QuadTree< POINT >::SE, and GeoLib::QuadTree< POINT >::SW.
Referenced by FileIO::GMSH::GMSHAdaptiveMeshDensity::getMeshDensityAtPoint(), and FileIO::GMSH::GMSHAdaptiveMeshDensity::getMeshDensityAtStation().
|
inline |
add all leafs of the quadtree to the list
leaf_list | list of leafs |
Definition at line 243 of file QuadTree.h.
References GeoLib::QuadTree< POINT >::_children, and GeoLib::QuadTree< POINT >::_is_leaf.
Referenced by GeoLib::QuadTree< POINT >::balance(), FileIO::GMSH::GMSHAdaptiveMeshDensity::getQuadTreeGeometry(), and FileIO::GMSH::GMSHAdaptiveMeshDensity::getSteinerPoints().
|
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 314 of file QuadTree.h.
References GeoLib::QuadTree< POINT >::_children, and GeoLib::QuadTree< POINT >::_depth.
Referenced by FileIO::GMSH::GMSHAdaptiveMeshDensity::getSteinerPoints().
|
inlineprivate |
Definition at line 349 of file QuadTree.h.
References GeoLib::QuadTree< POINT >::_father, GeoLib::QuadTree< POINT >::getChild(), GeoLib::QuadTree< POINT >::isLeaf(), GeoLib::QuadTree< POINT >::NE, GeoLib::QuadTree< POINT >::NW, GeoLib::QuadTree< POINT >::SE, and GeoLib::QuadTree< POINT >::SW.
Referenced by GeoLib::QuadTree< POINT >::balance(), and GeoLib::QuadTree< POINT >::needToRefine().
|
inline |
|
inlineprivate |
Definition at line 383 of file QuadTree.h.
References GeoLib::QuadTree< POINT >::_father, GeoLib::QuadTree< POINT >::getChild(), GeoLib::QuadTree< POINT >::isLeaf(), GeoLib::QuadTree< POINT >::NE, GeoLib::QuadTree< POINT >::NW, GeoLib::QuadTree< POINT >::SE, and GeoLib::QuadTree< POINT >::SW.
Referenced by GeoLib::QuadTree< POINT >::balance(), and GeoLib::QuadTree< POINT >::needToRefine().
|
inline |
Definition at line 260 of file QuadTree.h.
References GeoLib::QuadTree< POINT >::_ll, and GeoLib::QuadTree< POINT >::_ur.
|
inlineprivate |
Definition at line 451 of file QuadTree.h.
References GeoLib::QuadTree< POINT >::_father, GeoLib::QuadTree< POINT >::getChild(), GeoLib::QuadTree< POINT >::isLeaf(), GeoLib::QuadTree< POINT >::NE, GeoLib::QuadTree< POINT >::NW, GeoLib::QuadTree< POINT >::SE, and GeoLib::QuadTree< POINT >::SW.
Referenced by GeoLib::QuadTree< POINT >::balance(), and GeoLib::QuadTree< POINT >::needToRefine().
|
inlineprivate |
Definition at line 344 of file QuadTree.h.
References GeoLib::QuadTree< POINT >::_children.
|
inlineprivate |
Definition at line 342 of file QuadTree.h.
References GeoLib::QuadTree< POINT >::_is_leaf.
Referenced by GeoLib::QuadTree< POINT >::balance(), GeoLib::QuadTree< POINT >::getEastNeighbor(), GeoLib::QuadTree< POINT >::getLeaf(), GeoLib::QuadTree< POINT >::getNorthNeighbor(), GeoLib::QuadTree< POINT >::getSouthNeighbor(), GeoLib::QuadTree< POINT >::getWestNeighbor(), and GeoLib::QuadTree< POINT >::needToRefine().
|
inlinestaticprivate |
Definition at line 544 of file QuadTree.h.
References GeoLib::QuadTree< POINT >::getChild(), GeoLib::QuadTree< POINT >::getDepth(), GeoLib::QuadTree< POINT >::getEastNeighbor(), GeoLib::QuadTree< POINT >::getNorthNeighbor(), GeoLib::QuadTree< POINT >::getSouthNeighbor(), GeoLib::QuadTree< POINT >::getWestNeighbor(), GeoLib::QuadTree< POINT >::isLeaf(), GeoLib::QuadTree< POINT >::NE, GeoLib::QuadTree< POINT >::NW, GeoLib::QuadTree< POINT >::SE, and GeoLib::QuadTree< POINT >::SW.
Referenced by GeoLib::QuadTree< POINT >::balance().
|
inlineprivate |
Definition at line 507 of file QuadTree.h.
References GeoLib::QuadTree< POINT >::_children, GeoLib::QuadTree< POINT >::_depth, GeoLib::QuadTree< POINT >::_is_leaf, GeoLib::QuadTree< POINT >::_ll, GeoLib::QuadTree< POINT >::_max_points_per_leaf, GeoLib::QuadTree< POINT >::_pnts, GeoLib::QuadTree< POINT >::_ur, GeoLib::QuadTree< POINT >::addPoint(), and GeoLib::POINT.
Referenced by GeoLib::QuadTree< POINT >::addPoint(), and GeoLib::QuadTree< POINT >::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 632 of file QuadTree.h.
Referenced by GeoLib::QuadTree< POINT >::~QuadTree(), GeoLib::QuadTree< POINT >::addPoint(), GeoLib::QuadTree< POINT >::getChild(), GeoLib::QuadTree< POINT >::getLeaf(), GeoLib::QuadTree< POINT >::getLeafs(), GeoLib::QuadTree< POINT >::getMaxDepth(), GeoLib::QuadTree< POINT >::isChild(), and GeoLib::QuadTree< POINT >::splitNode().
|
private |
Definition at line 642 of file QuadTree.h.
Referenced by GeoLib::QuadTree< POINT >::QuadTree(), GeoLib::QuadTree< POINT >::getDepth(), GeoLib::QuadTree< POINT >::getMaxDepth(), and GeoLib::QuadTree< POINT >::splitNode().
|
private |
|
private |
Definition at line 644 of file QuadTree.h.
Referenced by GeoLib::QuadTree< POINT >::addPoint(), GeoLib::QuadTree< POINT >::getLeafs(), GeoLib::QuadTree< POINT >::isLeaf(), and GeoLib::QuadTree< POINT >::splitNode().
|
private |
lower left point of the square
Definition at line 637 of file QuadTree.h.
Referenced by GeoLib::QuadTree< POINT >::QuadTree(), GeoLib::QuadTree< POINT >::addPoint(), GeoLib::QuadTree< POINT >::getLeaf(), GeoLib::QuadTree< POINT >::getSquarePoints(), and GeoLib::QuadTree< POINT >::splitNode().
|
private |
maximum number of points per leaf
Definition at line 648 of file QuadTree.h.
Referenced by GeoLib::QuadTree< POINT >::QuadTree(), GeoLib::QuadTree< POINT >::addPoint(), and GeoLib::QuadTree< POINT >::splitNode().
|
private |
Definition at line 643 of file QuadTree.h.
Referenced by GeoLib::QuadTree< POINT >::addPoint(), GeoLib::QuadTree< POINT >::getPoints(), and GeoLib::QuadTree< POINT >::splitNode().
|
private |
upper right point of the square
Definition at line 641 of file QuadTree.h.
Referenced by GeoLib::QuadTree< POINT >::QuadTree(), GeoLib::QuadTree< POINT >::addPoint(), GeoLib::QuadTree< POINT >::getLeaf(), GeoLib::QuadTree< POINT >::getSquarePoints(), and GeoLib::QuadTree< POINT >::splitNode().