1

Is there a way in OpenMesh to copy element properties in between different mesh instances? copy_all_properties() does copy all element properties from one element to another as described here, however, it is bound to a mesh instance and does not seem to copy anything if the two elements belong to different mesh objects.

I tried the following:

    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;

which outputs:

face1 prop 5
face2 prop 0

so the property does not get copied.

Botond
  • 2,640
  • 6
  • 28
  • 44

1 Answers1

1

I don't think there is a method that copies all properties for a single element from one mesh to another.

mesh1.copy_all_properties(face1, face2) copies all properties of mesh1 from face1 to face2 where both face1 and face2 are considered to be faces of mesh1. So with your call you are copying all properties of the first face to itself.

You can assign mesh1 to mesh2 which will give you a copy of mesh1 in mesh2 which will also contain a copy of all properties.

You can also use mesh2_props = mesh1_props to copy that one property for all faces.

Max
  • 101
  • 4