Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r69572 - in sandbox-branches/geometry/index_080_nhch: boost/geometry/extensions/index/rtree tests
From: adam.wulkiewicz_at_[hidden]
Date: 2011-03-04 18:34:32


Author: awulkiew
Date: 2011-03-04 18:34:30 EST (Fri, 04 Mar 2011)
New Revision: 69572
URL: http://svn.boost.org/trac/boost/changeset/69572

Log:
gcc compilation errors corrected
Text files modified:
   sandbox-branches/geometry/index_080_nhch/boost/geometry/extensions/index/rtree/rtree.hpp | 28 +++++++++----
   sandbox-branches/geometry/index_080_nhch/boost/geometry/extensions/index/rtree/rtree_internal_node.hpp | 80 +++++++++++++++++++++++++++------------
   sandbox-branches/geometry/index_080_nhch/boost/geometry/extensions/index/rtree/rtree_leaf.hpp | 65 ++++++++++++++++++++------------
   sandbox-branches/geometry/index_080_nhch/boost/geometry/extensions/index/rtree/rtree_node.hpp | 27 +++++++++----
   sandbox-branches/geometry/index_080_nhch/tests/additional_sizes_and_times.cpp | 6 ++
   sandbox-branches/geometry/index_080_nhch/tests/rtree_filters.hpp | 2
   sandbox-branches/geometry/index_080_nhch/tests/rtree_native.hpp | 2
   sandbox-branches/geometry/index_080_nhch/tests/translators.hpp | 2
   8 files changed, 141 insertions(+), 71 deletions(-)

Modified: sandbox-branches/geometry/index_080_nhch/boost/geometry/extensions/index/rtree/rtree.hpp
==============================================================================
--- sandbox-branches/geometry/index_080_nhch/boost/geometry/extensions/index/rtree/rtree.hpp (original)
+++ sandbox-branches/geometry/index_080_nhch/boost/geometry/extensions/index/rtree/rtree.hpp 2011-03-04 18:34:30 EST (Fri, 04 Mar 2011)
@@ -10,10 +10,11 @@
 // awulkiew 2011
 // typedefs added
 // nodes hierarchy changed
-// gl_draw added - temporary
 // coordinate_type changed to area_result<Box>::type in areas calculation
+// translator added
+// gl_draw added - temporary
 
-// TODO: awulkiew - implement different method of drawing tree
+// TODO: awulkiew - implement different method of tree drawing algorithm
 
 #ifndef BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_RTREE_HPP
 #define BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_RTREE_HPP
@@ -50,9 +51,9 @@
     // awulkiew - typedefs added
     typedef Value value_type;
 
- typedef rtree_node<Value, Translator, Box> rtree_node;
- typedef rtree_leaf<Value, Translator, Box> rtree_leaf;
- typedef rtree_internal_node<Value, Translator, Box> rtree_internal_node;
+ typedef geometry::index::rtree_node<Value, Translator, Box> rtree_node;
+ typedef geometry::index::rtree_leaf<Value, Translator, Box> rtree_leaf;
+ typedef geometry::index::rtree_internal_node<Value, Translator, Box> rtree_internal_node;
 
     typedef boost::shared_ptr<rtree_node> node_pointer;
     typedef boost::shared_ptr<rtree_internal_node> internal_node_pointer;
@@ -176,11 +177,11 @@
     /**
      * \brief Remove element inside the box with value
      */
