Hi Patrick,

Patrick J. LoPresti wrote On 27-5-2014 23:13:
I have an existing library of code dealing with 2D points, boxes,
etc., and I am looking for a good spatial index. I believe
boost::geometry::rtree might fit the bill.

However...

My library uses SSE registers to represent 2D points/vectors. This
makes the operations I care about very fast (e.g. vector arithmetic,
box union/intersection), but accessing the components of a point is a
bit painful.

Is there any way to teach boost::geometry -- and especially
boost::geometry::rtree -- to use my functions for these operations,
avoiding get<0> and get<1> as much as possible?

get<0> and get<1> are the methods to teach Boost.Geometry to access coordinates...

They are all templated and inlined so it should have no speed penalty (on "normal" C++ applications). But I don't have experience with that in combination with SSE.

If you want to optimize one operation further (say: box intersection), then you can make a specialization (of dispatch) for your specific box type. That is not often done, but it should be possible. The box-intersection can then make use of SSE (while other things still work the "Boost.Geometry" way).

This must be done per algorithm / geometry type.

Most functions are modelled like that (using dispatch). But vector arithmetic is currently not modelled like that - if you continue with this, and it works fine, we can consider adding a dispatch layer there too.

(I have read the documentation but not yet the source code, so please
forgive me if this is a stupid question.)

It is a very interesting question ;-)


Regards, Barend