diff --git a/src/main.cpp b/src/main.cpp index 708bbbc..a5be378 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -89,11 +89,23 @@ void stats_surface_area(MyMesh &mesh) { } +void stats_n_neighbors(MyMesh &mesh) { + for (const VertexHandle &vh : mesh.vertices()) { + unsigned count = 0; + for (auto vv_it = mesh.vv_iter(vh); vv_it.is_valid(); ++vv_it) { + count++; + } + std::cout << count << " "; + } + std::cout << std::endl; +} + + int main(int argc, char *argv[]) { using namespace std; - if (argc != 2) { - cerr << "Utilisation : " << argv[0] << " [fichier.obj]" << endl; + if (argc != 2 && argc != 3) { + cerr << "Utilisation : " << argv[0] << " fichier.obj [surface|valence]" << endl; return 1; } MyMesh mesh; @@ -113,6 +125,12 @@ int main(int argc, char *argv[]) { float area = total_area(mesh); cerr << "Aire totale : " << area << endl; cerr << "Aire moyenne : " << area / mesh.n_faces() << endl; - stats_surface_area(mesh); + if (argc == 3) { + string cmd = argv[2]; + if (cmd == "surface") + stats_surface_area(mesh); + else if (cmd == "valence") + stats_n_neighbors(mesh); + } return 0; }