implements checking for lonely edges

This commit is contained in:
ccolin 2020-10-01 16:32:33 +02:00
parent b748a8d9ae
commit 717603d5d3

View File

@ -1,6 +1,7 @@
#include "my_mesh.h" #include "my_mesh.h"
#include <iostream> #include <iostream>
#include <fstream>
bool check_faces_are_triangles(MyMesh &mesh) { bool check_faces_are_triangles(MyMesh &mesh) {
@ -39,15 +40,15 @@ bool check_vertices_arent_lonely(MyMesh &mesh) {
} }
bool check_edges_arent_lonely(MyMesh &mesh) { bool check_edges_arent_lonely(const char *path) {
MyMesh::HalfedgeHandle heh, heh_init; using namespace std;
heh = heh_init = mesh.halfedge_handle((*mesh.vertices_begin())); ifstream f(path);
heh = mesh.next_halfedge_handle(heh); string line;
while (heh != heh_init) { while (getline(f, line)) {
if (mesh.is_boundary(heh)) { istringstream iss(line);
return false; char first;
} iss >> first;
heh = mesh.next_halfedge_handle(heh); if (first == 'l') return false;
} }
return true; return true;
} }
@ -72,7 +73,7 @@ int main(int argc, char *argv[]) {
<< (check_vertices_arent_lonely(mesh) ? "oui" : "non") << (check_vertices_arent_lonely(mesh) ? "oui" : "non")
<< endl; << endl;
cout << "Les arêtes sont sur une face : " cout << "Les arêtes sont sur une face : "
<< (check_edges_arent_lonely(mesh) ? "oui" : "non") << (check_edges_arent_lonely(argv[1]) ? "oui" : "non")
<< endl; << endl;
return 0; return 0;
} }