1
我弄了半天编译器错误,当我尝试提升几何形状的差异功能,同时集和交集具有相同的接口,并可能与实施工作:提升几何差异编译器错误
bg::unique_(OldPolygon, Node->Polygon, NodePolygon); // compiles
bg::intersection(OldPolygon, Node->Polygon, NodePolygon); // compiles
bg::difference(OldPolygon, Node->Polygon, NodePolygon); // dies
第一个错误是:
boost/range/size.hpp:32:13: error: invalid operands to
binary expression ('
boost::reverse_iterator<
__gnu_cxx::__normal_iterator<
const GraphPoint *,
std::vector<
GraphPoint,
std::allocator<GraphPoint>
>
>
>' and 'int')
BOOST_ASSERT((boost::end(rng) - boost::begin(rng)) >= 0 &&
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
似乎出于某种原因,迭代差异返回反向迭代器,而不是距离...
的类型声明:
namespace bg = boost::geometry;
struct GraphPoint
{
int x, y;
GraphPoint(int x, int y) : x(x), y(y) { }
GraphPoint() : x(0), y(0) { }
GraphPoint(const GraphPoint &other) : x(other.x), y(other.y) { }
bool operator ==(const GraphPoint &other) const
{
return x == other.x && y == other.y;
}
};
BOOST_GEOMETRY_REGISTER_POINT_2D(GraphPoint, int, bg::cs::cartesian, x, y)
typedef bg::model::polygon<GraphPoint> Polygon;
typedef Polygon::ring_type Ring;
typedef bg::model::multi_polygon<Polygon> MultiPolygon;
MultiPolygon OldPolygon;
struct Node
{
Polygon Polygon;
}
MultiPolygon NodePolygon;
完整的错误是在here任何人都喜欢挖。
我该如何编译?