Я хочу наследовать от bg::model::point, чтобы расширить его собственными функциями. *Точки* должны храниться в дерево.
В следующем минимальном примере не удается скомпилировать использование моей производной точки (boost 1.54, gcc 4.7.2):
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point.hpp>
#include <boost/geometry/geometries/box.hpp>
#include <boost/geometry/index/rtree.hpp>
#include <iostream>
#include <boost/shared_ptr.hpp>
namespace bg = boost::geometry;
namespace bgi = boost::geometry::index;
namespace boost { namespace geometry { namespace index {
// apparently necessary:
template <typename Box>
struct indexable< boost::shared_ptr<Box> >
{
typedef boost::shared_ptr<Box> V;
typedef Box const& result_type;
result_type operator()(V const& v) const { return *v; }
};
}}} // namespace boost::geometry::index
namespace { // anonymous namespace
// myPoint
template<typename CoordinateType, std::size_t DimensionCount, typename CoordinateSystem>
class myPoint : public bg::model::point<CoordinateType, DimensionCount, CoordinateSystem>{
public:
void sayHello(void);
};
template<typename CoordinateType, std::size_t DimensionCount, typename CoordinateSystem>
void myPoint< CoordinateType, DimensionCount, CoordinateSystem >::sayHello() {
std::cout<<"Hello!"<<std::endl;
}
} // end anonymous namespace
int main(void)
{
typedef bg::model::point<float, 2, bg::cs::cartesian> point; // boost point version
typedef myPoint<float, 2, bg::cs::cartesian> mypoint; // custom point version
// create the rtree using default constructor
bgi::rtree< boost::shared_ptr<point>, bgi::rstar<16, 4> > rtree; // that works
bgi::rtree< boost::shared_ptr<mypoint>, bgi::rstar<16, 4> > myrtree; // that doesn't works
return 0;
}
как я могу получить от bg::model::point? или вместо наследования есть лучший подход?
Благодарность!