implements statistics computation on vertex connectivity

This commit is contained in:
ccolin 2020-10-02 11:25:28 +02:00
parent c17e01d366
commit e7caf40445

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[]) { int main(int argc, char *argv[]) {
using namespace std; using namespace std;
if (argc != 2) { if (argc != 2 && argc != 3) {
cerr << "Utilisation: " << argv[0] << " [fichier.obj]" << endl; cerr << "Utilisation: " << argv[0] << " fichier.obj [surface|valence]" << endl;
return 1; return 1;
} }
MyMesh mesh; MyMesh mesh;
@ -113,6 +125,12 @@ int main(int argc, char *argv[]) {
float area = total_area(mesh); float area = total_area(mesh);
cerr << "Aire totale : " << area << endl; cerr << "Aire totale : " << area << endl;
cerr << "Aire moyenne : " << area / mesh.n_faces() << endl; cerr << "Aire moyenne : " << area / mesh.n_faces() << endl;
if (argc == 3) {
string cmd = argv[2];
if (cmd == "surface")
stats_surface_area(mesh); stats_surface_area(mesh);
else if (cmd == "valence")
stats_n_neighbors(mesh);
}
return 0; return 0;
} }