16#ifndef dealii_numerics_rtree_h
17#define dealii_numerics_rtree_h
29#include <boost/geometry/algorithms/distance.hpp>
30#include <boost/geometry/index/rtree.hpp>
31#include <boost/geometry/strategies/strategies.hpp>
141template <
typename LeafType,
142 typename IndexType = boost::geometry::index::linear<16>,
143 typename IndexableGetter =
146 boost::geometry::index::rtree<LeafType, IndexType, IndexableGetter>;
155template <
typename IndexType = boost::geometry::index::linear<16>,
156 typename LeafTypeIterator,
157 typename IndexableGetter = boost::geometry::index::indexable<
158 typename LeafTypeIterator::value_type>>
160pack_rtree(
const LeafTypeIterator &begin,
const LeafTypeIterator &end);
172template <
typename IndexType = boost::geometry::index::linear<16>,
173 typename ContainerType,
174 typename IndexableGetter = boost::geometry::index::indexable<
175 typename ContainerType::value_type>>
197template <
typename Container>
216 using size_t =
typename Container::size_type;
277template <
typename IndexType = boost::geometry::index::linear<16>,
278 typename ContainerType>
279RTree<
typename ContainerType::size_type,
296template <
typename Value,
302 :
public boost::geometry::index::detail::rtree::visitor<
304 typename Options::parameters_type,
307 typename Options::node_tag,
323 typename boost::geometry::index::detail::rtree::internal_node<
325 typename Options::parameters_type,
328 typename Options::node_tag>::type;
333 using Leaf =
typename boost::geometry::index::detail::rtree::leaf<
335 typename Options::parameters_type,
338 typename Options::node_tag>::type;
371 std::vector<BoundingBox<boost::geometry::dimension<Box>::value>> &
boxes;
425template <
typename Rtree>
427 boost::geometry::dimension<typename Rtree::indexable_type>::value>>
435template <
typename IndexType,
436 typename LeafTypeIterator,
437 typename IndexableGetter>
439pack_rtree(
const LeafTypeIterator &begin,
const LeafTypeIterator &end)
441 return RTree<
typename LeafTypeIterator::value_type,
443 IndexableGetter>(begin, end);
448template <
typename IndexType,
typename ContainerType,
typename IndexableGetter>
452 return pack_rtree<IndexType,
decltype(container.begin()), IndexableGetter>(
453 container.begin(), container.end());
458template <
typename IndexType,
typename ContainerType>
459RTree<
typename ContainerType::size_type,
465 typename ContainerType::size_type>
466 indices(0, container.size());
467 return RTree<
typename ContainerType::size_type,
478template <
typename Value,
485 const Translator & translator,
486 const unsigned int target_level,
487 std::vector<
BoundingBox<boost::geometry::dimension<Box>::value>> &boxes)
488 : translator(translator)
490 , target_level(target_level)
496template <
typename Value,
506 typename boost::geometry::index::detail::rtree::elements_type<
509 const auto &elements = boost::geometry::index::detail::rtree::elements(node);
511 if (
level == target_level)
513 const auto offset = boxes.size();
514 boxes.resize(offset + elements.size());
516 unsigned int i = offset;
517 for (
typename ElmentsType::const_iterator it = elements.begin();
518 it != elements.end();
521 boost::geometry::convert(it->first, boxes[i]);
527 const size_t level_backup =
level;
530 for (
typename ElmentsType::const_iterator it = elements.begin();
531 it != elements.end();
534 boost::geometry::index::detail::rtree::apply_visitor(*
this, *it->second);
537 level = level_backup;
540template <
typename Value,
552template <
typename Rtree>
554 boost::geometry::dimension<typename Rtree::indexable_type>::value>>
557 constexpr unsigned int dim =
558 boost::geometry::dimension<typename Rtree::indexable_type>::value;
561 boost::geometry::index::detail::rtree::utilities::view<Rtree>;
564 std::vector<BoundingBox<dim>> boxes;
566 if (rtv.depth() == 0)
572 boost::geometry::convert(tree.bounds(), boxes[0]);
576 const unsigned int target_level =
577 std::min<unsigned int>(
level, rtv.depth() - 1);
580 typename RtreeView::options_type,
581 typename RtreeView::translator_type,
582 typename RtreeView::box_type,
583 typename RtreeView::allocators_type>
584 extract_level_visitor(rtv.translator(), target_level, boxes);
585 rtv.apply_visitor(extract_level_visitor);
593template <
class Rtree>
595n_levels(
const Rtree &tree)
597 boost::geometry::index::detail::rtree::utilities::view<Rtree> rtv(tree);
result_type operator()(size_t i) const
const Container & container
typename Container::size_type size_t
typename boost::geometry::index::indexable< typename Container::value_type > IndexableGetter
typename IndexableGetter::result_type result_type
IndexableGetterFromIndices(Container const &c)
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
#define DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_ENABLE_EXTRA_DIAGNOSTICS
boost::integer_range< IncrementableType > iota_view
std::vector< BoundingBox< boost::geometry::dimension< typename Rtree::indexable_type >::value > > extract_rtree_level(const Rtree &tree, const unsigned int level)
boost::geometry::index::rtree< LeafType, IndexType, IndexableGetter > RTree
RTree< typename LeafTypeIterator::value_type, IndexType, IndexableGetter > pack_rtree(const LeafTypeIterator &begin, const LeafTypeIterator &end)
RTree< typename ContainerType::size_type, IndexType, IndexableGetterFromIndices< ContainerType > > pack_rtree_of_indices(const ContainerType &container)