Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r82872 - in sandbox-branches/geometry/index: example test/rtree test/rtree/exceptions test/rtree/generated test/rtree/interprocess tests
From: adam.wulkiewicz_at_[hidden]
Date: 2013-02-14 09:23:16


Author: awulkiew
Date: 2013-02-14 09:23:09 EST (Thu, 14 Feb 2013)
New Revision: 82872
URL: http://svn.boost.org/trac/boost/changeset/82872

Log:
tests and examples files structure rearranged
Added:
   sandbox-branches/geometry/index/example/
      - copied from r82871, /sandbox-branches/geometry/index/tests/
   sandbox-branches/geometry/index/example/benchmark.cpp
      - copied, changed from r82871, /sandbox-branches/geometry/index/tests/additional_speed.cpp
   sandbox-branches/geometry/index/example/glut_vis.cpp
      - copied unchanged from r82871, /sandbox-branches/geometry/index/tests/additional_glut_vis.cpp
   sandbox-branches/geometry/index/test/rtree/exceptions/
   sandbox-branches/geometry/index/test/rtree/exceptions/Jamfile.v2 (contents, props changed)
   sandbox-branches/geometry/index/test/rtree/exceptions/rtree_exceptions.cpp (contents, props changed)
   sandbox-branches/geometry/index/test/rtree/exceptions/test_rtree_exceptions.hpp (contents, props changed)
   sandbox-branches/geometry/index/test/rtree/exceptions/test_throwing.hpp (contents, props changed)
   sandbox-branches/geometry/index/test/rtree/interprocess/
   sandbox-branches/geometry/index/test/rtree/interprocess/Jamfile.v2 (contents, props changed)
   sandbox-branches/geometry/index/test/rtree/interprocess/rtree_interprocess_b2f_linear.cpp (contents, props changed)
   sandbox-branches/geometry/index/test/rtree/interprocess/rtree_interprocess_b2f_linear_rt.cpp (contents, props changed)
   sandbox-branches/geometry/index/test/rtree/interprocess/rtree_interprocess_b2f_quadratic.cpp (contents, props changed)
   sandbox-branches/geometry/index/test/rtree/interprocess/rtree_interprocess_b2f_quadratic_rt.cpp (contents, props changed)
   sandbox-branches/geometry/index/test/rtree/interprocess/rtree_interprocess_b2f_rstar.cpp (contents, props changed)
   sandbox-branches/geometry/index/test/rtree/interprocess/rtree_interprocess_b2f_rstar_rt.cpp (contents, props changed)
   sandbox-branches/geometry/index/test/rtree/interprocess/test_interprocess.hpp (contents, props changed)
   sandbox-branches/geometry/index/test/rtree/rtree_test_generator.cpp (contents, props changed)
Removed:
   sandbox-branches/geometry/index/example/additional_glut_vis.cpp
   sandbox-branches/geometry/index/example/additional_sizes_and_times.cpp
   sandbox-branches/geometry/index/example/additional_speed.cpp
   sandbox-branches/geometry/index/example/rtree_test_generator.cpp
   sandbox-branches/geometry/index/test/rtree/rtree_exceptions.cpp
   sandbox-branches/geometry/index/test/rtree/rtree_interprocess.cpp
   sandbox-branches/geometry/index/test/rtree/test_rtree_exceptions.hpp
   sandbox-branches/geometry/index/test/rtree/test_throwing.hpp
   sandbox-branches/geometry/index/tests/
Text files modified:
   sandbox-branches/geometry/index/example/benchmark.cpp | 4 -
   sandbox-branches/geometry/index/test/rtree/Jamfile.v2 | 19 ------
   sandbox-branches/geometry/index/test/rtree/generated/Jamfile.v2 | 113 ++++-----------------------------------
   3 files changed, 15 insertions(+), 121 deletions(-)

