Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r84661 - in trunk/boost/geometry/index: . detail/rtree/utilities detail/rtree/visitors
From: adam.wulkiewicz_at_[hidden]
Date: 2013-06-06 18:52:19


Author: awulkiew
Date: 2013-06-06 18:52:19 EDT (Thu, 06 Jun 2013)
New Revision: 84661
URL: http://svn.boost.org/trac/boost/changeset/84661

Log:
geometry.index: info and test visitors + functions moved to detail::rtree::utilities. Added detail::rtree::utilities::view<>. Definition of BOOST_GEOMETRY_INDEX_DETAIL_ENABLE_DEBUG_INTERFACE no longer needed.

Added:
   trunk/boost/geometry/index/detail/rtree/utilities/
   trunk/boost/geometry/index/detail/rtree/utilities/are_boxes_ok.hpp (contents, props changed)
   trunk/boost/geometry/index/detail/rtree/utilities/are_levels_ok.hpp (contents, props changed)
   trunk/boost/geometry/index/detail/rtree/utilities/gl_draw.hpp (contents, props changed)
   trunk/boost/geometry/index/detail/rtree/utilities/print.hpp (contents, props changed)
   trunk/boost/geometry/index/detail/rtree/utilities/statistics.hpp (contents, props changed)
   trunk/boost/geometry/index/detail/rtree/utilities/view.hpp (contents, props changed)
Deleted:
   trunk/boost/geometry/index/detail/rtree/visitors/are_boxes_ok.hpp
   trunk/boost/geometry/index/detail/rtree/visitors/are_levels_ok.hpp
   trunk/boost/geometry/index/detail/rtree/visitors/gl_draw.hpp
   trunk/boost/geometry/index/detail/rtree/visitors/print.hpp
   trunk/boost/geometry/index/detail/rtree/visitors/statistics.hpp
Text files modified:
   trunk/boost/geometry/index/detail/rtree/utilities/are_boxes_ok.hpp | 140 ++++++++++++++++++++++++
   trunk/boost/geometry/index/detail/rtree/utilities/are_levels_ok.hpp | 109 +++++++++++++++++++
   trunk/boost/geometry/index/detail/rtree/utilities/gl_draw.hpp | 225 ++++++++++++++++++++++++++++++++++++++++
   trunk/boost/geometry/index/detail/rtree/utilities/print.hpp | 203 ++++++++++++++++++++++++++++++++++++
   trunk/boost/geometry/index/detail/rtree/utilities/statistics.hpp | 106 ++++++++++++++++++
   trunk/boost/geometry/index/detail/rtree/utilities/view.hpp | 61 ++++++++++
   /dev/null | 144 -------------------------
   /dev/null | 114 --------------------
   /dev/null | 221 ---------------------------------------
   /dev/null | 197 -----------------------------------
   /dev/null | 109 -------------------
   trunk/boost/geometry/index/rtree.hpp | 26 +---
   12 files changed, 851 insertions(+), 804 deletions(-)

Added: trunk/boost/geometry/index/detail/rtree/utilities/are_boxes_ok.hpp
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/boost/geometry/index/detail/rtree/utilities/are_boxes_ok.hpp 2013-06-06 18:52:19 EDT (Thu, 06 Jun 2013) (r84661)
@@ -0,0 +1,140 @@
+// Boost.Geometry Index
+//
+// R-tree boxes validating visitor implementation
+//
+// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
+//
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_UTILITIES_ARE_BOXES_OK_HPP
+#define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_UTILITIES_ARE_BOXES_OK_HPP
+
+#include <boost/geometry/algorithms/equals.hpp>
+#include <boost/geometry/index/detail/rtree/node/node.hpp>
+
+namespace boost { namespace geometry { namespace index { namespace detail { namespace rtree { namespace utilities {
+
+namespace visitors {
+
+template <typename Value, typename Options, typename Translator, typename Box, typename Allocators>
+class are_boxes_ok
+ : public rtree::visitor<Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag, true>::type
+{
+ typedef typename rtree::internal_node<Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag>::type internal_node;
+ typedef typename rtree::leaf<Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag>::type leaf;
+
+public:
+ are_boxes_ok(Translator const& tr, bool exact_match)
+ : result(false), m_tr(tr), m_is_root(true), m_exact_match(exact_match)
+ {}
+
+ void operator()(internal_node const& n)
+ {
+ typedef typename rtree::elements_type<internal_node>::type elements_type;
+ elements_type const& elements = rtree::elements(n);
+
+ if (elements.empty())
+ {
+ result = false;
+ return;
+ }
+
+ Box box_bckup = m_box;
+ bool is_root_bckup = m_is_root;
+
+ m_is_root = false;
+
+ for ( typename elements_type::const_iterator it = elements.begin();
+ it != elements.end() ; ++it)
+ {
+ m_box = it->first;
+
+ rtree::apply_visitor(*this, *it->second);
+
+ if ( result == false )
+ return;
+ }
+
+ m_box = box_bckup;
+ m_is_root = is_root_bckup;
+
+ Box box_exp;
+ geometry::convert(elements.front().first, box_exp);
+ for( typename elements_type::const_iterator it = elements.begin() + 1;
+ it != elements.end() ; ++it)
+ {
+ geometry::expand(box_exp, it->first);
+ }
+
+ if ( m_exact_match )
+ result = m_is_root || geometry::equals(box_exp, m_box);
+ else
+ result = m_is_root || geometry::covered_by(box_exp, m_box);
+ }
+
+ void operator()(leaf const& n)
+ {
+ typedef typename rtree::elements_type<leaf>::type elements_type;
+ elements_type const& elements = rtree::elements(n);
+
+ // non-root node
+ if (!m_is_root)
+ {
+ if ( elements.empty() )
+ {
+ result = false;
+ return;
+ }
+
+ Box box_exp;
+ geometry::convert(m_tr(elements.front()), box_exp);
+ for(typename elements_type::const_iterator it = elements.begin() + 1;
+ it != elements.end() ; ++it)
+ {
+ geometry::expand(box_exp, m_tr(*it));
+ }
+
+ if ( m_exact_match )
+ result = geometry::equals(box_exp, m_box);
+ else
+ result = geometry::covered_by(box_exp, m_box);
+ }
+ else
+ result = true;
+ }
+
+ bool result;
+
+private:
+ Translator const& m_tr;
+ Box m_box;
+ bool m_is_root;
+ bool m_exact_match;
+};
+
+} // namespace visitors
+
+template <typename Rtree> inline
+bool are_boxes_ok(Rtree const& tree, bool exact_match = true)
+{
+ typedef utilities::view<Rtree> RTV;
+ RTV rtv(tree);
+
+ visitors::are_boxes_ok<
+ typename RTV::value_type,
+ typename RTV::options_type,
+ typename RTV::translator_type,
+ typename RTV::box_type,
+ typename RTV::allocators_type
+ > v(rtv.translator(), exact_match);
+
+ rtv.apply_visitor(v);
+
+ return v.result;
+}
+
+}}}}}} // namespace boost::geometry::index::detail::rtree::utilities
+
+#endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_UTILITIES_ARE_BOXES_OK_HPP

