Compare commits

..

No commits in common. "c564671b9326ce27b0845816da79d1481fdc42a6" and "c86240455d28d6e51718cae2a155bbd9da3cdfb2" have entirely different histories.

2 changed files with 16 additions and 28 deletions

View File

@ -1,6 +1,6 @@
#include "my_mesh.h" #include "my_mesh.h"
#include <cmath> #include <ctgmath>
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
@ -104,19 +104,7 @@ void stats_n_neighbors(MyMesh &mesh) {
} }
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
static float f(int n, float h, float s, float v) {
float k = fmod(n + h / 60, 6);
return v - v * s * MAX(0, MIN(k, MIN(4 - k, 1)));
}
static OpenMesh::Vec3uc hsv_to_rgb(float h, float s, float v) {
return OpenMesh::Vec3uc {f(5, h, s, v) * 255, f(3, h, s, v) * 255, f(1, h, s, v) * 255};
}
void stats_normal_deviation(MyMesh &mesh) { void stats_normal_deviation(MyMesh &mesh) {
const float s = 1, v = 1, min_h = 50, max_h = 0;
mesh.update_normals(); mesh.update_normals();
for (const VertexHandle &vh : mesh.vertices()) { for (const VertexHandle &vh : mesh.vertices()) {
MyMesh::Normal normal = mesh.normal(vh); MyMesh::Normal normal = mesh.normal(vh);
@ -126,7 +114,6 @@ void stats_normal_deviation(MyMesh &mesh) {
if (angle > max) if (angle > max)
max = angle; max = angle;
} }
mesh.set_color(vh, (MyMesh::Color) hsv_to_rgb(fmod(max * 360 / (max_h - min_h) + max_h, 360), s, v));
std::cout << max << " "; std::cout << max << " ";
} }
std::cout << std::endl; std::cout << std::endl;
@ -169,20 +156,14 @@ int main(int argc, char *argv[]) {
cerr << "Aire moyenne : " << area / mesh.n_faces() << endl; cerr << "Aire moyenne : " << area / mesh.n_faces() << endl;
if (argc == 3) { if (argc == 3) {
string cmd = argv[2]; string cmd = argv[2];
if (cmd == "surface") { if (cmd == "surface")
stats_surface_area(mesh); stats_surface_area(mesh);
} else if (cmd == "valence")
else if (cmd == "valence") {
stats_n_neighbors(mesh); stats_n_neighbors(mesh);
} else if (cmd == "deviation")
else if (cmd == "deviation") {
stats_normal_deviation(mesh); stats_normal_deviation(mesh);
OpenMesh::IO::write_mesh(mesh, "out.ply", else if (cmd == "dièdre")
OpenMesh::IO::Options(OpenMesh::IO::Options::VertexColor));
}
else if (cmd == "dièdre") {
stats_dihedral_angles(mesh); stats_dihedral_angles(mesh);
}
else { else {
cerr << "Commande inconnue : " << cmd << endl; cerr << "Commande inconnue : " << cmd << endl;
return 1; return 1;

View File

@ -10,10 +10,17 @@ using namespace OpenMesh;
using namespace OpenMesh::Attributes; using namespace OpenMesh::Attributes;
struct MyTraits : public OpenMesh::DefaultTraits { struct MyTraits : public OpenMesh::DefaultTraits {
VertexAttributes(OpenMesh::Attributes::Normal | OpenMesh::Attributes::Color); // use vertex normals and vertex colors
HalfedgeAttributes(OpenMesh::Attributes::PrevHalfedge); VertexAttributes( OpenMesh::Attributes::Normal | OpenMesh::Attributes::Color );
FaceAttributes(OpenMesh::Attributes::Normal); // store the previous halfedge
EdgeAttributes(OpenMesh::Attributes::Color); HalfedgeAttributes( OpenMesh::Attributes::PrevHalfedge );
// use face normals face colors
FaceAttributes( OpenMesh::Attributes::Normal | OpenMesh::Attributes::Color );
EdgeAttributes( OpenMesh::Attributes::Color );
// vertex thickness
VertexTraits{float thickness; float value; Color faceShadingColor;};
// edge thickness
EdgeTraits{float thickness;};
}; };
typedef OpenMesh::PolyMesh_ArrayKernelT<MyTraits> MyMesh; typedef OpenMesh::PolyMesh_ArrayKernelT<MyTraits> MyMesh;