I am trying to calculate the nearest segment from another segment in a 3-dimensional space using the boost::geometry::index::nearest
query on a boost:: boost::geometry::index::rtree
but I get the following compilation error:
error C2664: 'boost::mpl::assertion_failed' : cannot convert parameter 1 from 'boost::mpl::failed ************(__cdecl boost::geometry::nyi::not_implemented_error::THIS_OPERATION_IS_NOT_OR_NOT_YET_IMPLEMENTED::* ***********)(boost::mpl::assert_::types)' to 'boost::mpl::assert::type'
I have managed to narrow down the same issue to using just the boost::geometry::distance
function:
typedef boost::geometry::model::point <float, 3, boost::geometry::cs::cartesian> point;
typedef boost::geometry::model::segment <point> segment;
point pa = point(x1, y1, z1);
point pc = point(x2, y2, z2);
point pb = point(x3, y3, z3);
float dist = boost::geometry::distance(segment(pa, pb), segment(pa, pc));
According to the documentation of the version of Boost I'm using (1.60) this should be supported, however it works just fine when using two dimensions.
I could not find anything in the docs either about how to extend the functionality or whether it's possible at all.
After exchanging a few messages with @awulkiew from Boost development you can see the current workarounds in this ticket.
At this point there's no implementation for a few internal functions for N-dimensional segments:
There's also another workaround involving overriding internal Boost functions, but it's been discouraged as those may change in the future:
Also, there's no ETA for adding support for this feature at the moment.
In my case the solution would be to implement my own distance functions and use an algorithm like the proposed in the first workaround.