Added: trunk/boost/geometry/index/detail/rtree/utilities/are_levels_ok.hpp
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/boost/geometry/index/detail/rtree/utilities/are_levels_ok.hpp 2013-06-06 18:52:19 EDT (Thu, 06 Jun 2013) (r84661)
@@ -0,0 +1,109 @@
+// Boost.Geometry Index
+//
+// R-tree levels validating visitor implementation
+//
+// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
+//
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_UTILITIES_ARE_LEVELS_OK_HPP
+#define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_UTILITIES_ARE_LEVELS_OK_HPP
+
+#include <boost/geometry/index/detail/rtree/node/node.hpp>
+
+namespace boost { namespace geometry { namespace index { namespace detail { namespace rtree { namespace utilities {
+
+namespace visitors {
+
+template <typename Value, typename Options, typename Box, typename Allocators>
+class are_levels_ok
+ : public rtree::visitor<Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag, true>::type
+{
+ typedef typename rtree::internal_node<Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag>::type internal_node;
+ typedef typename rtree::leaf<Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag>::type leaf;
+
+public:
+ inline are_levels_ok()
+ : result(true), m_leafs_level((std::numeric_limits<size_t>::max)()), m_current_level(0)
+ {}
+
+ inline void operator()(internal_node const& n)
+ {
+ typedef typename rtree::elements_type<internal_node>::type elements_type;
+ elements_type const& elements = rtree::elements(n);
+
+ if (elements.empty())
+ {
+ result = false;
+ return;
+ }
+
+ size_t current_level_backup = m_current_level;
+ ++m_current_level;
+
+ for ( typename elements_type::const_iterator it = elements.begin();
+ it != elements.end() ; ++it)
+ {
+ rtree::apply_visitor(*this, *it->second);
+
+ if ( result == false )
+ return;
+ }
+
+ m_current_level = current_level_backup;
+ }
+
+ inline void operator()(leaf const& n)
+ {
+ typedef typename rtree::elements_type<leaf>::type elements_type;
+ elements_type const& elements = rtree::elements(n);
+
+ // empty leaf in non-root node
+ if (0 < m_current_level && elements.empty())
+ {
+ result = false;
+ return;
+ }
+
+ if ( m_leafs_level == (std::numeric_limits<size_t>::max)() )
+ {
+ m_leafs_level = m_current_level;
+ }
+ else if ( m_leafs_level != m_current_level )
+ {
+ result = false;
+ }
+ }
+
+ bool result;
+
+private:
+ size_t m_leafs_level;
+ size_t m_current_level;
+};
+
+} // namespace visitors
+
+template <typename Rtree> inline
+bool are_levels_ok(Rtree const& tree)
+{
+ typedef utilities::view<Rtree> RTV;
+ RTV rtv(tree);
+
+ visitors::are_levels_ok<
+ typename RTV::value_type,
+ typename RTV::options_type,
+ typename RTV::box_type,
+ typename RTV::allocators_type
+ > v;
+
+ rtv.apply_visitor(v);
+
+ return v.result;
+}
+
+}}}}}} // namespace boost::geometry::index::detail::rtree::utilities
+
+#endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_UTILITIES_ARE_LEVELS_OK_HPP

Added: trunk/boost/geometry/index/detail/rtree/utilities/gl_draw.hpp
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/boost/geometry/index/detail/rtree/utilities/gl_draw.hpp 2013-06-06 18:52:19 EDT (Thu, 06 Jun 2013) (r84661)
@@ -0,0 +1,225 @@
+// Boost.Geometry Index
+//
+// R-tree OpenGL drawing visitor implementation
+//
+// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
+//
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_UTILITIES_GL_DRAW_HPP
+#define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_UTILITIES_GL_DRAW_HPP
+
+#include <boost/geometry/index/detail/indexable.hpp>
+
+namespace boost { namespace geometry { namespace index { namespace detail {
+
+namespace utilities {
+
+namespace dispatch {
+
+template <typename Point, size_t Dimension>
+struct gl_draw_point
+{};
+
+template <typename Point>
+struct gl_draw_point<Point, 2>
+{
+ static inline void apply(Point const& p, typename index::detail::traits::coordinate_type<Point>::type z)
+ {
+ glBegin(GL_POINT);
+ glVertex3f(geometry::get<0>(p), geometry::get<1>(p), z);
+ glEnd();
+ }
+};
+
+template <typename Box, size_t Dimension>
+struct gl_draw_box
+{};
+
+template <typename Box>
+struct gl_draw_box<Box, 2>
+{
+ static inline void apply(Box const& b, typename index::detail::traits::coordinate_type<Box>::type z)
+ {
+ glBegin(GL_LINE_LOOP);
+ glVertex3f(geometry::get<min_corner, 0>(b), geometry::get<min_corner, 1>(b), z);
+ glVertex3f(geometry::get<max_corner, 0>(b), geometry::get<min_corner, 1>(b), z);
+ glVertex3f(geometry::get<max_corner, 0>(b), geometry::get<max_corner, 1>(b), z);
+ glVertex3f(geometry::get<min_corner, 0>(b), geometry::get<max_corner, 1>(b), z);
+ glEnd();
+ }
+};
+
+template <typename Indexable, typename Tag>
+struct gl_draw_indexable
+{
+};
+
+template <typename Indexable>
+struct gl_draw_indexable<Indexable, box_tag>
+{
+ static const size_t dimension = index::detail::traits::dimension<Indexable>::value;
+
+ static inline void apply(Indexable const& i, typename index::detail::traits::coordinate_type<Indexable>::type z)
+ {
+ gl_draw_box<Indexable, dimension>::apply(i, z);
+ }
+};
+
+template <typename Indexable>
+struct gl_draw_indexable<Indexable, point_tag>
+{
+ static const size_t dimension = index::detail::traits::dimension<Indexable>::value;
+
+ static inline void apply(Indexable const& i, typename index::detail::traits::coordinate_type<Indexable>::type z)
+ {
+ gl_draw_point<Indexable, dimension>::apply(i, z);
+ }
+};
+
+} // namespace dispatch
+
+template <typename Indexable> inline
+void gl_draw_indexable(Indexable const& i, typename index::detail::traits::coordinate_type<Indexable>::type z)
+{
+ dispatch::gl_draw_indexable<
+ Indexable,
+ typename index::detail::traits::tag<Indexable>::type
+ >::apply(i, z);
+}
+
+} // namespace utilities
+
+namespace rtree { namespace utilities {
+
+namespace visitors {
+
+template <typename Value, typename Options, typename Translator, typename Box, typename Allocators>
+struct gl_draw : public rtree::visitor<Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag, true>::type
+{
+ typedef typename rtree::internal_node<Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag>::type internal_node;
+ typedef typename rtree::leaf<Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag>::type leaf;
+
+ inline gl_draw(Translator const& t,
+ size_t level_first = 0,
+ size_t level_last = (std::numeric_limits<size_t>::max)(),
+ typename index::detail::traits::coordinate_type<Box>::type z_coord_level_multiplier = 1
+ )
+ : tr(t)
+ , level_f(level_first)
+ , level_l(level_last)
+ , z_mul(z_coord_level_multiplier)
+ , level(0)
+ {}
+
+ inline void operator()(internal_node const& n)
+ {
+ typedef typename rtree::elements_type<internal_node>::type elements_type;
+ elements_type const& elements = rtree::elements(n);
+
+ if ( level_f <= level )
+ {
+ size_t level_rel = level - level_f;
+
+ if ( level_rel == 0 )
+ glColor3f(0.75f, 0.0f, 0.0f);
+ else if ( level_rel == 1 )
+ glColor3f(0.0f, 0.75f, 0.0f);
+ else if ( level_rel == 2 )
+ glColor3f(0.0f, 0.0f, 0.75f);
+ else if ( level_rel == 3 )
+ glColor3f(0.75f, 0.75f, 0.0f);
+ else if ( level_rel == 4 )
+ glColor3f(0.75f, 0.0f, 0.75f);
+ else if ( level_rel == 5 )
+ glColor3f(0.0f, 0.75f, 0.75f);
+ else
+ glColor3f(0.5f, 0.5f, 0.5f);
+
+ for (typename elements_type::const_iterator it = elements.begin();
+ it != elements.end(); ++it)
+ {
+ detail::utilities::gl_draw_indexable(it->first, level_rel * z_mul);
+ }
+ }
+
+ size_t level_backup = level;
+ ++level;
+
+ if ( level < level_l )
+ {
+ for (typename elements_type::const_iterator it = elements.begin();
+ it != elements.end(); ++it)
+ {
+ rtree::apply_visitor(*this, *it->second);
+ }
+ }
+
+ level = level_backup;
+ }
+
+ inline void operator()(leaf const& n)
+ {
+ typedef typename rtree::elements_type<leaf>::type elements_type;
+ elements_type const& elements = rtree::elements(n);
+
+ if ( level_f <= level )
+ {
+ size_t level_rel = level - level_f;
+
+ glColor3f(0.25f, 0.25f, 0.25f);
+
+ for (typename elements_type::const_iterator it = elements.begin();
+ it != elements.end(); ++it)
+ {
+ detail::utilities::gl_draw_indexable(tr(*it), level_rel * z_mul);
+ }
+ }
+ }
+
+ Translator const& tr;
+ size_t level_f;
+ size_t level_l;
+ typename index::detail::traits::coordinate_type<Box>::type z_mul;
+
+ size_t level;
+};
+
+} // namespace visitors
+
+template <typename Rtree> inline
+void gl_draw(Rtree const& tree,
+ size_t level_first = 0,
+ size_t level_last = (std::numeric_limits<size_t>::max)(),
+ typename index::detail::traits::coordinate_type<
+ typename Rtree::bounds_type
+ >::type z_coord_level_multiplier = 1
+ )
+{
+ typedef utilities::view<Rtree> RTV;
+ RTV rtv(tree);
+
+ if ( !tree.empty() )
+ {
+ glColor3f(0.75f, 0.75f, 0.75f);
+ detail::utilities::gl_draw_indexable(tree.bounds(), 0);
+ }
+
+ visitors::gl_draw<
+ typename RTV::value_type,
+ typename RTV::options_type,
+ typename RTV::translator_type,
+ typename RTV::box_type,
+ typename RTV::allocators_type
+ > gl_draw_v(rtv.translator(), level_first, level_last, z_coord_level_multiplier);
+
+ rtv.apply_visitor(gl_draw_v);
+}
+
+}} // namespace rtree::utilities
+
+}}}} // namespace boost::geometry::index::detail
+
+#endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_UTILITIES_GL_DRAW_HPP

