I've been following the OpenMesh tutorial First Steps - Building a Cube with a few modifications, I'm using a TriMesh instead of a PolyMesh and am building a pyramid instead of a cube.
Somehow, I'm getting the error PolymeshT::add_face:complex edge
for my second and third faces. These faces should be between the points (0,0,0), (0,1,0) and (0,0,1) and the points (0,0,0), (0,0,1), and (1,0,0).
Two edges already exist when each face is constructed (0,0,0) to (0,1,0) and (0,0,0) to (0,0,1), but I should be able to create faces where some of the edges are already existing, shouldn't I?
Solutions I've tried so far
- Changing coordinates
- Using PolyMesh instead of TriMesh
I can't spot anything else that I'm doing differently than the tutorial.
#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());
}