Search code examples
c++openmesh

How to get a MeshHandle from a mesh instance in OpenMesh?


I am trying to use this function to compute the center of mass of a mesh structure. This is the signature:

Point   calc_centroid (MeshHandle _mh) const

So it takes a MeshHandle object as a parameter. My question is, how to get such a MeshHandle from a mesh instance? I have a mesh instance defined as

typedef OpenMesh::TriMesh_ArrayKernelT<>  MyMesh;
MyMesh mesh;

however, I seem to be unable to get a MeshHandle to it.


Solution

  • A MeshHandle holds no reference to a mesh instance. You can just create one with a default constructor:

    MyMesh mesh;
    mesh.calc_centroid(OpenMesh::MeshHandle());