Added: trunk/boost/geometry/index/detail/rtree/utilities/print.hpp
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/boost/geometry/index/detail/rtree/utilities/print.hpp 2013-06-06 18:52:19 EDT (Thu, 06 Jun 2013) (r84661)
@@ -0,0 +1,203 @@
+// Boost.Geometry Index
+//
+// R-tree ostreaming visitor implementation
+//
+// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
+//
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_UTILITIES_PRINT_HPP
+#define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_UTILITIES_PRINT_HPP
+
+#include <iostream>
+
+namespace boost { namespace geometry { namespace index { namespace detail {
+
+namespace utilities {
+
+namespace dispatch {
+
+template <typename Point, size_t Dimension>
+struct print_point
+{
+ BOOST_STATIC_ASSERT(0 < Dimension);
+
+ static inline void apply(std::ostream & os, Point const& p)
+ {
+ print_point<Point, Dimension - 1>::apply(os, p);
+
+ os << ", " << geometry::get<Dimension - 1>(p);
+ }
+};
+
+template <typename Point>
+struct print_point<Point, 1>
+{
+ static inline void apply(std::ostream & os, Point const& p)
+ {
+ os << geometry::get<0>(p);
+ }
+};
+
+template <typename Box, size_t Corner, size_t Dimension>
+struct print_corner
+{
+ BOOST_STATIC_ASSERT(0 < Dimension);
+
+ static inline void apply(std::ostream & os, Box const& b)
+ {
+ print_corner<Box, Corner, Dimension - 1>::apply(os, b);
+
+ os << ", " << geometry::get<Corner, Dimension - 1>(b);
+ }
+};
+
+template <typename Box, size_t Corner>
+struct print_corner<Box, Corner, 1>
+{
+ static inline void apply(std::ostream & os, Box const& b)
+ {
+ os << geometry::get<Corner, 0>(b);
+ }
+};
+
+template <typename Indexable, typename Tag>
+struct print_indexable
+{
+};
+
+template <typename Indexable>
+struct print_indexable<Indexable, box_tag>
+{
+ static const size_t dimension = index::detail::traits::dimension<Indexable>::value;
+
+ static inline void apply(std::ostream &os, Indexable const& i)
+ {
+ os << '(';
+ print_corner<Indexable, min_corner, dimension>::apply(os, i);
+ os << ")x(";
+ print_corner<Indexable, max_corner, dimension>::apply(os, i);
+ os << ')';
+ }
+};
+
+template <typename Indexable>
+struct print_indexable<Indexable, point_tag>
+{
+ static const size_t dimension = index::detail::traits::dimension<Indexable>::value;
+
+ static inline void apply(std::ostream &os, Indexable const& i)
+ {
+ os << '(';
+ print_point<Indexable, dimension>::apply(os, i);
+ os << ')';
+ }
+};
+
+} // namespace dispatch
+
+template <typename Indexable> inline
+void print_indexable(std::ostream & os, Indexable const& i)
+{
+ dispatch::print_indexable<
+ Indexable,
+ typename geometry::traits::tag<Indexable>::type
+ >::apply(os, i);
+}
+
+} // namespace utilities
+
+namespace rtree { namespace utilities {
+
+namespace visitors {
+
+template <typename Value, typename Options, typename Translator, typename Box, typename Allocators>
+struct print : public rtree::visitor<Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag, true>::type
+{
+ typedef typename rtree::internal_node<Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag>::type internal_node;
+ typedef typename rtree::leaf<Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag>::type leaf;
+
+ inline print(std::ostream & o, Translator const& t)
+ : os(o), tr(t), level(0)
+ {}
+
+ inline void operator()(internal_node const& n)
+ {
+ typedef typename rtree::elements_type<internal_node>::type elements_type;
+ elements_type const& elements = rtree::elements(n);
+
+ spaces(level) << "INTERNAL NODE - L:" << level << " Ch:" << elements.size() << " @:" << &n << '\n';
+
+ for (typename elements_type::const_iterator it = elements.begin();
+ it != elements.end(); ++it)
+ {
+ spaces(level);
+ detail::utilities::print_indexable(os, it->first);
+ os << " ->" << it->second << '\n';
+ }
+
+ size_t level_backup = level;
+ ++level;
+
+ for (typename elements_type::const_iterator it = elements.begin();
+ it != elements.end(); ++it)
+ {
+ rtree::apply_visitor(*this, *it->second);
+ }
+
+ level = level_backup;
+ }
+
+ inline void operator()(leaf const& n)
+ {
+ typedef typename rtree::elements_type<leaf>::type elements_type;
+ elements_type const& elements = rtree::elements(n);
+
+ spaces(level) << "LEAF - L:" << level << " V:" << elements.size() << " @:" << &n << '\n';
+ for (typename elements_type::const_iterator it = elements.begin();
+ it != elements.end(); ++it)
+ {
+ spaces(level);
+ detail::utilities::print_indexable(os, tr(*it));
+ os << '\n';
+ }
+ }
+
+ inline std::ostream & spaces(size_t level)
+ {
+ for ( size_t i = 0 ; i < 2 * level ; ++i )
+ os << ' ';
+ return os;
+ }
+
+ std::ostream & os;
+ Translator const& tr;
+
+ size_t level;
+};
+
+} // namespace visitors
+
+template <typename Rtree> inline
+void print(std::ostream & os, Rtree const& tree)
+{
+ typedef utilities::view<Rtree> RTV;
+ RTV rtv(tree);
+
+ visitors::print<
+ typename RTV::value_type,
+ typename RTV::options_type,
+ typename RTV::translator_type,
+ typename RTV::box_type,
+ typename RTV::allocators_type
+ > print_v(os, rtv.translator());
+ rtv.apply_visitor(print_v);
+}
+
+}} // namespace rtree::utilities
+
+}}}} // namespace boost::geometry::index::detail
+
+#endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_UTILITIES_PRINT_HPP

