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 |
|
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 GeoLib::QuadTree< POINT >::_depth, GeoLib::QuadTree< POINT >::_ll, GeoLib::QuadTree< POINT >::_max_points_per_leaf, GeoLib::QuadTree< POINT >::_ur, and DBUG().
Referenced by GeoLib::QuadTree< POINT >::splitNode().
|
inline |
destructor
Definition at line 87 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 495 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 101 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 162 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 339 of file QuadTree.h.
References GeoLib::QuadTree< POINT >::_children.
|
inline |
Definition at line 305 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 336 of file QuadTree.h.
References GeoLib::QuadTree< POINT >::_depth.
Referenced by GeoLib::QuadTree< POINT >::balance(), and GeoLib::QuadTree< POINT >::needToRefine().
|
inlineprivate |
Definition at line 419 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 265 of file QuadTree.h.
References GeoLib::QuadTree< POINT >::_children, GeoLib::QuadTree< POINT >::_ll, GeoLib::QuadTree< POINT >::_ur, GeoLib::QuadTree< POINT >::getLeaf(), 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 >::getLeaf(), 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 242 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 316 of file QuadTree.h.
References GeoLib::QuadTree< POINT >::_children, and GeoLib::QuadTree< POINT >::_depth.
Referenced by FileIO::GMSH::GMSHAdaptiveMeshDensity::getSteinerPoints().
|
inlineprivate |
Definition at line 351 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 385 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 259 of file QuadTree.h.
References GeoLib::QuadTree< POINT >::_ll, and GeoLib::QuadTree< POINT >::_ur.
|
inlineprivate |
Definition at line 453 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 346 of file QuadTree.h.
References GeoLib::QuadTree< POINT >::_children.
|
inlineprivate |
Definition at line 344 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 550 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 508 of file QuadTree.h.
References GeoLib::QuadTree< POINT >::QuadTree(), 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 638 of file QuadTree.h.
Referenced by GeoLib::QuadTree< POINT >::~QuadTree(), GeoLib::QuadTree< POINT >::addPoint(), GeoLib::QuadTree< POINT >::getChild(), 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 648 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 650 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 643 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 654 of file QuadTree.h.
Referenced by GeoLib::QuadTree< POINT >::QuadTree(), GeoLib::QuadTree< POINT >::addPoint(), and GeoLib::QuadTree< POINT >::splitNode().
|
private |
Definition at line 649 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 647 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().