添加带有提升的多边形::p奥利贡不编译?



也许这是一个愚蠢的问题,只是一个简单的问题,但我无法编译相对简单的代码。我尝试做的是使用 boost::p olygon(一些显示相关部分的伪代码(添加/连接两个多边形:

#include <boost/polygon/polygon.hpp>
boost::polygon::polygon_with_holes_data<int>     baseData; // base data to work with
boost::polygon::polygon_with_holes_data<int>     opData;   // operational data to be applied to base 
fill both baseData and opData via set() and set_holes() here...
boost::polygon::polygon_set_data<int> result=baseData + opData;

最后一行是我偶然发现的地方:编译器说运算符"+"在polygon_with_holes_data中是未知的:

error C2678: binary '+' : no operator found which takes a left-hand operand of type 'boost::polygon::polygon_with_holes_data<T>' (or there is no acceptable conversion)

当我使用polygon_data而不是polygon_with_holes_data时,会出现相同的错误。知道我做错了什么吗?

谢谢!

我在文档中看到的唯一运算符是在多边形集上

另外,请注意:

运算符在命名空间boost::polygon::operators内声明。

因此,请确保实际使用它们:

住在科里鲁

#include <boost/polygon/polygon.hpp>
#include <boost/polygon/polygon_set_data.hpp>
#include <boost/polygon/polygon_with_holes_data.hpp>
namespace bp = boost::polygon;
using poly = bp::polygon_with_holes_data<int>;
using pset = bp::polygon_set_data<int>;
int main() {
poly baseData; // base data to work with
poly opData;   // operational data to be applied to base
// fill both baseData and opData via set() and set_holes() here...
using namespace bp::operators;
pset x = baseData + opData;
}

最新更新