Added: trunk/boost/geometry/index/detail/rtree/utilities/statistics.hpp
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/boost/geometry/index/detail/rtree/utilities/statistics.hpp 2013-06-06 18:52:19 EDT (Thu, 06 Jun 2013) (r84661)
@@ -0,0 +1,106 @@
+// Boost.Geometry Index
+//
+// R-tree visitor collecting basic statistics
+//
+// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
+// Copyright (c) 2013 Mateusz Loskot, London, UK.
+//
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_UTILITIES_STATISTICS_HPP
+#define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_UTILITIES_STATISTICS_HPP
+
+#include <boost/geometry/index/detail/indexable.hpp>
+#include <algorithm>
+#include <tuple>
+
+namespace boost { namespace geometry { namespace index { namespace detail { namespace rtree { namespace utilities {
+
+namespace visitors {
+
+template <typename Value, typename Options, typename Box, typename Allocators>
+struct statistics : public rtree::visitor<Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag, true>::type
+{
+ typedef typename rtree::internal_node<Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag>::type internal_node;
+ typedef typename rtree::leaf<Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag>::type leaf;
+
+ inline statistics()
+ : level(0)
+ , levels(1) // count root
+ , nodes(0)
+ , leaves(0)
+ , values(0)
+ , values_min(0)
+ , values_max(0)
+ {}
+
+ inline void operator()(internal_node const& n)
+ {
+ typedef typename rtree::elements_type<internal_node>::type elements_type;
+ elements_type const& elements = rtree::elements(n);
+
+ ++nodes; // count node
+
+ size_t const level_backup = level;
+ ++level;
+
+ levels += level++ > levels ? 1 : 0; // count level (root already counted)
+
+ for (typename elements_type::const_iterator it = elements.begin();
+ it != elements.end(); ++it)
+ {
+ rtree::apply_visitor(*this, *it->second);
+ }
+
+ level = level_backup;
+ }
+
+ inline void operator()(leaf const& n)
+ {
+ typedef typename rtree::elements_type<leaf>::type elements_type;
+ elements_type const& elements = rtree::elements(n);
+
+ ++leaves; // count leaves
+
+ std::size_t const v = elements.size();
+ // count values spread per node and total
+ values_min = (std::min)(values_min == 0 ? v : values_min, v);
+ values_max = (std::max)(values_max, v);
+ values += v;
+ }
+
+ std::size_t level;
+ std::size_t levels;
+ std::size_t nodes;
+ std::size_t leaves;
+ std::size_t values;
+ std::size_t values_min;
+ std::size_t values_max;
+};
+
+} // namespace visitors
+
+template <typename Rtree> inline
+boost::tuple<std::size_t, std::size_t, std::size_t, std::size_t, std::size_t, std::size_t>
+statistics(Rtree const& tree)
+{
+ typedef utilities::view<Rtree> RTV;
+ RTV rtv(tree);
+
+ visitors::statistics<
+ typename RTV::value_type,
+ typename RTV::options_type,
+ typename RTV::box_type,
+ typename RTV::allocators_type
+ > stats_v;
+
+ rtv.apply_visitor(stats_v);
+
+ return boost::make_tuple(stats_v.levels, stats_v.nodes, stats_v.leaves, stats_v.values, stats_v.values_min, stats_v.values_max);
+}
+
+}}}}}} // namespace boost::geometry::index::detail::rtree::utilities
+
+#endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_UTILITIES_STATISTICS_HPP

Added: trunk/boost/geometry/index/detail/rtree/utilities/view.hpp
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/boost/geometry/index/detail/rtree/utilities/view.hpp 2013-06-06 18:52:19 EDT (Thu, 06 Jun 2013) (r84661)
@@ -0,0 +1,61 @@
+// Boost.Geometry Index
+//
+// Rtree utilities view
+//
+// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
+//
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_UTILITIES_VIEW_HPP
+#define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_UTILITIES_VIEW_HPP
+
+namespace boost { namespace geometry { namespace index {
+
+namespace detail { namespace rtree { namespace utilities {
+
+template <typename Rtree>
+class view
+{
+public:
+ typedef typename Rtree::size_type size_type;
+
+ typedef typename Rtree::translator_type translator_type;
+ typedef typename Rtree::value_type value_type;
+ typedef typename Rtree::options_type options_type;
+ typedef typename Rtree::box_type box_type;
+ typedef typename Rtree::allocators_type allocators_type;
+
+ view(Rtree const& rt) : m_rtree(rt) {}
+
+ template <typename Visitor>
+ void apply_visitor(Visitor & vis) const
+ {
+ m_rtree.apply_visitor(vis);
+ }
+
+ // This will most certainly be removed in the future
+ translator_type translator() const
+ {
+ return m_rtree.translator();
+ }
+
+ // This will probably be removed in the future
+ size_type depth() const
+ {
+ return m_rtree.depth();
+ }
+
+private:
+ view(view const&);
+ view & operator=(view const&);
+
+ Rtree const& m_rtree;
+};
+
+}}} // namespace detail::rtree::utilities
+
+}}} // namespace boost::geometry::index
+
+#endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_UTILITIES_VIEW_HPP

