16 #ifndef dealii_numerics_rtree_h
17 #define dealii_numerics_rtree_h
28 #include <boost/geometry/index/rtree.hpp>
29 #include <boost/geometry/strategies/strategies.hpp>
132 template <
typename LeafType,
133 typename IndexType = boost::geometry::index::linear<16>>
134 using RTree = boost::geometry::index::rtree<LeafType, IndexType>;
146 template <
typename IndexType = boost::geometry::index::linear<16>,
147 typename LeafTypeIterator>
163 template <
typename IndexType = boost::geometry::index::linear<16>,
164 typename ContainerType>
182 template <
typename Value,
188 :
public boost::geometry::index::detail::rtree::visitor<
190 typename Options::parameters_type,
193 typename Options::node_tag,
209 typename boost::geometry::index::detail::rtree::internal_node<
211 typename Options::parameters_type,
214 typename Options::node_tag>::type;
219 using Leaf =
typename boost::geometry::index::detail::rtree::leaf<
221 typename Options::parameters_type,
224 typename Options::node_tag>::type;
313 template <
typename Rtree>
322 template <
typename IndexType,
typename LeafTypeIterator>
331 template <
typename IndexType,
typename ContainerType>
335 return pack_rtree<IndexType>(container.begin(), container.end());
340 template <
typename Value,
347 const Translator & translator,
348 const unsigned int target_level,
350 : translator(translator)
352 , target_level(target_level)
358 template <
typename Value,
368 typename boost::geometry::index::detail::rtree::elements_type<
371 const auto &elements = boost::geometry::index::detail::rtree::elements(node);
373 if (
level == target_level)
375 const auto offset = boxes.size();
376 boxes.resize(offset + elements.size());
378 unsigned int i = offset;
379 for (
typename ElmentsType::const_iterator it = elements.begin();
380 it != elements.end();
383 boost::geometry::convert(it->first, boxes[i]);
389 const size_t level_backup =
level;
392 for (
typename ElmentsType::const_iterator it = elements.begin();
393 it != elements.end();
396 boost::geometry::index::detail::rtree::apply_visitor(*
this, *it->second);
399 level = level_backup;
402 template <
typename Value,
414 template <
typename Rtree>
419 constexpr
unsigned int dim =
423 boost::geometry::index::detail::rtree::utilities::view<Rtree>;
426 std::vector<BoundingBox<dim>> boxes;
428 if (rtv.depth() == 0)
434 boost::geometry::convert(tree.bounds(), boxes[0]);
438 const unsigned int target_level =
439 std::min<unsigned int>(
level, rtv.depth() - 1);
442 typename RtreeView::options_type,
443 typename RtreeView::translator_type,
444 typename RtreeView::box_type,
445 typename RtreeView::allocators_type>
446 extract_level_visitor(rtv.translator(), target_level, boxes);
447 rtv.apply_visitor(extract_level_visitor);
455 template <
class Rtree>
457 n_levels(
const Rtree &tree)
459 boost::geometry::index::detail::rtree::utilities::view<Rtree> rtv(tree);