Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r71775 - in sandbox-branches/geometry/index_080_new: boost/geometry/extensions/index/rtree boost/geometry/extensions/index/rtree/linear boost/geometry/extensions/index/rtree/visitors tests
From: adam.wulkiewicz_at_[hidden]
Date: 2011-05-06 19:59:06


Author: awulkiew
Date: 2011-05-06 19:59:05 EDT (Fri, 06 May 2011)
New Revision: 71775
URL: http://svn.boost.org/trac/boost/changeset/71775

Log:
cleanup
Text files modified:
   sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/linear/linear.hpp | 3 ---
   sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/node.hpp | 35 ++++++++---------------------------
   sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/visitors/are_boxes_ok.hpp | 26 ++++++++++++++++----------
   sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/visitors/destroy.hpp | 7 ++++---
   sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/visitors/find.hpp | 14 ++++++++------
   sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/visitors/gl_draw.hpp | 18 ++++++++++--------
   sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/visitors/insert.hpp | 10 +++++-----
   sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/visitors/print.hpp | 22 ++++++++++++----------
   sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/visitors/remove.hpp | 2 +-
   sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/visitors/save.hpp | 36 +++++++++++++++++++++---------------
   sandbox-branches/geometry/index_080_new/tests/main.cpp | 10 +++++-----
   11 files changed, 90 insertions(+), 93 deletions(-)

Modified: sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/linear/linear.hpp
==============================================================================
--- sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/linear/linear.hpp (original)
+++ sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/linear/linear.hpp 2011-05-06 19:59:05 EDT (Fri, 06 May 2011)
@@ -16,9 +16,6 @@
 
 }}} // namespace boost::geometry::index
 
-//TEST
-// TODO
-
 #include <boost/geometry/extensions/index/rtree/linear/redistribute_elements.hpp>
 
 #endif // BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_LINEAR_LINEAR_HPP

Modified: sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/node.hpp
==============================================================================
--- sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/node.hpp (original)
+++ sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/node.hpp 2011-05-06 19:59:05 EDT (Fri, 06 May 2011)
@@ -30,16 +30,16 @@
             Box,
             typename node<Value, Box, Tag>::type *
>
- > children_type;
+ > elements_type;
 
- children_type children;
+ elements_type elements;
 };
 
 template <typename Value, typename Box, typename Tag>
 struct leaf_def
 {
- typedef std::vector<Value> values_type;
- values_type values;
+ typedef std::vector<Value> elements_type;
+ elements_type elements;
 };
 
 // nodes traits
@@ -73,18 +73,6 @@
     typedef typename Node::elements_type type;
 };
 
-template <typename Value, typename Box, typename Tag>
-struct elements_type< internal_node_def<Value, Box, Tag> >
-{
- typedef typename internal_node_def<Value, Box, Tag>::children_type type;
-};
-
-template <typename Value, typename Box, typename Tag>
-struct elements_type< leaf_def<Value, Box, Tag> >
-{
- typedef typename leaf_def<Value, Box, Tag>::values_type type;
-};
-
 template <typename Node>
 typename elements_type<Node>::type &
 elements_get(Node & n)
@@ -92,18 +80,11 @@
     return n.elements;
 }
 
-template <typename Value, typename Box, typename Tag>
-typename internal_node_def<Value, Box, Tag>::children_type &
-elements_get(internal_node_def<Value, Box, Tag> & n)
-{
- return n.children;
-}
-
-template <typename Value, typename Box, typename Tag>
-typename leaf_def<Value, Box, Tag>::values_type &
-elements_get(leaf_def<Value, Box, Tag> & n)
+template <typename Node>
+typename elements_type<Node>::type const&
+elements_get(Node const& n)
 {
- return n.values;
+ return n.elements;
 }
 
 //template <typename Node>