Deleted: trunk/boost/geometry/index/detail/rtree/visitors/are_boxes_ok.hpp
==============================================================================
--- trunk/boost/geometry/index/detail/rtree/visitors/are_boxes_ok.hpp 2013-06-06 18:52:19 EDT (Thu, 06 Jun 2013) (r84660)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,144 +0,0 @@
-// Boost.Geometry Index
-//
-// R-tree boxes validating visitor implementation
-//
-// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
-//
-// Use, modification and distribution is subject to the Boost Software License,
-// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-#ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_VISITORS_ARE_BOXES_OK_HPP
-#define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_VISITORS_ARE_BOXES_OK_HPP
-
-#include <boost/geometry/algorithms/equals.hpp>
-#include <boost/geometry/index/detail/rtree/node/node.hpp>
-
-namespace boost { namespace geometry { namespace index { namespace detail { namespace rtree {
-
-namespace visitors {
-
-template <typename Value, typename Options, typename Translator, typename Box, typename Allocators>
-class are_boxes_ok
- : public rtree::visitor<Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag, true>::type
-{
- typedef typename rtree::internal_node<Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag>::type internal_node;
- typedef typename rtree::leaf<Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag>::type leaf;
-
-public:
- are_boxes_ok(Translator const& tr, bool exact_match)
- : result(false), m_tr(tr), m_is_root(true), m_exact_match(exact_match)
- {}
-
- void operator()(internal_node const& n)
- {
- typedef typename rtree::elements_type<internal_node>::type elements_type;
- elements_type const& elements = rtree::elements(n);
-
- if (elements.empty())
- {
- result = false;
- return;
- }
-
- Box box_bckup = m_box;
- bool is_root_bckup = m_is_root;
-
- m_is_root = false;
-
- for ( typename elements_type::const_iterator it = elements.begin();
- it != elements.end() ; ++it)
- {
- m_box = it->first;
-
- rtree::apply_visitor(*this, *it->second);
-
- if ( result == false )
- return;
- }
-
- m_box = box_bckup;
- m_is_root = is_root_bckup;
-
- Box box_exp;
- geometry::convert(elements.front().first, box_exp);
- for( typename elements_type::const_iterator it = elements.begin() + 1;
- it != elements.end() ; ++it)
- {
- geometry::expand(box_exp, it->first);
- }
-
- if ( m_exact_match )
- result = m_is_root || geometry::equals(box_exp, m_box);
- else
- result = m_is_root || geometry::covered_by(box_exp, m_box);
- }
-
- void operator()(leaf const& n)
- {
- typedef typename rtree::elements_type<leaf>::type elements_type;
- elements_type const& elements = rtree::elements(n);
-
- // non-root node
- if (!m_is_root)
- {
- if ( elements.empty() )
- {
- result = false;
- return;
- }
-
- Box box_exp;
- geometry::convert(m_tr(elements.front()), box_exp);
- for(typename elements_type::const_iterator it = elements.begin() + 1;
- it != elements.end() ; ++it)
- {
- geometry::expand(box_exp, m_tr(*it));
- }
-
- if ( m_exact_match )
- result = geometry::equals(box_exp, m_box);
- else
- result = geometry::covered_by(box_exp, m_box);
- }
- else
- result = true;
- }
-
- bool result;
-
-private:
- Translator const& m_tr;
- Box m_box;
- bool m_is_root;
- bool m_exact_match;
-};
-
-} // namespace visitors
-
-#ifndef BOOST_GEOMETRY_INDEX_DETAIL_ENABLE_DEBUG_INTERFACE
-#error "To use are_boxes_ok BOOST_GEOMETRY_INDEX_DETAIL_ENABLE_DEBUG_INTERFACE should be defined before including the rtree"
-#endif
-
-template <typename Value, typename Parameters, typename IndexableGetter, typename EqualTo, typename Allocator>
-bool are_boxes_ok(index::rtree<Value, Parameters, IndexableGetter, EqualTo, Allocator> const& tree,
- bool exact_match = true)
-{
- typedef index::rtree<Value, Parameters, IndexableGetter, EqualTo, Allocator> rt;
-
- detail::rtree::visitors::are_boxes_ok<
- typename rt::value_type,
- typename rt::options_type,
- typename rt::translator_type,
- typename rt::box_type,
- typename rt::allocators_type
- > v(tree.translator(), exact_match);
-
- tree.apply_visitor(v);
-
- return v.result;
-}
-
-}}}}} // namespace boost::geometry::index::detail::rtree
-
-#endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_VISITORS_ARE_BOXES_OK_HPP

Deleted: trunk/boost/geometry/index/detail/rtree/visitors/are_levels_ok.hpp
==============================================================================
--- trunk/boost/geometry/index/detail/rtree/visitors/are_levels_ok.hpp 2013-06-06 18:52:19 EDT (Thu, 06 Jun 2013) (r84660)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,114 +0,0 @@
-// Boost.Geometry Index
-//
-// R-tree levels validating visitor implementation
-//
-// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
-//
-// Use, modification and distribution is subject to the Boost Software License,
-// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-#ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_VISITORS_ARE_LEVELS_OK_HPP
-#define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_VISITORS_ARE_LEVELS_OK_HPP
-
-#include <boost/geometry/index/detail/rtree/node/node.hpp>
-
-namespace boost { namespace geometry { namespace index { namespace detail { namespace rtree {
-
-namespace visitors {
-
-template <typename Value, typename Options, typename Translator, typename Box, typename Allocators>
-class are_levels_ok
- : public rtree::visitor<Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag, true>::type
-{
- typedef typename rtree::internal_node<Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag>::type internal_node;
- typedef typename rtree::leaf<Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag>::type leaf;
-
-public:
- inline are_levels_ok(Translator const& tr)
- : result(true), m_tr(tr), m_leafs_level((std::numeric_limits<size_t>::max)()), m_current_level(0)
- {}
-
- inline void operator()(internal_node const& n)
- {
- typedef typename rtree::elements_type<internal_node>::type elements_type;
- elements_type const& elements = rtree::elements(n);
-
- if (elements.empty())
- {
- result = false;
- return;
- }
-
- size_t current_level_backup = m_current_level;
- ++m_current_level;
-
- for ( typename elements_type::const_iterator it = elements.begin();
- it != elements.end() ; ++it)
- {
- rtree::apply_visitor(*this, *it->second);
-
- if ( result == false )
- return;
- }
-
- m_current_level = current_level_backup;
- }
-
- inline void operator()(leaf const& n)
- {
- typedef typename rtree::elements_type<leaf>::type elements_type;
- elements_type const& elements = rtree::elements(n);
-
- // empty leaf in non-root node
- if (0 < m_current_level && elements.empty())
- {
- result = false;
- return;
- }
-
- if ( m_leafs_level == (std::numeric_limits<size_t>::max)() )
- {
- m_leafs_level = m_current_level;
- }
- else if ( m_leafs_level != m_current_level )
- {
- result = false;
- }
- }
-
- bool result;
-
-private:
- Translator const& m_tr;
- size_t m_leafs_level;
- size_t m_current_level;
-};
-
-} // namespace visitors
-
-#ifndef BOOST_GEOMETRY_INDEX_DETAIL_ENABLE_DEBUG_INTERFACE
-#error "To use are_levels_ok() BOOST_GEOMETRY_INDEX_DETAIL_ENABLE_DEBUG_INTERFACE should be defined before including the rtree"
-#endif
-
-template <typename Value, typename Parameters, typename IndexableGetter, typename EqualTo, typename Allocator>
-bool are_levels_ok(index::rtree<Value, Parameters, IndexableGetter, EqualTo, Allocator> const& tree)
-{
- typedef index::rtree<Value, Parameters, IndexableGetter, EqualTo, Allocator> rt;
-
- detail::rtree::visitors::are_levels_ok<
- typename rt::value_type,
- typename rt::options_type,
- typename rt::translator_type,
- typename rt::box_type,
- typename rt::allocators_type
- > v(tree.translator());
-
- tree.apply_visitor(v);
-
- return v.result;
-}
-
-}}}}} // namespace boost::geometry::index::detail::rtree
-
-#endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_VISITORS_ARE_LEVELS_OK_HPP

