implements statistics computation on vertex connectivity

This commit is contained in:
ccolin 2020-10-02 11:25:28 +02:00
parent c17e01d366
commit e7caf40445
1 changed files with 21 additions and 3 deletions

View File

@ -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;
}