Modified: sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/visitors/are_boxes_ok.hpp
==============================================================================
--- sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/visitors/are_boxes_ok.hpp (original)
+++ sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/visitors/are_boxes_ok.hpp 2011-05-06 19:59:05 EDT (Fri, 06 May 2011)
@@ -30,7 +30,10 @@
 
     inline bool operator()(internal_node const& n)
     {
- if (n.children.empty())
+ typedef typename rtree::elements_type<internal_node>::type elements_type;
+ elements_type const& elements = rtree::elements_get(n);
+
+ if (elements.empty())
             return false;
 
         Box box_bckup = m_box;
@@ -38,8 +41,8 @@
 
         m_is_root = false;
 
- for ( internal_node::children_type::const_iterator it = n.children.begin();
- it != n.children.end() ; ++it)
+ for ( typename elements_type::const_iterator it = elements.begin();
+ it != elements.end() ; ++it)
         {
             m_box = it->first;
 
@@ -51,9 +54,9 @@
         m_is_root = is_root_bckup;
 
         Box result;
- geometry::convert(n.children.front().first, result);
- for(internal_node::children_type::const_iterator it = n.children.begin() + 1;
- it != n.children.end() ; ++it)
+ geometry::convert(elements.front().first, result);
+ for( typename elements_type::const_iterator it = elements.begin() + 1;
+ it != elements.end() ; ++it)
         {
             geometry::expand(result, it->first);
         }
@@ -63,13 +66,16 @@
 
     inline bool operator()(leaf const& n)
     {
- if (n.values.empty())
+ typedef typename rtree::elements_type<leaf>::type elements_type;
+ elements_type const& elements = rtree::elements_get(n);
+
+ if (elements.empty())
             return false;
 
         Box result;
- geometry::convert(m_tr(n.values.front()), result);
- for(leaf::values_type::const_iterator it = n.values.begin() + 1;
- it != n.values.end() ; ++it)
+ geometry::convert(m_tr(elements.front()), result);
+ for(typename elements_type::const_iterator it = elements.begin() + 1;
+ it != elements.end() ; ++it)
         {
             geometry::expand(result, m_tr(*it));
         }

Modified: sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/visitors/destroy.hpp
==============================================================================
--- sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/visitors/destroy.hpp (original)
+++ sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/visitors/destroy.hpp 2011-05-06 19:59:05 EDT (Fri, 06 May 2011)
@@ -24,10 +24,11 @@
 
     inline void operator()(internal_node & n) const
     {
- typedef typename internal_node::children_type children_type;
+ typedef typename rtree::elements_type<internal_node>::type elements_type;
+ elements_type & elements = rtree::elements_get(n);
 
- for (typename children_type::iterator it = n.children.begin();
- it != n.children.end(); ++it)
+ for (typename elements_type::iterator it = elements.begin();
+ it != elements.end(); ++it)
         {
             boost::apply_visitor(*this, *it->second);
 

Modified: sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/visitors/find.hpp
==============================================================================
--- sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/visitors/find.hpp (original)
+++ sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/visitors/find.hpp 2011-05-06 19:59:05 EDT (Fri, 06 May 2011)
@@ -193,10 +193,11 @@
         // }
         //}
 
- typedef typename internal_node::children_type children_type;
+ typedef typename rtree::elements_type<internal_node>::type elements_type;
+ elements_type const& elements = rtree::elements_get(n);
 
- for (typename children_type::const_iterator it = n.children.begin();
- it != n.children.end(); ++it)
+ for (typename elements_type::const_iterator it = elements.begin();
+ it != elements.end(); ++it)
         {
             if ( geometry::intersects(it->first, geom) )
                 boost::apply_visitor(*this, *it->second);
@@ -205,10 +206,11 @@
 
     inline void operator()(leaf const& n)
     {
- typedef typename leaf::values_type values_type;
+ typedef typename rtree::elements_type<leaf>::type elements_type;
+ elements_type const& elements = rtree::elements_get(n);
 
- for (typename values_type::const_iterator it = n.values.begin();
- it != n.values.end(); ++it)
+ for (typename elements_type::const_iterator it = elements.begin();
+ it != elements.end(); ++it)
         {
             if ( geometry::intersects(tr(*it), geom) )
             {

Modified: sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/visitors/gl_draw.hpp
==============================================================================
--- sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/visitors/gl_draw.hpp (original)
+++ sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/visitors/gl_draw.hpp 2011-05-06 19:59:05 EDT (Fri, 06 May 2011)
@@ -114,7 +114,8 @@
 
     inline void operator()(internal_node const& n)
     {
- typedef typename internal_node::children_type children_type;
+ typedef typename rtree::elements_type<internal_node>::type elements_type;
+ elements_type const& elements = rtree::elements_get(n);
 
         if ( level_f <= level )
         {
@@ -135,8 +136,8 @@
             else
                 glColor3f(0.5f, 0.5f, 0.5f);
 
- for (typename children_type::const_iterator it = n.children.begin();
- it != n.children.end(); ++it)
+ for (typename elements_type::const_iterator it = elements.begin();
+ it != elements.end(); ++it)
             {
                 detail::gl_draw_indexable(it->first, level_rel * z_mul);
             }
@@ -147,8 +148,8 @@
 
         if ( level < level_l )
         {
- for (typename children_type::const_iterator it = n.children.begin();
- it != n.children.end(); ++it)
+ for (typename elements_type::const_iterator it = elements.begin();
+ it != elements.end(); ++it)
             {
                 boost::apply_visitor(*this, *it->second);
             }
@@ -159,7 +160,8 @@
 
     inline void operator()(leaf const& n)
     {
- typedef typename leaf::values_type values_type;
+ typedef typename rtree::elements_type<leaf>::type elements_type;
+ elements_type const& elements = rtree::elements_get(n);
 
         if ( level_f <= level )
         {
@@ -167,8 +169,8 @@
 
             glColor3f(1.0f, 1.0f, 1.0f);
 
- for (typename values_type::const_iterator it = n.values.begin();
- it != n.values.end(); ++it)
+ for (typename elements_type::const_iterator it = elements.begin();
+ it != elements.end(); ++it)
             {
                 detail::gl_draw_indexable(tr(*it), level_rel * z_mul);
             }

Modified: sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/visitors/insert.hpp
==============================================================================
--- sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/visitors/insert.hpp (original)
+++ sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/visitors/insert.hpp 2011-05-06 19:59:05 EDT (Fri, 06 May 2011)
@@ -111,9 +111,9 @@
         if ( parent != 0 )
         {
             // update old node's box
- parent->children[current_child_index].first = box1;
+ rtree::elements_get(*parent)[current_child_index].first = box1;
             // add new node to the parent's children
- parent->children.push_back(std::make_pair(box2, second_node));
+ rtree::elements_get(*parent).push_back(std::make_pair(box2, second_node));
         }
         // node is the root
         else
@@ -123,8 +123,8 @@
             // create new root and add nodes
             node * new_root = rtree::create_node(internal_node());
 
- boost::get<internal_node>(*new_root).children.push_back(std::make_pair(box1, root));
- boost::get<internal_node>(*new_root).children.push_back(std::make_pair(box2, second_node));
+ rtree::elements_get(boost::get<internal_node>(*new_root)).push_back(std::make_pair(box1, root));
+ rtree::elements_get(boost::get<internal_node>(*new_root)).push_back(std::make_pair(box2, second_node));
 
             root = new_root;
         }
@@ -209,7 +209,7 @@
 
         // expand the node to contain value
         geometry::expand(
- n.children[choosen_node_index].first,
+ rtree::elements_get(n)[choosen_node_index].first,
             rtree::element_indexable(m_element, m_tr));
 
         // next traversing step

Modified: sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/visitors/print.hpp
==============================================================================
--- sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/visitors/print.hpp (original)
+++ sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/visitors/print.hpp 2011-05-06 19:59:05 EDT (Fri, 06 May 2011)
@@ -125,12 +125,13 @@
 
     inline void operator()(internal_node const& n)
     {
- typedef typename internal_node::children_type children_type;
+ typedef typename rtree::elements_type<internal_node>::type elements_type;
+ elements_type const& elements = rtree::elements_get(n);
 
- spaces(level) << "INTERNAL NODE - L:" << level << " Ch:" << n.children.size() << " @:" << &n << '\n';
+ spaces(level) << "INTERNAL NODE - L:" << level << " Ch:" << elements.size() << " @:" << &n << '\n';
         
- for (typename children_type::const_iterator it = n.children.begin();
- it != n.children.end(); ++it)
+ for (typename elements_type::const_iterator it = elements.begin();
+ it != elements.end(); ++it)
         {
             spaces(level);
             detail::print_indexable(os, it->first);
@@ -140,8 +141,8 @@
         size_t level_backup = level;
         ++level;
 
- for (typename children_type::const_iterator it = n.children.begin();
- it != n.children.end(); ++it)
+ for (typename elements_type::const_iterator it = elements.begin();
+ it != elements.end(); ++it)
         {
             boost::apply_visitor(*this, *it->second);
         }
@@ -151,11 +152,12 @@
 
     inline void operator()(leaf const& n)
     {
- typedef typename leaf::values_type values_type;
+ typedef typename rtree::elements_type<leaf>::type elements_type;
+ elements_type const& elements = rtree::elements_get(n);
 
- spaces(level) << "LEAF - L:" << level << " V:" << n.values.size() << " @:" << &n << '\n';
- for (typename values_type::const_iterator it = n.values.begin();
- it != n.values.end(); ++it)
+ 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));

Modified: sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/visitors/remove.hpp
==============================================================================
--- sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/visitors/remove.hpp (original)
+++ sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/visitors/remove.hpp 2011-05-06 19:59:05 EDT (Fri, 06 May 2011)
@@ -167,7 +167,7 @@
         ++m_current_level;
 
         // next traversing step
- boost::apply_visitor(*this, *n.children[choosen_node_index].second);
+ boost::apply_visitor(*this, *rtree::elements_get(n)[choosen_node_index].second);
 
         // restore previous traverse inputs
         m_parent = parent_bckup;

Modified: sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/visitors/save.hpp
==============================================================================
--- sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/visitors/save.hpp (original)
+++ sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/visitors/save.hpp 2011-05-06 19:59:05 EDT (Fri, 06 May 2011)
@@ -54,35 +54,41 @@
 
     inline void operator()(internal_node & n)
     {
- os << n.children.size() << '\n';
+ typedef typename rtree::elements_type<internal_node>::type elements_type;
+ elements_type & elements = rtree::elements_get(n);
 
- for ( size_t i = 0 ; i < n.children.size() ; ++i )
+ os << elements.size() << '\n';
+
+ for ( size_t i = 0 ; i < elements.size() ; ++i )
         {
- if ( boost::apply_visitor(visitors::is_leaf<value_type, Box, Tag>(), *(n.children[i].second)) )
+ if ( boost::apply_visitor(visitors::is_leaf<value_type, Box, Tag>(), *(elements[i].second)) )
                 os << "l ";
             else
                 os << "i ";
- os << geometry::get<min_corner, 0>(n.children[i].first) << ' ';
- os << geometry::get<min_corner, 1>(n.children[i].first) << ' ';
- os << geometry::get<max_corner, 0>(n.children[i].first) << ' ';
- os << geometry::get<max_corner, 1>(n.children[i].first) << ' ';
+ os << geometry::get<min_corner, 0>(elements[i].first) << ' ';
+ os << geometry::get<min_corner, 1>(elements[i].first) << ' ';
+ os << geometry::get<max_corner, 0>(elements[i].first) << ' ';
+ os << geometry::get<max_corner, 1>(elements[i].first) << ' ';
 
- boost::apply_visitor(*this, *(n.children[i].second));
+ boost::apply_visitor(*this, *(elements[i].second));
         }
     }
 
     inline void operator()(leaf & n)
     {
- os << n.values.size() << '\n';
+ typedef typename rtree::elements_type<leaf>::type elements_type;
+ elements_type & elements = rtree::elements_get(n);
+
+ os << elements.size() << '\n';
 
- for ( size_t i = 0 ; i < n.values.size() ; ++i )
+ for ( size_t i = 0 ; i < elements.size() ; ++i )
         {
             os << "v ";
- os << geometry::get<min_corner, 0>(n.values[i].first) << ' ';
- os << geometry::get<min_corner, 1>(n.values[i].first) << ' ';
- os << geometry::get<max_corner, 0>(n.values[i].first) << ' ';
- os << geometry::get<max_corner, 1>(n.values[i].first) << ' ';
- os << n.values[i].second << '\n';
+ os << geometry::get<min_corner, 0>(elements[i].first) << ' ';
+ os << geometry::get<min_corner, 1>(elements[i].first) << ' ';
+ os << geometry::get<max_corner, 0>(elements[i].first) << ' ';
+ os << geometry::get<max_corner, 1>(elements[i].first) << ' ';
+ os << elements[i].second << '\n';
         }
     }
 

Modified: sandbox-branches/geometry/index_080_new/tests/main.cpp
==============================================================================
--- sandbox-branches/geometry/index_080_new/tests/main.cpp (original)
+++ sandbox-branches/geometry/index_080_new/tests/main.cpp 2011-05-06 19:59:05 EDT (Fri, 06 May 2011)
@@ -8,9 +8,9 @@
 {
     tests_translators_hpp();
     tests_rtree_native_hpp<boost::geometry::index::linear_tag>();
- //tests_rtree_native_hpp<boost::geometry::index::rstar_tag>();
+ tests_rtree_native_hpp<boost::geometry::index::quadratic_tag>();
     tests_rtree_filters_hpp();
-
+ /*
     {
         namespace bg = boost::geometry;
         namespace bgi = boost::geometry::index;
@@ -22,21 +22,21 @@
         const int m = 15;
         for ( int i = 0 ; i < m ; ++i )
         {
- bgi::insert(t, V(B(P(i*2, i*2), P(i*2+1, i*2+1)), i));
+ bgi::insert(t, V(B(P(i*2.0f, i*2.0f), P(i*2.0f+1, i*2.0f+1)), i));
         }
         std::cout << t << "\n------------------------------------\n";
         std::cin.get();
 
         for ( int i = 0 ; i < m ; ++i )
         {
- bgi::remove(t, V(B(P(i*2, i*2), P(i*2+1, i*2+1)), i));
+ bgi::remove(t, V(B(P(i*2.0f, i*2.0f), P(i*2.0f+1, i*2.0f+1)), i));
             std::cout << t << '\n';
             std::cout << ( boost::geometry::index::are_boxes_ok(t) ? "boxes OK" : "WRONG BOXES!" );
             std::cout << "\n------------------------------------\n";
             std::cin.get();
         }
     }
-
+ */
 #ifdef _MSC_VER
     std::cin.get();
 #endif


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