今天直接编译老师给的材料里几年前的代码,用的是OpenMesh 7.1的库,在 handle() 函数中遇到了“This function clutters your code. Use dereferencing operators -> and * instead.”的问题,搜索发现网上的解答不多,而且大多OpenMesh的教程都是前几年的,比较过时了。按照提示改代码后解决了,但由此引出了不少相关的问题,大多是之前的函数在 OpenMesh7 中不再支持的原因。在这里总结一下两个现在已经deprecated的函数。
1. handle()
示例代码:
//输出所有的顶点
for (auto it = mesh.vertices_begin(); it != mesh.vertices_end(); it++)
{
auto point = mesh.point(it.handle());//这里会报错,应该改成auto point = mesh.point(*it);
std::cout << point[0] << "," << point[1] << "," << point[2] << std::endl;
}
在这里,it是迭代器,但mesh.point(it.handle())这里会报错“This function clutters your code. Use dereferencing operators -> and * instead.”,让你不要再用 handle(),而是用*。也就是把it.handle()改成 *it,就可以了,这两句代