|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r69448 - in sandbox-branches/geometry/index_080_nhch: boost/geometry/extensions/index/rtree tests
From: adam.wulkiewicz_at_[hidden]
Date: 2011-03-01 17:40:50
Author: awulkiew
Date: 2011-03-01 17:40:44 EST (Tue, 01 Mar 2011)
New Revision: 69448
URL: http://svn.boost.org/trac/boost/changeset/69448
Log:
inconsistent names changed
Text files modified:
sandbox-branches/geometry/index_080_nhch/boost/geometry/extensions/index/rtree/helpers.hpp | 5 +++
sandbox-branches/geometry/index_080_nhch/boost/geometry/extensions/index/rtree/rtree.hpp | 61 ++++++++++++++++++++++-----------------
sandbox-branches/geometry/index_080_nhch/boost/geometry/extensions/index/rtree/rtree_internal_node.hpp | 24 ++++++++++-----
sandbox-branches/geometry/index_080_nhch/boost/geometry/extensions/index/rtree/rtree_leaf.hpp | 60 +++++++++++++++++++++-----------------
sandbox-branches/geometry/index_080_nhch/boost/geometry/extensions/index/rtree/rtree_node.hpp | 7 +++
sandbox-branches/geometry/index_080_nhch/tests/main.cpp | 6 +++
6 files changed, 101 insertions(+), 62 deletions(-)
Modified: sandbox-branches/geometry/index_080_nhch/boost/geometry/extensions/index/rtree/helpers.hpp
==============================================================================
--- sandbox-branches/geometry/index_080_nhch/boost/geometry/extensions/index/rtree/helpers.hpp (original)
+++ sandbox-branches/geometry/index_080_nhch/boost/geometry/extensions/index/rtree/helpers.hpp 2011-03-01 17:40:44 EST (Tue, 01 Mar 2011)
@@ -7,6 +7,11 @@
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
+// awulkiew 2011
+// enlarge_box, is_overlapping removed (functions from boost::geometry used)
+// compute_union_area changed
+// other helpers added - some of them temporary
+
#ifndef BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_HELPERS_HPP
#define BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_HELPERS_HPP
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-01 17:40:44 EST (Tue, 01 Mar 2011)
@@ -7,6 +7,14 @@
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
+// awulkiew 2011
+// typedefs added
+// nodes hierarchy changed
+// gl_draw added - temporary
+// coordinate_type changed to area_result<Box>::type in areas calculation
+
+// TODO: awulkiew - implement different method of drawing tree
+
#ifndef BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_RTREE_HPP
#define BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_RTREE_HPP
@@ -27,8 +35,7 @@
// awulkiew - added
#include <boost/geometry/extensions/index/translator/def.hpp>
-namespace boost { namespace geometry { namespace index
-{
+namespace boost { namespace geometry { namespace index {
// awulkiew - template parameters changed
template <
@@ -41,6 +48,8 @@
{
public:
// 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;
@@ -96,13 +105,13 @@
// remember that remove_in() function is used in remove() so changing it may corrupt the other one
node_pointer leaf(choose_exact_leaf(box));
- typename rtree_leaf::leaf_map q_leaves;
+ typename rtree_leaf::values_map q_values;
leaf->remove_in(box, m_translator);
if (leaf->elements() < m_min_elems_per_node && elements() > m_min_elems_per_node)
{
- q_leaves = leaf->get_leaves();
+ q_values = leaf->get_values();
// we remove the leaf_node in the parent node because now it's empty
leaf->get_parent()->remove_in(leaf->get_parent()->get_box(leaf), m_translator);
@@ -115,11 +124,11 @@
for (typename rtree_internal_node::node_map::const_iterator it = q_nodes.begin();
it != q_nodes.end(); ++it)
{
- typename rtree_leaf::leaf_map leaves = it->second->get_leaves();
+ typename rtree_leaf::values_map values = it->second->get_values();
- // reinserting leaves from nodes
- for (typename rtree_leaf::leaf_map::const_iterator itl = leaves.begin();
- itl != leaves.end(); ++itl)
+ // reinserting values from nodes
+ for (typename rtree_leaf::values_map::const_iterator itl = values.begin();
+ itl != values.end(); ++itl)
{
s.push_back(*itl);
}
@@ -144,8 +153,8 @@
}
}
// reinserting leaves
- for (typename rtree_leaf::leaf_map::const_iterator it = q_leaves.begin();
- it != q_leaves.end(); ++it)
+ for (typename rtree_leaf::values_map::const_iterator it = q_values.begin();
+ it != q_values.end(); ++it)
{
m_count--;
// awulkiew - parameters changed
@@ -200,11 +209,11 @@
if (!leaf)
return;
- typename rtree_leaf::leaf_map q_leaves;
+ typename rtree_leaf::values_map q_values;
if (leaf->elements() < m_min_elems_per_node && elements() > m_min_elems_per_node)
{
- q_leaves = leaf->get_leaves();
+ q_values = leaf->get_values();
// we remove the leaf_node in the parent node because now it's empty
leaf->get_parent()->remove_in(leaf->get_parent()->get_box(leaf), m_translator);
@@ -217,11 +226,11 @@
for (typename rtree_internal_node::node_map::const_iterator it = q_nodes.begin();
it != q_nodes.end(); ++it)
{
- typename rtree_leaf::leaf_map leaves = it->second->get_leaves();
+ typename rtree_leaf::values_map values = it->second->get_values();
// reinserting leaves from nodes
- for (typename rtree_leaf::leaf_map::const_iterator itl = leaves.begin();
- itl != leaves.end(); ++itl)
+ for (typename rtree_leaf::values_map::const_iterator itl = values.begin();
+ itl != values.end(); ++itl)
{
s.push_back(*itl);
}
@@ -247,8 +256,8 @@
}
// reinserting leaves
- for (typename rtree_leaf::leaf_map::const_iterator it = q_leaves.begin();
- it != q_leaves.end(); ++it)
+ for (typename rtree_leaf::values_map::const_iterator it = q_values.begin();
+ it != q_values.end(); ++it)
{
m_count--;
// awulkiew - changed
@@ -329,7 +338,7 @@
{
os << "===================================" << std::endl;
os << " Min/Max: " << r.m_min_elems_per_node << " / " << r.m_max_elems_per_node << std::endl;
- os << "Leaves: " << r.m_root->get_leaves().size() << std::endl;
+ os << "Leaves: " << r.m_root->get_values().size() << std::endl;
r.m_root->print(os, r.m_translator);
os << "===================================" << std::endl;
@@ -497,11 +506,11 @@
{
// TODO: mloskot - add assert(node.size() >= 2); or similar
- typename rtree_leaf::leaf_map nodes = n->get_leaves();
- unsigned int remaining = nodes.size() - 2;
+ typename rtree_leaf::values_map values = n->get_values();
+ unsigned int remaining = values.size() - 2;
- for (typename rtree_leaf::leaf_map::const_iterator it = nodes.begin();
- it != nodes.end(); ++it, index++)
+ for (typename rtree_leaf::values_map::const_iterator it = values.begin();
+ it != values.end(); ++it, index++)
{
if (index != seed1 && index != seed2)
{
@@ -818,11 +827,11 @@
// refine the result
for (typename node_type::const_iterator it = nodes.begin(); it != nodes.end(); ++it)
{
- typedef std::vector<Value> leaves_type;
- leaves_type leaves = (*it)->get_leaves();
+ typedef typename rtree_leaf::values_map values_map;
+ values_map values = (*it)->get_values();
- for (typename leaves_type::const_iterator itl = leaves.begin();
- itl != leaves.end(); ++itl)
+ for (typename values_map::const_iterator itl = values.begin();
+ itl != values.end(); ++itl)
{
// awulkiew - operator== changed to geometry::equals
// TODO - implement object specific equals() function
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-01 17:40:44 EST (Tue, 01 Mar 2011)
@@ -7,6 +7,12 @@
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
+// awulkiew 2011
+// typedefs added
+// nodes hierarchy changed, rtree_node changed to rtree_internal_node
+// inconsistent names changed - get_leafs to get_values
+// gl_draw added - temporary
+
#ifndef BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_RTREE_INTERNAL_NODE_HPP
#define BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_RTREE_INTERNAL_NODE_HPP
@@ -128,24 +134,26 @@
/**
* \brief Get leaves for a node
*/
- virtual std::vector<Value> get_leaves() const
+ virtual std::vector<Value> get_values() const
{
- typedef std::vector<Value> leaf_type;
- leaf_type leaf;
+ typedef typename rtree_leaf::values_map values_map;
+ values_map values;
for (typename node_map::const_iterator it = m_nodes.begin();
it != m_nodes.end(); ++it)
{
- leaf_type this_leaves = it->second->get_leaves();
+ values_map this_values = it->second->get_values();
- for (typename leaf_type::iterator it_leaf = this_leaves.begin();
- it_leaf != this_leaves.end(); ++it_leaf)
+ //TODO:
+ // awulkiew - reserve/resize, std::copy may be used here
+ for (typename values_map::iterator it_leaf = this_values.begin();
+ it_leaf != this_values.end(); ++it_leaf)
{
- leaf.push_back(*it_leaf);
+ values.push_back(*it_leaf);
}
}
- return leaf;
+ return values;
}
/**
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-01 17:40:44 EST (Tue, 01 Mar 2011)
@@ -7,6 +7,12 @@
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
+// awulkiew 2011
+// typedefs added
+// nodes hierarchy changed
+// inconsistent names changed - leafs to values, leaf_map to values_map, get_leafs to get_values
+// gl_draw added - temporary
+
#ifndef BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_RTREE_LEAF_HPP
#define BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_RTREE_LEAF_HPP
@@ -40,7 +46,7 @@
typedef boost::shared_ptr<rtree_node> node_pointer;
/// container type for the leaves
- typedef std::vector<Value> leaf_map;
+ typedef std::vector<Value> values_map;
/**
* \brief Creates an empty leaf
@@ -65,7 +71,7 @@
// awulkiew - name changed from empty_nodes to clear_values
void clear_values()
{
- m_nodes.clear();
+ m_values.clear();
}
// awulkiew - internal node and leaf virtual methods
@@ -83,7 +89,7 @@
*/
virtual size_t elements() const
{
- return m_nodes.size();
+ return m_values.size();
}
/**
@@ -94,8 +100,8 @@
// awulkiew - exact match case removed
virtual void find(Box const& box, std::deque<Value>& result, Translator const& tr)
{
- for (typename leaf_map::const_iterator it = m_nodes.begin();
- it != m_nodes.end(); ++it)
+ for (typename values_map::const_iterator it = m_values.begin();
+ it != m_values.end(); ++it)
{
// awulkiew - commented
//if (exact_match)
@@ -123,14 +129,14 @@
*/
virtual Box compute_box(Translator const& tr) const
{
- if (m_nodes.empty())
+ if (m_values.empty())
{
return Box ();
}
Box r;
geometry::assign_inverse(r);
- for(typename leaf_map::const_iterator it = m_nodes.begin(); it != m_nodes.end(); ++it)
+ for(typename values_map::const_iterator it = m_values.begin(); it != m_values.end(); ++it)
{
geometry::combine(r, tr(*it));
}
@@ -140,9 +146,9 @@
/**
* \brief Proyect leaves of this node.
*/
- virtual std::vector<Value> get_leaves() const
+ virtual std::vector<Value> get_values() const
{
- return m_nodes;
+ return m_values;
}
/**
@@ -152,15 +158,15 @@
virtual void remove_in(Box const& box, Translator const& tr)
{
- for (typename leaf_map::iterator it = m_nodes.begin();
- it != m_nodes.end(); ++it)
+ for (typename values_map::iterator it = m_values.begin();
+ it != m_values.end(); ++it)
{
// TODO - awulkiew - implement object specific equals() function
Box b;
detail::convert_to_box(tr(*it), b);
if (geometry::equals(b, box))
{
- m_nodes.erase(it);
+ m_values.erase(it);
return;
}
}
@@ -175,8 +181,8 @@
virtual std::vector<Box> get_boxes(Translator const& tr) const
{
std::vector<Box> result;
- for (typename leaf_map::const_iterator it = m_nodes.begin();
- it != m_nodes.end(); ++it)
+ for (typename values_map::const_iterator it = m_values.begin();
+ it != m_values.end(); ++it)
{
// TODO: awulkiew - implement object specific behaviour - get_bounding_objects(get boxes or points)
Box box;
@@ -195,9 +201,9 @@
virtual void print(std::ostream &os, Translator const& tr) const
{
os << "\t" << " --> Leaf --------" << std::endl;
- os << "\t" << " Size: " << m_nodes.size() << std::endl;
- for (typename leaf_map::const_iterator it = m_nodes.begin();
- it != m_nodes.end(); ++it)
+ os << "\t" << " Size: " << m_values.size() << std::endl;
+ for (typename values_map::const_iterator it = m_values.begin();
+ it != m_values.end(); ++it)
{
// TODO: awulkiew - implement object specific behaviour - display boxes or points
Box box;
@@ -228,8 +234,8 @@
// TODO: awulkiew - implement 3d version
if ( traits::dimension<traits::point_type<Box>::type>::value == 2 )
{
- for (typename leaf_map::const_iterator it = m_nodes.begin();
- it != m_nodes.end(); ++it)
+ for (typename values_map::const_iterator it = m_values.begin();
+ it != m_values.end(); ++it)
{
glColor3f(1.0f, 1.0f, 1.0f);
@@ -263,7 +269,7 @@
*/
virtual void insert(Value const& v)
{
- m_nodes.push_back(v);
+ m_values.push_back(v);
}
/**
@@ -271,7 +277,7 @@
*/
virtual void add_value(Value const& v)
{
- m_nodes.push_back(v);
+ m_values.push_back(v);
}
/**
@@ -279,7 +285,7 @@
*/
virtual Value get_value(unsigned int index) const
{
- return m_nodes[index];
+ return m_values[index];
}
/**
@@ -287,13 +293,13 @@
*/
virtual void remove(Value const& v, Translator const& tr)
{
- for (typename leaf_map::iterator it = m_nodes.begin();
- it != m_nodes.end(); ++it)
+ for (typename values_map::iterator it = m_values.begin();
+ it != m_values.end(); ++it)
{
// awulkiew - use of translator
if ( tr.equals(*it, v) )
{
- m_nodes.erase(it);
+ m_values.erase(it);
return;
}
}
@@ -313,14 +319,14 @@
// // TODO: awulkiew - get_bounding_object - add object specific behaviour
// // or just base on get_value
// Box box;
- // detail::convert_to_box(tr(m_nodes[index]), box);
+ // detail::convert_to_box(tr(m_values[index]), box);
// return box;
//}
private:
/// leaves of this node
- leaf_map m_nodes;
+ values_map m_values;
};
}}} // namespace boost::geometry::index
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-01 17:40:44 EST (Tue, 01 Mar 2011)
@@ -7,6 +7,11 @@
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
+// awulkiew 2011
+// nodes hierarchy changed, rtree_node changed to rtree_internal_node
+// inconsistent names changed - get_leafs to get_values
+// gl_draw added - temporary
+
#ifndef BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_RTREE_NODE_HPP
#define BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_RTREE_NODE_HPP
@@ -106,7 +111,7 @@
/**
* \brief Get leaves for a node
*/
- virtual std::vector<Value> get_leaves() const
+ virtual std::vector<Value> get_values() const
{
// TODO: mloskot - define & use GGL exception
throw std::logic_error("shouldn't be here");
Modified: sandbox-branches/geometry/index_080_nhch/tests/main.cpp
==============================================================================
--- sandbox-branches/geometry/index_080_nhch/tests/main.cpp (original)
+++ sandbox-branches/geometry/index_080_nhch/tests/main.cpp 2011-03-01 17:40:44 EST (Tue, 01 Mar 2011)
@@ -1,12 +1,18 @@
#include <tests/translators.hpp>
#include <tests/rtree_native.hpp>
#include <tests/rtree_filters.hpp>
+//#include <tests/rtree_iterator.hpp>
int main()
{
tests_translators_hpp();
tests_rtree_native_hpp();
tests_rtree_filters_hpp();
+ //tests_rtree_iterator_hpp();
+
+#ifdef _MSC_VER
+ std::cin.get();
+#endif
return 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