|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r69090 - sandbox-branches/geometry/index_080/tests
From: adam.wulkiewicz_at_[hidden]
Date: 2011-02-20 14:25:13
Author: awulkiew
Date: 2011-02-20 14:25:12 EST (Sun, 20 Feb 2011)
New Revision: 69090
URL: http://svn.boost.org/trac/boost/changeset/69090
Log:
tests redesigned
Removed:
sandbox-branches/geometry/index_080/tests/rtree_filters.cpp
sandbox-branches/geometry/index_080/tests/rtree_native.cpp
sandbox-branches/geometry/index_080/tests/translators.cpp
Deleted: sandbox-branches/geometry/index_080/tests/rtree_filters.cpp
==============================================================================
--- sandbox-branches/geometry/index_080/tests/rtree_filters.cpp 2011-02-20 14:25:12 EST (Sun, 20 Feb 2011)
+++ (empty file)
@@ -1,49 +0,0 @@
-#include <boost/geometry/geometry.hpp>
-#include <boost/geometry/extensions/index/rtree/rtree.hpp>
-
-#include <boost/geometry/extensions/index/rtree/filters.hpp>
-#include <boost/geometry/extensions/index/filters/nearest_filter.hpp>
-
-#include <iostream>
-
-#include <boost/range/algorithm.hpp>
-#include <boost/foreach.hpp>
-
-template <typename R>
-void print_range(R const& r)
-{
- BOOST_FOREACH(typename boost::iterator_value<typename R::const_iterator>::type const& b, r)
- {
- float min_x = b.min_corner().template get<0>();
- float min_y = b.min_corner().template get<1>();
- float max_x = b.max_corner().template get<0>();
- float max_y = b.max_corner().template get<1>();
- std::cout << "(" << min_x << ", " << min_y << ")";
- std::cout << 'x';
- std::cout << "(" << max_x << ", " << max_y << ")";
- std::cout << '\n';
- }
- std::cout << std::endl;
-}
-
-int main()
-{
- typedef boost::geometry::model::point<float, 2, boost::geometry::cs::cartesian> P;
- typedef boost::geometry::model::box<P> B;
-
- {
- boost::geometry::index::rtree<B> t(3, 0);
- t.insert(B(P(0, 0), P(1, 1)));
- t.insert(B(P(2, 2), P(3, 3)));
- t.insert(B(P(4, 4), P(5, 5)));
- t.insert(B(P(6, 6), P(7, 7)));
- t.print();
-
- namespace f = boost::geometry::index::filters;
- print_range(t | f::spatially_filtered(B(P(2.5f, 2.5f), P(4.5f, 4.5f))));
- print_range(t | f::nearest_filtered(P(3.5f, 3.5f), 1.0f));
- }
-
- std::cin.get();
- return 0;
-}
Deleted: sandbox-branches/geometry/index_080/tests/rtree_native.cpp
==============================================================================
--- sandbox-branches/geometry/index_080/tests/rtree_native.cpp 2011-02-20 14:25:12 EST (Sun, 20 Feb 2011)
+++ (empty file)
@@ -1,207 +0,0 @@
-#include <boost/geometry/geometry.hpp>
-
-#include <boost/geometry/extensions/index/rtree/rtree.hpp>
-#include <boost/geometry/extensions/index/translator/index.hpp>
-
-#include <iostream>
-
-#include <boost/range/algorithm.hpp>
-#include <boost/foreach.hpp>
-
-#include <map>
-
-int main()
-{
- // Box
- {
- typedef boost::geometry::model::point<float, 2, boost::geometry::cs::cartesian> P;
- typedef boost::geometry::model::box<P> B;
-
- boost::geometry::index::rtree<B> t(3, 0);
- t.insert(B(P(0, 0), P(1, 1)));
- t.insert(B(P(2, 2), P(3, 3)));
- t.insert(B(P(4, 4), P(5, 5)));
- t.insert(B(P(6, 6), P(7, 7)));
- t.print();
-
- // error
- t.remove_in(B(P(-1, -1), P(2, 2)));
- // ok
- t.remove_in(B(P(0, 0), P(1, 1)));
- t.print();
-
- t.remove(B(P(6, 6), P(7, 7)));
- t.print();
- }
-
- std::cout << "-------------------------------------------------\n";
- std::cout << "-------------------------------------------------\n";
-
- // Point
- {
- typedef boost::geometry::model::point<float, 2, boost::geometry::cs::cartesian> P;
- typedef boost::geometry::model::box<P> B;
-
- boost::geometry::index::rtree<P> t(3, 0);
- t.insert(P(0, 0));
- t.insert(P(2, 2));
- t.insert(P(4, 4));
- t.insert(P(6, 6));
- t.print();
-
- // error
- t.remove_in(B(P(-1, -1), P(1, 1)));
- // ok
- t.remove_in(B(P(0, 0), P(0, 0)));
- t.print();
-
- t.remove(P(6, 6));
- t.print();
- }
-
- std::cout << "-------------------------------------------------\n";
- std::cout << "-------------------------------------------------\n";
-
- // std::pair<Box, int>
- {
- typedef boost::geometry::model::point<float, 2, boost::geometry::cs::cartesian> P;
- typedef boost::geometry::model::box<P> B;
- typedef std::pair<B, int> V;
-
- boost::geometry::index::rtree<V> t(3, 0);
- t.insert(V(B(P(0, 0), P(1, 1)), 0));
- t.insert(V(B(P(2, 2), P(3, 3)), 1));
- t.insert(V(B(P(4, 4), P(5, 5)), 2));
- t.insert(V(B(P(6, 6), P(7, 7)), 3));
- t.print();
-
- // error
- t.remove_in(B(P(0, 0), P(2, 1)));
- // ok
- t.remove_in(B(P(0, 0), P(1, 1)));
- t.print();
-
- t.remove(V(B(P(6, 6), P(7, 7)), 3));
- t.print();
- }
-
- std::cout << "-------------------------------------------------\n";
- std::cout << "-------------------------------------------------\n";
-
- // boost::shared_ptr< std::pair<Box, int> >
- {
- typedef boost::geometry::model::point<float, 2, boost::geometry::cs::cartesian> P;
- typedef boost::geometry::model::box<P> B;
-
- typedef boost::shared_ptr< std::pair<B, int> > V;
-
- V v1( new std::pair<B, int>(B(P(0, 0), P(1, 1)), 0) );
- V v2( new std::pair<B, int>(B(P(2, 2), P(3, 3)), 1) );
- V v3( new std::pair<B, int>(B(P(4, 4), P(5, 5)), 2) );
- V v4( new std::pair<B, int>(B(P(6, 6), P(7, 7)), 3) );
-
- boost::geometry::index::rtree<V> t(3, 0);
- t.insert(v1);
- t.insert(v2);
- t.insert(v3);
- t.insert(v4);
- t.print();
-
- // error
- t.remove_in(B(P(0, 0), P(2, 1)));
- // ok
- t.remove_in(B(P(0, 0), P(1, 1)));
- t.print();
-
- t.remove(v4);
- t.print();
- }
-
- std::cout << "-------------------------------------------------\n";
- std::cout << "-------------------------------------------------\n";
-
- // std::map<int, Box>::iterator
- {
- typedef boost::geometry::model::point<float, 2, boost::geometry::cs::cartesian> P;
- typedef boost::geometry::model::box<P> B;
-
- typedef std::map<int, B>::iterator V;
-
- std::map<int, B> m;
- m.insert(std::pair<int, B>(0, B(P(0, 0), P(1, 1))));
- m.insert(std::pair<int, B>(1, B(P(2, 2), P(3, 3))));
- m.insert(std::pair<int, B>(2, B(P(4, 4), P(5, 5))));
- m.insert(std::pair<int, B>(3, B(P(6, 6), P(7, 7))));
-
- boost::geometry::index::rtree<V> t(3, 0);
- V vit = m.begin();
- t.insert(vit++);
- t.insert(vit++);
- t.insert(vit++);
- t.insert(vit);
- t.print();
-
- // error
- t.remove_in(B(P(0, 0), P(2, 1)));
- // ok
- t.remove_in(B(P(0, 0), P(1, 1)));
- t.print();
-
- t.remove(m.find(3));
- t.print();
- }
-
- std::cout << "-------------------------------------------------\n";
- std::cout << "-------------------------------------------------\n";
-
- // size_t
- {
- typedef boost::geometry::model::point<float, 2, boost::geometry::cs::cartesian> P;
- typedef boost::geometry::model::box<P> B;
-
- typedef size_t V;
- typedef boost::geometry::index::translator::index<std::vector<B> > T;
-
- std::vector<B> v;
- v.push_back(B(P(0, 0), P(1, 1)));
- v.push_back(B(P(2, 2), P(3, 3)));
- v.push_back(B(P(4, 4), P(5, 5)));
- v.push_back(B(P(6, 6), P(7, 7)));
-
- boost::geometry::index::rtree<V, T> t(3, 0, T(v));
-
- t.insert(0);
- t.insert(1);
- t.insert(2);
- t.insert(3);
- t.print();
-
- // error
- t.remove_in(B(P(0, 0), P(2, 1)));
- // ok
- t.remove_in(B(P(0, 0), P(1, 1)));
- t.print();
-
- t.remove(3);
- t.print();
- }
-
- {
- typedef boost::geometry::model::point<float, 2, boost::geometry::cs::cartesian> P;
- typedef boost::geometry::model::box<P> B;
-
- boost::geometry::index::rtree<B>::rtree_leaf l;
- boost::geometry::index::rtree<B>::rtree_node n;
-
- std::cout << sizeof(boost::shared_ptr<int>) << '\n';
- std::cout << sizeof(std::vector<int>) << '\n';
- std::cout << sizeof(n) << '\n';
- std::cout << sizeof(l) << '\n';
- }
-
- // ERROR!
- // remove_in expects previously inserted box - it should remove all objects inside some bigger box
-
- std::cin.get();
- return 0;
-}
Deleted: sandbox-branches/geometry/index_080/tests/translators.cpp
==============================================================================
--- sandbox-branches/geometry/index_080/tests/translators.cpp 2011-02-20 14:25:12 EST (Sun, 20 Feb 2011)
+++ (empty file)
@@ -1,67 +0,0 @@
-#include <boost/geometry/geometry.hpp>
-#include <boost/geometry/extensions/index/rtree/rtree.hpp>
-
-#include <boost/geometry/extensions/index/translator/def.hpp>
-#include <boost/geometry/extensions/index/translator/index.hpp>
-
-#include <vector>
-#include <map>
-
-#include <boost/shared_ptr.hpp>
-#include <boost/scoped_ptr.hpp>
-
-int main()
-{
- typedef boost::geometry::model::point<float, 2, boost::geometry::cs::cartesian> P;
- typedef boost::geometry::model::box<P> B;
- typedef boost::geometry::index::rtree<B, size_t> I;
-
- using namespace boost::geometry;
-
- index::translator::def<P> p;
- index::translator::def<P*> pp;
- index::translator::def<std::pair<int, P>*> pip;
- index::translator::def< boost::shared_ptr<P> > sp;
- index::translator::def< std::vector<P>::iterator > ip;
- index::translator::def< std::map<int, P>::iterator > mip;
- index::translator::def< std::pair<P, size_t> > ppi;
- index::translator::def< boost::shared_ptr< std::pair<int, P> > > spip;
- index::translator::def< boost::shared_ptr< std::pair<P, int> > > sppi;
- index::translator::def< boost::scoped_ptr< std::pair<P, int> > > scppi;
- index::translator::def< boost::scoped_ptr< std::pair<int, P> > > scpip;
-
- P tmp_p;
- boost::shared_ptr<P> tmp_sp(new P());
- std::vector<P> tmp_v(1);
- std::map<int, P> tmp_m;
- tmp_m.insert(std::pair<int, P>(0, P()));
- std::pair<int, P> tmp_pip;
- boost::shared_ptr< std::pair<int, P> > tmp_spip(new std::pair<int, P>(0, P()));
- boost::shared_ptr< std::pair<P, int> > tmp_sppi(new std::pair<P, int>(P(), 0));
- boost::scoped_ptr< std::pair<int, P> > tmp_scpip(new std::pair<int, P>(0, P()));
- boost::scoped_ptr< std::pair<P, int> > tmp_scppi(new std::pair<P, int>(P(), 0));
-
- tmp_p = p(P());
- tmp_p = pp(&tmp_p);
- tmp_p = pip(&tmp_pip);
- tmp_p = sp(tmp_sp);
- tmp_p = ip(tmp_v.begin());
- tmp_p = mip(tmp_m.begin());
- tmp_p = ppi(std::pair<P, size_t>(P(), 0));
- tmp_p = spip(tmp_spip);
- tmp_p = sppi(tmp_sppi);
- tmp_p = scpip(tmp_scpip);
- tmp_p = scppi(tmp_scppi);
-
- //index::translator::def<int> d; // error
- //index::translator::def< model::segment<P> > d; // error
-
- index::translator::def< std::pair<model::polygon<P>, B> > d;
- index::translator::def< std::pair<B, model::polygon<P> > > dd;
-
- B tmp_b;
- tmp_b = d( std::pair<model::polygon<P>, B>() );
- tmp_b = dd( std::pair<B, model::polygon<P> >() );
-
- 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