Deleted: trunk/boost/geometry/index/detail/rtree/visitors/gl_draw.hpp
==============================================================================
--- trunk/boost/geometry/index/detail/rtree/visitors/gl_draw.hpp 2013-06-06 18:52:19 EDT (Thu, 06 Jun 2013) (r84660)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,221 +0,0 @@
-// Boost.Geometry Index
-//
-// R-tree OpenGL drawing visitor implementation
-//
-// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
-//
-// Use, modification and distribution is subject to the Boost Software License,
-// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-#ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_VISITORS_GL_DRAW_HPP
-#define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_VISITORS_GL_DRAW_HPP
-
-#include <boost/geometry/index/detail/indexable.hpp>
-
-namespace boost { namespace geometry { namespace index {
-
-namespace detail { namespace rtree { namespace visitors {
-
-namespace dispatch {
-
-template <typename Point, size_t Dimension>
-struct gl_draw_point
-{};
-
-template <typename Point>
-struct gl_draw_point<Point, 2>
-{
- static inline void apply(Point const& p, typename index::detail::traits::coordinate_type<Point>::type z)
- {
- glBegin(GL_POINT);
- glVertex3f(geometry::get<0>(p), geometry::get<1>(p), z);
- glEnd();
- }
-};
-
-template <typename Box, size_t Dimension>
-struct gl_draw_box
-{};
-
-template <typename Box>
-struct gl_draw_box<Box, 2>
-{
- static inline void apply(Box const& b, typename index::detail::traits::coordinate_type<Box>::type z)
- {
- glBegin(GL_LINE_LOOP);
- glVertex3f(geometry::get<min_corner, 0>(b), geometry::get<min_corner, 1>(b), z);
- glVertex3f(geometry::get<max_corner, 0>(b), geometry::get<min_corner, 1>(b), z);
- glVertex3f(geometry::get<max_corner, 0>(b), geometry::get<max_corner, 1>(b), z);
- glVertex3f(geometry::get<min_corner, 0>(b), geometry::get<max_corner, 1>(b), z);
- glEnd();
- }
-};
-
-template <typename Indexable, typename Tag>
-struct gl_draw_indexable
-{
-};
-
-template <typename Indexable>
-struct gl_draw_indexable<Indexable, box_tag>
-{
- static const size_t dimension = index::detail::traits::dimension<Indexable>::value;
-
- static inline void apply(Indexable const& i, typename index::detail::traits::coordinate_type<Indexable>::type z)
- {
- gl_draw_box<Indexable, dimension>::apply(i, z);
- }
-};
-
-template <typename Indexable>
-struct gl_draw_indexable<Indexable, point_tag>
-{
- static const size_t dimension = index::detail::traits::dimension<Indexable>::value;
-
- static inline void apply(Indexable const& i, typename index::detail::traits::coordinate_type<Indexable>::type z)
- {
- gl_draw_point<Indexable, dimension>::apply(i, z);
- }
-};
-
-} // namespace dispatch
-
-namespace detail {
-
-template <typename Indexable>
-inline void gl_draw_indexable(Indexable const& i, typename index::detail::traits::coordinate_type<Indexable>::type z)
-{
- dispatch::gl_draw_indexable<
- Indexable,
- typename index::detail::traits::tag<Indexable>::type
- >::apply(i, z);
-}
-
-} // namespace detail
-
-template <typename Value, typename Options, typename Translator, typename Box, typename Allocators>
-struct gl_draw : public rtree::visitor<Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag, true>::type
-{
- typedef typename rtree::internal_node<Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag>::type internal_node;
- typedef typename rtree::leaf<Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag>::type leaf;
-
- inline gl_draw(Translator const& t,
- size_t level_first = 0,
- size_t level_last = (std::numeric_limits<size_t>::max)(),
- typename index::detail::traits::coordinate_type<Box>::type z_coord_level_multiplier = 1
- )
- : tr(t)
- , level_f(level_first)
- , level_l(level_last)
- , z_mul(z_coord_level_multiplier)
- , level(0)
- {}
-
- inline void operator()(internal_node const& n)
- {
- typedef typename rtree::elements_type<internal_node>::type elements_type;
- elements_type const& elements = rtree::elements(n);
-
- if ( level_f <= level )
- {
- size_t level_rel = level - level_f;
-
- if ( level_rel == 0 )
- glColor3f(0.75f, 0.0f, 0.0f);
- else if ( level_rel == 1 )
- glColor3f(0.0f, 0.75f, 0.0f);
- else if ( level_rel == 2 )
- glColor3f(0.0f, 0.0f, 0.75f);
- else if ( level_rel == 3 )
- glColor3f(0.75f, 0.75f, 0.0f);
- else if ( level_rel == 4 )
- glColor3f(0.75f, 0.0f, 0.75f);
- else if ( level_rel == 5 )
- glColor3f(0.0f, 0.75f, 0.75f);
- else
- glColor3f(0.5f, 0.5f, 0.5f);
-
- for (typename elements_type::const_iterator it = elements.begin();
- it != elements.end(); ++it)
- {
- detail::gl_draw_indexable(it->first, level_rel * z_mul);
- }
- }
-
- size_t level_backup = level;
- ++level;
-
- if ( level < level_l )
- {
- for (typename elements_type::const_iterator it = elements.begin();
- it != elements.end(); ++it)
- {
- rtree::apply_visitor(*this, *it->second);
- }
- }
-
- level = level_backup;
- }
-
- inline void operator()(leaf const& n)
- {
- typedef typename rtree::elements_type<leaf>::type elements_type;
- elements_type const& elements = rtree::elements(n);
-
- if ( level_f <= level )
- {
- size_t level_rel = level - level_f;
-
- glColor3f(0.25f, 0.25f, 0.25f);
-
- for (typename elements_type::const_iterator it = elements.begin();
- it != elements.end(); ++it)
- {
- detail::gl_draw_indexable(tr(*it), level_rel * z_mul);
- }
- }
- }
-
- Translator const& tr;
- size_t level_f;
- size_t level_l;
- typename index::detail::traits::coordinate_type<Box>::type z_mul;
-
- size_t level;
-};
-
-}}} // namespace detail::rtree::visitors
-
-template <typename Value, typename Options, typename IndexableGetter, typename EqualTo, typename Allocator>
-void gl_draw(rtree<Value, Options, IndexableGetter, EqualTo, Allocator> const& tree,
- size_t level_first = 0,
- size_t level_last = (std::numeric_limits<size_t>::max)(),
- typename index::detail::traits::coordinate_type<
- typename rtree<Value, Options, IndexableGetter, EqualTo, Allocator>::box_type
- >::type z_coord_level_multiplier = 1
- )
-{
- typedef rtree<Value, Options, IndexableGetter, EqualTo, Allocator> rtree_type;
-
- typedef typename rtree_type::value_type value_type;
- typedef typename rtree_type::options_type options_type;
- typedef typename rtree_type::translator_type translator_type;
- typedef typename rtree_type::box_type box_type;
- typedef typename rtree_type::allocators_type allocators_type;
-
- if ( !tree.empty() )
- {
- glColor3f(0.75f, 0.75f, 0.75f);
- detail::rtree::visitors::detail::gl_draw_indexable(tree.bounds(), 0);
- }
-
- detail::rtree::visitors::gl_draw<value_type, options_type, translator_type, box_type, allocators_type>
- gl_draw_v(tree.translator(), level_first, level_last, z_coord_level_multiplier);
-
- tree.apply_visitor(gl_draw_v);
-}
-
-}}} // namespace boost::geometry::index
-
-#endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_VISITORS_GL_DRAW_HPP