Deleted: /sandbox-branches/geometry/index/tests/additional_glut_vis.cpp
==============================================================================
--- /sandbox-branches/geometry/index/tests/additional_glut_vis.cpp 2013-02-14 09:23:09 EST (Thu, 14 Feb 2013)
+++ (empty file)
@@ -1,625 +0,0 @@
-// Boost.Geometry Index
-// Additional tests
-
-// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
-
-// Use, modification and distribution is subject to the Boost Software License,
-// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-#include <GL/glut.h>
-
-#define BOOST_GEOMETRY_INDEX_ENABLE_DEBUG_INTERFACE
-
-#include <boost/foreach.hpp>
-
-#include <boost/geometry/index/rtree.hpp>
-
-#include <boost/geometry/geometries/ring.hpp>
-#include <boost/geometry/geometries/polygon.hpp>
-#include <boost/geometry/multi/geometries/multi_polygon.hpp>
-
-#include <boost/geometry/index/detail/rtree/visitors/gl_draw.hpp>
-#include <boost/geometry/index/detail/rtree/visitors/print.hpp>
-#include <boost/geometry/index/detail/rtree/visitors/are_boxes_ok.hpp>
-#include <boost/geometry/index/detail/rtree/visitors/are_levels_ok.hpp>
-
-namespace bg = boost::geometry;
-namespace bgi = bg::index;
-
-typedef bg::model::point<float, 2, boost::geometry::cs::cartesian> P;
-typedef bg::model::box<P> B;
-//bgi::rtree<B> t(2, 1);
-typedef bg::model::ring<P> R;
-typedef bg::model::polygon<P> Poly;
-typedef bg::model::multi_polygon<Poly> MPoly;
-
-bgi::rtree<
- B,
- bgi::rstar<4, 2>
-> t;
-std::vector<B> vect;
-
-size_t found_count = 0;
-P search_point;
-size_t count = 5;
-std::vector<B> nearest_boxes;
-B search_box;
-R search_ring;
-Poly search_poly;
-MPoly search_multi_poly;
-
-enum query_mode_type {
- qm_knn, qm_c, qm_d, qm_i, qm_o, qm_w, qm_nc, qm_nd, qm_ni, qm_no, qm_nw, qm_all, qm_ri, qm_pi, qm_mpi
-} query_mode = qm_knn;
-
-bool search_valid = false;
-
-void knn()
-{
- float x = ( rand() % 1000 ) / 10.0f;
- float y = ( rand() % 1000 ) / 10.0f;
-
- search_point = P(x, y);
- nearest_boxes.clear();
- found_count = t.query(
- bgi::nearest(search_point, count),
- std::back_inserter(nearest_boxes)
- );
-
- if ( found_count > 0 )
- {
- std::cout << "search point: ";
- bgi::detail::rtree::visitors::detail::print_indexable(std::cout, search_point);
- std::cout << "\nfound: ";
- for ( size_t i = 0 ; i < nearest_boxes.size() ; ++i )
- {
- bgi::detail::rtree::visitors::detail::print_indexable(std::cout, nearest_boxes[i]);
- std::cout << '\n';
- }
- }
- else
- std::cout << "nearest not found\n";
-}
-
-template <typename Predicate>
-void query()
-{
- if ( query_mode != qm_all )
- {
- float x = ( rand() % 1000 ) / 10.0f;
- float y = ( rand() % 1000 ) / 10.0f;
- float w = 10 + ( rand() % 1000 ) / 100.0f;
- float h = 10 + ( rand() % 1000 ) / 100.0f;
-
- search_box = B(P(x - w, y - h), P(x + w, y + h));
- nearest_boxes.clear();
- found_count = t.query(Predicate(search_box), std::back_inserter(nearest_boxes) );
- }
- else
- {
- search_box = t.bounds();
- nearest_boxes.clear();
- found_count = t.query(Predicate(search_box), std::back_inserter(nearest_boxes) );
- }
-
- if ( found_count > 0 )
- {
- std::cout << "search box: ";
- bgi::detail::rtree::visitors::detail::print_indexable(std::cout, search_box);
- std::cout << "\nfound: ";
- for ( size_t i = 0 ; i < nearest_boxes.size() ; ++i )
- {
- bgi::detail::rtree::visitors::detail::print_indexable(std::cout, nearest_boxes[i]);
- std::cout << '\n';
- }
- }
- else
- std::cout << "boxes not found\n";
-}
-
-template <typename Predicate>
-void query_ring()
-{
- float x = ( rand() % 1000 ) / 10.0f;
- float y = ( rand() % 1000 ) / 10.0f;
- float w = 10 + ( rand() % 1000 ) / 100.0f;
- float h = 10 + ( rand() % 1000 ) / 100.0f;
-
- search_ring.clear();
- search_ring.push_back(P(x - w, y - h));
- search_ring.push_back(P(x - w/2, y - h));
- search_ring.push_back(P(x, y - 3*h/2));
- search_ring.push_back(P(x + w/2, y - h));
- search_ring.push_back(P(x + w, y - h));
- search_ring.push_back(P(x + w, y - h/2));
- search_ring.push_back(P(x + 3*w/2, y));
- search_ring.push_back(P(x + w, y + h/2));
- search_ring.push_back(P(x + w, y + h));
- search_ring.push_back(P(x + w/2, y + h));
- search_ring.push_back(P(x, y + 3*h/2));
- search_ring.push_back(P(x - w/2, y + h));
- search_ring.push_back(P(x - w, y + h));
- search_ring.push_back(P(x - w, y + h/2));
- search_ring.push_back(P(x - 3*w/2, y));
- search_ring.push_back(P(x - w, y - h/2));
- search_ring.push_back(P(x - w, y - h));
-
- nearest_boxes.clear();
- found_count = t.query(Predicate(search_ring), std::back_inserter(nearest_boxes) );
-
- if ( found_count > 0 )
- {
- std::cout << "search ring: ";
- BOOST_FOREACH(P const& p, search_ring)
- {
- bgi::detail::rtree::visitors::detail::print_indexable(std::cout, p);
- std::cout << ' ';
- }
- std::cout << "\nfound: ";
- for ( size_t i = 0 ; i < nearest_boxes.size() ; ++i )
- {
- bgi::detail::rtree::visitors::detail::print_indexable(std::cout, nearest_boxes[i]);
- std::cout << '\n';
- }
- }
- else
- std::cout << "boxes not found\n";
-}
-
-template <typename Predicate>
-void query_poly()
-{
- float x = ( rand() % 1000 ) / 10.0f;
- float y = ( rand() % 1000 ) / 10.0f;
- float w = 10 + ( rand() % 1000 ) / 100.0f;
- float h = 10 + ( rand() % 1000 ) / 100.0f;
-
- search_poly.clear();
- search_poly.outer().push_back(P(x - w, y - h));
- search_poly.outer().push_back(P(x - w/2, y - h));
- search_poly.outer().push_back(P(x, y - 3*h/2));
- search_poly.outer().push_back(P(x + w/2, y - h));
- search_poly.outer().push_back(P(x + w, y - h));
- search_poly.outer().push_back(P(x + w, y - h/2));
- search_poly.outer().push_back(P(x + 3*w/2, y));
- search_poly.outer().push_back(P(x + w, y + h/2));
- search_poly.outer().push_back(P(x + w, y + h));
- search_poly.outer().push_back(P(x + w/2, y + h));
- search_poly.outer().push_back(P(x, y + 3*h/2));
- search_poly.outer().push_back(P(x - w/2, y + h));
- search_poly.outer().push_back(P(x - w, y + h));
- search_poly.outer().push_back(P(x - w, y + h/2));
- search_poly.outer().push_back(P(x - 3*w/2, y));
- search_poly.outer().push_back(P(x - w, y - h/2));
- search_poly.outer().push_back(P(x - w, y - h));
-
- search_poly.inners().push_back(Poly::ring_type());
- search_poly.inners()[0].push_back(P(x - w/2, y - h/2));
- search_poly.inners()[0].push_back(P(x + w/2, y - h/2));
- search_poly.inners()[0].push_back(P(x + w/2, y + h/2));
- search_poly.inners()[0].push_back(P(x - w/2, y + h/2));
- search_poly.inners()[0].push_back(P(x - w/2, y - h/2));
-
- nearest_boxes.clear();
- found_count = t.query(Predicate(search_poly), std::back_inserter(nearest_boxes) );
-
- if ( found_count > 0 )
- {
- std::cout << "search poly outer: ";
- BOOST_FOREACH(P const& p, search_poly.outer())
- {
- bgi::detail::rtree::visitors::detail::print_indexable(std::cout, p);
- std::cout << ' ';
- }
- std::cout << "\nfound: ";
- for ( size_t i = 0 ; i < nearest_boxes.size() ; ++i )
- {
- bgi::detail::rtree::visitors::detail::print_indexable(std::cout, nearest_boxes[i]);
- std::cout << '\n';
- }
- }
- else
- std::cout << "boxes not found\n";
-}
-
-template <typename Predicate>
-void query_multi_poly()
-{
- float x = ( rand() % 1000 ) / 10.0f;
- float y = ( rand() % 1000 ) / 10.0f;
- float w = 10 + ( rand() % 1000 ) / 100.0f;
- float h = 10 + ( rand() % 1000 ) / 100.0f;
-
- search_multi_poly.clear();
-
- search_multi_poly.push_back(Poly());
- search_multi_poly[0].outer().push_back(P(x - w, y - h));
- search_multi_poly[0].outer().push_back(P(x - w/2, y - h));
- search_multi_poly[0].outer().push_back(P(x, y - 3*h/2));
- search_multi_poly[0].outer().push_back(P(x + w/2, y - h));
- search_multi_poly[0].outer().push_back(P(x + w, y - h));
- search_multi_poly[0].outer().push_back(P(x + w, y - h/2));
- search_multi_poly[0].outer().push_back(P(x + 3*w/2, y));
- search_multi_poly[0].outer().push_back(P(x + w, y + h/2));
- search_multi_poly[0].outer().push_back(P(x + w, y + h));
- search_multi_poly[0].outer().push_back(P(x + w/2, y + h));
- search_multi_poly[0].outer().push_back(P(x, y + 3*h/2));
- search_multi_poly[0].outer().push_back(P(x - w/2, y + h));
- search_multi_poly[0].outer().push_back(P(x - w, y + h));
- search_multi_poly[0].outer().push_back(P(x - w, y + h/2));
- search_multi_poly[0].outer().push_back(P(x - 3*w/2, y));
- search_multi_poly[0].outer().push_back(P(x - w, y - h/2));
- search_multi_poly[0].outer().push_back(P(x - w, y - h));
-
- search_multi_poly[0].inners().push_back(Poly::ring_type());
- search_multi_poly[0].inners()[0].push_back(P(x - w/2, y - h/2));
- search_multi_poly[0].inners()[0].push_back(P(x + w/2, y - h/2));
- search_multi_poly[0].inners()[0].push_back(P(x + w/2, y + h/2));
- search_multi_poly[0].inners()[0].push_back(P(x - w/2, y + h/2));
- search_multi_poly[0].inners()[0].push_back(P(x - w/2, y - h/2));
-
- search_multi_poly.push_back(Poly());
- search_multi_poly[1].outer().push_back(P(x - 2*w, y - 2*h));
- search_multi_poly[1].outer().push_back(P(x - 6*w/5, y - 2*h));
- search_multi_poly[1].outer().push_back(P(x - 6*w/5, y - 6*h/5));
- search_multi_poly[1].outer().push_back(P(x - 2*w, y - 6*h/5));
- search_multi_poly[1].outer().push_back(P(x - 2*w, y - 2*h));
-
- search_multi_poly.push_back(Poly());
- search_multi_poly[2].outer().push_back(P(x + 6*w/5, y + 6*h/5));
- search_multi_poly[2].outer().push_back(P(x + 2*w, y + 6*h/5));
- search_multi_poly[2].outer().push_back(P(x + 2*w, y + 2*h));
- search_multi_poly[2].outer().push_back(P(x + 6*w/5, y + 2*h));
- search_multi_poly[2].outer().push_back(P(x + 6*w/5, y + 6*h/5));
-
- nearest_boxes.clear();
- found_count = t.query(Predicate(search_multi_poly), std::back_inserter(nearest_boxes) );
-
- if ( found_count > 0 )
- {
- std::cout << "search multi_poly[0] outer: ";
- BOOST_FOREACH(P const& p, search_multi_poly[0].outer())
- {
- bgi::detail::rtree::visitors::detail::print_indexable(std::cout, p);
- std::cout << ' ';
- }
- std::cout << "\nfound: ";
- for ( size_t i = 0 ; i < nearest_boxes.size() ; ++i )
- {
- bgi::detail::rtree::visitors::detail::print_indexable(std::cout, nearest_boxes[i]);
- std::cout << '\n';
- }
- }
- else
- std::cout << "boxes not found\n";
-}
-
-void search()
-{
- if ( query_mode == qm_knn )
- knn();
- else if ( query_mode == qm_c )
- query< bgi::detail::covered_by<B> >();
- else if ( query_mode == qm_d )
- query< bgi::detail::disjoint<B> >();
- else if ( query_mode == qm_i )
- query< bgi::detail::intersects<B> >();
- else if ( query_mode == qm_o )
- query< bgi::detail::overlaps<B> >();
- else if ( query_mode == qm_w )
- query< bgi::detail::within<B> >();
- else if ( query_mode == qm_nc )
- query< bgi::detail::not_covered_by<B> >();
- else if ( query_mode == qm_nd )
- query< bgi::detail::not_disjoint<B> >();
- else if ( query_mode == qm_ni )
- query< bgi::detail::not_intersects<B> >();
- else if ( query_mode == qm_no )
- query< bgi::detail::not_overlaps<B> >();
- else if ( query_mode == qm_nw )
- query< bgi::detail::not_within<B> >();
- else if ( query_mode == qm_all )
- query< bgi::detail::intersects<B> >();
- else if ( query_mode == qm_ri )
- query_ring< bgi::detail::intersects<R> >();
- else if ( query_mode == qm_pi )
- query_poly< bgi::detail::intersects<Poly> >();
- else if ( query_mode == qm_mpi )
- query_multi_poly< bgi::detail::intersects<MPoly> >();
-
- search_valid = true;
-}
-
-void draw_knn_area(float min_distance, float max_distance)
-{
- float x = boost::geometry::get<0>(search_point);
- float y = boost::geometry::get<1>(search_point);
- float z = t.depth();
-
- // search point
- glBegin(GL_TRIANGLES);
- glVertex3f(x, y, z);
- glVertex3f(x + 1, y, z);
- glVertex3f(x + 1, y + 1, z);
- glEnd();
-
- // search min circle
-
- glBegin(GL_LINE_LOOP);
- for(float a = 0 ; a < 3.14158f * 2 ; a += 3.14158f / 180)
- glVertex3f(x + min_distance * ::cos(a), y + min_distance * ::sin(a), z);
- glEnd();
-
- // search max circle
-
- glBegin(GL_LINE_LOOP);
- for(float a = 0 ; a < 3.14158f * 2 ; a += 3.14158f / 180)
- glVertex3f(x + max_distance * ::cos(a), y + max_distance * ::sin(a), z);
- glEnd();
-}
-
-template <typename Box>
-void draw_box(Box const& box)
-{
- float x1 = boost::geometry::get<bg::min_corner, 0>(box);
- float y1 = boost::geometry::get<bg::min_corner, 1>(box);
- float x2 = boost::geometry::get<bg::max_corner, 0>(box);
- float y2 = boost::geometry::get<bg::max_corner, 1>(box);
- float z = t.depth();
-
- // search box
- glBegin(GL_LINE_LOOP);
- glVertex3f(x1, y1, z);
- glVertex3f(x2, y1, z);
- glVertex3f(x2, y2, z);
- glVertex3f(x1, y2, z);
- glEnd();
-}
-
-template <typename Range>
-void draw_ring(Range const& range)
-{
- float z = t.depth();
-
- // search box
- glBegin(GL_LINE_LOOP);
-
- BOOST_FOREACH(P const& p, range)
- {
- float x = boost::geometry::get<0>(p);
- float y = boost::geometry::get<1>(p);
-
- glVertex3f(x, y, z);
- }
- glEnd();
-}
-
-template <typename Polygon>
-void draw_polygon(Polygon const& polygon)
-{
- draw_ring(polygon.outer());
- BOOST_FOREACH(Poly::ring_type const& r, polygon.inners())
- draw_ring(r);
-}
-
-template <typename MultiPolygon>
-void draw_multi_polygon(MultiPolygon const& multi_polygon)
-{
- BOOST_FOREACH(Poly const& p, multi_polygon)
- draw_polygon(p);
-}
-
-void render_scene(void)
-{
- glClear(GL_COLOR_BUFFER_BIT);
-
- boost::geometry::index::gl_draw(t);
-
- if ( search_valid )
- {
- glColor3f(1.0f, 0.5f, 0.0f);
-
- if ( query_mode == qm_knn )
- draw_knn_area(0, 0);
- else if ( query_mode == qm_ri )
- draw_ring(search_ring);
- else if ( query_mode == qm_pi )
- draw_polygon(search_poly);
- else if ( query_mode == qm_mpi )
- draw_multi_polygon(search_multi_poly);
- else
- draw_box(search_box);
-
- for ( size_t i = 0 ; i < nearest_boxes.size() ; ++i )
- boost::geometry::index::detail::rtree::visitors::detail::gl_draw_indexable(nearest_boxes[i], t.depth());
- }
-
- glFlush();
-}
-
-void resize(int w, int h)
-{
- if ( h == 0 )
- h = 1;
-
- float ratio = float(w) / h;
-
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
-
- glViewport(0, 0, w, h);
-
- //gluPerspective(45, ratio, 1, 1000);
- glOrtho(-150, 150, -150, 150, -150, 150);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- /*gluLookAt(
- 120.0f, 120.0f, 120.0f,
- 50.0f, 50.0f, -1.0f,
- 0.0f, 1.0f, 0.0f);*/
- gluLookAt(
- 50.0f, 50.0f, 75.0f,
- 50.0f, 50.0f, -1.0f,
- 0.0f, 1.0f, 0.0f);
-
- glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
- glLineWidth(1.5f);
-
- srand(1);
-}
-
-void mouse(int button, int state, int x, int y)
-{
- if ( button == GLUT_LEFT_BUTTON && state == GLUT_DOWN )
- {
- float x = ( rand() % 100 );
- float y = ( rand() % 100 );
- float w = ( rand() % 2 ) + 1;
- float h = ( rand() % 2 ) + 1;
-
- B b(P(x - w, y - h),P(x + w, y + h));
-
- boost::geometry::index::insert(t, b);
- vect.push_back(b);
-
- std::cout << "inserted: ";
- bgi::detail::rtree::visitors::detail::print_indexable(std::cout, b);
- std::cout << '\n';
-
- std::cout << ( bgi::detail::rtree::are_boxes_ok(t) ? "boxes OK\n" : "WRONG BOXES!\n" );
- std::cout << ( bgi::detail::rtree::are_levels_ok(t) ? "levels OK\n" : "WRONG LEVELS!\n" );
- std::cout << "\n";
-
- search_valid = false;
- }
- else if ( button == GLUT_RIGHT_BUTTON && state == GLUT_DOWN )
- {
- if ( vect.empty() )
- return;
-
- size_t i = rand() % vect.size();
- B b = vect[i];
-
- bgi::remove(t, b);
- vect.erase(vect.begin() + i);
-
- std::cout << "removed: ";
- bgi::detail::rtree::visitors::detail::print_indexable(std::cout, b);
- std::cout << '\n';
-
- std::cout << ( bgi::detail::rtree::are_boxes_ok(t) ? "boxes OK\n" : "WRONG BOXES!\n" );
- std::cout << ( bgi::detail::rtree::are_levels_ok(t) ? "levels OK\n" : "WRONG LEVELS!\n" );
- std::cout << "\n";
-
- search_valid = false;
- }
- else if ( button == GLUT_MIDDLE_BUTTON && state == GLUT_DOWN )
- {
- search();
- }
-
- glutPostRedisplay();
-}
-
-std::string current_line;
-
-void keyboard(unsigned char key, int x, int y)
-{
- if ( key == '\r' || key == '\n' )
- {
- if ( current_line == "t" )
- {
- std::cout << "\n" << t << "\n";
- }
- else if ( current_line == "rand" )
- {
- for ( size_t i = 0 ; i < 35 ; ++i )
- {
- float x = ( rand() % 100 );
- float y = ( rand() % 100 );
- float w = ( rand() % 2 ) + 1;
- float h = ( rand() % 2 ) + 1;
-
- B b(P(x - w, y - h),P(x + w, y + h));
-
- boost::geometry::index::insert(t, b);
- vect.push_back(b);
-
- std::cout << "inserted: ";
- bgi::detail::rtree::visitors::detail::print_indexable(std::cout, b);
- std::cout << '\n';
- }
-
- std::cout << ( bgi::detail::rtree::are_boxes_ok(t) ? "boxes OK\n" : "WRONG BOXES!\n" );
- std::cout << ( bgi::detail::rtree::are_levels_ok(t) ? "levels OK\n" : "WRONG LEVELS!\n" );
- std::cout << "\n";
-
- search_valid = false;
-
- glutPostRedisplay();
- }
- else
- {
- if ( current_line == "knn" )
- query_mode = qm_knn;
- else if ( current_line == "c" )
- query_mode = qm_c;
- else if ( current_line == "d" )
- query_mode = qm_d;
- else if ( current_line == "i" )
- query_mode = qm_i;
- else if ( current_line == "o" )
- query_mode = qm_o;
- else if ( current_line == "w" )
- query_mode = qm_w;
- else if ( current_line == "nc" )
- query_mode = qm_nc;
- else if ( current_line == "nd" )
- query_mode = qm_nd;
- else if ( current_line == "ni" )
- query_mode = qm_ni;
- else if ( current_line == "no" )
- query_mode = qm_no;
- else if ( current_line == "nw" )
- query_mode = qm_nw;
- else if ( current_line == "all" )
- query_mode = qm_all;
- else if ( current_line == "ri" )
- query_mode = qm_ri;
- else if ( current_line == "pi" )
- query_mode = qm_pi;
- else if ( current_line == "mpi" )
- query_mode = qm_mpi;
-
- search();
- glutPostRedisplay();
- }
-
- current_line.clear();
- std::cout << '\n';
- }
- else
- {
- current_line += key;
- std::cout << key;
- }
-}
-
-int main(int argc, char **argv)
-{
- glutInit(&argc, argv);
- glutInitDisplayMode(GLUT_DEPTH | GLUT_SINGLE | GLUT_RGBA);
- glutInitWindowPosition(100,100);
- glutInitWindowSize(600, 600);
- glutCreateWindow("boost::geometry::index::rtree GLUT test");
-
- glutDisplayFunc(render_scene);
- glutReshapeFunc(resize);
- glutMouseFunc(mouse);
- glutKeyboardFunc(keyboard);
-
- glutMainLoop();
-
- return 0;
-}

