刚从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)
}已经查过文件了,但不能说我找到了答案。
发布于 2016-07-07 00:24:06
您不必/不能显式地创建或删除边缘。每当你修改网格时,比如用add_face创建一个脸,网格就会创建(或删除)必要的(一半)边缘。同时,它将调整顶点、边和面之间的链接,以反映网格的拓扑结构。
https://stackoverflow.com/questions/38234248
复制相似问题