thb
thb

Reputation: 3

Query for intersection with boost::geometry::index::rtree

I'm having instance of boost::geometry::index::rtree of axis aligned boxes in three dimensions. I'm already using point intersection in 1.54 version of the boost. Works like charm. Well, I'd like also to query for intersection with line (ray, section), which seems to be supported by boost 1.59 (err, with some glitches, but still pretty impressive). Unfortunately as I've said I'm on the version 1.54. and I don't have any chance to change it for now. So the question is: How to extend geometry in boost 1.54. so it supports section intersections with bounding boxes within rtree? What templates do I have to specialize? Is there anything else I have to do? Ideas? thb

Upvotes: 0

Views: 2103

Answers (1)

Adam Wulkiewicz
Adam Wulkiewicz

Reputation: 2098

If you pass bgi::intersects() predicate into the query the rtree internally calls bg::intersects() which calls bg::disjoint(). And those spatial relation checks are tested for QueryGeometry/Box and QueryGeometry/Indexable. E.g. if you're storing Boxes then the rtree internally calls bg::intersects(Box, QueryGeometry).

If the QueryGeometry type was adapted to one of the Boost.Geometry concepts, e.g. Segment, but the function was simply not implemented in a version of Boost you're using, you could see how an algorithm is implemented for a combination of concepts in the latest version of Boost. E.g. disjoint(Box, Segment) is implemented here: https://github.com/boostorg/geometry/blob/master/include/boost/geometry/algorithms/detail/disjoint/segment_box.hpp. Then you could probably find the corresponding place in Boost 1.54 and put this code there. Though AFAIR the directories and files structure was altered since 1.54. I guess you could also try to use the whole 1.59 Boost.Geometry code with Boost 1.54 though of course it's not guaranteed that it will work. And as @sehe pointed out in the comments there is an error in disjoint/intersects for Box/Segment combination in 1.59.

If the QueryGeometry was not the kind of a geometry supported by the library, which is AFAIU your case, e.g. Frustum, Cone, Plane, Ray, etc. you could simply overload bg::intersects() or bg::disjoint() for the combination of types the rtree would like to call, in this case for your QueryGeometry and Box. See this for more information: Boost Geometry/Spatial Query Shapes

Upvotes: 0

Related Questions