mirror of
https://github.com/boostorg/geometry.git
synced 2025-05-09 23:24:02 +00:00
[geometry][index]: tests and examples modified with respect to recent changes - detail:: predicates, traits, etc.
[SVN r84841]
This commit is contained in:
parent
45970c5696
commit
740ff6b0bb
@ -27,6 +27,23 @@ typedef bg::model::point<double, 2, bg::cs::cartesian> P;
|
||||
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 @@ int main()
|
||||
|
||||
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 @@ int main()
|
||||
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 @@ int main()
|
||||
&&
|
||||
!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 @@ int main()
|
||||
{
|
||||
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';
|
||||
|
@ -337,36 +337,38 @@ void query_multi_poly()
|
||||
|
||||
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();
|
||||
|
||||
|
@ -579,7 +579,7 @@ value_outside()
|
||||
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 @@ void rtree(Rtree & tree, Elements & input, Box & qbox)
|
||||
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 @@ template <typename Rtree, typename Value, typename Box>
|
||||
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 @@ template <typename Rtree, typename Value, typename Box>
|
||||
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 @@ template <typename Rtree, typename Value, typename Box>
|
||||
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 @@ void queries(Rtree const& tree, std::vector<Value> const& input, Box const& qbox
|
||||
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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user