刚开始使用 OpenMesh,到目前为止,我已经能够添加顶点和制作面。我现在在理解如何向网格中添加边缘时遇到问题。
我知道openMesh使用的半边数据结构,但我真的不明白我应该如何添加边缘..
代码:
定义:
Variables in header:
vector<OpenMesh::PolyMesh_ArrayKernelT<OpenMeshExt::MyOwnTraits>::VertexHandle> vHandlers;
OpenMesh::PolyMesh_ArrayKernelT<OpenMeshExt::MyOwnTraits> myMesh;
在 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)
}
已经搜索了文档,但不能说我找到了答案..