Deleted: trunk/boost/geometry/index/detail/rtree/visitors/print.hpp
==============================================================================
--- trunk/boost/geometry/index/detail/rtree/visitors/print.hpp 2013-06-06 18:52:19 EDT (Thu, 06 Jun 2013) (r84660)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,197 +0,0 @@
-// Boost.Geometry Index
-//
-// R-tree ostreaming visitor implementation
-//
-// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
-//
-// Use, modification and distribution is subject to the Boost Software License,
-// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-#ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_VISITORS_PRINT_HPP
-#define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_VISITORS_PRINT_HPP
-
-#include <iostream>
-
-namespace boost { namespace geometry { namespace index {
-
-namespace detail { namespace rtree { namespace visitors {
-
-namespace dispatch {
-
-template <typename Point, size_t Dimension>
-struct print_point
-{
- BOOST_STATIC_ASSERT(0 < Dimension);
-
- static inline void apply(std::ostream & os, Point const& p)
- {
- print_point<Point, Dimension - 1>::apply(os, p);
-
- os << ", " << geometry::get<Dimension - 1>(p);
- }
-};
-
-template <typename Point>
-struct print_point<Point, 1>
-{
- static inline void apply(std::ostream & os, Point const& p)
- {
- os << geometry::get<0>(p);
- }
-};
-
-template <typename Box, size_t Corner, size_t Dimension>
-struct print_corner
-{
- BOOST_STATIC_ASSERT(0 < Dimension);
-
- static inline void apply(std::ostream & os, Box const& b)
- {
- print_corner<Box, Corner, Dimension - 1>::apply(os, b);
-
- os << ", " << geometry::get<Corner, Dimension - 1>(b);
- }
-};
-
-template <typename Box, size_t Corner>
-struct print_corner<Box, Corner, 1>
-{
- static inline void apply(std::ostream & os, Box const& b)
- {
- os << geometry::get<Corner, 0>(b);
- }
-};
-
-template <typename Indexable, typename Tag>
-struct print_indexable
-{
-};
-
-template <typename Indexable>
-struct print_indexable<Indexable, box_tag>
-{
- static const size_t dimension = index::detail::traits::dimension<Indexable>::value;
-
- static inline void apply(std::ostream &os, Indexable const& i)
- {
- os << '(';
- print_corner<Indexable, min_corner, dimension>::apply(os, i);
- os << ")x(";
- print_corner<Indexable, max_corner, dimension>::apply(os, i);
- os << ')';
- }
-};
-
-template <typename Indexable>
-struct print_indexable<Indexable, point_tag>
-{
- static const size_t dimension = index::detail::traits::dimension<Indexable>::value;
-
- static inline void apply(std::ostream &os, Indexable const& i)
- {
- os << '(';
- print_point<Indexable, dimension>::apply(os, i);
- os << ')';
- }
-};
-
-} // namespace dispatch
-
-namespace detail {
-
-template <typename Indexable>
-inline void print_indexable(std::ostream & os, Indexable const& i)
-{
- dispatch::print_indexable<
- Indexable,
- typename geometry::traits::tag<Indexable>::type
- >::apply(os, i);
-}
-
-} // namespace detail
-
-template <typename Value, typename Options, typename Translator, typename Box, typename Allocators>
-struct print : public rtree::visitor<Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag, true>::type
-{
- typedef typename rtree::internal_node<Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag>::type internal_node;
- typedef typename rtree::leaf<Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag>::type leaf;
-
- inline print(std::ostream & o, Translator const& t)
- : os(o), tr(t), level(0)
- {}
-
- inline void operator()(internal_node const& n)
- {
- typedef typename rtree::elements_type<internal_node>::type elements_type;
- elements_type const& elements = rtree::elements(n);
-
- spaces(level) << "INTERNAL NODE - L:" << level << " Ch:" << elements.size() << " @:" << &n << '\n';
-
- for (typename elements_type::const_iterator it = elements.begin();
- it != elements.end(); ++it)
- {
- spaces(level);
- detail::print_indexable(os, it->first);
- os << " ->" << it->second << '\n';
- }
-
- size_t level_backup = level;
- ++level;
-
- for (typename elements_type::const_iterator it = elements.begin();
- it != elements.end(); ++it)
- {
- rtree::apply_visitor(*this, *it->second);
- }
-
- level = level_backup;
- }
-
- inline void operator()(leaf const& n)
- {
- typedef typename rtree::elements_type<leaf>::type elements_type;
- elements_type const& elements = rtree::elements(n);
-
- spaces(level) << "LEAF - L:" << level << " V:" << elements.size() << " @:" << &n << '\n';
- for (typename elements_type::const_iterator it = elements.begin();
- it != elements.end(); ++it)
- {
- spaces(level);
- detail::print_indexable(os, tr(*it));
- os << '\n';
- }
- }
-
- inline std::ostream & spaces(size_t level)
- {
- for ( size_t i = 0 ; i < 2 * level ; ++i )
- os << ' ';
- return os;
- }
-
- std::ostream & os;
- Translator const& tr;
-
- size_t level;
-};
-
-}}} // namespace detail::rtree::visitors
-
-template <typename Value, typename Options, typename IndexableGetter, typename EqualTo, typename Allocator>
-std::ostream & operator<<(std::ostream & os, rtree<Value, Options, IndexableGetter, EqualTo, Allocator> const& tree)
-{
- typedef rtree<Value, Options, IndexableGetter, EqualTo, Allocator> rtree_type;
- typedef typename rtree_type::value_type value_type;
- typedef typename rtree_type::options_type options_type;
- typedef typename rtree_type::translator_type translator_type;
- typedef typename rtree_type::box_type box_type;
- typedef typename rtree_type::allocators_type allocators_type;
- detail::rtree::visitors::print<value_type, options_type, translator_type, box_type, allocators_type> print_v(os, tree.translator());
- tree.apply_visitor(print_v);
- return os;
-}
-
-}}} // namespace boost::geometry::index
-
-#endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_VISITORS_PRINT_HPP

