From 6f60dc61735b1227d96511e13da6f10289264f5d Mon Sep 17 00:00:00 2001 From: ccolin Date: Wed, 23 Sep 2020 15:06:06 +0200 Subject: [PATCH] implements triangle face check (poorly) --- src/main.cpp | 23 ++++++++++++++++++++++- src/my_mesh.h | 4 ++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index dd0671c..0b2845d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,6 +3,20 @@ #include +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[]) { using namespace std; @@ -12,6 +26,13 @@ int main(int argc, char *argv[]) { } MyMesh mesh; 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; } diff --git a/src/my_mesh.h b/src/my_mesh.h index 0ca0ce0..e48fa14 100644 --- a/src/my_mesh.h +++ b/src/my_mesh.h @@ -2,7 +2,7 @@ #define MY_MESH_H #include -#include +#include #include @@ -22,7 +22,7 @@ struct MyTraits : public OpenMesh::DefaultTraits { // edge thickness EdgeTraits{float thickness;}; }; -typedef OpenMesh::TriMesh_ArrayKernelT MyMesh; +typedef OpenMesh::PolyMesh_ArrayKernelT MyMesh; #endif