3

首先,非常感谢新 boost::geometry 库背后的人们!

这个问题取代了之前的一个问题,我现在将其分成两个,因为两个单独的问题变得更加清晰。

我已经阅读了http://www.boost.org/doc/libs/1_47_0/libs/geometry/doc/html/geometry/design.html,它解释了特征机制,但我不知道为什么这段代码没有编译...

//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

如果我使用多边形而不是多点,则代码可以正常工作,尽管可能有我不需要的开销。到底是怎么回事?

4

1 回答 1

3

事实证明,这是 boost 中的一个错误。它现在已在头部修订中得到修复,并应在 1.49.0 中推出。

于 2012-01-17T16:58:43.620 回答