$include_dir="/home/hyper-archives/geometry/include"; include("$include_dir/msg-header.inc") ?>
Subject: [ggl] rtree documentation?
From: Bernhard Kornberger (bkorn)
Date: 2010-06-24 09:23:12
On 2010-06-24 10:49, Barend Gehrels wrote:
> They are not yet there. Sorry about that. The rtree interface will be
> changed (and it was therefore not part of the review).
>
> However, it works and can be used. Herewith a code snippet.
Dear Barend,
thank you very much for your help! I was able to get it running
in 2D. However, in 3D it won't compile. Is the rtree not ready
for 3D or do I have an error in my code:
#include <stdio.h>
#include <iostream>
#include "boost/geometry/geometry.hpp"
#include <boost/geometry/geometries/geometries.hpp>
#include "boost/geometry/geometries/cartesian3d.hpp"
#include "boost/geometry/extensions/index/rtree/rtree.hpp"
using namespace std;
namespace bg = boost::geometry;
int main(int argc,char* argv[])
{
         // declare a spatial index with an ID (int), the ID can also be 
e.g. an index of a vector
         bg::index::rtree<bg::box_3d, int> spatial_index(12, 4); // 
<box, ID>
         // fill it somewhere, normally in a loop over polygons (here: 
polygon)
         int id=0;
         bg::point_3d p1(0.0,0.0,0.0);
         bg::point_3d p2(1.0,1.0,1.0);
         bg::box_3d box3(p1,p2);
         spatial_index.insert(box3, id);
         // get all ID's intersecting a specified box:
         bg::point_3d q0(.5,.5,.5);
         bg::point_3d q1(3.0,3.0,3.0);
         bg::box_3d q(q0,q1);
         std::deque<int> overlapping = spatial_index.find(q);
         cout<<"result size="<<overlapping.size()<<endl;
}
make
/usr/bin/g++ -I/home/bernd/openSource/dev/test_rtree3d -Wall 
-frounding-math '-I/opt/CGAL331/include' -I/usr/include/qt3  -O3 
-DNDEBUG -DCGAL_NO_ASSERTIONS   -c test.cpp
In file included from 
/home/bernd/openSource/dev/test_rtree3d/boost/geometry/geometries/concepts/box_concept.hpp:20,
                  from 
/home/bernd/openSource/dev/test_rtree3d/boost/geometry/geometries/concepts/check.hpp:67,
                  from 
/home/bernd/openSource/dev/test_rtree3d/boost/geometry/core/num_geometries.hpp:18,
                  from boost/geometry/geometry.hpp:24,
                  from test.cpp:3:
/home/bernd/openSource/dev/test_rtree3d/boost/geometry/core/coordinate_dimension.hpp: 
In function ?void boost::geometry::assert_dimension() [with G = 
boost::geometry::box<boost::geometry::point<double, 3ul, 
boost::geometry::cs::cartesian> >, int D = 2]?:
/home/bernd/openSource/dev/test_rtree3d/boost/geometry/algorithms/area.hpp:80: 
   instantiated from ?static typename 
boost::geometry::coordinate_type<Geometry>::type 
boost::geometry::detail::area::box_area<Box, Strategy>::apply(const 
Box&, const Strategy&) [with Box = 
boost::geometry::box<boost::geometry::point<double, 3ul, 
boost::geometry::cs::cartesian> >, Strategy = 
boost::geometry::strategy::area::by_triangles<boost::geometry::point<double, 
3ul, boost::geometry::cs::cartesian>, void>]?
/home/bernd/openSource/dev/test_rtree3d/boost/geometry/algorithms/area.hpp:247: 
   instantiated from ?typename 
boost::geometry::area_result<Geometry>::type boost::geometry::area(const 
Geometry&) [with Geometry = 
boost::geometry::box<boost::geometry::point<double, 3ul, 
boost::geometry::cs::cartesian> >]?
boost/geometry/extensions/index/rtree/rtree.hpp:473:   instantiated from 
?void boost::geometry::index::rtree<Box, Value>::split_node(const 
boost::shared_ptr<boost::geometry::index::rtree_node<Box, Value> >&, 
boost::shared_ptr<boost::geometry::index::rtree_node<Box, Value> >&, 
boost::shared_ptr<boost::geometry::index::rtree_node<Box, Value> >&) 
const [with Box = boost::geometry::box<boost::geometry::point<double, 
3ul, boost::geometry::cs::cartesian> >, Value = int]?
boost/geometry/extensions/index/rtree/rtree.hpp:262:   instantiated from 
?void boost::geometry::index::rtree<Box, Value>::insert(const Box&, 
const Value&) [with Box = 
boost::geometry::box<boost::geometry::point<double, 3ul, 
boost::geometry::cs::cartesian> >, Value = int]?
test.cpp:24:   instantiated from here
/home/bernd/openSource/dev/test_rtree3d/boost/geometry/core/coordinate_dimension.hpp:80: 
error: invalid application of ?sizeof? to incomplete type 
?boost::STATIC_ASSERTION_FAILURE<false>?
/home/bernd/openSource/dev/test_rtree3d/boost/geometry/core/coordinate_dimension.hpp:80: 
error: invalid application of ?sizeof? to incomplete type 
?boost::STATIC_ASSERTION_FAILURE<false>?
make: *** [test.o] Error 1
Best
Bernhard