Vector operations on Vertices
I am trying to do arithmetic on vertices, such as finding the distance between two vertices, but cannot find a method that is supported. geometrycentral::surface::Vertex does not seem to define vertex coordinates, nor are arithmetic operations defined. I also tried converting to geomectrycentral::Vector3, but that does not seem possible either. Is there a way to do this?
The Vertex objects in geometry-central are just logical handles, which represent an element in the mesh connectivity. The geometry is stored separately, for instance in the VertexPositionGeometry you get back when loading a mesh from file. We use this architecture to allow techniques like associating multiple sets of positions with a single mesh, or defining geometry by data other than vertex positions.
To get a vertex position, do something like
SurfaceMesh& mesh;
VertexPositionGeometry& geometry; // you probably have this from however you got the mesh
for(Vertex v : mesh.vertices()) {
Vector3& pos = geometry.inputVertexPositions[v];
// do stuff
}
Thanks so much, this is very helpful. Is there a way to create the mesh from a shape_msgs::Mesh? Or does it have to be from a file?