implements triangle face check (poorly)

This commit is contained in:
ccolin 2020-09-23 15:06:06 +02:00
parent 54f87ce8d7
commit 6f60dc6173
2 changed files with 24 additions and 3 deletions

View File

@ -3,6 +3,20 @@
#include <iostream> #include <iostream>
bool check_faces_are_triangles(MyMesh &mesh) {
for (auto f_it = mesh.faces_begin(); f_it != mesh.faces_end(); ++f_it) {
size_t n_edges = 0;
for (auto fe_it = mesh.fe_iter(*f_it); fe_it.is_valid(); ++fe_it) {
n_edges++;
}
if (n_edges != 3) {
return false;
}
}
return true;
}
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
using namespace std; using namespace std;
@ -12,6 +26,13 @@ int main(int argc, char *argv[]) {
} }
MyMesh mesh; MyMesh mesh;
OpenMesh::IO::read_mesh(mesh, argv[1]); OpenMesh::IO::read_mesh(mesh, argv[1]);
cout << "Les faces sont des triangles : ";
if (check_faces_are_triangles(mesh)) {
cout << "oui";
}
else {
cout << "non";
}
cout << endl;
return 0; return 0;
} }

View File

@ -2,7 +2,7 @@
#define MY_MESH_H #define MY_MESH_H
#include <OpenMesh/Core/IO/MeshIO.hh> #include <OpenMesh/Core/IO/MeshIO.hh>
#include <OpenMesh/Core/Mesh/TriMesh_ArrayKernelT.hh> #include <OpenMesh/Core/Mesh/PolyMesh_ArrayKernelT.hh>
#include <OpenMesh/Core/Geometry/VectorT.hh> #include <OpenMesh/Core/Geometry/VectorT.hh>
@ -22,7 +22,7 @@ struct MyTraits : public OpenMesh::DefaultTraits {
// edge thickness // edge thickness
EdgeTraits{float thickness;}; EdgeTraits{float thickness;};
}; };
typedef OpenMesh::TriMesh_ArrayKernelT<MyTraits> MyMesh; typedef OpenMesh::PolyMesh_ArrayKernelT<MyTraits> MyMesh;
#endif #endif