- // awulkiew - added conversion to Box
     void remove(Value const& value)
     {
         try
         {
+ // awulkiew - added conversion to Box
             Box box;
             detail::convert_to_box(m_translator(value), box);
             
@@ -197,6 +198,8 @@
                 leaf = *it;
                 try
                 {
+ // TODO: awulkiew - exception shouldn't be used as a way to check if value wasn't removed from leaf
+
                     // awulkiew - translator passed
                     leaf->remove(value, m_translator);
                     break;
@@ -274,6 +277,8 @@
 
             // not found
             std::cerr << e.what() << std::endl;
+
+ // awulkiew - not needed
             return;
         }
     }
@@ -290,9 +295,9 @@
     /**
      * \brief Inserts an element with 'box' as key with value.
      */
- // awulkiew - added conversion to Box
     inline void insert(Value const& value)
     {
+ // awulkiew - added conversion to Box
         Box box;
         detail::convert_to_box(m_translator(value), box);
 
@@ -358,6 +363,11 @@
 
 #endif // BOOST_GEOMETRY_INDEX_RTREE_ENABLE_GL_DRAW
 
+ std::vector<Box> get_level_boxes(size_t level) const
+ {
+ m_root->get_level_boxes(level, m_translator);
+ }
+
 private:
 
     /// number of elements
@@ -447,8 +457,8 @@
             n1->set_parent(new_root);
             n2->set_parent(new_root);
 
- n1->update_parent(n1);
- n2->update_parent(n2);
+ n1->set_children_parent(n1);
+ n2->set_children_parent(n2);
 
             m_root = new_root;
             return;

Modified: sandbox-branches/geometry/index_080_nhch/boost/geometry/extensions/index/rtree/rtree_internal_node.hpp
==============================================================================
--- sandbox-branches/geometry/index_080_nhch/boost/geometry/extensions/index/rtree/rtree_internal_node.hpp (original)
+++ sandbox-branches/geometry/index_080_nhch/boost/geometry/extensions/index/rtree/rtree_internal_node.hpp 2011-03-04 18:34:30 EST (Fri, 04 Mar 2011)
@@ -10,7 +10,9 @@
 // awulkiew 2011
 // typedefs added
 // nodes hierarchy changed, rtree_node changed to rtree_internal_node
-// inconsistent names changed - get_leafs to get_values
+// inconsistent names changed - get_leafs to get_values, update_parent to set_children_parent
+// translator added
+// exact match case removed
 // gl_draw added - temporary
 
 #ifndef BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_RTREE_INTERNAL_NODE_HPP
@@ -39,8 +41,8 @@
 {
 public:
 
- typedef rtree_node<Value, Translator, Box> rtree_node;
- typedef rtree_leaf<Value, Translator, Box> rtree_leaf;
+ typedef geometry::index::rtree_node<Value, Translator, Box> rtree_node;
+ typedef geometry::index::rtree_leaf<Value, Translator, Box> rtree_leaf;
 
     typedef boost::shared_ptr<rtree_node> node_pointer;
     typedef boost::shared_ptr<rtree_leaf> leaf_pointer;
@@ -65,14 +67,14 @@
 
     // awulkiew - internal node methods
 
- /**
- * \brief Clear the node
- */
- // awulkiew - name changed from empty_nodes to clear_nodes
- void clear_nodes()
- {
- m_nodes.clear();
- }
+ ///**
+ // * \brief Clear the node
+ // */
+ //// awulkiew - name changed from empty_nodes to clear_nodes
+ //void clear_nodes()
+ //{
+ // m_nodes.clear();
+ //}
 
     // awulkiew - internal node and leaf virtual methods
 
@@ -146,7 +148,7 @@
 
             //TODO:
             // awulkiew - reserve/resize, std::copy may be used here
- for (typename values_map::iterator it_leaf = this_values.begin();
+ for (typename values_map::const_iterator it_leaf = this_values.begin();
                 it_leaf != this_values.end(); ++it_leaf)
             {
                 values.push_back(*it_leaf);
@@ -187,6 +189,17 @@
     }
 
     /**
+ * \brief Update the parent of all children nodes
+ */
+ virtual void set_children_parent(node_pointer const& node)
+ {
+ for (typename node_map::iterator it = m_nodes.begin(); it != m_nodes.end(); ++it)
+ {
+ it->second->set_parent(node);
+ }
+ }
+
+ /**
      * \brief Print Rtree subtree (mainly for debug)
      */
     // awulkiew - ostream parameter added
@@ -273,6 +286,32 @@
 
 #endif // BOOST_GEOMETRY_INDEX_RTREE_ENABLE_GL_DRAW
 
+ typename std::vector<Box> get_level_boxes(size_t level, Translator const& tr) const
+ {
+ typename std::vector<Box> boxes;
+
+ if (level == this->get_level())
+ {
+ for (typename node_map::const_iterator it = m_nodes.begin();
+ it != m_nodes.end(); ++it)
+ boxes.push_back(it->first);
+ }
+ else
+ {
+ for (typename node_map::const_iterator it = m_nodes.begin();
+ it != m_nodes.end(); ++it)
+ {
+ typename std::vector<Box> current_boxes = it->second->get_level_boxes(level, tr);
+
+ for (typename std::vector<Box>::const_iterator box_it = current_boxes.begin();
+ box_it != current_boxes.end(); ++box_it)
+ boxes.push_back(*box_it);
+ }
+ }
+
+ return boxes;
+ }
+
     // awulkiew - internal node only virtual methods
 
     /**
@@ -281,7 +320,9 @@
     virtual void add_node(Box const& box, node_pointer const& node)
     {
         m_nodes.push_back(std::make_pair(box, node));
- node->update_parent(node);
+ // TODO: awulkiew - is this required?
+ // it updates the parent of all children nodes of a node which isn't changed
+ node->set_children_parent(node);
     }
 
     /**
@@ -356,7 +397,7 @@
             if (it->second.get() == leaf.get())
             {
                 m_nodes[index] = std::make_pair(new_leaf->compute_box(tr), new_leaf);
- new_leaf->update_parent(new_leaf);
+ new_leaf->set_children_parent(new_leaf);
                 return;
             }
         }
@@ -434,17 +475,6 @@
     }
 
     /**
- * \brief Update the parent of all the childs
- */
- virtual void update_parent(node_pointer const& node)
- {
- for (typename node_map::iterator it = m_nodes.begin(); it != m_nodes.end(); ++it)
- {
- it->second->set_parent(node);
- }
- }
-
- /**
      * \brief Box projector for node pointed by 'leaf'
      */
     virtual Box get_box(node_pointer const& leaf) const

Modified: sandbox-branches/geometry/index_080_nhch/boost/geometry/extensions/index/rtree/rtree_leaf.hpp
==============================================================================
--- sandbox-branches/geometry/index_080_nhch/boost/geometry/extensions/index/rtree/rtree_leaf.hpp (original)
+++ sandbox-branches/geometry/index_080_nhch/boost/geometry/extensions/index/rtree/rtree_leaf.hpp 2011-03-04 18:34:30 EST (Fri, 04 Mar 2011)
@@ -10,7 +10,8 @@
 // awulkiew 2011
 // typedefs added
 // nodes hierarchy changed
-// inconsistent names changed - leafs to values, leaf_map to values_map, get_leafs to get_values
+// inconsistent names changed - leafs to values, leaf_map to values_map, get_leafs to get_values, update_parent to set_children_parent
+// exact match case removed
 // gl_draw added - temporary
 
 #ifndef BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_RTREE_LEAF_HPP
@@ -41,7 +42,7 @@
 public:
 
     // awulkiew - typedef added
- typedef rtree_node<Value, Translator, Box> rtree_node;
+ typedef geometry::index::rtree_node<Value, Translator, Box> rtree_node;
 
     typedef boost::shared_ptr<rtree_node> node_pointer;
 
@@ -65,14 +66,14 @@
 
     // awulkiew - leaf methods
 
- /**
- * \brief Clear the node
- */
- // awulkiew - name changed from empty_nodes to clear_values
- void clear_values()
- {
- m_values.clear();
- }
+ ///**
+ // * \brief Clear the node
+ // */
+ //// awulkiew - name changed from empty_nodes to clear_values
+ //void clear_values()
+ //{
+ // m_values.clear();
+ //}
 
     // awulkiew - internal node and leaf virtual methods
 
@@ -97,30 +98,16 @@
      * If exact_match is true only return the elements having as
      * key the 'box'. Otherwise return everything inside 'box'.
      */
- // awulkiew - exact match case removed
     virtual void find(Box const& box, std::deque<Value>& result, Translator const& tr)
     {
         for (typename values_map::const_iterator it = m_values.begin();
              it != m_values.end(); ++it)
         {
- // awulkiew - commented
- //if (exact_match)
- //{
- // if (geometry::equals(it->first, box))
- // {
- // result.push_back(it->second);
- // }
- //}
- //else
- //{
-
             // awulkiew - is_overlapping changed to geometry::intersects
             if (geometry::intersects(tr(*it), box))
             {
                 result.push_back(*it);
             }
-
- //}
         }
     }
 
@@ -195,6 +182,15 @@
     }
 
     /**
+ * \brief Update the parent of all children nodes
+ */
+ virtual void set_children_parent(node_pointer const& node)
+ {
+ // TODO: awulkiew - should this method exist in leaf?
+ // Do nothing
+ }
+
+ /**
     * \brief Print leaf (mainly for debug)
     */
     // awulkiew - ostream parameter added
@@ -262,6 +258,27 @@
 
 #endif // BOOST_GEOMETRY_INDEX_RTREE_ENABLE_GL_DRAW
 
+ /**
+ * \brief Get boxes of objects if level is equal to leaf's level
+ */
+ std::vector<Box> get_level_boxes(size_t level, Translator const& tr) const
+ {
+ std::vector<Box> boxes;
+
+ /*if ( level == this->get_level())
+ {
+ for (typename values_map::const_iterator it = m_values.begin();
+ it != m_values.end(); ++it)
+ {
+ Box box;
+ detail::convert_to_box(tr(*it), box);
+ boxes.push_back(box);
+ }
+ }*/
+
+ return boxes;
+ }
+
     // awulkiew - leaf only virtual methods
 
     /**

Modified: sandbox-branches/geometry/index_080_nhch/boost/geometry/extensions/index/rtree/rtree_node.hpp
==============================================================================
--- sandbox-branches/geometry/index_080_nhch/boost/geometry/extensions/index/rtree/rtree_node.hpp (original)
+++ sandbox-branches/geometry/index_080_nhch/boost/geometry/extensions/index/rtree/rtree_node.hpp 2011-03-04 18:34:30 EST (Fri, 04 Mar 2011)
@@ -9,7 +9,9 @@
 
 // awulkiew 2011
 // nodes hierarchy changed, rtree_node changed to rtree_internal_node
-// inconsistent names changed - get_leafs to get_values
+// inconsistent names changed - get_leafs to get_values, update_parent to set_children_parent
+// translator added
+// exact match case removed
 // gl_draw added - temporary
 
 #ifndef BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_RTREE_NODE_HPP
@@ -141,6 +143,15 @@
     }
 
     /**
+ * \brief Update the parent of all children nodes
+ */
+ virtual void set_children_parent(node_pointer const& node)
+ {
+ // TODO: mloskot - define & use GGL exception
+ throw std::logic_error("shouldn't be here.");
+ }
+
+ /**
      * \brief Print Rtree subtree (mainly for debug)
      */
     // awulkiew - ostream parameter added
@@ -163,6 +174,12 @@
 
 #endif // BOOST_GEOMETRY_INDEX_RTREE_ENABLE_GL_DRAW
 
+ std::vector<Box> get_level_boxes(size_t, Translator const&) const
+ {
+ // TODO: mloskot - define & use GGL exception
+ throw std::logic_error("shouldn't be here");
+ }
+
     // awulkiew - leaf only virtual methods
 
     /**
@@ -275,14 +292,6 @@
     }
 
     /**
- * \brief Update the parent of all the childs
- */
- virtual void update_parent(node_pointer const& node)
- {
- // In case of leaf do nothing
- }
-
- /**
      * \brief Box projector for node pointed by 'leaf'
      */
     virtual Box get_box(node_pointer const& leaf) const

Modified: sandbox-branches/geometry/index_080_nhch/tests/additional_sizes_and_times.cpp
==============================================================================
--- sandbox-branches/geometry/index_080_nhch/tests/additional_sizes_and_times.cpp (original)
+++ sandbox-branches/geometry/index_080_nhch/tests/additional_sizes_and_times.cpp 2011-03-04 18:34:30 EST (Fri, 04 Mar 2011)
@@ -38,7 +38,7 @@
             v[i] = B(P(x - w, y - h),P(x + w, y + h));
         }
 
- boost::geometry::index::rtree<B> t(5, 1);
+ boost::geometry::index::rtree<B> t(10, 0);
 
         std::cout << "inserting time test...\n";
 
@@ -62,5 +62,9 @@
         std::cout << "time: " << tim.elapsed() << "s\n";
     }
 
+#ifdef _MSC_VER
+ std::cin.get();
+#endif
+
     return 0;
 }

