diff --git a/src/main.cpp b/src/main.cpp index feb3cab..24b30ec 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -26,6 +26,12 @@ bool check_faces_arent_lonely(MyMesh &mesh) { } return true; } + + +bool check_vertices_arent_lonely(MyMesh &mesh) { + for (auto v_it = mesh.vertices_begin(); v_it != mesh.vertices_end(); ++v_it) { + auto ve_it = mesh.ve_iter(*v_it); + if (!ve_it.is_valid()) { return false; } } @@ -33,6 +39,20 @@ bool check_faces_arent_lonely(MyMesh &mesh) { } +bool check_edges_arent_lonely(MyMesh &mesh) { + MyMesh::HalfedgeHandle heh, heh_init; + heh = heh_init = mesh.halfedge_handle((*mesh.vertices_begin())); + heh = mesh.next_halfedge_handle(heh); + while (heh != heh_init) { + if (mesh.is_boundary(heh)) { + return false; + } + heh = mesh.next_halfedge_handle(heh); + } + return true; +} + + int main(int argc, char *argv[]) { using namespace std; @@ -42,22 +62,17 @@ 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; - - cout << "Les faces ont des voisines : "; - if (check_faces_arent_lonely(mesh)) { - cout << "oui"; - } - else { - cout << "non"; - } - cout << endl; + cout << "Les faces sont des triangles : " + << (check_faces_are_triangles(mesh) ? "oui" : "non") + << endl; + cout << "Les faces ont des voisines : " + << (check_faces_arent_lonely(mesh) ? "oui" : "non") + << endl; + cout << "Les sommets sont sur une arête : " + << (check_vertices_arent_lonely(mesh) ? "oui" : "non") + << endl; + cout << "Les arêtes sont sur une face : " + << (check_edges_arent_lonely(mesh) ? "oui" : "non") + << endl; return 0; }