Hi to all.
Before asking my question I would like to state two important things:
1) My goal is to work with 2d triangular/polygonal meshes, from which i don't see any examples in the documentation. As a starting point I want to create and export (to a .vtk file) a simple 2d polygonal mesh, i.e. just a square.
2) I'm new to the library so this might be a rather broad/general question.
Now, here's what i have tried.
1) I've started with the tutorial "Building a cube". There i have managed to export the mesh to a .vtk file doing the following (variable names follow from the tutorial):
//
typedef OpenMesh::IO::ExporterT<MyMesh> BaseExporter;
BaseExporter be = BaseExporter(mesh);
OpenMesh::IO::Options opt = OpenMesh::IO::Options::Default;
OpenMesh::IO::_VTKWriter_ mywriter;
mywriter.write("output.vtk",be,opt,sizeof(double));
//
2) Now i want to modify this tutorial example to have a single square. To be clear, I want a 2d geometry, not a 3d geometry whose vertices have constant z=0 coordinate. This is how i define the mesh:
//
MyMesh::VertexHandle vhandle[4];
vhandle[0] = mesh.add_vertex(MyMesh::Point(-1, -1));
vhandle[1] = mesh.add_vertex(MyMesh::Point( 1, -1));
vhandle[2] = mesh.add_vertex(MyMesh::Point( 1, 1));
vhandle[3] = mesh.add_vertex(MyMesh::Point(-1, 1));
std::vector<MyMesh::VertexHandle> face_vhandles;
face_vhandles.clear();
face_vhandles.push_back(vhandle[0]);
face_vhandles.push_back(vhandle[1]);
face_vhandles.push_back(vhandle[2]);
face_vhandles.push_back(vhandle[3]);
mesh.add_face(face_vhandles)
//
When i try to compile the code last code i get the following error, amongst many others:
no matching function for call to ‘OpenMesh::VectorT<float, 3>::VectorT(int, int)’ vhandle[0] = mesh.add_vertex(MyMesh::Point(-1, -1));
Now, these are my questions:
1) How can i create a 2d polygonal mesh? I guess i have to give the proper template parameter to type definition on
typedef OpenMesh::PolyMesh_ArrayKernelT<> MyMesh;
but i don't know what to put in there exactly.
2) How is that going to affect the BaseExporter that i use to create the .vtk file? I am asking this because i already manage to create a 2d mesh following what i found in one of the unit tests, namely unittests_polymesh_vec2i.cc, but then i cannot export the mesh following the approach i had used for the cube. So, just in case anyone would suggest that piece of code as an answer to my question.
Any thoughts or suggestions will be greatly appreciated :)
Kind regards,