Modified glut_vis additional test and added generated rtree images.

[SVN r81528]
This commit is contained in:
Adam Wulkiewicz
2012-11-25 17:28:12 +00:00
parent 5a6e87b146
commit f7d7e88bbb
12 changed files with 62 additions and 17 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
doc/rtree/images/knn.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
doc/rtree/images/linear.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
doc/rtree/images/rstar.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
doc/rtree/images/within.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@@ -122,17 +122,17 @@ struct gl_draw : public rtree::visitor<Value, typename Options::parameters_type,
size_t level_rel = level - level_f;
if ( level_rel == 0 )
glColor3f(1.0f, 0.0f, 0.0f);
glColor3f(0.75f, 0.0f, 0.0f);
else if ( level_rel == 1 )
glColor3f(0.0f, 1.0f, 0.0f);
glColor3f(0.0f, 0.75f, 0.0f);
else if ( level_rel == 2 )
glColor3f(0.0f, 0.0f, 1.0f);
glColor3f(0.0f, 0.0f, 0.75f);
else if ( level_rel == 3 )
glColor3f(1.0f, 1.0f, 0.0f);
glColor3f(0.75f, 0.75f, 0.0f);
else if ( level_rel == 4 )
glColor3f(1.0f, 0.0f, 1.0f);
glColor3f(0.75f, 0.0f, 0.75f);
else if ( level_rel == 5 )
glColor3f(0.0f, 1.0f, 1.0f);
glColor3f(0.0f, 0.75f, 0.75f);
else
glColor3f(0.5f, 0.5f, 0.5f);
@@ -167,7 +167,7 @@ struct gl_draw : public rtree::visitor<Value, typename Options::parameters_type,
{
size_t level_rel = level - level_f;
glColor3f(1.0f, 1.0f, 1.0f);
glColor3f(0.25f, 0.25f, 0.25f);
for (typename elements_type::const_iterator it = elements.begin();
it != elements.end(); ++it)
@@ -204,6 +204,12 @@ void gl_draw(rtree<Value, Options, Translator, Allocator> const& tree,
typedef typename rtree_type::box_type box_type;
typedef typename rtree_type::allocators_type allocators_type;
if ( !tree.empty() )
{
glColor3f(0.75f, 0.75f, 0.75f);
detail::rtree::visitors::detail::gl_draw_indexable(tree.box(), 0);
}
detail::rtree::visitors::gl_draw<value_type, options_type, translator_type, box_type, allocators_type>
gl_draw_v(tree.translator(), level_first, level_last, z_coord_level_multiplier);

View File

@@ -9,6 +9,8 @@
#include <gl/glut.h>
#define BOOST_GEOMETRY_INDEX_ENABLE_DEBUG_INTERFACE
#include <boost/geometry/extensions/index/rtree/rtree.hpp>
#include <boost/geometry/extensions/index/rtree/visitors/gl_draw.hpp>
@@ -31,9 +33,9 @@ std::vector<B> vect;
size_t found_count = 0;
P search_point;
float min_distance = 20;
float min_distance = 10;
float max_distance = 30;
size_t count = 10;
size_t count = 5;
std::vector<B> nearest_boxes;
B search_box;
@@ -50,11 +52,11 @@ void knn()
search_point = P(x, y);
nearest_boxes.clear();
found_count = t.nearest(
found_count = t.nearest_query(
bgi::bounded(
search_point,
bgi::far(min_distance),
bgi::near(max_distance)
bgi::to_furthest(min_distance),
bgi::to_nearest(max_distance)
),
count,
std::back_inserter(nearest_boxes)
@@ -87,13 +89,13 @@ void query()
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) );
found_count = t.spatial_query(Predicate(search_box), std::back_inserter(nearest_boxes) );
}
else
{
search_box = t.box();
nearest_boxes.clear();
found_count = t.query(Predicate(search_box), std::back_inserter(nearest_boxes) );
found_count = t.spatial_query(Predicate(search_box), std::back_inserter(nearest_boxes) );
}
if ( found_count > 0 )
@@ -220,13 +222,23 @@ void resize(int w, int h)
glViewport(0, 0, w, h);
gluPerspective(45, ratio, 1, 1000);
//gluPerspective(45, ratio, 1, 1000);
glOrtho(-150, 150, -150, 150, -150, 150);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(
/*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)
@@ -292,6 +304,33 @@ void keyboard(unsigned char key, int x, int y)
{
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::are_boxes_ok(t) ? "boxes OK\n" : "WRONG BOXES!\n" );
std::cout << ( bgi::are_levels_ok(t) ? "levels OK\n" : "WRONG LEVELS!\n" );
std::cout << "\n";
search_valid = false;
glutPostRedisplay();
}
else
{
if ( current_line == "knn" )
@@ -338,7 +377,7 @@ int main(int argc, char **argv)
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_SINGLE | GLUT_RGBA);
glutInitWindowPosition(100,100);
glutInitWindowSize(800, 600);
glutInitWindowSize(600, 600);
glutCreateWindow("boost::geometry::index::rtree GLUT test");
glutDisplayFunc(render_scene);