Modified: sandbox-branches/geometry/index_080_nhch/tests/rtree_filters.hpp
==============================================================================
--- sandbox-branches/geometry/index_080_nhch/tests/rtree_filters.hpp (original)
+++ sandbox-branches/geometry/index_080_nhch/tests/rtree_filters.hpp 2011-03-04 18:34:30 EST (Fri, 04 Mar 2011)
@@ -31,7 +31,7 @@
 
 void tests_rtree_filters_hpp()
 {
- std::cout << "tests\rtree_filters.hpp\n";
+ std::cout << "tests/rtree_filters.hpp\n";
 
     typedef boost::geometry::model::point<float, 2, boost::geometry::cs::cartesian> P;
     typedef boost::geometry::model::box<P> B;

Modified: sandbox-branches/geometry/index_080_nhch/tests/rtree_native.hpp
==============================================================================
--- sandbox-branches/geometry/index_080_nhch/tests/rtree_native.hpp (original)
+++ sandbox-branches/geometry/index_080_nhch/tests/rtree_native.hpp 2011-03-04 18:34:30 EST (Fri, 04 Mar 2011)
@@ -15,7 +15,7 @@
 
 void tests_rtree_native_hpp()
 {
- std::cout << "tests\rtree_native.hpp\n";
+ std::cout << "tests/rtree_native.hpp\n";
         
     // Box
     {

Modified: sandbox-branches/geometry/index_080_nhch/tests/translators.hpp
==============================================================================
--- sandbox-branches/geometry/index_080_nhch/tests/translators.hpp (original)
+++ sandbox-branches/geometry/index_080_nhch/tests/translators.hpp 2011-03-04 18:34:30 EST (Fri, 04 Mar 2011)
@@ -15,7 +15,7 @@
 
 void tests_translators_hpp()
 {
- std::cout << "tests\translators.hpp\n";
+ std::cout << "tests/translators.hpp\n";
 
     typedef boost::geometry::model::point<float, 2, boost::geometry::cs::cartesian> P;
     typedef boost::geometry::model::box<P> B;


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