我一直在关注 OpenMesh 教程First Steps - Building a Cube并进行了一些修改,我使用 TriMesh 而不是 PolyMesh,并且正在构建金字塔而不是立方体。
不知何故,我的PolymeshT::add_face:complex edge
第二张和第三张脸出现了错误。这些面应位于点 (0,0,0)、(0,1,0) 和 (0,0,1) 与点 (0,0,0)、(0,0,1) 和(1,0,0)。
当每个面构造为 (0,0,0) 到 (0,1,0) 和 (0,0,0) 到 (0,0,1) 时,两条边已经存在,但我应该能够创建面一些边缘已经存在,不是吗?
到目前为止我尝试过的解决方案
- 改变坐标
- 使用 PolyMesh 代替 TriMesh
我找不到与教程不同的任何其他内容。
#include <OpenMesh/Core/IO/MeshIO.hh>
#include <OpenMesh/Core/Mesh/TriMesh_ArrayKernelT.hh>
typedef OpenMesh::TriMesh_ArrayKernelT<> MyTriMesh;
// Make a pyramid
int main()
{
MyTriMesh tin;
// generate vertices
MyTriMesh::VertexHandle vhandle[4];
vhandle[0] = tin.add_vertex(MyTriMesh::Point(0, 0, 0));
vhandle[1] = tin.add_vertex(MyTriMesh::Point(0, 1, 0));
vhandle[2] = tin.add_vertex(MyTriMesh::Point(1, 0, 0));
vhandle[3] = tin.add_vertex(MyTriMesh::Point(0, 0, 1));
// generate (trianglar) faces
std::vector<MyTriMesh::VertexHandle> face_vhandles;
face_vhandles.clear();
face_vhandles.push_back(vhandle[0]);
face_vhandles.push_back(vhandle[1]);
face_vhandles.push_back(vhandle[2]);
tin.add_face(face_vhandles);
printf("Vertices: %u\nEdges: %u\nTriangles: %u\n",
tin.n_vertices(), tin.n_edges(), tin.n_faces());
face_vhandles.clear();
face_vhandles.push_back(vhandle[0]);
face_vhandles.push_back(vhandle[1]);
face_vhandles.push_back(vhandle[3]);
tin.add_face(face_vhandles);
printf("Vertices: %u\nEdges: %u\nTriangles: %u\n",
tin.n_vertices(), tin.n_edges(), tin.n_faces());
face_vhandles.clear();
face_vhandles.push_back(vhandle[0]);
face_vhandles.push_back(vhandle[3]);
face_vhandles.push_back(vhandle[2]);
tin.add_face(face_vhandles);
printf("Vertices: %u\nEdges: %u\nTriangles: %u\n",
tin.n_vertices(), tin.n_edges(), tin.n_faces());
face_vhandles.clear();
face_vhandles.push_back(vhandle[1]);
face_vhandles.push_back(vhandle[3]);
face_vhandles.push_back(vhandle[2]);
tin.add_face(face_vhandles);
printf("Vertices: %u\nEdges: %u\nTriangles: %u\n",
tin.n_vertices(), tin.n_edges(), tin.n_faces());
}