![]() |
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 27 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 30 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 44 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 484 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 90 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 151 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 328 of file QuadTree.h.
References QuadTree(), and _children.
|
inline |
Definition at line 294 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 325 of file QuadTree.h.
References _depth.
Referenced by balance(), and needToRefine().
|
inlineprivate |
Definition at line 408 of file QuadTree.h.
References QuadTree(), _father, getChild(), isLeaf(), NE, NW, SE, and SW.
Referenced by balance(), and needToRefine().
|
inline |
|
inline |
Definition at line 254 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 231 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 305 of file QuadTree.h.
|
inlineprivate |
Definition at line 340 of file QuadTree.h.
References QuadTree(), _father, getChild(), isLeaf(), NE, NW, SE, and SW.
Referenced by balance(), and needToRefine().
|
inline |
|
inlineprivate |
Definition at line 374 of file QuadTree.h.
References QuadTree(), _father, getChild(), isLeaf(), NE, NW, SE, and SW.
Referenced by balance(), and needToRefine().
|
inline |
Definition at line 248 of file QuadTree.h.
References _ll, _ur, and GeoLib::POINT.
|
inlineprivate |
Definition at line 442 of file QuadTree.h.
References QuadTree(), _father, getChild(), isLeaf(), NE, NW, SE, and SW.
Referenced by balance(), and needToRefine().
|
inlineprivate |
Definition at line 335 of file QuadTree.h.
References QuadTree(), and _children.
|
inlineprivate |
Definition at line 333 of file QuadTree.h.
References _is_leaf.
Referenced by balance(), getEastNeighbor(), getLeaf(), getNorthNeighbor(), getSouthNeighbor(), getWestNeighbor(), and needToRefine().
|
inlinestaticprivate |
Definition at line 539 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 497 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 627 of file QuadTree.h.
Referenced by ~QuadTree(), addPoint(), getChild(), getChild(), getLeaf(), getLeafs(), getMaxDepth(), isChild(), and splitNode().
|
private |
Definition at line 637 of file QuadTree.h.
Referenced by QuadTree(), QuadTree(), getDepth(), getMaxDepth(), and splitNode().
|
private |
Definition at line 619 of file QuadTree.h.
Referenced by QuadTree(), QuadTree(), getEastNeighbor(), getFather(), getNorthNeighbor(), getSouthNeighbor(), and getWestNeighbor().
|
private |
Definition at line 639 of file QuadTree.h.
Referenced by addPoint(), getLeafs(), isLeaf(), and splitNode().
|
private |
lower left point of the square
Definition at line 632 of file QuadTree.h.
Referenced by QuadTree(), QuadTree(), addPoint(), getLeaf(), getSquarePoints(), and splitNode().
|
private |
maximum number of points per leaf
Definition at line 643 of file QuadTree.h.
Referenced by QuadTree(), QuadTree(), addPoint(), and splitNode().
|
private |
Definition at line 638 of file QuadTree.h.
Referenced by addPoint(), getPoints(), and splitNode().
|
private |
upper right point of the square
Definition at line 636 of file QuadTree.h.
Referenced by QuadTree(), QuadTree(), addPoint(), getLeaf(), getSquarePoints(), and splitNode().