diff --git a/include/boost/geometry/extensions/index/rtree/node.hpp b/include/boost/geometry/extensions/index/rtree/node.hpp index aee3567a4..95cafd568 100644 --- a/include/boost/geometry/extensions/index/rtree/node.hpp +++ b/include/boost/geometry/extensions/index/rtree/node.hpp @@ -1,8 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // -// Boost.Index - R-tree details +// Boost.Index - R-tree default nodes // -// Copyright 2008 Federico J. Fernandez. // Copyright 2011 Adam Wulkiewicz. // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at diff --git a/include/boost/geometry/extensions/index/rtree/rtree.hpp b/include/boost/geometry/extensions/index/rtree/rtree.hpp index d1e40ce7b..77428920f 100644 --- a/include/boost/geometry/extensions/index/rtree/rtree.hpp +++ b/include/boost/geometry/extensions/index/rtree/rtree.hpp @@ -72,7 +72,9 @@ public: template inline void find(Geometry const& geom, OutIter out_it) const { - detail::rtree::visitors::find find_v(m_translator, geom, out_it); + detail::rtree::visitors::find + find_v(m_translator, geom, out_it); + boost::apply_visitor(find_v, *m_root); } diff --git a/include/boost/geometry/extensions/index/rtree/visitors/find.hpp b/include/boost/geometry/extensions/index/rtree/visitors/find.hpp index 400976e33..5cdc65e12 100644 --- a/include/boost/geometry/extensions/index/rtree/visitors/find.hpp +++ b/include/boost/geometry/extensions/index/rtree/visitors/find.hpp @@ -20,17 +20,88 @@ namespace boost { namespace geometry { namespace index { namespace detail { namespace rtree { namespace visitors { +//template +//class array +//{ +//public: +// inline array() +// : arr_elements(0) +// {} +// +// inline void push(T const& v) +// { +// arr[arr_elements++] = v; +// } +// +// inline T pop() +// { +// assert(0 < arr_elements); +// return arr[--arr_elements]; +// } +// +// inline bool empty() const +// { +// return 0 == arr_elements; +// } +// +// inline size_t size() const +// { +// return arr_elements; +// } +// +//private: +// boost::array arr; +// size_t arr_elements; +//}; +// +//template +//class dynamic +//{ +//public: +// typedef typename Cont::value_type value_type; +// +// inline void push(value_type const& v) +// { +// cont.push_back(v); +// } +// +// inline value_type pop() +// { +// value_type v = cont.back(); +// cont.pop_back(); +// return v; +// } +// +// inline bool empty() const +// { +// return cont.empty(); +// } +// +// inline size_t size() const +// { +// return cont.size(); +// } +// +// inline void clear() +// { +// cont.clear(); +// } +// +//private: +// Cont cont; +//}; +// //template //class array_semi_dynamic //{ //public: // typedef typename Cont::value_type value_type; // -// array_semi_dynamic() +// inline array_semi_dynamic() // : arr_elements(0) // {} // -// void push_back(value_type const& v) +// inline void push(value_type const& v) // { // if ( arr_elements < N ) // arr[arr_elements++] = v; @@ -38,46 +109,27 @@ namespace detail { namespace rtree { namespace visitors { // cont.push_back(v); // } // -// void pop_back() +// inline value_type pop() // { // if ( !cont.empty() ) +// { +// value_type v = cont.back(); // cont.pop_back(); +// return v; +// } // else // { // assert(0 < arr_elements); -// --arr_elements; +// return arr[--arr_elements]; // } // } // -// value_type & back() +// inline bool empty() const // { -// if ( !cont.empty() ) -// return cont.back(); -// else -// { -// assert(0 < arr_elements); -// return arr[arr_elements - 1]; -// } +// return cont.empty() && 0 == arr_elements; // } // -// value_type const& back() const -// { -// if ( !cont.empty() ) -// return cont.back(); -// else -// { -// assert(0 < arr_elements); -// return arr[arr_elements - 1]; -// } -// } -// -// bool empty() const -// { -// assert(cont.empty()); -// return 0 == arr_elements; -// } -// -// size_t size() const +// inline size_t size() const // { // return arr_elements + cont.size(); // } @@ -103,42 +155,43 @@ struct find : public boost::static_visitor<> inline void operator()(internal_node const& n) { - /*typedef typename internal_node::children_type children_type; + //typedef typename internal_node::children_type children_type; - array_semi_dynamic<512, std::deque > nodes; - - for (typename children_type::const_iterator it = n.children.begin(); - it != n.children.end(); ++it) - { - if ( geometry::intersects(it->first, geom) ) - { - nodes.push_back(it->second); - } - } + //array_semi_dynamic<1024, std::deque > nodes; + ////array<1024, node*> nodes; + ////dynamic< std::deque > nodes; + // + //for (typename children_type::const_iterator it = n.children.begin(); + // it != n.children.end(); ++it) + //{ + // if ( geometry::intersects(it->first, geom) ) + // { + // nodes.push(it->second); + // } + //} - while ( !nodes.empty() ) - { - node *n = nodes.back(); - nodes.pop_back(); + //while ( !nodes.empty() ) + //{ + // node *n = nodes.pop(); - if ( !boost::apply_visitor(visitors::is_leaf(), *n) ) - { - internal_node &in = boost::get(*n); + // if ( !boost::apply_visitor(visitors::is_leaf(), *n) ) + // { + // internal_node &in = boost::get(*n); - for (typename children_type::const_iterator it = in.children.begin(); - it != in.children.end(); ++it) - { - if ( geometry::intersects(it->first, geom) ) - { - nodes.push_back(it->second); - } - } - } - else - { - operator()(boost::get(*n)); - } - }*/ + // for (typename children_type::const_iterator it = in.children.begin(); + // it != in.children.end(); ++it) + // { + // if ( geometry::intersects(it->first, geom) ) + // { + // nodes.push(it->second); + // } + // } + // } + // else + // { + // operator()(boost::get(*n)); + // } + //} typedef typename internal_node::children_type children_type; diff --git a/tests/additional_sizes_and_times.cpp b/tests/additional_sizes_and_times.cpp index a4cd11e42..3398d8d71 100644 --- a/tests/additional_sizes_and_times.cpp +++ b/tests/additional_sizes_and_times.cpp @@ -12,8 +12,12 @@ int main() { boost::timer tim; - typedef boost::geometry::model::point P; - typedef boost::geometry::model::box

