使用boost ::几何::缓冲函数
using boost::geometry::buffer function
这是我第一次使用boost库,所以我对此感到非常不舒服,我可能做错了。我在使用boost ::几何:: buffer()函数时遇到了一些问题。
这是我的代码:
#include <vector>
#include <boostgeometry.hpp>
#include <boostgeometrygeometriesregisterpoint.hpp>
struct PNT_2D
{
double x, y;
};
BOOST_GEOMETRY_REGISTER_POINT_2D(PNT_2D, double, boost::geometry::cs::cartesian, x, y);
typedef boost::geometry::model::polygon<PNT_2D, false> BoostPolygon;
typedef std::vector<PNT_2D> StlPolygon;
int main(int argc, char * argv[])
{
int nStaph;
BoostPolygon polygon;
BoostPolygon off_polygon;
PNT_2D p2dPunto;
StlPolygon stlPolygon;
stlPolygon.resize(5);
stlPolygon[0].x = stlPolygon[0].y = stlPolygon[4].x = stlPolygon[4].y = 0.0;
stlPolygon[1].x = 25.0; stlPolygon[1].y = 0.0;
stlPolygon[2].x = 25.0; stlPolygon[2].y = 25.0;
stlPolygon[3].x = 0.0; stlPolygon[3].y = 25.0;
boost::geometry::append(polygon, stlPolygon);
boost::geometry::buffer(polygon, off_polygon, 1);
stlPolygon = off_polygon.outer();
for (auto punto = stlPolygon.begin(); punto != stlPolygon.end(); punto++)
std::cout << "(" << punto->x << ", " << punto->y << ")" << std::endl;
}
在编译时给出以下错误:
'int boost::mpl::assertion_failed<false>(boost::mpl::assert<false>::type)': impossibile convertire l'argomento 1 da 'boost::mpl::failed ************(__thiscall boost::geometry::nyi::not_implemented_error<boost::geometry::info::POLYGON,boost::geometry::info::POLYGON,void>::THIS_OPERATION_IS_NOT_OR_NOT_YET_IMPLEMENTED::* ***********)(boost::mpl::assert_::types<Term1,Term2,Term3,boost::mpl::na>)' a 'boost::mpl::assert<false>::type'
我缺少什么?
编辑
我已经通过以下方式更新了我的代码:
//////////////////////// DEFINITIONS
typedef BG::model::polygon<PNT_2D, false> BoostPolygon;
typedef BG::model::multi_polygon<BoostPolygon> BoostMultiPolygon;
typedef SB::distance_symmetric<double> DistanceStrategy;
typedef SB::end_round EndStrategy;
typedef SB::join_round JoinStrategy;
typedef SB::point_circle PointStrategy;
typedef SB::side_straight SideStrategy;
typedef std::vector<PNT_2D> StlPolygon;
/////////////////////////////////////////////////////////////
///////////////////////// CODE
BoostMultiPolygon off_polygon;
BoostPolygon polygon;
DistanceStrategy distance_strategy(1.0);
EndStrategy end_strategy;
JoinStrategy join_strategy;
PointStrategy point_strategy;
PNT_2D p2dPunto;
SideStrategy side_strategy;
StlPolygon stlPolygon;
p2dPunto.x = p2dPunto.y = 0.0;
boost::geometry::append(polygon, p2dPunto);
p2dPunto.x = 25.0; p2dPunto.y = 0.0;
boost::geometry::append(polygon, p2dPunto);
p2dPunto.x = 25.0; p2dPunto.y = 25.0;
boost::geometry::append(polygon, p2dPunto);
p2dPunto.x = 0.0; p2dPunto.y = 25.0;
boost::geometry::append(polygon, p2dPunto);
p2dPunto.x = 0.0; p2dPunto.y = 0.0;
boost::geometry::append(polygon, p2dPunto);
boost::geometry::buffer(polygon, off_polygon, distance_strategy, side_strategy, join_strategy, end_strategy, point_strategy);
for (auto poligono = off_polygon.begin(); poligono != off_polygon.end(); poligono++)
{
for (auto punto = poligono->outer().begin(); punto != poligono->outer().end(); punto++)
std::cout << "(" << punto->x << ", " << punto->y << ")" << std::endl;
}
std::cin >> nStaph;
return EXIT_SUCCESS;
现在我有一个错误:
'std::copy::_Unchecked_iterators::_Deprecate': Call to 'std::copy' with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators'
Not in the main project, but in xutility.
- 您提出的代码是缓冲一个框。对于带有多边形的缓冲液,您(当前)需要使用带有缓冲区的策略(请参阅DOC其中一个例子)
- 如果您这样做并提供策略,则结果应为多组合
- 您的样本有效地使用了一个盒子,所以这可能是一种选择也。但是,您的输入几何形状应该满足框概念
相关文章:
- "error: no matching function for call to"构造函数错误
- 什么时候调用组成单元对象的析构函数
- 继承函数的重载解析
- 为什么随机数生成器不在void函数中随机化数字,而在main函数中随机化
- C++模板来检查友元函数的存在
- 递归函数计算序列中的平方和(并输出过程)
- 对RValue对象调用的LValue ref限定成员函数
- C++17复制构造函数,在std::unordereded_map上进行深度复制
- 将数组作为参数传递给函数安全吗?作为第三方职能部门,可以探索他们想要的之外的其他元素
- 在C++STL中是否有Polyval(Matlab函数)等价物?
- 为什么使用 "this" 指针调用派生成员函数?
- 将对象数组的引用传递给函数
- 函数调用中参数的顺序重要吗
- 函数向量_指针有不同的原型,我可以构建一个吗
- 使用不带参数的函数访问结构元素
- 代码在main()中运行,但在函数中出现错误
- 内置函数可查看CPP中的成员变量
- 如何获取std::result_of函数的返回类型
- 使用boost ::几何::缓冲函数
- OpenGL帧缓冲函数不能在单独的类中完全工作