Deleted: /sandbox-branches/geometry/index/tests/additional_sizes_and_times.cpp
==============================================================================
--- /sandbox-branches/geometry/index/tests/additional_sizes_and_times.cpp 2013-02-14 09:23:09 EST (Thu, 14 Feb 2013)
+++ (empty file)
@@ -1,485 +0,0 @@
-// Boost.Geometry Index
-// Additional tests
-
-// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
-
-// Use, modification and distribution is subject to the Boost Software License,
-// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-#include <iostream>
-#include <fstream>
-
-#define BOOST_GEOMETRY_INDEX_ENABLE_DEBUG_INTERFACE
-#include <boost/geometry/index/rtree.hpp>
-#include <boost/geometry/index/inserter.hpp>
-
-#include <boost/geometry/index/detail/rtree/visitors/are_boxes_ok.hpp>
-#include <boost/geometry/index/detail/rtree/visitors/are_levels_ok.hpp>
-
-#include <boost/timer.hpp>
-#include <boost/foreach.hpp>
-#include <boost/random.hpp>
-
-template <typename V>
-struct test_pred
-{
- bool operator()(V const& v) const
- {
- return v.second % 2 != 0;
- }
-};
-
-int main()
-{
- boost::timer tim;
-
- namespace bg = boost::geometry;
- namespace bgi = bg::index;
-
- //typedef bg::model::d2::point_xy<double> P;
- typedef bg::model::point<double, 2, bg::cs::cartesian> P;
- typedef bg::model::box<P> B;
- typedef bgi::rtree<
- std::pair<B, size_t>,
- bgi::linear<32, 8>,
- bgi::translator::def< std::pair<B, size_t> >/*,
- boost::fast_pool_allocator< std::pair<B, size_t> >*/
- > RT;
- //typedef bgi::rtree<std::pair<B, size_t>, bgi::quadratic<32, 8> > RT;
- //typedef bgi::rtree<std::pair<B, size_t>, bgi::rstar<32, 8> > RT;
- /*typedef bgi::rtree<
- std::pair<B, size_t>,
- bgi::options::rtree<bgi::rstar<32, 8, 0, 10>, bgi::reinsert_tag, bgi::choose_by_area_diff_tag, bgi::rstar_tag, bgi::default_tag>
- > RT;*/
-
- // load config file
- std::ifstream file_cfg("config.txt");
- size_t values_count = 0;
- size_t remove_count = 0;
- size_t queries_count = 0;
- std::string file_name("");
- file_cfg >> values_count;
- file_cfg >> remove_count;
- file_cfg >> queries_count;
- file_cfg >> file_name;
- std::cout << "v: " << values_count << ", r: " << remove_count << ", q: " << queries_count << "\n";
-
- if ( values_count < remove_count )
- {
- std::cout << "can't remove more data than was inserted\n";
- return 0;
- }
-
- // prepare data buffer
- std::vector< std::pair<float, float> > coords;
- coords.reserve(values_count);
-
- // load test coordinates
- if ( file_name != "" )
- {
- std::ifstream file(file_name.c_str());
- if ( !file.is_open() )
- {
- std::cout << "can't open file containing coordinates\n";
- return 0;
- }
-
- std::cout << "loading data\n";
- for ( size_t i = 0 ; i < values_count ; ++i )
- {
- std::pair<float, float> v;
- file >> v.first;
- file >> v.second;
- coords.push_back(v);
- }
- std::cout << "loaded\n";
-
- if ( coords.size() != values_count || coords.size() < remove_count )
- {
- std::cout << "not enough coordinates loaded\n";
- return 0;
- }
- }
- // randomize
- else
- {
- boost::mt19937 rng;
- //rng.seed(static_cast<unsigned int>(std::time(0)));
- float max_val = static_cast<float>(values_count / 2);
- boost::uniform_real<float> range(-max_val, max_val);
- boost::variate_generator<boost::mt19937&, boost::uniform_real<float> > rnd(rng, range);
-
- //::srand( ::time(NULL) );
- //float factor = values_count / float(RAND_MAX);
- //float comp = values_count / 2;
-
- std::cout << "randomizing data\n";
- for ( size_t i = 0 ; i < values_count ; ++i )
- {
- coords.push_back(std::make_pair(rnd(), rnd()));
- //float x = rand() * factor + comp;
- //float y = rand() * factor + comp;
- //coords.push_back( std::make_pair( x, y ));
- }
- std::cout << "randomized\n";
- }
-
- // create rtree
- RT t;
-
- // elements inserting test
- {
- std::cout << "rtree inserting time test... ("
- << values_count << ")\n";
- tim.restart();
- for (size_t i = 0 ; i < values_count ; ++i )
- {
- 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.insert(std::make_pair(b, i));
- }
- std::cout << "time: " << tim.elapsed() << "s\n";
- }
-
- // elements inserting test using insert_iterator
- {
- RT t;
-
- std::cout << "rtree inserting time test using insert_iterator<>... ("
- << values_count << ")\n";
- bgi::insert_iterator<RT> ii = bgi::inserter(t);
- tim.restart();
- for (size_t i = 0 ; i < values_count ; ++i )
- {
- 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));
-
- *ii++ = std::make_pair(b, i);
- }
- std::cout << "time: " << tim.elapsed() << "s\n";
- }
-
- std::vector< std::pair<B, size_t> > v;
-
- // elements inserting test
- {
- std::cout << "vector inserting time test... ("
- << values_count << ")\n";
- tim.restart();
- for (size_t i = 0 ; i < values_count ; ++i )
- {
- 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));
-
- v.push_back(std::make_pair(b, i));
- }
- std::cout << "time: " << tim.elapsed() << "s\n";
- }
-
- // check
- if ( bgi::detail::rtree::are_boxes_ok(t) )
- std::cout << "BOXES OK\n";
- else
- std::cout << "WRONG BOXES\n";
- if ( bgi::detail::rtree::are_levels_ok(t) )
- std::cout << "LEVELS OK\n";
- else
- std::cout << "WRONG LEVELS\n";
-
- // searching test
- {
- std::cout << "query(intersects(B)) searching time test... ("
- << queries_count << ")\n";
- tim.restart();
- size_t temp = 0;
- for (size_t i = 0 ; i < queries_count ; ++i )
- {
- float x = coords[i].first;
- float y = coords[i].second;
- std::deque< std::pair<B, size_t> > result;
- t.query(bgi::intersects(B(P(x - 10, y - 10), P(x + 10, y + 10))), std::back_inserter(result));
- temp += result.size();
- }
- std::cout << "time: " << tim.elapsed() << "s\n";
- std::cout << "found: " << temp << "\n";
- }
-
- // copying test
- {
- std::cout << "rtree copying time test... ("
- << values_count << ")\n";
- tim.restart();
- RT t_copy(t);
- std::cout << "time: " << tim.elapsed() << "s\n";
- std::cout << "new size: " << t_copy.size() << '\n';
-
- // t_copy searching test
- {
- std::cout << "tree copy query(intersects(B)) searching time test... ("
- << queries_count << ")\n";
- tim.restart();
- size_t temp = 0;
- for (size_t i = 0 ; i < queries_count ; ++i )
- {
- float x = coords[i].first;
- float y = coords[i].second;
- std::deque< std::pair<B, size_t> > result;
- t_copy.query(bgi::intersects(B(P(x - 10, y - 10), P(x + 10, y + 10))), std::back_inserter(result));
- temp += result.size();
- }
- std::cout << "time: " << tim.elapsed() << "s\n";
- std::cout << "found: " << temp << "\n";
- }
- }
-
- // searching test
- {
- std::cout << "query(!disjoint(B)) searching time test... ("
- << queries_count << ")\n";
- tim.restart();
- size_t temp = 0;
- for (size_t i = 0 ; i < queries_count ; ++i )
- {
- float x = coords[i].first;
- float y = coords[i].second;
- std::deque< std::pair<B, size_t> > result;
- t.query(!bgi::disjoint(B(P(x - 10, y - 10), P(x + 10, y + 10))), std::back_inserter(result));
- temp += result.size();
- }
- std::cout << "time: " << tim.elapsed() << "s\n";
- std::cout << "found: " << temp << "\n";
- }
-
- // searching test
- {
- std::cout << "query(B) searching time test... ("
- << queries_count << ")\n";
- tim.restart();
- size_t temp = 0;
- for (size_t i = 0 ; i < queries_count ; ++i )
- {
- float x = coords[i].first;
- float y = coords[i].second;
- std::deque< std::pair<B, size_t> > result;
- t.query(B(P(x - 10, y - 10), P(x + 10, y + 10)), std::back_inserter(result));
- temp += result.size();
- }
- std::cout << "time: " << tim.elapsed() << "s\n";
- std::cout << "found: " << temp << "\n";
- }
-
- // searching test
- {
- std::cout << "pair: query(B) and value(odd index) searching time test... ("
- << queries_count << ")\n";
- tim.restart();
- size_t temp = 0;
- for (size_t i = 0 ; i < queries_count ; ++i )
- {
- float x = coords[i].first;
- float y = coords[i].second;
- std::deque< std::pair<B, size_t> > result;
- t.query(
- B(P(x - 10, y - 10), P(x + 10, y + 10)) && bgi::value(test_pred< std::pair<B, size_t> >())
- , std::back_inserter(result));
- temp += result.size();
- }
- std::cout << "time: " << tim.elapsed() << "s\n";
- std::cout << "found: " << temp << "\n";
- }
-
- // searching test
- {
- std::cout << "tuple: query(B) and value(odd index) searching time test... ("
- << queries_count << ")\n";
- tim.restart();
- size_t temp = 0;
- for (size_t i = 0 ; i < queries_count ; ++i )
- {
- float x = coords[i].first;
- float y = coords[i].second;
- std::deque< std::pair<B, size_t> > result;
- t.query(
- B(P(x - 10, y - 10), P(x + 10, y + 10)) && bgi::value(test_pred< std::pair<B, size_t> >())
- , std::back_inserter(result));
- temp += result.size();
- }
- std::cout << "time: " << tim.elapsed() << "s\n";
- std::cout << "found: " << temp << "\n";
- }
-
- // searching test
- {
- std::cout << "vector searching time test... ("
- << queries_count / 1000 << ")\n";
- tim.restart();
- size_t temp = 0;
- for (size_t i = 0 ; i < queries_count / 1000 ; ++i )
- {
- float x = coords[i].first;
- float y = coords[i].second;
- std::deque< std::pair<B, size_t> > result;
- for ( std::vector< std::pair<B, size_t> >::const_iterator it = v.begin();
- it != v.end() ;
- ++it )
- {
- if ( bg::intersects(
- it->first,
- B(P(x - 10, y - 10), P(x + 10, y + 10))
- )
- )
- result.push_back(*it);
- }
- temp += result.size();
- }
- std::cout << "time: " << tim.elapsed() << "s\n";
- std::cout << "found: " << temp << "\n";
- }
-
- // searching test
- {
- std::cout << "nearest 5 searching time test... ("
- << queries_count / 10 << ")\n";
- tim.restart();
- size_t temp = 0;
- for (size_t i = 0 ; i < queries_count / 10 ; ++i )
- {
- float x = coords[i].first + 100;
- float y = coords[i].second + 100;
- std::vector< std::pair<B, size_t> > result;
- temp += t.query(bgi::nearest(P(x, y), 5), std::back_inserter(result));
- }
- std::cout << "time: " << tim.elapsed() << "s\n";
- std::cout << "found: " << temp << "\n";
- }
-
- // searching test
- {
- std::cout << "vector nearest searching time test... ("
- << queries_count / 1000 << ")\n";
- tim.restart();
- size_t temp = 0;
- for (size_t i = 0 ; i < queries_count / 1000 ; ++i )
- {
- typedef bg::default_distance_result<P, B>::type distance_type;
-
- float x = coords[i].first + 100;
- float y = coords[i].second + 100;
- std::pair<B, size_t> result;
- distance_type dist = (std::numeric_limits<distance_type>::max)();
-
- for ( std::vector< std::pair<B, size_t> >::const_iterator it = v.begin();
- it != v.end();
- ++it )
- {
- distance_type cd = bgi::detail::comparable_distance_near(P(x, y), it->first);
-
- if ( cd < dist )
- {
- result = *it;
- dist = cd;
- }
- }
- temp += dist < (std::numeric_limits<distance_type>::max)() ? 1 : 0;
- }
- std::cout << "time: " << tim.elapsed() << "s\n";
- std::cout << "found: " << temp << "\n";
- }
-
- // elements removing test
- {
- std::cout << "removing time test... ("
- << remove_count << ")\n";
- tim.restart();
- for (size_t i = 0 ; i < remove_count ; ++i )
- {
- 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(std::make_pair(b, i));
- }
- std::cout << "time: " << tim.elapsed() << "s\n";
- }
-
- // check
- if ( bgi::detail::rtree::are_boxes_ok(t) )
- std::cout << "BOXES OK\n";
- else
- std::cout << "WRONG BOXES\n";
- if ( bgi::detail::rtree::are_levels_ok(t) )
- std::cout << "LEVELS OK\n";
- else
- std::cout << "WRONG LEVELS\n";
-
- // searching test
- {
- std::cout << "searching time test... ("
- << queries_count << ")\n";
- tim.restart();
- size_t temp = 0;
- for (size_t i = 0 ; i < queries_count ; ++i )
- {
- float x = coords[i].first;
- float y = coords[i].second;
- std::deque< std::pair<B, size_t> > result;
- t.query(bgi::intersects(B(P(x - 10, y - 10), P(x + 10, y + 10))), std::back_inserter(result));
- temp += result.size();
- }
- std::cout << "time: " << tim.elapsed() << "s\n";
- std::cout << "found: " << temp << "\n";
- }
-
- // inserting test
- {
- std::cout << "inserting time test... ("
- << remove_count << ")\n";
- tim.restart();
- for (size_t i = 0 ; i < remove_count ; ++i )
- {
- 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.insert(std::make_pair(b, i));
- }
- std::cout << "time: " << tim.elapsed() << "s\n";
- }
-
- // check
- if ( bgi::detail::rtree::are_boxes_ok(t) )
- std::cout << "BOXES OK\n";
- else
- std::cout << "WRONG BOXES\n";
- if ( bgi::detail::rtree::are_levels_ok(t) )
- std::cout << "LEVELS OK\n";
- else
- std::cout << "WRONG LEVELS\n";
-
- // searching test
- {
- std::cout << "searching time test... ("
- << queries_count << ")\n";
- tim.restart();
- size_t temp = 0;
- for (size_t i = 0 ; i < queries_count ; ++i )
- {
- float x = coords[i].first;
- float y = coords[i].second;
- std::deque< std::pair<B, size_t> > result;
- t.query(bgi::intersects(B(P(x - 10, y - 10), P(x + 10, y + 10))), std::back_inserter(result));
- temp += result.size();
- }
- std::cout << "time: " << tim.elapsed() << "s\n";
- std::cout << "found: " << temp << "\n";
- }
-
- std::cin.get();
-
- return 0;
-}

Deleted: /sandbox-branches/geometry/index/tests/additional_speed.cpp
==============================================================================
--- /sandbox-branches/geometry/index/tests/additional_speed.cpp 2013-02-14 09:23:09 EST (Thu, 14 Feb 2013)
+++ (empty file)
@@ -1,164 +0,0 @@
-// Boost.Geometry Index
-// Additional tests
-
-// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
-
-// Use, modification and distribution is subject to the Boost Software License,
-// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-#include <iostream>
-#include <fstream>
-
-#include <boost/geometry/index/rtree.hpp>
-#include <boost/geometry/index/inserter.hpp>
-
-#include <boost/timer.hpp>
-#include <boost/foreach.hpp>
-#include <boost/random.hpp>
-
-#include <boost/pool/pool_alloc.hpp>
-
-int main()
-{
- boost::timer tim;
-
- namespace bg = boost::geometry;
- namespace bgi = bg::index;
-
- size_t values_count = 1000000;
- size_t queries_count = 100000;
-
- std::vector< std::pair<float, float> > coords;
-
- //randomize values
- {
- boost::mt19937 rng;
- //rng.seed(static_cast<unsigned int>(std::time(0)));
- float max_val = static_cast<float>(values_count / 2);
- boost::uniform_real<float> range(-max_val, max_val);
- boost::variate_generator<boost::mt19937&, boost::uniform_real<float> > rnd(rng, range);
-
- coords.reserve(values_count);
-
- std::cout << "randomizing data\n";
- for ( size_t i = 0 ; i < values_count ; ++i )
- {
- coords.push_back(std::make_pair(rnd(), rnd()));
- }
- std::cout << "randomized\n";
- }
-
- //typedef bg::model::d2::point_xy<double> P;
- typedef bg::model::point<double, 2, bg::cs::cartesian> P;
- typedef bg::model::box<P> B;
- typedef bgi::rtree<B, bgi::linear<32, 8> > RT;
- //typedef bgi::rtree<B, bgi::runtime::linear > RT;
- //typedef bgi::rtree<B, bgi::quadratic<32, 8> > RT;
- //typedef bgi::rtree<B, bgi::runtime::quadratic > RT;
- //typedef bgi::rtree<B, bgi::rstar<32, 8> > RT;
- //typedef bgi::rtree<B, bgi::runtime::rstar > RT;
-
- for (;;)
- {
- RT t;
- //RT t(bgi::runtime::linear(32, 8));
- //RT t(bgi::runtime::quadratic(32, 8));
- //RT t(bgi::runtime::rstar(32, 8));
-
- // inserting test
- {
- tim.restart();
- for (size_t i = 0 ; i < values_count ; ++i )
- {
- 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.insert(b);
- }
- double time = tim.elapsed();
- std::cout << time << "s - insert " << values_count << '\n';
- }
-
- std::vector<B> result;
- result.reserve(100);
- B result_one;
-
- {
- tim.restart();
- size_t temp = 0;
- for (size_t i = 0 ; i < queries_count ; ++i )
- {
- float x = coords[i].first;
- float y = coords[i].second;
- result.clear();
- t.query(B(P(x - 10, y - 10), P(x + 10, y + 10)), std::back_inserter(result));
- temp += result.size();
- }
- double time = tim.elapsed();
- std::cout << time << "s - query(B) " << queries_count << " found " << temp << '\n';
- }
-
- {
- tim.restart();
- size_t temp = 0;
- for (size_t i = 0 ; i < queries_count / 2 ; ++i )
- {
- float x1 = coords[i].first;
- float y1 = coords[i].second;
- float x2 = coords[i+1].first;
- float y2 = coords[i+1].second;
- float x3 = coords[i+2].first;
- float y3 = coords[i+2].second;
- result.clear();
- t.query(
- bgi::intersects(B(P(x1 - 10, y1 - 10), P(x1 + 10, y1 + 10)))
- &&
- !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)))
- ,
- std::back_inserter(result)
- );
- temp += result.size();
- }
- double time = tim.elapsed();
- std::cout << time << "s - query(i && !w && !o) " << queries_count << " found " << temp << '\n';
- }
-
- result.clear();
-
- {
- tim.restart();
- size_t temp = 0;
- for (size_t i = 0 ; i < queries_count / 10 ; ++i )
- {
- float x = coords[i].first + 100;
- float y = coords[i].second + 100;
- result.clear();
- temp += t.query(bgi::nearest(P(x, y), 5), std::back_inserter(result));
- }
- double time = tim.elapsed();
- std::cout << time << "s - query(nearest(P, 5)) " << (queries_count / 10) << " found " << temp << '\n';
- }
-
- {
- tim.restart();
- for (size_t i = 0 ; i < values_count / 10 ; ++i )
- {
- 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);
- }
- double time = tim.elapsed();
- std::cout << time << "s - remove " << values_count / 10 << '\n';
- }
-
- std::cout << "------------------------------------------------\n";
- }
-
- return 0;
-}