B; + namespace bg = boost::geometry; + namespace bgi = bg::index; + + typedef bg::model::point P; + typedef bg::model::box

B; + typedef bgi::rtree, bgi::default_parameter, bgi::linear_tag> RT; std::ifstream file_cfg("config.txt"); size_t max_elems = 4; @@ -41,7 +45,7 @@ int main() std::cout << "inserting time test...\n"; tim.restart(); - boost::geometry::index::rtree< std::pair > t(max_elems, min_elems); + RT t(max_elems, min_elems); for (size_t i = 0 ; i < values_count ; ++i ) { float x = coords[i].first; @@ -78,11 +82,11 @@ int main() std::cout << "saving...\n"; std::ofstream file("save_new.txt", std::ofstream::trunc); file << std::fixed; - boost::geometry::index::detail::rtree::visitors::save< - boost::geometry::index::rtree< std::pair >::value_type, - boost::geometry::index::rtree< std::pair >::translator_type, - boost::geometry::index::rtree< std::pair >::box_type, - boost::geometry::index::rtree< std::pair >::tag_type + bgi::detail::rtree::visitors::save< + RT::value_type, + RT::translator_type, + RT::box_type, + RT::tag_type > saving_v(file, t.get_translator()); t.apply_visitor(saving_v); std::cout << "saved...\n";