Deleted: trunk/boost/geometry/index/detail/rtree/visitors/statistics.hpp
==============================================================================
--- trunk/boost/geometry/index/detail/rtree/visitors/statistics.hpp 2013-06-06 18:52:19 EDT (Thu, 06 Jun 2013) (r84660)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,109 +0,0 @@
-// Boost.Geometry Index
-//
-// R-tree visitor collecting basic statistics
-//
-// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
-// Copyright (c) 2013 Mateusz Loskot, London, UK.
-//
-// Use, modification and distribution is subject to the Boost Software License,
-// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-#ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_VISITORS_STATISTICS_HPP
-#define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_VISITORS_STATISTICS_HPP
-
-#include <boost/geometry/index/detail/indexable.hpp>
-#include <algorithm>
-#include <tuple>
-
-namespace boost { namespace geometry { namespace index {
-
-namespace detail { namespace rtree { namespace visitors {
-
-template <typename Value, typename Options, typename Translator, typename Box, typename Allocators>
-struct statistics : public rtree::visitor<Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag, true>::type
-{
- typedef typename rtree::internal_node<Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag>::type internal_node;
- typedef typename rtree::leaf<Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag>::type leaf;
-
- inline statistics()
- : level(0)
- , levels(1) // count root
- , nodes(0)
- , leaves(0)
- , values(0)
- , values_min(0)
- , values_max(0)
- {}
-
- inline void operator()(internal_node const& n)
- {
- typedef typename rtree::elements_type<internal_node>::type elements_type;
- elements_type const& elements = rtree::elements(n);
-
- ++nodes; // count node
-
- size_t const level_backup = level;
- ++level;
-
- levels += level++ > levels ? 1 : 0; // count level (root already counted)
-
- for (typename elements_type::const_iterator it = elements.begin();
- it != elements.end(); ++it)
- {
- rtree::apply_visitor(*this, *it->second);
- }
-
- level = level_backup;
- }
-
- inline void operator()(leaf const& n)
- {
- typedef typename rtree::elements_type<leaf>::type elements_type;
- elements_type const& elements = rtree::elements(n);
-
- ++leaves; // count leaves
-
- std::size_t const v = elements.size();
- // count values spread per node and total
- values_min = (std::min)(values_min == 0 ? v : values_min, v);
- values_max = (std::max)(values_max, v);
- values += v;
- }
-
- std::size_t level;
- std::size_t levels;
- std::size_t nodes;
- std::size_t leaves;
- std::size_t values;
- std::size_t values_min;
- std::size_t values_max;
-};
-
-}}} // namespace detail::rtree::visitors
-
-template <typename Value, typename Options, typename IndexableGetter, typename EqualTo, typename Allocator>
-std::tuple<std::size_t, std::size_t, std::size_t, std::size_t, std::size_t, std::size_t>
- statistics(rtree<Value, Options, IndexableGetter, EqualTo, Allocator> const& tree)
-{
- typedef rtree<Value, Options, IndexableGetter, EqualTo, Allocator> rtree_type;
-
- typedef typename rtree_type::value_type value_type;
- typedef typename rtree_type::options_type options_type;
- typedef typename rtree_type::translator_type translator_type;
- typedef typename rtree_type::box_type box_type;
- typedef typename rtree_type::allocators_type allocators_type;
-
- detail::rtree::visitors::statistics
- <
- value_type, options_type, translator_type, box_type, allocators_type
- > stats_v;
-
- tree.apply_visitor(stats_v);
-
- return std::make_tuple(stats_v.levels, stats_v.nodes, stats_v.leaves, stats_v.values, stats_v.values_min, stats_v.values_max);
-}
-
-}}} // namespace boost::geometry::index
-
-#endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_VISITORS_STATISTICS_HPP

Modified: trunk/boost/geometry/index/rtree.hpp
==============================================================================
--- trunk/boost/geometry/index/rtree.hpp Thu Jun 6 18:45:25 2013 (r84660)
+++ trunk/boost/geometry/index/rtree.hpp 2013-06-06 18:52:19 EDT (Thu, 06 Jun 2013) (r84661)
@@ -58,6 +58,8 @@
 
 #include <boost/geometry/index/inserter.hpp>
 
+#include <boost/geometry/index/detail/rtree/utilities/view.hpp>
+
 #ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL
 #include <boost/geometry/index/detail/rtree/query_iterators.hpp>
 #ifdef BOOST_GEOMETRY_INDEX_DETAIL_ENABLE_TYPE_ERASED_ITERATORS
@@ -141,9 +143,8 @@
     /*! \brief The Box type used by the R-tree. */
     typedef typename index::detail::default_box_type<indexable_type>::type bounds_type;
 
-#if !defined(BOOST_GEOMETRY_INDEX_DETAIL_ENABLE_DEBUG_INTERFACE)
 private:
-#endif
+
     typedef detail::translator<IndexableGetter, EqualTo> translator_type;
 
     typedef bounds_type box_type;
@@ -158,6 +159,8 @@
     typedef typename allocators_type::node_pointer node_pointer;
     typedef ::boost::container::allocator_traits<Allocator> allocator_traits_type;
 
+ friend class detail::rtree::utilities::view<rtree>;
+
 public:
 
     /*! \brief Type of reference to Value. */
@@ -972,9 +975,8 @@
         return m_members.allocators().allocator();
     }
 
-#if !defined(BOOST_GEOMETRY_INDEX_DETAIL_ENABLE_DEBUG_INTERFACE)
 private:
-#endif
+
     /*!
     \brief Returns the translator object.
 
@@ -1007,21 +1009,6 @@
     }
 
     /*!
- \brief Returns the number of stored objects. Same as size().
-
- This function is not a part of the 'official' interface.
-
- \return The number of stored objects.
-
- \par Throws
- Nothing.
- */
- inline size_type values_count() const
- {
- return m_members.values_count;
- }
-
- /*!
     \brief Returns the depth of the R-tree.
 
     This function is not a part of the 'official' interface.
@@ -1037,6 +1024,7 @@
     }
 
 private:
+
     /*!
     \pre Root node must exist - m_root != 0.
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk