OpenMesh 中有没有办法在不同的网格实例之间复制元素属性?确实如此处copy_all_properties()
所述将所有元素属性从一个元素复制到另一个元素,但是,它绑定到一个网格实例,并且如果两个元素属于不同的网格对象,它似乎不会复制任何内容。
我尝试了以下方法:
MyMesh mesh1, mesh2;
std::vector<MyMesh::VertexHandle> vhandles;
MyMesh::FaceHandle face1, face2;
auto mesh1_props = OpenMesh::FProp<int>(mesh1, "face_props");
auto mesh2_props = OpenMesh::FProp<int>(mesh2, "face_props");
vhandles.push_back(mesh1.add_vertex(MyMesh::Point(0,0,0)));
vhandles.push_back(mesh1.add_vertex(MyMesh::Point(0,1,0)));
vhandles.push_back(mesh1.add_vertex(MyMesh::Point(1,0,0)));
face1 = mesh1.add_face(vhandles);
mesh1_props[face1] = 5;
vhandles.clear();
vhandles.push_back(mesh2.add_vertex(MyMesh::Point(0,0,0)));
vhandles.push_back(mesh2.add_vertex(MyMesh::Point(0,1,0)));
vhandles.push_back(mesh2.add_vertex(MyMesh::Point(1,0,0)));
face2 = mesh2.add_face(vhandles);
mesh1.copy_all_properties(face1, face2);
std::cout<<"face1 prop "<<mesh1_props[face1]<<std::endl;
std::cout<<"face2 prop "<<mesh2_props[face2]<<std::endl;
输出:
face1 prop 5
face2 prop 0
所以该属性不会被复制。