2011-10-12 65 views
3

首先,非常感谢新的boost :: geometry库背后的人!boost :: geometry multi_point不能像多边形一样构造

这个问题取代了我现在分成两个的较早的一个,因为两个单独的问题已经变得更加清晰。

我已阅读http://www.boost.org/doc/libs/1_47_0/libs/geometry/doc/html/geometry/design.html这也解释了traits机制,但我没有,为什么这个代码不编译聪明......

//code to calculate area of convex hull from a set of points 

#include <boost/geometry.hpp> 
#include <boost/geometry/geometries/point_xy.hpp> 
#include <boost/geometry/geometries/polygon.hpp> 
#include <boost/geometry/multi/geometries/multi_point.hpp> 

double convex_hull_area() 
{ 
    using boost::geometry::model::d2::point_xy; 
    using boost::geometry::append; 
    using boost::geometry::make; 

    //this bit works if I use a polygon instead of multi_point 
    boost::geometry::model::multi_point<point_xy<float> > all_points_in_radius; 

    append(all_points_in_radius,make<point_xy<float> >(0,0)); 
    append(all_points_in_radius,make<point_xy<float> >(3,0)); 
    append(all_points_in_radius,make<point_xy<float> >(3,3)); 
    append(all_points_in_radius,make<point_xy<float> >(2,1)); 

    boost::geometry::model::polygon<point_xy<float> > hull; 
    boost::geometry::convex_hull(all_points_in_radius,hull); 
    return boost::geometry::area(hull); 
} 

第一个错误是

Error 1 error C2039: 'apply' : is not a member of 'boost::geometry::dispatch::for_each_range<Tag,Geometry,Actor,IsConst>' d:\boost\boost_1_47_0\boost\geometry\algorithms\detail\for_each_range.hpp 115 boost_geom_test 

如果我使用多边形而不是多点,代码工作得很好,尽管可能会带来我不需要的开销。到底是怎么回事?

+0

我已经报告这是一个现在提升的bug。 –

回答

3

这原来是一个提升的bug。它现在已经修正在头版本中,并且应该在1.49.0中推出。