![]() |
deal.II version GIT relicensing-6759-gba22b5843e 2026-09-18 10:10:01+00:00
|
#include <deal.II/numerics/rtree.h>
A depth-first visitor for RTree that invokes user-provided lambdas.
For every RTree object, we distinguish between the root node, the internal nodes (i.e., nodes that have other nodes as children) and leaf nodes (i.e., nodes that store the actual leaf values). During the traversal of the tree, we may want to hook into the traversal at different levels of the hierarchy. For example, we may want to print the bounding box of each internal node, then print the bounding box of each leaf node, and then finally print each element stored in the leaf nodes.
This is a convenience visitor for the RTree data structure that forwards each traversal event to four (optional) independent callables:
The traversal is depth-first: starting from the root, internal nodes are visited, their children are recursed immediately, and leaf elements are delivered in the order stored inside each leaf node. This allows users to plug lambdas directly without defining a specific visitor class.
Example (taken from one of the tests): build a tree from 8 random points, then hook all four callbacks:
A possible output (indices and boxes depend on the random points) is:
This structure exists to make it easy to instrument or analyze an rtree (bounding boxes, counts, aggregations, debug prints, etc.) without writing the boilerplate of a custom visitor type every time.
Users can call directly the function visit_rtree() (see below) instead of instantiating this class.
Public Types | |
| using | internal_node_type = typename boost::geometry::index::detail::rtree::internal_node< typename RTreeView< RTreeType >::value_type, typename RTreeView< RTreeType >::options_type::parameters_type, typename RTreeView< RTreeType >::box_type, typename RTreeView< RTreeType >::allocators_type, typename RTreeView< RTreeType >::options_type::node_tag >::type |
| using | leaf_type = typename boost::geometry::index::detail::rtree::leaf< typename RTreeView< RTreeType >::value_type, typename RTreeView< RTreeType >::options_type::parameters_type, typename RTreeView< RTreeType >::box_type, typename RTreeView< RTreeType >::allocators_type, typename RTreeView< RTreeType >::options_type::node_tag >::type |
| using | value_type = typename RTreeType::value_type |
| using | indexable_type = typename RTreeType::indexable_type |
| using | translator_type = typename RTreeView< RTreeType >::translator_type |
| using | empty_visitor = internal::RTreeImplementation::EmptyVisitor |
Public Member Functions | |
| void | operator() (internal_node_type &node) |
| void | operator() (leaf_type &leaf) |
| RTreeFunctionalVisitor (const RTreeType &tree, InternalVisitor internal_node_visitor={}, LeafVisitor leaf_visitor={}, ElementVisitor element_visitor={}, IndexableVisitor indexable_visitor={}) | |
Public Attributes | |
| InternalVisitor | internal_node_visitor |
| LeafVisitor | leaf_visitor |
| ElementVisitor | element_visitor |
| IndexableVisitor | indexable_visitor |
| std::size_t | current_level |
| translator_type | translator |
Static Public Attributes | |
| static constexpr unsigned int | dim |
| static constexpr bool | has_internal_visitor |
| static constexpr bool | has_leaf_visitor |
| static constexpr bool | has_element_visitor |
| static constexpr bool | has_indexable_visitor |
| using RTreeFunctionalVisitor< RTreeType, InternalVisitor, LeafVisitor, ElementVisitor, IndexableVisitor >::internal_node_type = typename boost::geometry::index::detail::rtree::internal_node< typename RTreeView<RTreeType>::value_type, typename RTreeView<RTreeType>::options_type::parameters_type, typename RTreeView<RTreeType>::box_type, typename RTreeView<RTreeType>::allocators_type, typename RTreeView<RTreeType>::options_type::node_tag>::type |
| using RTreeFunctionalVisitor< RTreeType, InternalVisitor, LeafVisitor, ElementVisitor, IndexableVisitor >::leaf_type = typename boost::geometry::index::detail::rtree::leaf< typename RTreeView<RTreeType>::value_type, typename RTreeView<RTreeType>::options_type::parameters_type, typename RTreeView<RTreeType>::box_type, typename RTreeView<RTreeType>::allocators_type, typename RTreeView<RTreeType>::options_type::node_tag>::type |
| using RTreeFunctionalVisitor< RTreeType, InternalVisitor, LeafVisitor, ElementVisitor, IndexableVisitor >::value_type = typename RTreeType::value_type |
| using RTreeFunctionalVisitor< RTreeType, InternalVisitor, LeafVisitor, ElementVisitor, IndexableVisitor >::indexable_type = typename RTreeType::indexable_type |
| using RTreeFunctionalVisitor< RTreeType, InternalVisitor, LeafVisitor, ElementVisitor, IndexableVisitor >::translator_type = typename RTreeView<RTreeType>::translator_type |
| using RTreeFunctionalVisitor< RTreeType, InternalVisitor, LeafVisitor, ElementVisitor, IndexableVisitor >::empty_visitor = internal::RTreeImplementation::EmptyVisitor |
| RTreeFunctionalVisitor< RTreeType, InternalVisitor, LeafVisitor, ElementVisitor, IndexableVisitor >::RTreeFunctionalVisitor | ( | const RTreeType & | tree, |
| InternalVisitor | internal_node_visitor = {}, |
||
| LeafVisitor | leaf_visitor = {}, |
||
| ElementVisitor | element_visitor = {}, |
||
| IndexableVisitor | indexable_visitor = {} |
||
| ) |
Constructor wiring optional callbacks and starting a traversal of the provided rtree through apply_visitor().
You may call this constructor directly, but the preferred way is to use the visit_rtree() function below.
| void RTreeFunctionalVisitor< RTreeType, InternalVisitor, LeafVisitor, ElementVisitor, IndexableVisitor >::operator() | ( | internal_node_type & | node | ) |
Implements the internal-node branch of the boost::geometry::index::detail::rtree::visitor interface so this functor can be passed to apply_visitor() when traversing an rtree.
| void RTreeFunctionalVisitor< RTreeType, InternalVisitor, LeafVisitor, ElementVisitor, IndexableVisitor >::operator() | ( | leaf_type & | leaf | ) |
Implements the leaf branch of the boost::geometry::index::detail::rtree::visitor interface so this functor can be passed to apply_visitor() when traversing an rtree.
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
| InternalVisitor RTreeFunctionalVisitor< RTreeType, InternalVisitor, LeafVisitor, ElementVisitor, IndexableVisitor >::internal_node_visitor |
Optional callback invoked once per internal node, before descending into its children.
This function is only called when the child is an internal_node_type. If the child is a leaf_type, the leaf_visitor is called instead.
Arguments:
n_levels(tree)-1),| LeafVisitor RTreeFunctionalVisitor< RTreeType, InternalVisitor, LeafVisitor, ElementVisitor, IndexableVisitor >::leaf_visitor |
| ElementVisitor RTreeFunctionalVisitor< RTreeType, InternalVisitor, LeafVisitor, ElementVisitor, IndexableVisitor >::element_visitor |
| IndexableVisitor RTreeFunctionalVisitor< RTreeType, InternalVisitor, LeafVisitor, ElementVisitor, IndexableVisitor >::indexable_visitor |
Optional callback invoked for each value after translating it to the corresponding indexable type via the tree's indexable getter. If the tree is built without an indexable getter, this function is in fact identical to the element_visitor, and therefore both can be used interchangeably.
Arguments:
| std::size_t RTreeFunctionalVisitor< RTreeType, InternalVisitor, LeafVisitor, ElementVisitor, IndexableVisitor >::current_level |
| translator_type RTreeFunctionalVisitor< RTreeType, InternalVisitor, LeafVisitor, ElementVisitor, IndexableVisitor >::translator |