使用boost :: geometry :: buffer函数

问题描述 投票:0回答:1

这是我第一次使用boost库,所以我对它很不舒服,我可能做错了。我在使用boost :: geometry :: buffer()函数时遇到了一些问题。

这是我的代码:

#include <vector>
#include <boost\geometry.hpp>
#include <boost\geometry\geometries\register\point.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.
c++ boost boost-geometry
1个回答
1
投票
  • 您提供的代码是缓冲一个框。对于具有多边形的缓冲区,您(当前)需要使用缓冲区与策略(请参阅doc及其中的示例)
  • 如果您这样做并提供策略,结果应该是多边形
  • 您的样本实际上是使用一个盒子,所以这也许是一个选项。但是,您的输入几何应该符合框概念
© www.soinside.com 2019 - 2024. All rights reserved.