1 // Boost.Geometry Index
2 //
3 // R-tree node children box calculating visitor implementation
4 //
5 // Copyright (c) 2011-2015 Adam Wulkiewicz, Lodz, Poland.
6 //
7 // Use, modification and distribution is subject to the Boost Software License,
8 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
9 // http://www.boost.org/LICENSE_1_0.txt)
10 
11 #ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_VISITORS_CHILDREN_BOX_HPP
12 #define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_VISITORS_CHILDREN_BOX_HPP
13 
14 namespace boost { namespace geometry { namespace index {
15 
16 namespace detail { namespace rtree { namespace visitors {
17 
18 template <typename Value, typename Options, typename Translator, typename Box, typename Allocators>
19 class children_box
20     : public rtree::visitor<Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag, true>::type
21 {
22     typedef typename rtree::internal_node<Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag>::type internal_node;
23     typedef typename rtree::leaf<Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag>::type leaf;
24 
25 public:
children_box(Box & result,Translator const & tr)26     inline children_box(Box & result, Translator const& tr)
27         : m_result(result), m_tr(tr)
28     {}
29 
operator ()(internal_node const & n)30     inline void operator()(internal_node const& n)
31     {
32         typedef typename rtree::elements_type<internal_node>::type elements_type;
33         elements_type const& elements = rtree::elements(n);
34 
35         m_result = rtree::elements_box<Box>(elements.begin(), elements.end(), m_tr);
36     }
37 
operator ()(leaf const & n)38     inline void operator()(leaf const& n)
39     {
40         typedef typename rtree::elements_type<leaf>::type elements_type;
41         elements_type const& elements = rtree::elements(n);
42 
43         m_result = rtree::values_box<Box>(elements.begin(), elements.end(), m_tr);
44     }
45 
46 private:
47     Box & m_result;
48     Translator const& m_tr;
49 };
50 
51 }}} // namespace detail::rtree::visitors
52 
53 }}} // namespace boost::geometry::index
54 
55 #endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_VISITORS_CHILDREN_BOX_HPP
56