Copied: sandbox-branches/geometry/index/example/benchmark.cpp (from r82871, /sandbox-branches/geometry/index/tests/additional_speed.cpp)
==============================================================================
--- /sandbox-branches/geometry/index/tests/additional_speed.cpp (original)
+++ sandbox-branches/geometry/index/example/benchmark.cpp 2013-02-14 09:23:09 EST (Thu, 14 Feb 2013)
@@ -8,17 +8,13 @@
 // http://www.boost.org/LICENSE_1_0.txt)
 
 #include <iostream>
-#include <fstream>
 
 #include <boost/geometry/index/rtree.hpp>
-#include <boost/geometry/index/inserter.hpp>
 
 #include <boost/timer.hpp>
 #include <boost/foreach.hpp>
 #include <boost/random.hpp>
 
-#include <boost/pool/pool_alloc.hpp>
-
 int main()
 {
     boost::timer tim;

Deleted: /sandbox-branches/geometry/index/tests/rtree_test_generator.cpp
==============================================================================
--- /sandbox-branches/geometry/index/tests/rtree_test_generator.cpp 2013-02-14 09:23:09 EST (Thu, 14 Feb 2013)
+++ (empty file)
@@ -1,122 +0,0 @@
-// Boost.Geometry Index
-// Rtree tests generator
-
-// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
-
-// Use, modification and distribution is subject to the Boost Software License,
-// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-#include <fstream>
-#include <vector>
-#include <string>
-#include <boost/foreach.hpp>
-#include <boost/tuple/tuple.hpp>
-
-int main()
-{
- std::vector<std::string> generated_files;
-
- typedef boost::tuple<std::string, std::string, std::string> CT;
- std::vector<CT> coordinate_types;
- coordinate_types.push_back(boost::make_tuple("double", "d", ""));
- coordinate_types.push_back(boost::make_tuple("float", "f", ""));
- coordinate_types.push_back(boost::make_tuple("int", "i", ""));
- coordinate_types.push_back(boost::make_tuple("ttmath_big", "tt", "HAVE_TTMATH"));
-
- std::vector<std::string> dimensions;
- dimensions.push_back("2");
- dimensions.push_back("3");
-
- typedef boost::tuple<std::string, std::string> P;
- std::vector<P> parameters;
- parameters.push_back(boost::make_tuple("bgi::linear<4, 2>()", "linear"));
- parameters.push_back(boost::make_tuple("bgi::quadratic<4, 2>()", "quadratic"));
- parameters.push_back(boost::make_tuple("bgi::rstar<4, 2>()", "rstar"));
- parameters.push_back(boost::make_tuple("bgi::runtime::linear(4, 2)", "linear_rt"));
- parameters.push_back(boost::make_tuple("bgi::runtime::quadratic(4, 2)", "quadratic_rt"));
- parameters.push_back(boost::make_tuple("bgi::runtime::rstar(4, 2)","rstar_rt"));
-
- std::vector<std::string> indexables;
- indexables.push_back("p");
- indexables.push_back("b");
-
- BOOST_FOREACH(std::string const& d, dimensions)
- {
- BOOST_FOREACH(CT const& c, coordinate_types)
- {
- BOOST_FOREACH(P const& p, parameters)
- {
- BOOST_FOREACH(std::string const& i, indexables)
- {
- std::string point_type = std::string() +
- "bg::model::point<" + boost::get<0>(c) + ", " + d + ", bg::cs::cartesian>";
-
- std::string filename = std::string() +
- "rtree_" + i + d + boost::get<1>(c) + '_' + boost::get<1>(p) + ".cpp";
-
- std::ofstream f(filename.c_str(), std::ios::trunc);
-
- f <<
- "// Boost.Geometry Index\n" <<
- "// Unit Test\n" <<
- "\n" <<
- "// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.\n" <<
- "\n" <<
- "// Use, modification and distribution is subject to the Boost Software License,\n" <<
- "// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at\n" <<
- "// http://www.boost.org/LICENSE_1_0.txt)\n" <<
- "\n";
-
- f <<
- "#include <rtree/test_rtree.hpp>\n" <<
- "\n" <<
- "#include <boost/geometry/geometries/point.hpp>\n" <<
- (i == "p" ? "" : "#include <boost/geometry/geometries/box.hpp>\n") <<
- "\n";
-
- f <<
- "int test_main(int, char* [])\n" <<
- "{\n" <<
- (boost::get<2>(c).empty() ? "" : "#ifdef HAVE_TTMATH\n") <<
- " typedef " << point_type << " Point;\n" <<
- " " <<
- (i == "p" ? "test_rtree_for_point" : "test_rtree_for_box" ) <<
- "<Point>(" << boost::get<0>(p) << ");\n" <<
- (boost::get<2>(c).empty() ? "" : "#endif\n") <<
- " return 0;\n" <<
- "}\n";
-
- generated_files.push_back(filename);
- }
- }
-
- }
- }
-
- std::ofstream f("Jamfile.v2", std::ios::trunc);
-
- f <<
- "# Boost.Geometry Index\n" <<
- "#\n" <<
- "# Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.\n" <<
- "#\n" <<
- "# Use, modification and distribution is subject to the Boost Software License,\n" <<
- "# Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at\n" <<
- "# http://www.boost.org/LICENSE_1_0.txt)\n" <<
- "\n" <<
- "test-suite boost-geometry-index-rtree-generated\n" <<
- " :\n";
-
- BOOST_FOREACH(std::string const& s, generated_files)
- {
- f <<
- " [ run " << s << " ]\n";
- }
-
- f <<
- " ;\n" <<
- "\n";
-
- return 0;
-}
\ No newline at end of file

Modified: sandbox-branches/geometry/index/test/rtree/Jamfile.v2
==============================================================================
--- sandbox-branches/geometry/index/test/rtree/Jamfile.v2 (original)
+++ sandbox-branches/geometry/index/test/rtree/Jamfile.v2 2013-02-14 09:23:09 EST (Thu, 14 Feb 2013)
@@ -6,21 +6,6 @@
 # Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 # http://www.boost.org/LICENSE_1_0.txt)
 
+build-project exceptions ;
+build-project interprocess ;
 build-project generated ;
-
-test-suite boost-geometry-index-rtree
- :
- [ run rtree_exceptions.cpp ]
- ;
-
-test-suite boost-geometry-index-rtree_interprocess
- : [ run rtree_interprocess.cpp /boost/thread//boost_thread
- : # additional args
- : # test-files
- : # requirements
- <toolset>acc:<linkflags>-lrt
- <toolset>acc-pa_risc:<linkflags>-lrt
- <toolset>gcc-mingw:<linkflags>"-lole32 -loleaut32 -lpsapi -ladvapi32"
- <host-os>hpux,<toolset>gcc:<linkflags>"-Wl,+as,mpas"
- ] : <threading>multi
- ;
\ No newline at end of file

Added: sandbox-branches/geometry/index/test/rtree/exceptions/Jamfile.v2
==============================================================================
--- (empty file)
+++ sandbox-branches/geometry/index/test/rtree/exceptions/Jamfile.v2 2013-02-14 09:23:09 EST (Thu, 14 Feb 2013)
@@ -0,0 +1,13 @@
+# Boost.Geometry Index
+#
+# Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
+#
+# Use, modification and distribution is subject to the Boost Software License,
+# Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+# http://www.boost.org/LICENSE_1_0.txt)
+
+test-suite boost-geometry-index-rtree-exceptions
+ :
+ [ run rtree_exceptions.cpp ]
+ ;
+

Added: sandbox-branches/geometry/index/test/rtree/exceptions/rtree_exceptions.cpp
==============================================================================
--- (empty file)
+++ sandbox-branches/geometry/index/test/rtree/exceptions/rtree_exceptions.cpp 2013-02-14 09:23:09 EST (Thu, 14 Feb 2013)
@@ -0,0 +1,179 @@
+// Boost.Geometry Index
+// Unit Test
+
+// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <rtree/exceptions/test_rtree_exceptions.hpp>
+
+#include <boost/geometry/geometries/point_xy.hpp>
+#include <boost/geometry/geometries/point.hpp>
+#include <boost/geometry/geometries/box.hpp>
+
+// test value exceptions
+template <typename Parameters>
+void test_rtree_value_exceptions(Parameters const& parameters = Parameters())
+{
+ typedef std::pair<bg::model::point<float, 2, bg::cs::cartesian>, throwing_value> Value;
+ typedef bgi::rtree<Value, Parameters> Tree;
+ typedef typename Tree::box_type B;
+
+ throwing_value::reset_calls_counter();
+ throwing_value::set_max_calls((std::numeric_limits<size_t>::max)());
+ std::vector<Value> input;
+ B qbox;
+ generate_input<2>::apply(input, qbox);
+
+ for ( size_t i = 0 ; i < 50 ; i += 2 )
+ {
+ throwing_value::reset_calls_counter();
+ throwing_value::set_max_calls(10000);
+
+ Tree tree(parameters);
+
+ throwing_value::reset_calls_counter();
+ throwing_value::set_max_calls(i);
+
+ BOOST_CHECK_THROW( tree.insert(input.begin(), input.end()), throwing_value_copy_exception );
+ }
+
+ for ( size_t i = 0 ; i < 20 ; i += 2 )
+ {
+ throwing_value::reset_calls_counter();
+ throwing_value::set_max_calls(10000);
+
+ Tree tree(parameters);
+
+ tree.insert(input.begin(), input.end());
+
+ throwing_value::reset_calls_counter();
+ throwing_value::set_max_calls(i);
+
+ BOOST_CHECK_THROW( tree.remove(input.begin(), input.end()), throwing_value_copy_exception );
+ }
+
+ for ( size_t i = 0 ; i < 20 ; i += 2 )
+ {
+ throwing_value::reset_calls_counter();
+ throwing_value::set_max_calls(10000);
+
+ Tree tree(parameters);
+
+ tree.insert(input.begin(), input.end());
+
+ throwing_value::reset_calls_counter();
+ throwing_value::set_max_calls(i);
+
+ BOOST_CHECK_THROW( Tree tree2(tree), throwing_value_copy_exception );
+ }
+
+ for ( size_t i = 0 ; i < 20 ; i += 2 )
+ {
+ throwing_value::reset_calls_counter();
+ throwing_value::set_max_calls(10000);
+
+ Tree tree(parameters);
+ Tree tree2(parameters);
+
+ tree.insert(input.begin(), input.end());
+
+ throwing_value::reset_calls_counter();
+ throwing_value::set_max_calls(i);
+
+ BOOST_CHECK_THROW(tree2 = tree, throwing_value_copy_exception );
+ }
+}
+
+// test value exceptions
+template <typename Parameters>
+void test_rtree_elements_exceptions(Parameters const& parameters = Parameters())
+{
+ typedef std::pair<bg::model::point<float, 2, bg::cs::cartesian>, throwing_value> Value;
+ typedef bgi::rtree<Value, Parameters> Tree;
+ typedef typename Tree::box_type B;
+
+ throwing_value::reset_calls_counter();
+ throwing_value::set_max_calls((std::numeric_limits<size_t>::max)());
+
+ std::vector<Value> input;
+ B qbox;
+ generate_input<2>::apply(input, qbox, 2);
+
+ for ( size_t i = 0 ; i < 100 ; i += 2 )
+ {
+ throwing_varray_settings::reset_calls_counter();
+ throwing_varray_settings::set_max_calls(10000);
+
+ Tree tree(parameters);
+
+ throwing_varray_settings::reset_calls_counter();
+ throwing_varray_settings::set_max_calls(i);
+
+ BOOST_CHECK_THROW( tree.insert(input.begin(), input.end()), throwing_varray_exception );
+ }
+
+ for ( size_t i = 0 ; i < 50 ; i += 2 )
+ {
+ throwing_varray_settings::reset_calls_counter();
+ throwing_varray_settings::set_max_calls(10000);
+
+ Tree tree(parameters);
+
+ tree.insert(input.begin(), input.end());
+
+ throwing_varray_settings::reset_calls_counter();
+ throwing_varray_settings::set_max_calls(i);
+
+ BOOST_CHECK_THROW( tree.remove(input.begin(), input.end()), throwing_varray_exception );
+ }
+
+ for ( size_t i = 0 ; i < 50 ; i += 2 )
+ {
+ throwing_varray_settings::reset_calls_counter();
+ throwing_varray_settings::set_max_calls(10000);
+
+ Tree tree(parameters);
+
+ tree.insert(input.begin(), input.end());
+
+ throwing_varray_settings::reset_calls_counter();
+ throwing_varray_settings::set_max_calls(i);
+
+ BOOST_CHECK_THROW( Tree tree2(tree), throwing_varray_exception );
+ }
+
+ for ( size_t i = 0 ; i < 50 ; i += 2 )
+ {
+ throwing_varray_settings::reset_calls_counter();
+ throwing_varray_settings::set_max_calls(10000);
+
+ Tree tree(parameters);
+ Tree tree2(parameters);
+
+ tree.insert(input.begin(), input.end());
+
+ throwing_varray_settings::reset_calls_counter();
+ throwing_varray_settings::set_max_calls(i);
+
+ BOOST_CHECK_THROW(tree2 = tree, throwing_varray_exception );
+ }
+}
+
+int test_main(int, char* [])
+{
+ test_rtree_value_exceptions< bgi::linear<4, 2> >();
+ test_rtree_value_exceptions(bgi::runtime::linear(4, 2));
+ test_rtree_value_exceptions< bgi::quadratic<4, 2> >();
+ test_rtree_value_exceptions(bgi::runtime::quadratic(4, 2));
+ test_rtree_value_exceptions< bgi::rstar<4, 2, 0, 2> >();
+ test_rtree_value_exceptions(bgi::runtime::rstar(4, 2, 0, 2));
+
+ test_rtree_elements_exceptions< bgi::linear_throwing<4, 2> >();
+ test_rtree_elements_exceptions< bgi::quadratic_throwing<4, 2> >();
+ test_rtree_elements_exceptions< bgi::rstar_throwing<4, 2, 0, 2> >();
+
+ return 0;
+}

Added: sandbox-branches/geometry/index/test/rtree/exceptions/test_rtree_exceptions.hpp
==============================================================================
--- (empty file)
+++ sandbox-branches/geometry/index/test/rtree/exceptions/test_rtree_exceptions.hpp 2013-02-14 09:23:09 EST (Thu, 14 Feb 2013)
@@ -0,0 +1,273 @@
+// Boost.Geometry Index
+//
+// R-tree nodes based on runtime-polymorphism, storing static-size containers
+// test version throwing exceptions on creation
+//
+// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
+//
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_INDEX_TEST_RTREE_EXCEPTIONS_HPP
+#define BOOST_GEOMETRY_INDEX_TEST_RTREE_EXCEPTIONS_HPP
+
+#include <rtree/test_rtree.hpp>
+
+#include <boost/geometry/index/detail/rtree/node/dynamic_visitor.hpp>
+
+#include <rtree/exceptions/test_throwing.hpp>
+
+namespace boost { namespace geometry { namespace index {
+
+template <size_t MaxElements, size_t MinElements>
+struct linear_throwing : public linear<MaxElements, MinElements> {};
+
+template <size_t MaxElements, size_t MinElements>
+struct quadratic_throwing : public quadratic<MaxElements, MinElements> {};
+
+template <size_t MaxElements, size_t MinElements, size_t OverlapCostThreshold = 0, size_t ReinsertedElements = detail::default_rstar_reinserted_elements_s<MaxElements>::value>
+struct rstar_throwing : public rstar<MaxElements, MinElements, OverlapCostThreshold, ReinsertedElements> {};
+
+namespace detail { namespace rtree {
+
+// options implementation (from options.hpp)
+
+struct node_throwing_d_mem_static_tag {};
+
+template <size_t MaxElements, size_t MinElements>
+struct options_type< linear_throwing<MaxElements, MinElements> >
+{
+ typedef options<
+ linear_throwing<MaxElements, MinElements>,
+ insert_default_tag, choose_by_content_diff_tag, split_default_tag, linear_tag,
+ node_throwing_d_mem_static_tag
+ > type;
+};
+
+template <size_t MaxElements, size_t MinElements>
+struct options_type< quadratic_throwing<MaxElements, MinElements> >
+{
+ typedef options<
+ quadratic_throwing<MaxElements, MinElements>,
+ insert_default_tag, choose_by_content_diff_tag, split_default_tag, quadratic_tag,
+ node_throwing_d_mem_static_tag
+ > type;
+};
+
+template <size_t MaxElements, size_t MinElements, size_t OverlapCostThreshold, size_t ReinsertedElements>
+struct options_type< rstar_throwing<MaxElements, MinElements, OverlapCostThreshold, ReinsertedElements> >
+{
+ typedef options<
+ rstar_throwing<MaxElements, MinElements, OverlapCostThreshold, ReinsertedElements>,
+ insert_reinsert_tag, choose_by_overlap_diff_tag, split_default_tag, rstar_tag,
+ node_throwing_d_mem_static_tag
+ > type;
+};
+
+}} // namespace detail::rtree
+
+// node implementation
+
+namespace detail { namespace rtree {
+
+template <typename Value, typename Parameters, typename Box, typename Allocators>
+struct dynamic_internal_node<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag>
+ : public dynamic_node<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag>
+{
+ typedef throwing_varray<
+ std::pair<
+ Box,
+ typename Allocators::node_pointer
+ >,
+ Parameters::max_elements + 1
+ > elements_type;
+
+ template <typename Dummy>
+ inline dynamic_internal_node(Dummy) {}
+
+ void apply_visitor(dynamic_visitor<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag, false> & v) { v(*this); }
+ void apply_visitor(dynamic_visitor<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag, true> & v) const { v(*this); }
+
+ elements_type elements;
+};
+
+template <typename Value, typename Parameters, typename Box, typename Allocators>
+struct dynamic_leaf<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag>
+ : public dynamic_node<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag>
+{
+ typedef throwing_varray<Value, Parameters::max_elements + 1> elements_type;
+
+ template <typename Dummy>
+ inline dynamic_leaf(Dummy) {}
+
+ void apply_visitor(dynamic_visitor<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag, false> & v) { v(*this); }
+ void apply_visitor(dynamic_visitor<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag, true> & v) const { v(*this); }
+
+ elements_type elements;
+};
+
+// elements derived type
+template <typename OldValue, size_t N, typename NewValue>
+struct container_from_elements_type<throwing_varray<OldValue, N>, NewValue>
+{
+ typedef throwing_varray<NewValue, N> type;
+};
+
+// nodes traits
+
+template <typename Value, typename Parameters, typename Box, typename Allocators>
+struct node<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag>
+{
+ typedef dynamic_node<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag> type;
+};
+
+template <typename Value, typename Parameters, typename Box, typename Allocators>
+struct internal_node<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag>
+{
+ typedef dynamic_internal_node<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag> type;
+};
+
+template <typename Value, typename Parameters, typename Box, typename Allocators>
+struct leaf<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag>
+{
+ typedef dynamic_leaf<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag> type;
+};
+
+template <typename Value, typename Parameters, typename Box, typename Allocators, bool IsVisitableConst>
+struct visitor<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag, IsVisitableConst>
+{
+ typedef dynamic_visitor<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag, IsVisitableConst> type;
+};
+
+// allocators
+
+template <typename Allocator, typename Value, typename Parameters, typename Box>
+class allocators<Allocator, Value, Parameters, Box, node_throwing_d_mem_static_tag>
+{
+ BOOST_COPYABLE_AND_MOVABLE_ALT(allocators)
+
+public:
+ typedef Allocator allocator_type;
+ typedef typename allocator_type::size_type size_type;
+
+ typedef typename allocator_type::template rebind<
+ typename node<Value, Parameters, Box, allocators, node_throwing_d_mem_static_tag>::type
+ >::other::pointer node_pointer;
+
+ typedef typename allocator_type::template rebind<
+ typename internal_node<Value, Parameters, Box, allocators, node_throwing_d_mem_static_tag>::type
+ >::other::pointer internal_node_pointer;
+
+ typedef typename allocator_type::template rebind<
+ typename internal_node<Value, Parameters, Box, allocators, node_throwing_d_mem_static_tag>::type
+ >::other internal_node_allocator_type;
+
+ typedef typename allocator_type::template rebind<
+ typename leaf<Value, Parameters, Box, allocators, node_throwing_d_mem_static_tag>::type
+ >::other leaf_allocator_type;
+
+ inline allocators()
+ : allocator()
+ , internal_node_allocator()
+ , leaf_allocator()
+ {}
+
+ inline explicit allocators(Allocator alloc)
+ : allocator(alloc)
+ , internal_node_allocator(allocator)
+ , leaf_allocator(allocator)
+ {}
+
+ inline allocators(allocators const& a)
+ : allocator(a.allocator)
+ , internal_node_allocator(a.internal_node_allocator)
+ , leaf_allocator(a.leaf_allocator)
+ {}
+
+ inline allocators(BOOST_RV_REF(allocators) a)
+ : allocator(boost::move(a.allocator))
+ , internal_node_allocator(boost::move(a.internal_node_allocator))
+ , leaf_allocator(boost::move(a.leaf_allocator))
+ {}
+
+ void swap(allocators & a)
+ {
+ boost::swap(allocator, a.allocator);
+ boost::swap(internal_node_allocator, a.internal_node_allocator);
+ boost::swap(leaf_allocator, a.leaf_allocator);
+ }
+
+ allocator_type allocator;
+ internal_node_allocator_type internal_node_allocator;
+ leaf_allocator_type leaf_allocator;
+};
+
+struct node_bad_alloc : public std::exception
+{
+ const char * what() const throw() { return "internal node creation failed."; }
+};
+
+struct throwing_node_settings
+{
+ static void throw_if_required()
+ {
+ // throw if counter meets max count
+ if ( get_max_calls_ref() <= get_calls_counter_ref() )
+ throw node_bad_alloc();
+ else
+ ++get_calls_counter_ref();
+ }
+
+ static void reset_calls_counter() { get_calls_counter_ref() = 0; }
+ static void set_max_calls(size_t mc) { get_max_calls_ref() = mc; }
+
+ static size_t & get_calls_counter_ref() { static size_t cc = 0; return cc; }
+ static size_t & get_max_calls_ref() { static size_t mc = (std::numeric_limits<size_t>::max)(); return mc; }
+};
+
+// create_node
+
+template <typename Allocators, typename Value, typename Parameters, typename Box>
+struct create_node<
+ Allocators,
+ dynamic_internal_node<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag>
+>
+{
+ static inline typename Allocators::node_pointer
+ apply(Allocators & allocators)
+ {
+ // throw if counter meets max count
+ throwing_node_settings::throw_if_required();
+
+ return create_dynamic_node<
+ typename Allocators::node_pointer,
+ dynamic_internal_node<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag>
+ >::apply(allocators.internal_node_allocator, allocators.internal_node_allocator);
+ }
+};
+
+template <typename Allocators, typename Value, typename Parameters, typename Box>
+struct create_node<
+ Allocators,
+ dynamic_leaf<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag>
+>
+{
+ static inline typename Allocators::node_pointer
+ apply(Allocators & allocators)
+ {
+ // throw if counter meets max count
+ throwing_node_settings::throw_if_required();
+
+ return create_dynamic_node<
+ typename Allocators::node_pointer,
+ dynamic_leaf<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag>
+ >::apply(allocators.leaf_allocator, allocators.leaf_allocator);
+ }
+};
+
+}} // namespace detail::rtree
+
+}}} // namespace boost::geometry::index
+
+#endif // BOOST_GEOMETRY_INDEX_TEST_RTREE_EXCEPTIONS_HPP

Added: sandbox-branches/geometry/index/test/rtree/exceptions/test_throwing.hpp
==============================================================================
--- (empty file)
+++ sandbox-branches/geometry/index/test/rtree/exceptions/test_throwing.hpp 2013-02-14 09:23:09 EST (Thu, 14 Feb 2013)
@@ -0,0 +1,198 @@
+// Boost.Geometry Index
+//
+// Throwing objects implementation
+//
+// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
+//
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_INDEX_TEST_THROWING_HPP
+#define BOOST_GEOMETRY_INDEX_TEST_THROWING_HPP
+
+// value
+
+struct throwing_value_copy_exception : public std::exception
+{
+ const char * what() const throw() { return "value copy failed."; }
+};
+
+struct throwing_value
+{
+ explicit throwing_value(int v = 0)
+ : value(v)
+ {}
+
+ bool operator==(throwing_value const& v) const
+ {
+ return value == v.value;
+ }
+
+ throwing_value(throwing_value const& v)
+ {
+ throw_if_required();
+
+ value = v.value;
+ }
+
+ throwing_value & operator=(throwing_value const& v)
+ {
+ throw_if_required();
+
+ value = v.value;
+ return *this;
+ }
+
+ void throw_if_required()
+ {
+ // throw if counter meets max count
+ if ( get_max_calls_ref() <= get_calls_counter_ref() )
+ throw throwing_value_copy_exception();
+ else
+ ++get_calls_counter_ref();
+ }
+
+ static void reset_calls_counter() { get_calls_counter_ref() = 0; }
+ static void set_max_calls(size_t mc) { get_max_calls_ref() = mc; }
+
+ static size_t & get_calls_counter_ref() { static size_t cc = 0; return cc; }
+ static size_t & get_max_calls_ref() { static size_t mc = (std::numeric_limits<size_t>::max)(); return mc; }
+
+ int value;
+};
+
+template <typename T, typename C>
+struct generate_value< std::pair<bg::model::point<T, 2, C>, throwing_value> >
+{
+ typedef bg::model::point<T, 2, C> P;
+ typedef std::pair<P, throwing_value> R;
+ static R apply(int x, int y)
+ {
+ return std::make_pair(P(x, y), throwing_value(x + y * 100));
+ }
+};
+
+// box
+//
+//#include <boost/geometry/geometries/register/box.hpp>
+//
+//struct throwing_box_copy_exception : public std::exception
+//{
+// const char * what() const throw() { return "box copy failed."; }
+//};
+//
+//template <typename Point>
+//struct throwing_box
+//{
+// throwing_box(){}
+//
+// throwing_box(Point const& m, Point const& mm)
+// : min_p(m), max_p(mm)
+// {}
+//
+// throwing_box(throwing_box const& o)
+// {
+// throw_if_required();
+//
+// min_p = o.min_p;
+// max_p = o.max_p;
+// }
+//
+// throwing_box & operator=(throwing_box const& o)
+// {
+// throw_if_required();
+//
+// min_p = o.min_p;
+// max_p = o.max_p;
+// return *this;
+// }
+//
+// void throw_if_required()
+// {
+// // throw if counter meets max count
+// if ( get_max_calls_ref() <= get_calls_counter_ref() )
+// throw throwing_box_copy_exception();
+// else
+// ++get_calls_counter_ref();
+// }
+//
+// static void reset_calls_counter() { get_calls_counter_ref() = 0; }
+// static void set_max_calls(size_t mc) { get_max_calls_ref() = mc; }
+//
+// static size_t & get_calls_counter_ref() { static size_t cc = 0; return cc; }
+// static size_t & get_max_calls_ref() { static size_t mc = (std::numeric_limits<size_t>::max)(); return mc; }
+//
+// Point min_p;
+// Point max_p;
+//};
+//
+//BOOST_GEOMETRY_REGISTER_BOX_TEMPLATED(throwing_box, min_p, max_p)
+//
+//namespace boost { namespace geometry { namespace index {
+//
+//template <typename CT, size_t D, typename CS>
+//struct default_box_type< bg::model::point<CT, D, CS> >
+//{
+// typedef throwing_box<
+// bg::model::point<CT, D, CS>
+// > type;
+//};
+//
+//}}} // namespace boost::geometry::index
+
+#include <boost/geometry/index/detail/varray.hpp>
+
+struct throwing_varray_exception : public std::exception
+{
+ const char * what() const throw() { return "static vector exception."; }
+};
+
+struct throwing_varray_settings
+{
+ static void throw_if_required()
+ {
+ // throw if counter meets max count
+ if ( get_max_calls_ref() <= get_calls_counter_ref() )
+ throw throwing_varray_exception();
+ else
+ ++get_calls_counter_ref();
+ }
+
+ static void reset_calls_counter() { get_calls_counter_ref() = 0; }
+ static void set_max_calls(size_t mc) { get_max_calls_ref() = mc; }
+
+ static size_t & get_calls_counter_ref() { static size_t cc = 0; return cc; }
+ static size_t & get_max_calls_ref() { static size_t mc = (std::numeric_limits<size_t>::max)(); return mc; }
+};
+
+template <typename Element, size_t Capacity>
+class throwing_varray
+ : public boost::geometry::index::detail::varray<Element, Capacity>
+{
+ typedef boost::geometry::index::detail::varray<Element, Capacity> container;
+
+public:
+ typedef typename container::value_type value_type;
+ typedef typename container::size_type size_type;
+ typedef typename container::iterator iterator;
+ typedef typename container::const_iterator const_iterator;
+ typedef typename container::reverse_iterator reverse_iterator;
+ typedef typename container::const_reverse_iterator const_reverse_iterator;
+ typedef typename container::reference reference;
+ typedef typename container::const_reference const_reference;
+
+ inline void resize(size_type s)
+ {
+ throwing_varray_settings::throw_if_required();
+ container::resize(s);
+ }
+
+ void push_back(Element const& v)
+ {
+ throwing_varray_settings::throw_if_required();
+ container::push_back(v);
+ }
+};
+
+#endif // BOOST_GEOMETRY_INDEX_TEST_THROWING_HPP

Modified: sandbox-branches/geometry/index/test/rtree/generated/Jamfile.v2
==============================================================================
--- sandbox-branches/geometry/index/test/rtree/generated/Jamfile.v2 (original)
+++ sandbox-branches/geometry/index/test/rtree/generated/Jamfile.v2 2013-02-14 09:23:09 EST (Thu, 14 Feb 2013)
@@ -1,108 +1,21 @@
 # Boost.Geometry Index
 #
-# Copyright (c) 2011-2012 Adam Wulkiewicz, Lodz, Poland.
+# Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
 #
 # Use, modification and distribution is subject to the Boost Software License,
 # Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 # http://www.boost.org/LICENSE_1_0.txt)
 
-test-suite boost-geometry-index-rtree-generated
- :
- [ run rtree_p2d_linear.cpp ]
- [ run rtree_b2d_linear.cpp ]
- [ run rtree_p2d_quadratic.cpp ]
- [ run rtree_b2d_quadratic.cpp ]
- [ run rtree_p2d_rstar.cpp ]
- [ run rtree_b2d_rstar.cpp ]
- [ run rtree_p2d_linear_rt.cpp ]
- [ run rtree_b2d_linear_rt.cpp ]
- [ run rtree_p2d_quadratic_rt.cpp ]
- [ run rtree_b2d_quadratic_rt.cpp ]
- [ run rtree_p2d_rstar_rt.cpp ]
- [ run rtree_b2d_rstar_rt.cpp ]
- [ run rtree_p2f_linear.cpp ]
- [ run rtree_b2f_linear.cpp ]
- [ run rtree_p2f_quadratic.cpp ]
- [ run rtree_b2f_quadratic.cpp ]
- [ run rtree_p2f_rstar.cpp ]
- [ run rtree_b2f_rstar.cpp ]
- [ run rtree_p2f_linear_rt.cpp ]
- [ run rtree_b2f_linear_rt.cpp ]
- [ run rtree_p2f_quadratic_rt.cpp ]
- [ run rtree_b2f_quadratic_rt.cpp ]
- [ run rtree_p2f_rstar_rt.cpp ]
- [ run rtree_b2f_rstar_rt.cpp ]
- [ run rtree_p2i_linear.cpp ]
- [ run rtree_b2i_linear.cpp ]
- [ run rtree_p2i_quadratic.cpp ]
- [ run rtree_b2i_quadratic.cpp ]
- [ run rtree_p2i_rstar.cpp ]
- [ run rtree_b2i_rstar.cpp ]
- [ run rtree_p2i_linear_rt.cpp ]
- [ run rtree_b2i_linear_rt.cpp ]
- [ run rtree_p2i_quadratic_rt.cpp ]
- [ run rtree_b2i_quadratic_rt.cpp ]
- [ run rtree_p2i_rstar_rt.cpp ]
- [ run rtree_b2i_rstar_rt.cpp ]
- [ run rtree_p2tt_linear.cpp ]
- [ run rtree_b2tt_linear.cpp ]
- [ run rtree_p2tt_quadratic.cpp ]
- [ run rtree_b2tt_quadratic.cpp ]
- [ run rtree_p2tt_rstar.cpp ]
- [ run rtree_b2tt_rstar.cpp ]
- [ run rtree_p2tt_linear_rt.cpp ]
- [ run rtree_b2tt_linear_rt.cpp ]
- [ run rtree_p2tt_quadratic_rt.cpp ]
- [ run rtree_b2tt_quadratic_rt.cpp ]
- [ run rtree_p2tt_rstar_rt.cpp ]
- [ run rtree_b2tt_rstar_rt.cpp ]
- [ run rtree_p3d_linear.cpp ]
- [ run rtree_b3d_linear.cpp ]
- [ run rtree_p3d_quadratic.cpp ]
- [ run rtree_b3d_quadratic.cpp ]
- [ run rtree_p3d_rstar.cpp ]
- [ run rtree_b3d_rstar.cpp ]
- [ run rtree_p3d_linear_rt.cpp ]
- [ run rtree_b3d_linear_rt.cpp ]
- [ run rtree_p3d_quadratic_rt.cpp ]
- [ run rtree_b3d_quadratic_rt.cpp ]
- [ run rtree_p3d_rstar_rt.cpp ]
- [ run rtree_b3d_rstar_rt.cpp ]
- [ run rtree_p3f_linear.cpp ]
- [ run rtree_b3f_linear.cpp ]
- [ run rtree_p3f_quadratic.cpp ]
- [ run rtree_b3f_quadratic.cpp ]
- [ run rtree_p3f_rstar.cpp ]
- [ run rtree_b3f_rstar.cpp ]
- [ run rtree_p3f_linear_rt.cpp ]
- [ run rtree_b3f_linear_rt.cpp ]
- [ run rtree_p3f_quadratic_rt.cpp ]
- [ run rtree_b3f_quadratic_rt.cpp ]
- [ run rtree_p3f_rstar_rt.cpp ]
- [ run rtree_b3f_rstar_rt.cpp ]
- [ run rtree_p3i_linear.cpp ]
- [ run rtree_b3i_linear.cpp ]
- [ run rtree_p3i_quadratic.cpp ]
- [ run rtree_b3i_quadratic.cpp ]
- [ run rtree_p3i_rstar.cpp ]
- [ run rtree_b3i_rstar.cpp ]
- [ run rtree_p3i_linear_rt.cpp ]
- [ run rtree_b3i_linear_rt.cpp ]
- [ run rtree_p3i_quadratic_rt.cpp ]
- [ run rtree_b3i_quadratic_rt.cpp ]
- [ run rtree_p3i_rstar_rt.cpp ]
- [ run rtree_b3i_rstar_rt.cpp ]
- [ run rtree_p3tt_linear.cpp ]
- [ run rtree_b3tt_linear.cpp ]
- [ run rtree_p3tt_quadratic.cpp ]
- [ run rtree_b3tt_quadratic.cpp ]
- [ run rtree_p3tt_rstar.cpp ]
- [ run rtree_b3tt_rstar.cpp ]
- [ run rtree_p3tt_linear_rt.cpp ]
- [ run rtree_b3tt_linear_rt.cpp ]
- [ run rtree_p3tt_quadratic_rt.cpp ]
- [ run rtree_b3tt_quadratic_rt.cpp ]
- [ run rtree_p3tt_rstar_rt.cpp ]
- [ run rtree_b3tt_rstar_rt.cpp ]
- ;
+rule test_all
+{
+ local all_rules = ;
 
+ for local fileb in [ glob *.cpp ]
+ {
+ all_rules += [ run $(fileb) ] ;
+ }
+
+ return $(all_rules) ;
+}
+
+test-suite boost-geometry-index-rtree-generated : [ test_all r ] ;

Added: sandbox-branches/geometry/index/test/rtree/interprocess/Jamfile.v2
==============================================================================
--- (empty file)
+++ sandbox-branches/geometry/index/test/rtree/interprocess/Jamfile.v2 2013-02-14 09:23:09 EST (Thu, 14 Feb 2013)
@@ -0,0 +1,29 @@
+# Boost.Geometry Index
+#
+# Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
+#
+# Use, modification and distribution is subject to the Boost Software License,
+# Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+# http://www.boost.org/LICENSE_1_0.txt)
+
+rule test_all
+{
+ local all_rules = ;
+
+ for local fileb in [ glob *.cpp ]
+ {
+ all_rules += [ run $(fileb) /boost/thread//boost_thread
+ : # additional args
+ : # test-files
+ : # requirements
+ <toolset>acc:<linkflags>-lrt
+ <toolset>acc-pa_risc:<linkflags>-lrt
+ <toolset>gcc-mingw:<linkflags>"-lole32 -loleaut32 -lpsapi -ladvapi32"
+ <host-os>hpux,<toolset>gcc:<linkflags>"-Wl,+as,mpas"
+ ] ;
+ }
+
+ return $(all_rules) ;
+}
+
+test-suite boost-geometry-index-rtree-interprocess : [ test_all r ] : <threading>multi ;

Added: sandbox-branches/geometry/index/test/rtree/interprocess/rtree_interprocess_b2f_linear.cpp
==============================================================================
--- (empty file)
+++ sandbox-branches/geometry/index/test/rtree/interprocess/rtree_interprocess_b2f_linear.cpp 2013-02-14 09:23:09 EST (Thu, 14 Feb 2013)
@@ -0,0 +1,19 @@
+// Boost.Geometry Index
+// Unit Test
+
+// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <rtree/interprocess/test_interprocess.hpp>
+
+int test_main(int, char* [])
+{
+ typedef bg::model::point<float, 2, bg::cs::cartesian> P2f;
+
+ test_rtree_interprocess<P2f>(bgi::linear<32, 8>());
+
+ return 0;
+}

Added: sandbox-branches/geometry/index/test/rtree/interprocess/rtree_interprocess_b2f_linear_rt.cpp
==============================================================================
--- (empty file)
+++ sandbox-branches/geometry/index/test/rtree/interprocess/rtree_interprocess_b2f_linear_rt.cpp 2013-02-14 09:23:09 EST (Thu, 14 Feb 2013)
@@ -0,0 +1,19 @@
+// Boost.Geometry Index
+// Unit Test
+
+// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <rtree/interprocess/test_interprocess.hpp>
+
+int test_main(int, char* [])
+{
+ typedef bg::model::point<float, 2, bg::cs::cartesian> P2f;
+
+ test_rtree_interprocess<P2f>(bgi::runtime::linear(32, 8));
+
+ return 0;
+}

Added: sandbox-branches/geometry/index/test/rtree/interprocess/rtree_interprocess_b2f_quadratic.cpp
==============================================================================
--- (empty file)
+++ sandbox-branches/geometry/index/test/rtree/interprocess/rtree_interprocess_b2f_quadratic.cpp 2013-02-14 09:23:09 EST (Thu, 14 Feb 2013)
@@ -0,0 +1,19 @@
+// Boost.Geometry Index
+// Unit Test
+
+// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <rtree/interprocess/test_interprocess.hpp>
+
+int test_main(int, char* [])
+{
+ typedef bg::model::point<float, 2, bg::cs::cartesian> P2f;
+
+ test_rtree_interprocess<P2f>(bgi::quadratic<32, 8>());
+
+ return 0;
+}

Added: sandbox-branches/geometry/index/test/rtree/interprocess/rtree_interprocess_b2f_quadratic_rt.cpp
==============================================================================
--- (empty file)
+++ sandbox-branches/geometry/index/test/rtree/interprocess/rtree_interprocess_b2f_quadratic_rt.cpp 2013-02-14 09:23:09 EST (Thu, 14 Feb 2013)
@@ -0,0 +1,19 @@
+// Boost.Geometry Index
+// Unit Test
+
+// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <rtree/interprocess/test_interprocess.hpp>
+
+int test_main(int, char* [])
+{
+ typedef bg::model::point<float, 2, bg::cs::cartesian> P2f;
+
+ test_rtree_interprocess<P2f>(bgi::runtime::quadratic(32, 8));
+
+ return 0;
+}

Added: sandbox-branches/geometry/index/test/rtree/interprocess/rtree_interprocess_b2f_rstar.cpp
==============================================================================
--- (empty file)
+++ sandbox-branches/geometry/index/test/rtree/interprocess/rtree_interprocess_b2f_rstar.cpp 2013-02-14 09:23:09 EST (Thu, 14 Feb 2013)
@@ -0,0 +1,19 @@
+// Boost.Geometry Index
+// Unit Test
+
+// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <rtree/interprocess/test_interprocess.hpp>
+
+int test_main(int, char* [])
+{
+ typedef bg::model::point<float, 2, bg::cs::cartesian> P2f;
+
+ test_rtree_interprocess<P2f>(bgi::rstar<32, 8>());
+
+ return 0;
+}

Added: sandbox-branches/geometry/index/test/rtree/interprocess/rtree_interprocess_b2f_rstar_rt.cpp
==============================================================================
--- (empty file)
+++ sandbox-branches/geometry/index/test/rtree/interprocess/rtree_interprocess_b2f_rstar_rt.cpp 2013-02-14 09:23:09 EST (Thu, 14 Feb 2013)
@@ -0,0 +1,19 @@
+// Boost.Geometry Index
+// Unit Test
+
+// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <rtree/interprocess/test_interprocess.hpp>
+
+int test_main(int, char* [])
+{
+ typedef bg::model::point<float, 2, bg::cs::cartesian> P2f;
+
+ test_rtree_interprocess<P2f>(bgi::runtime::rstar(32, 8));
+
+ return 0;
+}

Added: sandbox-branches/geometry/index/test/rtree/interprocess/test_interprocess.hpp
==============================================================================
--- (empty file)
+++ sandbox-branches/geometry/index/test/rtree/interprocess/test_interprocess.hpp 2013-02-14 09:23:09 EST (Thu, 14 Feb 2013)
@@ -0,0 +1,59 @@
+// Boost.Geometry Index
+// Unit Test
+
+// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <rtree/test_rtree.hpp>
+
+#include <boost/geometry/geometries/point_xy.hpp>
+#include <boost/geometry/geometries/point.hpp>
+#include <boost/geometry/geometries/box.hpp>
+
+#include <boost/interprocess/managed_shared_memory.hpp>
+#include <boost/interprocess/allocators/allocator.hpp>
+
+template <typename Point, typename Parameters>
+void test_rtree_interprocess(Parameters const& parameters = Parameters())
+{
+ namespace bi = boost::interprocess;
+ struct shm_remove
+ {
+ shm_remove() { bi::shared_memory_object::remove("shmem"); }
+ ~shm_remove(){ bi::shared_memory_object::remove("shmem"); }
+ } remover;
+
+ bi::managed_shared_memory segment(bi::create_only, "shmem", 65535);
+ typedef bi::allocator<Point, bi::managed_shared_memory::segment_manager> shmem_alloc;
+
+ test_rtree_for_box<Point>(parameters, shmem_alloc(segment.get_segment_manager()));
+
+ //typedef bgi::rtree<Value, Parameters, bgi::translator::def<Value>, shmem_alloc> Tree;
+
+ //Tree * tree = segment.construct<Tree>("Tree")(parameters, bgi::translator::def<Value>(), shmem_alloc(segment.get_segment_manager()));
+ //typedef typename Tree::bounds_type B;
+ //
+ //std::vector<Value> input;
+ //B qbox;
+ //
+ //generate_rtree(*tree, input, qbox);
+
+ //test_intersects(*tree, input, qbox);
+ //test_disjoint(*tree, input, qbox);
+ //test_covered_by(*tree, input, qbox);
+ //test_overlaps(*tree, input, qbox);
+ ////test_touches(*tree, input, qbox);
+ //test_within(*tree, input, qbox);
+
+ //typedef typename bgi::detail::traits::point_type<B>::type P;
+ //P pt;
+ //bg::centroid(qbox, pt);
+
+ //test_nearest_query_k(*tree, input, pt, 10);
+ //test_nearest_query_not_found(*tree, generate_outside_point<P>::apply());
+
+ //segment.destroy_ptr(tree);
+}

Deleted: sandbox-branches/geometry/index/test/rtree/rtree_exceptions.cpp
==============================================================================
--- sandbox-branches/geometry/index/test/rtree/rtree_exceptions.cpp 2013-02-14 09:23:09 EST (Thu, 14 Feb 2013)
+++ (empty file)
@@ -1,179 +0,0 @@
-// Boost.Geometry Index
-// Unit Test
-
-// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
-
-// Use, modification and distribution is subject to the Boost Software License,
-// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-#include <rtree/test_rtree_exceptions.hpp>
-
-#include <boost/geometry/geometries/point_xy.hpp>
-#include <boost/geometry/geometries/point.hpp>
-#include <boost/geometry/geometries/box.hpp>
-
-// test value exceptions
-template <typename Parameters>
-void test_rtree_value_exceptions(Parameters const& parameters = Parameters())
-{
- typedef std::pair<bg::model::point<float, 2, bg::cs::cartesian>, throwing_value> Value;
- typedef bgi::rtree<Value, Parameters> Tree;
- typedef typename Tree::box_type B;
-
- throwing_value::reset_calls_counter();
- throwing_value::set_max_calls((std::numeric_limits<size_t>::max)());
- std::vector<Value> input;
- B qbox;
- generate_input<2>::apply(input, qbox);
-
- for ( size_t i = 0 ; i < 50 ; i += 2 )
- {
- throwing_value::reset_calls_counter();
- throwing_value::set_max_calls(10000);
-
- Tree tree(parameters);
-
- throwing_value::reset_calls_counter();
- throwing_value::set_max_calls(i);
-
- BOOST_CHECK_THROW( tree.insert(input.begin(), input.end()), throwing_value_copy_exception );
- }
-
- for ( size_t i = 0 ; i < 20 ; i += 2 )
- {
- throwing_value::reset_calls_counter();
- throwing_value::set_max_calls(10000);
-
- Tree tree(parameters);
-
- tree.insert(input.begin(), input.end());
-
- throwing_value::reset_calls_counter();
- throwing_value::set_max_calls(i);
-
- BOOST_CHECK_THROW( tree.remove(input.begin(), input.end()), throwing_value_copy_exception );
- }
-
- for ( size_t i = 0 ; i < 20 ; i += 2 )
- {
- throwing_value::reset_calls_counter();
- throwing_value::set_max_calls(10000);
-
- Tree tree(parameters);
-
- tree.insert(input.begin(), input.end());
-
- throwing_value::reset_calls_counter();
- throwing_value::set_max_calls(i);
-
- BOOST_CHECK_THROW( Tree tree2(tree), throwing_value_copy_exception );
- }
-
- for ( size_t i = 0 ; i < 20 ; i += 2 )
- {
- throwing_value::reset_calls_counter();
- throwing_value::set_max_calls(10000);
-
- Tree tree(parameters);
- Tree tree2(parameters);
-
- tree.insert(input.begin(), input.end());
-
- throwing_value::reset_calls_counter();
- throwing_value::set_max_calls(i);
-
- BOOST_CHECK_THROW(tree2 = tree, throwing_value_copy_exception );
- }
-}
-
-// test value exceptions
-template <typename Parameters>
-void test_rtree_elements_exceptions(Parameters const& parameters = Parameters())
-{
- typedef std::pair<bg::model::point<float, 2, bg::cs::cartesian>, throwing_value> Value;
- typedef bgi::rtree<Value, Parameters> Tree;
- typedef typename Tree::box_type B;
-
- throwing_value::reset_calls_counter();
- throwing_value::set_max_calls((std::numeric_limits<size_t>::max)());
-
- std::vector<Value> input;
- B qbox;
- generate_input<2>::apply(input, qbox, 2);
-
- for ( size_t i = 0 ; i < 100 ; i += 2 )
- {
- throwing_varray_settings::reset_calls_counter();
- throwing_varray_settings::set_max_calls(10000);
-
- Tree tree(parameters);
-
- throwing_varray_settings::reset_calls_counter();
- throwing_varray_settings::set_max_calls(i);
-
- BOOST_CHECK_THROW( tree.insert(input.begin(), input.end()), throwing_varray_exception );
- }
-
- for ( size_t i = 0 ; i < 50 ; i += 2 )
- {
- throwing_varray_settings::reset_calls_counter();
- throwing_varray_settings::set_max_calls(10000);
-
- Tree tree(parameters);
-
- tree.insert(input.begin(), input.end());
-
- throwing_varray_settings::reset_calls_counter();
- throwing_varray_settings::set_max_calls(i);
-
- BOOST_CHECK_THROW( tree.remove(input.begin(), input.end()), throwing_varray_exception );
- }
-
- for ( size_t i = 0 ; i < 50 ; i += 2 )
- {
- throwing_varray_settings::reset_calls_counter();
- throwing_varray_settings::set_max_calls(10000);
-
- Tree tree(parameters);
-
- tree.insert(input.begin(), input.end());
-
- throwing_varray_settings::reset_calls_counter();
- throwing_varray_settings::set_max_calls(i);
-
- BOOST_CHECK_THROW( Tree tree2(tree), throwing_varray_exception );
- }
-
- for ( size_t i = 0 ; i < 50 ; i += 2 )
- {
- throwing_varray_settings::reset_calls_counter();
- throwing_varray_settings::set_max_calls(10000);
-
- Tree tree(parameters);
- Tree tree2(parameters);
-
- tree.insert(input.begin(), input.end());
-
- throwing_varray_settings::reset_calls_counter();
- throwing_varray_settings::set_max_calls(i);
-
- BOOST_CHECK_THROW(tree2 = tree, throwing_varray_exception );
- }
-}
-
-int test_main(int, char* [])
-{
- test_rtree_value_exceptions< bgi::linear<4, 2> >();
- test_rtree_value_exceptions(bgi::runtime::linear(4, 2));
- test_rtree_value_exceptions< bgi::quadratic<4, 2> >();
- test_rtree_value_exceptions(bgi::runtime::quadratic(4, 2));
- test_rtree_value_exceptions< bgi::rstar<4, 2, 0, 2> >();
- test_rtree_value_exceptions(bgi::runtime::rstar(4, 2, 0, 2));
-
- test_rtree_elements_exceptions< bgi::linear_throwing<4, 2> >();
- test_rtree_elements_exceptions< bgi::quadratic_throwing<4, 2> >();
- test_rtree_elements_exceptions< bgi::rstar_throwing<4, 2, 0, 2> >();
-
- return 0;
-}

Deleted: sandbox-branches/geometry/index/test/rtree/rtree_interprocess.cpp
==============================================================================
--- sandbox-branches/geometry/index/test/rtree/rtree_interprocess.cpp 2013-02-14 09:23:09 EST (Thu, 14 Feb 2013)
+++ (empty file)
@@ -1,73 +0,0 @@
-// Boost.Geometry Index
-// Unit Test
-
-// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
-
-// Use, modification and distribution is subject to the Boost Software License,
-// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-#include <rtree/test_rtree.hpp>
-
-#include <boost/geometry/geometries/point_xy.hpp>
-#include <boost/geometry/geometries/point.hpp>
-#include <boost/geometry/geometries/box.hpp>
-
-#include <boost/interprocess/managed_shared_memory.hpp>
-#include <boost/interprocess/allocators/allocator.hpp>
-
-template <typename Point, typename Parameters>
-void test_rtree_interprocess(Parameters const& parameters = Parameters())
-{
- namespace bi = boost::interprocess;
- struct shm_remove
- {
- shm_remove() { bi::shared_memory_object::remove("shmem"); }
- ~shm_remove(){ bi::shared_memory_object::remove("shmem"); }
- } remover;
-
- bi::managed_shared_memory segment(bi::create_only, "shmem", 65535);
- typedef bi::allocator<Point, bi::managed_shared_memory::segment_manager> shmem_alloc;
-
- test_rtree_for_box<Point>(parameters, shmem_alloc(segment.get_segment_manager()));
-
- //typedef bgi::rtree<Value, Parameters, bgi::translator::def<Value>, shmem_alloc> Tree;
-
- //Tree * tree = segment.construct<Tree>("Tree")(parameters, bgi::translator::def<Value>(), shmem_alloc(segment.get_segment_manager()));
- //typedef typename Tree::bounds_type B;
- //
- //std::vector<Value> input;
- //B qbox;
- //
- //generate_rtree(*tree, input, qbox);
-
- //test_intersects(*tree, input, qbox);
- //test_disjoint(*tree, input, qbox);
- //test_covered_by(*tree, input, qbox);
- //test_overlaps(*tree, input, qbox);
- ////test_touches(*tree, input, qbox);
- //test_within(*tree, input, qbox);
-
- //typedef typename bgi::detail::traits::point_type<B>::type P;
- //P pt;
- //bg::centroid(qbox, pt);
-
- //test_nearest_query_k(*tree, input, pt, 10);
- //test_nearest_query_not_found(*tree, generate_outside_point<P>::apply());
-
- //segment.destroy_ptr(tree);
-}
-
-int test_main(int, char* [])
-{
- typedef bg::model::point<float, 2, bg::cs::cartesian> P2f;
-
- test_rtree_interprocess<P2f>(bgi::linear<32, 8>());
- test_rtree_interprocess<P2f>(bgi::runtime::linear(32, 8));
- test_rtree_interprocess<P2f>(bgi::quadratic<32, 8>());
- test_rtree_interprocess<P2f>(bgi::runtime::quadratic(32, 8));
- test_rtree_interprocess<P2f>(bgi::rstar<32, 8>());
- test_rtree_interprocess<P2f>(bgi::runtime::rstar(32, 8));
-
- return 0;
-}

Added: sandbox-branches/geometry/index/test/rtree/rtree_test_generator.cpp
==============================================================================
--- (empty file)
+++ sandbox-branches/geometry/index/test/rtree/rtree_test_generator.cpp 2013-02-14 09:23:09 EST (Thu, 14 Feb 2013)
@@ -0,0 +1,122 @@
+// Boost.Geometry Index
+// Rtree tests generator
+
+// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <fstream>
+#include <vector>
+#include <string>
+#include <boost/foreach.hpp>
+#include <boost/tuple/tuple.hpp>
+
+int main()
+{
+ std::vector<std::string> generated_files;
+
+ typedef boost::tuple<std::string, std::string, std::string> CT;
+ std::vector<CT> coordinate_types;
+ coordinate_types.push_back(boost::make_tuple("double", "d", ""));
+ coordinate_types.push_back(boost::make_tuple("float", "f", ""));
+ coordinate_types.push_back(boost::make_tuple("int", "i", ""));
+ coordinate_types.push_back(boost::make_tuple("ttmath_big", "tt", "HAVE_TTMATH"));
+
+ std::vector<std::string> dimensions;
+ dimensions.push_back("2");
+ dimensions.push_back("3");
+
+ typedef boost::tuple<std::string, std::string> P;
+ std::vector<P> parameters;
+ parameters.push_back(boost::make_tuple("bgi::linear<4, 2>()", "linear"));
+ parameters.push_back(boost::make_tuple("bgi::quadratic<4, 2>()", "quadratic"));
+ parameters.push_back(boost::make_tuple("bgi::rstar<4, 2>()", "rstar"));
+ parameters.push_back(boost::make_tuple("bgi::runtime::linear(4, 2)", "linear_rt"));
+ parameters.push_back(boost::make_tuple("bgi::runtime::quadratic(4, 2)", "quadratic_rt"));
+ parameters.push_back(boost::make_tuple("bgi::runtime::rstar(4, 2)","rstar_rt"));
+
+ std::vector<std::string> indexables;
+ indexables.push_back("p");
+ indexables.push_back("b");
+
+ BOOST_FOREACH(std::string const& d, dimensions)
+ {
+ BOOST_FOREACH(CT const& c, coordinate_types)
+ {
+ BOOST_FOREACH(P const& p, parameters)
+ {
+ BOOST_FOREACH(std::string const& i, indexables)
+ {
+ std::string point_type = std::string() +
+ "bg::model::point<" + boost::get<0>(c) + ", " + d + ", bg::cs::cartesian>";
+
+ std::string filename = std::string() +
+ "rtree_" + i + d + boost::get<1>(c) + '_' + boost::get<1>(p) + ".cpp";
+
+ std::ofstream f(filename.c_str(), std::ios::trunc);
+
+ f <<
+ "// Boost.Geometry Index\n" <<
+ "// Unit Test\n" <<
+ "\n" <<
+ "// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.\n" <<
+ "\n" <<
+ "// Use, modification and distribution is subject to the Boost Software License,\n" <<
+ "// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at\n" <<
+ "// http://www.boost.org/LICENSE_1_0.txt)\n" <<
+ "\n";
+
+ f <<
+ "#include <rtree/test_rtree.hpp>\n" <<
+ "\n" <<
+ "#include <boost/geometry/geometries/point.hpp>\n" <<
+ (i == "p" ? "" : "#include <boost/geometry/geometries/box.hpp>\n") <<
+ "\n";
+
+ f <<
+ "int test_main(int, char* [])\n" <<
+ "{\n" <<
+ (boost::get<2>(c).empty() ? "" : "#ifdef HAVE_TTMATH\n") <<
+ " typedef " << point_type << " Point;\n" <<
+ " " <<
+ (i == "p" ? "test_rtree_for_point" : "test_rtree_for_box" ) <<
+ "<Point>(" << boost::get<0>(p) << ");\n" <<
+ (boost::get<2>(c).empty() ? "" : "#endif\n") <<
+ " return 0;\n" <<
+ "}\n";
+
+ generated_files.push_back(filename);
+ }
+ }
+
+ }
+ }
+
+ std::ofstream f("Jamfile.v2", std::ios::trunc);
+
+ f <<
+ "# Boost.Geometry Index\n" <<
+ "#\n" <<
+ "# Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.\n" <<
+ "#\n" <<
+ "# Use, modification and distribution is subject to the Boost Software License,\n" <<
+ "# Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at\n" <<
+ "# http://www.boost.org/LICENSE_1_0.txt)\n" <<
+ "\n" <<
+ "test-suite boost-geometry-index-rtree-generated\n" <<
+ " :\n";
+
+ BOOST_FOREACH(std::string const& s, generated_files)
+ {
+ f <<
+ " [ run " << s << " ]\n";
+ }
+
+ f <<
+ " ;\n" <<
+ "\n";
+
+ return 0;
+}
\ No newline at end of file

Deleted: sandbox-branches/geometry/index/test/rtree/test_rtree_exceptions.hpp
==============================================================================
--- sandbox-branches/geometry/index/test/rtree/test_rtree_exceptions.hpp 2013-02-14 09:23:09 EST (Thu, 14 Feb 2013)
+++ (empty file)
@@ -1,273 +0,0 @@
-// Boost.Geometry Index
-//
-// R-tree nodes based on runtime-polymorphism, storing static-size containers
-// test version throwing exceptions on creation
-//
-// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
-//
-// Use, modification and distribution is subject to the Boost Software License,
-// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-#ifndef BOOST_GEOMETRY_INDEX_TEST_RTREE_EXCEPTIONS_HPP
-#define BOOST_GEOMETRY_INDEX_TEST_RTREE_EXCEPTIONS_HPP
-
-#include <rtree/test_rtree.hpp>
-
-#include <boost/geometry/index/detail/rtree/node/dynamic_visitor.hpp>
-
-#include <rtree/test_throwing.hpp>
-
-namespace boost { namespace geometry { namespace index {
-
-template <size_t MaxElements, size_t MinElements>
-struct linear_throwing : public linear<MaxElements, MinElements> {};
-
-template <size_t MaxElements, size_t MinElements>
-struct quadratic_throwing : public quadratic<MaxElements, MinElements> {};
-
-template <size_t MaxElements, size_t MinElements, size_t OverlapCostThreshold = 0, size_t ReinsertedElements = detail::default_rstar_reinserted_elements_s<MaxElements>::value>
-struct rstar_throwing : public rstar<MaxElements, MinElements, OverlapCostThreshold, ReinsertedElements> {};
-
-namespace detail { namespace rtree {
-
-// options implementation (from options.hpp)
-
-struct node_throwing_d_mem_static_tag {};
-
-template <size_t MaxElements, size_t MinElements>
-struct options_type< linear_throwing<MaxElements, MinElements> >
-{
- typedef options<
- linear_throwing<MaxElements, MinElements>,
- insert_default_tag, choose_by_content_diff_tag, split_default_tag, linear_tag,
- node_throwing_d_mem_static_tag
- > type;
-};
-
-template <size_t MaxElements, size_t MinElements>
-struct options_type< quadratic_throwing<MaxElements, MinElements> >
-{
- typedef options<
- quadratic_throwing<MaxElements, MinElements>,
- insert_default_tag, choose_by_content_diff_tag, split_default_tag, quadratic_tag,
- node_throwing_d_mem_static_tag
- > type;
-};
-
-template <size_t MaxElements, size_t MinElements, size_t OverlapCostThreshold, size_t ReinsertedElements>
-struct options_type< rstar_throwing<MaxElements, MinElements, OverlapCostThreshold, ReinsertedElements> >
-{
- typedef options<
- rstar_throwing<MaxElements, MinElements, OverlapCostThreshold, ReinsertedElements>,
- insert_reinsert_tag, choose_by_overlap_diff_tag, split_default_tag, rstar_tag,
- node_throwing_d_mem_static_tag
- > type;
-};
-
-}} // namespace detail::rtree
-
-// node implementation
-
-namespace detail { namespace rtree {
-
-template <typename Value, typename Parameters, typename Box, typename Allocators>
-struct dynamic_internal_node<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag>
- : public dynamic_node<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag>
-{
- typedef throwing_varray<
- std::pair<
- Box,
- typename Allocators::node_pointer
- >,
- Parameters::max_elements + 1
- > elements_type;
-
- template <typename Dummy>
- inline dynamic_internal_node(Dummy) {}
-
- void apply_visitor(dynamic_visitor<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag, false> & v) { v(*this); }
- void apply_visitor(dynamic_visitor<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag, true> & v) const { v(*this); }
-
- elements_type elements;
-};
-
-template <typename Value, typename Parameters, typename Box, typename Allocators>
-struct dynamic_leaf<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag>
- : public dynamic_node<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag>
-{
- typedef throwing_varray<Value, Parameters::max_elements + 1> elements_type;
-
- template <typename Dummy>
- inline dynamic_leaf(Dummy) {}
-
- void apply_visitor(dynamic_visitor<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag, false> & v) { v(*this); }
- void apply_visitor(dynamic_visitor<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag, true> & v) const { v(*this); }
-
- elements_type elements;
-};
-
-// elements derived type
-template <typename OldValue, size_t N, typename NewValue>
-struct container_from_elements_type<throwing_varray<OldValue, N>, NewValue>
-{
- typedef throwing_varray<NewValue, N> type;
-};
-
-// nodes traits
-
-template <typename Value, typename Parameters, typename Box, typename Allocators>
-struct node<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag>
-{
- typedef dynamic_node<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag> type;
-};
-
-template <typename Value, typename Parameters, typename Box, typename Allocators>
-struct internal_node<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag>
-{
- typedef dynamic_internal_node<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag> type;
-};
-
-template <typename Value, typename Parameters, typename Box, typename Allocators>
-struct leaf<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag>
-{
- typedef dynamic_leaf<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag> type;
-};
-
-template <typename Value, typename Parameters, typename Box, typename Allocators, bool IsVisitableConst>
-struct visitor<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag, IsVisitableConst>
-{
- typedef dynamic_visitor<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag, IsVisitableConst> type;
-};
-
-// allocators
-
-template <typename Allocator, typename Value, typename Parameters, typename Box>
-class allocators<Allocator, Value, Parameters, Box, node_throwing_d_mem_static_tag>
-{
- BOOST_COPYABLE_AND_MOVABLE_ALT(allocators)
-
-public:
- typedef Allocator allocator_type;
- typedef typename allocator_type::size_type size_type;
-
- typedef typename allocator_type::template rebind<
- typename node<Value, Parameters, Box, allocators, node_throwing_d_mem_static_tag>::type
- >::other::pointer node_pointer;
-
- typedef typename allocator_type::template rebind<
- typename internal_node<Value, Parameters, Box, allocators, node_throwing_d_mem_static_tag>::type
- >::other::pointer internal_node_pointer;
-
- typedef typename allocator_type::template rebind<
- typename internal_node<Value, Parameters, Box, allocators, node_throwing_d_mem_static_tag>::type
- >::other internal_node_allocator_type;
-
- typedef typename allocator_type::template rebind<
- typename leaf<Value, Parameters, Box, allocators, node_throwing_d_mem_static_tag>::type
- >::other leaf_allocator_type;
-
- inline allocators()
- : allocator()
- , internal_node_allocator()
- , leaf_allocator()
- {}
-
- inline explicit allocators(Allocator alloc)
- : allocator(alloc)
- , internal_node_allocator(allocator)
- , leaf_allocator(allocator)
- {}
-
- inline allocators(allocators const& a)
- : allocator(a.allocator)
- , internal_node_allocator(a.internal_node_allocator)
- , leaf_allocator(a.leaf_allocator)
- {}
-
- inline allocators(BOOST_RV_REF(allocators) a)
- : allocator(boost::move(a.allocator))
- , internal_node_allocator(boost::move(a.internal_node_allocator))
- , leaf_allocator(boost::move(a.leaf_allocator))
- {}
-
- void swap(allocators & a)
- {
- boost::swap(allocator, a.allocator);
- boost::swap(internal_node_allocator, a.internal_node_allocator);
- boost::swap(leaf_allocator, a.leaf_allocator);
- }
-
- allocator_type allocator;
- internal_node_allocator_type internal_node_allocator;
- leaf_allocator_type leaf_allocator;
-};
-
-struct node_bad_alloc : public std::exception
-{
- const char * what() const throw() { return "internal node creation failed."; }
-};
-
-struct throwing_node_settings
-{
- static void throw_if_required()
- {
- // throw if counter meets max count
- if ( get_max_calls_ref() <= get_calls_counter_ref() )
- throw node_bad_alloc();
- else
- ++get_calls_counter_ref();
- }
-
- static void reset_calls_counter() { get_calls_counter_ref() = 0; }
- static void set_max_calls(size_t mc) { get_max_calls_ref() = mc; }
-
- static size_t & get_calls_counter_ref() { static size_t cc = 0; return cc; }
- static size_t & get_max_calls_ref() { static size_t mc = (std::numeric_limits<size_t>::max)(); return mc; }
-};
-
-// create_node
-
-template <typename Allocators, typename Value, typename Parameters, typename Box>
-struct create_node<
- Allocators,
- dynamic_internal_node<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag>
->
-{
- static inline typename Allocators::node_pointer
- apply(Allocators & allocators)
- {
- // throw if counter meets max count
- throwing_node_settings::throw_if_required();
-
- return create_dynamic_node<
- typename Allocators::node_pointer,
- dynamic_internal_node<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag>
- >::apply(allocators.internal_node_allocator, allocators.internal_node_allocator);
- }
-};
-
-template <typename Allocators, typename Value, typename Parameters, typename Box>
-struct create_node<
- Allocators,
- dynamic_leaf<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag>
->
-{
- static inline typename Allocators::node_pointer
- apply(Allocators & allocators)
- {
- // throw if counter meets max count
- throwing_node_settings::throw_if_required();
-
- return create_dynamic_node<
- typename Allocators::node_pointer,
- dynamic_leaf<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag>
- >::apply(allocators.leaf_allocator, allocators.leaf_allocator);
- }
-};
-
-}} // namespace detail::rtree
-
-}}} // namespace boost::geometry::index
-
-#endif // BOOST_GEOMETRY_INDEX_TEST_RTREE_EXCEPTIONS_HPP

Deleted: sandbox-branches/geometry/index/test/rtree/test_throwing.hpp
==============================================================================
--- sandbox-branches/geometry/index/test/rtree/test_throwing.hpp 2013-02-14 09:23:09 EST (Thu, 14 Feb 2013)
+++ (empty file)
@@ -1,198 +0,0 @@
-// Boost.Geometry Index
-//
-// Throwing objects implementation
-//
-// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
-//
-// Use, modification and distribution is subject to the Boost Software License,
-// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-#ifndef BOOST_GEOMETRY_INDEX_TEST_THROWING_HPP
-#define BOOST_GEOMETRY_INDEX_TEST_THROWING_HPP
-
-// value
-
-struct throwing_value_copy_exception : public std::exception
-{
- const char * what() const throw() { return "value copy failed."; }
-};
-
-struct throwing_value
-{
- explicit throwing_value(int v = 0)
- : value(v)
- {}
-
- bool operator==(throwing_value const& v) const
- {
- return value == v.value;
- }
-
- throwing_value(throwing_value const& v)
- {
- throw_if_required();
-
- value = v.value;
- }
-
- throwing_value & operator=(throwing_value const& v)
- {
- throw_if_required();
-
- value = v.value;
- return *this;
- }
-
- void throw_if_required()
- {
- // throw if counter meets max count
- if ( get_max_calls_ref() <= get_calls_counter_ref() )
- throw throwing_value_copy_exception();
- else
- ++get_calls_counter_ref();
- }
-
- static void reset_calls_counter() { get_calls_counter_ref() = 0; }
- static void set_max_calls(size_t mc) { get_max_calls_ref() = mc; }
-
- static size_t & get_calls_counter_ref() { static size_t cc = 0; return cc; }
- static size_t & get_max_calls_ref() { static size_t mc = (std::numeric_limits<size_t>::max)(); return mc; }
-
- int value;
-};
-
-template <typename T, typename C>
-struct generate_value< std::pair<bg::model::point<T, 2, C>, throwing_value> >
-{
- typedef bg::model::point<T, 2, C> P;
- typedef std::pair<P, throwing_value> R;
- static R apply(int x, int y)
- {
- return std::make_pair(P(x, y), throwing_value(x + y * 100));
- }
-};
-
-// box
-//
-//#include <boost/geometry/geometries/register/box.hpp>
-//
-//struct throwing_box_copy_exception : public std::exception
-//{
-// const char * what() const throw() { return "box copy failed."; }
-//};
-//
-//template <typename Point>
-//struct throwing_box
-//{
-// throwing_box(){}
-//
-// throwing_box(Point const& m, Point const& mm)
-// : min_p(m), max_p(mm)
-// {}
-//
-// throwing_box(throwing_box const& o)
-// {
-// throw_if_required();
-//
-// min_p = o.min_p;
-// max_p = o.max_p;
-// }
-//
-// throwing_box & operator=(throwing_box const& o)
-// {
-// throw_if_required();
-//
-// min_p = o.min_p;
-// max_p = o.max_p;
-// return *this;
-// }
-//
-// void throw_if_required()
-// {
-// // throw if counter meets max count
-// if ( get_max_calls_ref() <= get_calls_counter_ref() )
-// throw throwing_box_copy_exception();
-// else
-// ++get_calls_counter_ref();
-// }
-//
-// static void reset_calls_counter() { get_calls_counter_ref() = 0; }
-// static void set_max_calls(size_t mc) { get_max_calls_ref() = mc; }
-//
-// static size_t & get_calls_counter_ref() { static size_t cc = 0; return cc; }
-// static size_t & get_max_calls_ref() { static size_t mc = (std::numeric_limits<size_t>::max)(); return mc; }
-//
-// Point min_p;
-// Point max_p;
-//};
-//
-//BOOST_GEOMETRY_REGISTER_BOX_TEMPLATED(throwing_box, min_p, max_p)
-//
-//namespace boost { namespace geometry { namespace index {
-//
-//template <typename CT, size_t D, typename CS>
-//struct default_box_type< bg::model::point<CT, D, CS> >
-//{
-// typedef throwing_box<
-// bg::model::point<CT, D, CS>
-// > type;
-//};
-//
-//}}} // namespace boost::geometry::index
-
-#include <boost/geometry/index/detail/varray.hpp>
-
-struct throwing_varray_exception : public std::exception
-{
- const char * what() const throw() { return "static vector exception."; }
-};
-
-struct throwing_varray_settings
-{
- static void throw_if_required()
- {
- // throw if counter meets max count
- if ( get_max_calls_ref() <= get_calls_counter_ref() )
- throw throwing_varray_exception();
- else
- ++get_calls_counter_ref();
- }
-
- static void reset_calls_counter() { get_calls_counter_ref() = 0; }
- static void set_max_calls(size_t mc) { get_max_calls_ref() = mc; }
-
- static size_t & get_calls_counter_ref() { static size_t cc = 0; return cc; }
- static size_t & get_max_calls_ref() { static size_t mc = (std::numeric_limits<size_t>::max)(); return mc; }
-};
-
-template <typename Element, size_t Capacity>
-class throwing_varray
- : public boost::geometry::index::detail::varray<Element, Capacity>
-{
- typedef boost::geometry::index::detail::varray<Element, Capacity> container;
-
-public:
- typedef typename container::value_type value_type;
- typedef typename container::size_type size_type;
- typedef typename container::iterator iterator;
- typedef typename container::const_iterator const_iterator;
- typedef typename container::reverse_iterator reverse_iterator;
- typedef typename container::const_reverse_iterator const_reverse_iterator;
- typedef typename container::reference reference;
- typedef typename container::const_reference const_reference;
-
- inline void resize(size_type s)
- {
- throwing_varray_settings::throw_if_required();
- container::resize(s);
- }
-
- void push_back(Element const& v)
- {
- throwing_varray_settings::throw_if_required();
- container::push_back(v);
- }
-};
-
-#endif // BOOST_GEOMETRY_INDEX_TEST_THROWING_HPP


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