Boost失败.几何纠正()
Failure with Boost.Geometry correct()
我正在尝试使用Boost。一个项目的几何学,我遇到了一个奇怪的错误。当我运行这段代码时,它按预期工作:
#include <iostream>
#include <boost/geometry/algorithms/append.hpp>
#include <boost/geometry/algorithms/correct.hpp>
#include <boost/geometry/core/cs.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/polygon.hpp>
#include <boost/geometry/geometries/adapted/c_array.hpp>
BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(boost::geometry::cs::cartesian);
#include <boost/geometry/geometries/adapted/boost_tuple.hpp>
BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(boost::geometry::cs::cartesian)
int main() {
typedef boost::geometry::model::d2::point_xy<double> point_t;
typedef boost::geometry::model::polygon<point_t> polygon_t;
double points_a[][2] = {{0.0, 0.0},
{1.0, 0.0},
{1.0, 1.0},
{0.0, 1.0}};
polygon_t poly_a;
boost::geometry::append(poly_a, points_a);
// boost::geometry::correct(poly_a);
for(point_t p : boost::geometry::exterior_ring(poly_a)) {
std::cout << "(" << boost::geometry::get<0>(p) << ", " << boost::geometry::get<1>(p) << ")" << std::endl;
}
}
当我取消注释正确的()行时,我认为我在追加行中得到了一个错误,这对我来说没有意义。这是我的编译器给我的:
/opt/clion-2016.2.1/bin/cmake/bin/cmake --build /home/my_user_name/.CLion2016.2/system/cmake/generated/my_project_name-82c1f56b/82c1f56b/Debug --target my_project_name -- -j 8
Scanning dependencies of target my_project_name
[ 9%] Building CXX object CMakeFiles/my_project_name.dir/utils/PolygonTest.cpp.o
In file included from /usr/local/boost_1_61_0/boost/concept_check.hpp:27:0,
from /usr/local/boost_1_61_0/boost/range/concepts.hpp:19,
from /usr/local/boost_1_61_0/boost/range/size_type.hpp:20,
from /usr/local/boost_1_61_0/boost/range/size.hpp:21,
from /usr/local/boost_1_61_0/boost/range/functions.hpp:20,
from /usr/local/boost_1_61_0/boost/range.hpp:18,
from /usr/local/boost_1_61_0/boost/geometry/algorithms/append.hpp:24,
from /home/my_user_name/ClionProjects/my_project_name/utils/PolygonTest.cpp:7:
/usr/local/boost_1_61_0/boost/geometry/strategies/area.hpp: In instantiation of ‘struct boost::geometry::strategy::area::services::default_strategy<boost::geometry::cartesian_tag, boost::geometry::model::d2::point_xy<double> >’:
/usr/local/boost_1_61_0/boost/geometry/strategies/default_area_result.hpp:42:17: required from ‘struct boost::geometry::default_area_result<boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double> > >’
/usr/local/boost_1_61_0/boost/geometry/algorithms/correct.hpp:177:57: required from ‘struct boost::geometry::detail::correct::correct_polygon<boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double> > >’
/usr/local/boost_1_61_0/boost/geometry/algorithms/correct.hpp:245:8: required from ‘struct boost::geometry::dispatch::correct<boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double> >, boost::geometry::polygon_tag>’
/usr/local/boost_1_61_0/boost/geometry/algorithms/correct.hpp:287:43: required from ‘static void boost::geometry::resolve_variant::correct<Geometry>::apply(Geometry&) [with Geometry = boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double> >]’
/usr/local/boost_1_61_0/boost/geometry/algorithms/correct.hpp:328:46: required from ‘void boost::geometry::correct(Geometry&) [with Geometry = boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double> >]’
/home/my_user_name/ClionProjects/my_project_name/utils/PolygonTest.cpp:30:36: required from here
/usr/local/boost_1_61_0/boost/mpl/assert.hpp:429:42: error: no matching function for call to ‘assertion_failed(mpl_::failed************ (boost::geometry::strategy::area::services::default_strategy<boost::geometry::cartesian_tag, boost::geometry::model::d2::point_xy<double> >::NOT_IMPLEMENTED_FOR_THIS_POINT_TYPE::************)(mpl_::assert_::types<boost::geometry::model::d2::point_xy<double>, mpl_::na, mpl_::na, mpl_::na>))’
boost::mpl::assertion_failed<(c)>( BOOST_PP_CAT(mpl_assert_arg,counter)::assert_arg() )
^
/usr/local/boost_1_61_0/boost/mpl/assert.hpp:60:58: note: in definition of macro ‘BOOST_MPL_AUX_ASSERT_CONSTANT’
# define BOOST_MPL_AUX_ASSERT_CONSTANT(T, expr) enum { expr }
^
/usr/local/boost_1_61_0/boost/mpl/assert.hpp:436:1: note: in expansion of macro ‘BOOST_MPL_ASSERT_MSG_IMPL’
BOOST_MPL_ASSERT_MSG_IMPL( BOOST_MPL_AUX_PP_COUNTER(), c, msg, types_ )
^
/usr/local/boost_1_61_0/boost/geometry/strategies/area.hpp:37:5: note: in expansion of macro ‘BOOST_MPL_ASSERT_MSG’
BOOST_MPL_ASSERT_MSG
^
/usr/local/boost_1_61_0/boost/mpl/assert.hpp:83:5: [01;36mnote: candidate: template<bool C> int mpl_::assertion_failed(typename mpl_::assert<C>::type)
int assertion_failed( typename assert<C>::type );
^
/usr/local/boost_1_61_0/boost/mpl/assert.hpp:83:5: note: template argument deduction/substitution failed:
/usr/local/boost_1_61_0/boost/mpl/assert.hpp:429:92: note: cannot convert ‘boost::geometry::strategy::area::services::default_strategy<Tag, PointOfSegment>::NOT_IMPLEMENTED_FOR_THIS_POINT_TYPE41::assert_arg<boost::geometry::cartesian_tag, boost::geometry::model::d2::point_xy<double> >()’ (type ‘mpl_::failed************ (boost::geometry::strategy::area::services::default_strategy<boost::geometry::cartesian_tag, boost::geometry::model::d2::point_xy<double> >::NOT_IMPLEMENTED_FOR_THIS_POINT_TYPE::************)(mpl_::assert_::types<boost::geometry::model::d2::point_xy<double>, mpl_::na, mpl_::na, mpl_::na>)’) to type ‘mpl_::assert<false>::type {aka mpl_::assert<false>}’
boost::mpl::assertion_failed<(c)>( BOOST_PP_CAT(mpl_assert_arg,counter)::assert_arg() )
^
/usr/local/boost_1_61_0/boost/mpl/assert.hpp:60:58: note: in definition of macro ‘BOOST_MPL_AUX_ASSERT_CONSTANT’
# define BOOST_MPL_AUX_ASSERT_CONSTANT(T, expr) enum { expr }
^
/usr/local/boost_1_61_0/boost/mpl/assert.hpp:436:1: note: in expansion of macro ‘BOOST_MPL_ASSERT_MSG_IMPL’
BOOST_MPL_ASSERT_MSG_IMPL( BOOST_MPL_AUX_PP_COUNTER(), c, msg, types_ )
^
/usr/local/boost_1_61_0/boost/geometry/strategies/area.hpp:37:5: note: in expansion of macro ‘BOOST_MPL_ASSERT_MSG’
BOOST_MPL_ASSERT_MSG
^
In file included from /usr/local/boost_1_61_0/boost/geometry/algorithms/area.hpp:42:0,
from /usr/local/boost_1_61_0/boost/geometry/algorithms/correct.hpp:43,
from /home/my_user_name/ClionProjects/my_project_name/utils/PolygonTest.cpp:8:
/usr/local/boost_1_61_0/boost/geometry/strategies/default_area_result.hpp: In instantiation of ‘struct boost::geometry::default_area_result<boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double> > >’:
/usr/local/boost_1_61_0/boost/geometry/algorithms/correct.hpp:177:57: required from ‘struct boost::geometry::detail::correct::correct_polygon<boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double> > >’
/usr/local/boost_1_61_0/boost/geometry/algorithms/correct.hpp:245:8: required from ‘struct boost::geometry::dispatch::correct<boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double> >, boost::geometry::polygon_tag>’
/usr/local/boost_1_61_0/boost/geometry/algorithms/correct.hpp:287:43: required from ‘static void boost::geometry::resolve_variant::correct<Geometry>::apply(Geometry&) [with Geometry = boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double> >]’
/usr/local/boost_1_61_0/boost/geometry/algorithms/correct.hpp:328:46: required from ‘void boost::geometry::correct(Geometry&) [with Geometry = boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double> >]’
/home/my_user_name/ClionProjects/my_project_name/utils/PolygonTest.cpp:30:36: required from here
/usr/local/boost_1_61_0/boost/geometry/strategies/default_area_result.hpp:42:17: error: no type named ‘type’ in ‘struct boost::geometry::strategy::area::services::default_strategy<boost::geometry::cartesian_tag, boost::geometry::model::d2::point_xy<double> >’
>::type strategy_type;
^
CMakeFiles/my_project_name.dir/build.make:278: recipe for target 'CMakeFiles/my_project_name.dir/utils/PolygonTest.cpp.o' failed
make[3]: *** [CMakeFiles/my_project_name.dir/utils/PolygonTest.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/my_project_name.dir/all' failed
make[2]: *** [CMakeFiles/my_project_name.dir/all] Error 2
CMakeFiles/Makefile2:79: recipe for target 'CMakeFiles/my_project_name.dir/rule' failed
make[1]: *** [CMakeFiles/my_project_name.dir/rule] Error 2
Makefile:118: recipe for target 'my_project_name' failed
make: *** [my_project_name] Error 2
我在Ubuntu上使用CLion,如果有帮助的话。
谢谢!
编辑:我刚刚想出了解决办法!从下面的评论中,我意识到我必须在boost/geometry.hpp中寻找为point_xy定义区域策略的地方,并且我找到了boost/geometry/strategies/strategies.hpp,其中包含了解决问题的内容。没有区域策略:
/usr/local/boost_1_61_0/boost/mpl/assert.hpp:429:42: error: no matching function for call to
‘assertion_failed(mpl_::failed************
(boost::geometry::strategy::area::services::default_strategy<boost::geometry::cartesian_tag, boost::geometry::model::d2::point_xy<double> >::NOT_IMPLEMENTED_FOR_THIS_POINT_TYPE::************)(mpl_::assert_::types<boost::geometry::model::d2::point_xy<double>, mpl_::na, mpl_::na, mpl_::na>))’
boost::mpl::assertion_failed<(c)>( BOOST_PP_CAT(mpl_assert_arg,counter)::assert_arg() )
只需添加
#include <boost/geometry.hpp>
而不是显式地包含算法
相关文章:
- 如果没有malloc,链表实现将失败
- 模板参数替换失败,并且未完成隐式转换
- 具有默认模板参数的多态类的模板推导失败
- 视图中的参数推导失败:take_while
- 链接到自行创建的dll失败
- 带有特殊路径部分的"std::filesystem::weakly_canonical"失败
- 函数何时会在c++中包含stack_Unwind_Resume调用
- GetShortPathName在网络驱动器上使用中文文件夹时失败
- gcc和c++17的过载解析失败
- 为什么使用 P/Invoke 调用 dll 时,某些计算机中的 LoadLibrary 失败?
- 在WSL:configure_file上对config_file的每次调用都失败:配置文件时出现问题
- 使用 GCC 卸载的 OpenMP 卸载失败,并出现"Ptx assembly aborted due to errors"
- 使用cmake从源代码构建MySQL连接器/C++失败(与以前的声明冲突)
- 链接阶段在Ubuntu上失败,但在MacOS上失败
- 从父数组测试用例构造二叉树失败
- LibGit2 SSH身份验证失败
- 如何让LLDB在成功时退出,在失败时等待
- VS2017,C++包含目录与附加包含目录,子文件夹包含失败-但为什么
- Python中的for循环与C++有何不同
- Boost失败.几何纠正()