|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r84841 - in trunk/libs/geometry/index: example test/rtree
From: adam.wulkiewicz_at_[hidden]
Date: 2013-06-19 19:02:29
Author: awulkiew
Date: 2013-06-19 19:02:29 EDT (Wed, 19 Jun 2013)
New Revision: 84841
URL: http://svn.boost.org/trac/boost/changeset/84841
Log:
[geometry][index]: tests and examples modified with respect to recent changes - detail:: predicates, traits, etc.
Text files modified:
trunk/libs/geometry/index/example/benchmark_experimental.cpp | 38 +++++++++++++++++++++++++++-----------
trunk/libs/geometry/index/example/glut_vis.cpp | 30 ++++++++++++++++--------------
trunk/libs/geometry/index/test/rtree/test_rtree.hpp | 12 ++++++------
3 files changed, 49 insertions(+), 31 deletions(-)
Modified: trunk/libs/geometry/index/example/benchmark_experimental.cpp
==============================================================================
--- trunk/libs/geometry/index/example/benchmark_experimental.cpp Wed Jun 19 19:00:12 2013 (r84840)
+++ trunk/libs/geometry/index/example/benchmark_experimental.cpp 2013-06-19 19:02:29 EDT (Wed, 19 Jun 2013) (r84841)
@@ -27,6 +27,23 @@
typedef bg::model::box<P> B;
typedef bg::model::linestring<P> LS;
typedef bg::model::segment<P> S;
+typedef B V;
+//typedef P V;
+
+template <typename V>
+struct generate_value {};
+
+template <>
+struct generate_value<B>
+{
+ static inline B apply(float x, float y) { return B(P(x - 0.5f, y - 0.5f), P(x + 0.5f, y + 0.5f)); }
+};
+
+template <>
+struct generate_value<P>
+{
+ static inline P apply(float x, float y) { return P(x, y); }
+};
template <typename I1, typename I2, typename O>
void mycopy(I1 first, I2 last, O o)
@@ -62,7 +79,7 @@
float max_val = static_cast<float>(values_count / 2);
std::vector< std::pair<float, float> > coords;
- std::vector<B> values;
+ std::vector<V> values;
//randomize values
{
@@ -79,20 +96,20 @@
float x = rnd();
float y = rnd();
coords.push_back(std::make_pair(x, y));
- values.push_back(B(P(x - 0.5f, y - 0.5f), P(x + 0.5f, y + 0.5f)));
+ values.push_back(generate_value<V>::apply(x, y));
}
std::cout << "randomized\n";
}
- //typedef bgi::rtree<B, bgi::linear<100, 50> > RT;
- //typedef bgi::rtree<B, bgi::quadratic<8, 3> > RT;
- typedef bgi::rtree<B, bgi::rstar<8, 3> > RT;
+ //typedef bgi::rtree<V, bgi::linear<16, 4> > RT;
+ //typedef bgi::rtree<V, bgi::quadratic<16, 4> > RT;
+ typedef bgi::rtree<V, bgi::rstar<16, 4> > RT;
std::cout << "sizeof rtree: " << sizeof(RT) << std::endl;
for (;;)
{
- std::vector<B> result;
+ std::vector<V> result;
result.reserve(100);
B result_one;
@@ -220,14 +237,14 @@
&&
!bgi::within(B(P(x2 - 10, y2 - 10), P(x2 + 10, y2 + 10)))
&&
- !bgi::overlaps(B(P(x3 - 10, y3 - 10), P(x3 + 10, y3 + 10)))
+ !bgi::covered_by(B(P(x3 - 10, y3 - 10), P(x3 + 10, y3 + 10)))
,
std::back_inserter(result)
);
temp += result.size();
}
dur_t time = clock_t::now() - start;
- std::cout << time << " - query(i && !w && !o) " << queries_count << " found " << temp << '\n';
+ std::cout << time << " - query(i && !w && !c) " << queries_count << " found " << temp << '\n';
}
result.clear();
@@ -366,9 +383,8 @@
{
float x = coords[i].first;
float y = coords[i].second;
- B b(P(x - 0.5f, y - 0.5f), P(x + 0.5f, y + 0.5f));
-
- t.remove(b);
+
+ t.remove(generate_value<V>::apply(x, y));
}
dur_t time = clock_t::now() - start;
std::cout << time << " - remove " << values_count / 10 << '\n';
Modified: trunk/libs/geometry/index/example/glut_vis.cpp
==============================================================================
--- trunk/libs/geometry/index/example/glut_vis.cpp Wed Jun 19 19:00:12 2013 (r84840)
+++ trunk/libs/geometry/index/example/glut_vis.cpp 2013-06-19 19:02:29 EDT (Wed, 19 Jun 2013) (r84841)
@@ -337,36 +337,38 @@
void search()
{
+ namespace d = bgi::detail;
+
if ( query_mode == qm_knn )
query_knn();
else if ( query_mode == qm_c )
- query< bgi::detail::covered_by<B> >();
+ query< d::spatial_predicate<B, d::covered_by_tag, false> >();
else if ( query_mode == qm_d )
- query< bgi::detail::disjoint<B> >();
+ query< d::spatial_predicate<B, d::disjoint_tag, false> >();
else if ( query_mode == qm_i )
- query< bgi::detail::intersects<B> >();
+ query< d::spatial_predicate<B, d::intersects_tag, false> >();
else if ( query_mode == qm_o )
- query< bgi::detail::overlaps<B> >();
+ query< d::spatial_predicate<B, d::overlaps_tag, false> >();
else if ( query_mode == qm_w )
- query< bgi::detail::within<B> >();
+ query< d::spatial_predicate<B, d::within_tag, false> >();
else if ( query_mode == qm_nc )
- query< bgi::detail::not_covered_by<B> >();
+ query< d::spatial_predicate<B, d::covered_by_tag, true> >();
else if ( query_mode == qm_nd )
- query< bgi::detail::not_disjoint<B> >();
+ query< d::spatial_predicate<B, d::disjoint_tag, true> >();
else if ( query_mode == qm_ni )
- query< bgi::detail::not_intersects<B> >();
+ query< d::spatial_predicate<B, d::intersects_tag, true> >();
else if ( query_mode == qm_no )
- query< bgi::detail::not_overlaps<B> >();
+ query< d::spatial_predicate<B, d::overlaps_tag, true> >();
else if ( query_mode == qm_nw )
- query< bgi::detail::not_within<B> >();
+ query< d::spatial_predicate<B, d::within_tag, true> >();
else if ( query_mode == qm_all )
- query< bgi::detail::intersects<B> >();
+ query< d::spatial_predicate<B, d::intersects_tag, false> >();
else if ( query_mode == qm_ri )
- query_ring< bgi::detail::intersects<R> >();
+ query_ring< d::spatial_predicate<R, d::intersects_tag, false> >();
else if ( query_mode == qm_pi )
- query_poly< bgi::detail::intersects<Poly> >();
+ query_poly< d::spatial_predicate<Poly, d::intersects_tag, false> >();
else if ( query_mode == qm_mpi )
- query_multi_poly< bgi::detail::intersects<MPoly> >();
+ query_multi_poly< d::spatial_predicate<MPoly, d::intersects_tag, false> >();
else if ( query_mode == qm_path )
query_path();
Modified: trunk/libs/geometry/index/test/rtree/test_rtree.hpp
==============================================================================
--- trunk/libs/geometry/index/test/rtree/test_rtree.hpp Wed Jun 19 19:00:12 2013 (r84840)
+++ trunk/libs/geometry/index/test/rtree/test_rtree.hpp 2013-06-19 19:02:29 EDT (Wed, 19 Jun 2013) (r84841)
@@ -579,7 +579,7 @@
typedef typename Rtree::value_type V;
typedef typename Rtree::indexable_type I;
- return value_outside_impl<V, bgi::detail::traits::dimension<I>::value>::apply();
+ return value_outside_impl<V, bg::dimension<I>::value>::apply();
}
template<typename Rtree, typename Elements, typename Box>
@@ -588,7 +588,7 @@
typedef typename Rtree::indexable_type I;
generate::input<
- bgi::detail::traits::dimension<I>::value
+ bg::dimension<I>::value
>::apply(input, qbox);
tree.insert(input.begin(), input.end());
@@ -772,7 +772,7 @@
void contains(Rtree const& tree, std::vector<Value> const& input, Box const& qbox)
{
contains_impl<
- typename bgi::detail::traits::tag<
+ typename bg::tag<
typename Rtree::indexable_type
>::type
>::apply(tree, input, qbox);
@@ -838,7 +838,7 @@
void covers(Rtree const& tree, std::vector<Value> const& input, Box const& qbox)
{
covers_impl<
- typename bgi::detail::traits::tag<
+ typename bg::tag<
typename Rtree::indexable_type
>::type
>::apply(tree, input, qbox);
@@ -882,7 +882,7 @@
void overlaps(Rtree const& tree, std::vector<Value> const& input, Box const& qbox)
{
overlaps_impl<
- typename bgi::detail::traits::tag<
+ typename bg::tag<
typename Rtree::indexable_type
>::type
>::apply(tree, input, qbox);
@@ -1425,7 +1425,7 @@
basictest::covers(tree, input, qbox);
#endif
- typedef typename bgi::detail::traits::point_type<Box>::type P;
+ typedef typename bg::point_type<Box>::type P;
P pt;
bg::centroid(qbox, pt);
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