Я впервые использую библиотеки надстроек, поэтому мне это неудобно, и я могу что-то делать не так.У меня возникают некоторые проблемы при использовании функции 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.