Just starting out with OpenMesh, and I have so far been able to add vertices, and make faces. I now have a problem with understanding how i should add an edge to the mesh.
I am aware of the Half-edge datastructure that openMesh uses, but i can't really understand how i should add the edge..
Code:
Definitions:
Variables in header:
vector<OpenMesh::PolyMesh_ArrayKernelT<OpenMeshExt::MyOwnTraits>::VertexHandle> vHandlers;
OpenMesh::PolyMesh_ArrayKernelT<OpenMeshExt::MyOwnTraits> myMesh;
In cpp:
typedef OpenMesh::PolyMesh_ArrayKernelT<OpenMeshExt::CustomTraits> OpnMesh;
typedef OpnMesh::VertexHandle vertexHandle;
void Mesh::addVertexFromPoint(Point& position){
float x = static_cast <float> (position.x());
float y = static_cast <float> (position.y());
vertexHandle vhand= myMesh.add_vertex(OpnMesh::Point(x,y,.0f));
vHandlers.push_back(vhand);
}
void Mesh::makeFace(){
if(vHandlers.size()<=2){
return;
}
myMesh.add_face(vHandlers);
//Add edges between eg vertex 0 and 1 in vHandlers (vector with VertexHandlers)
}
Have searched the documentation, but can't really say I found the answer..
You don't have to/you can't explicitly create or delete edges. Whenever you modify the mesh e.g. by creating a face with add_face
, the mesh will create (or delete) the necessary (half-)edges. Also, it will adapt the links between the vertices, edges and faces to reflect the topology of your mesh.