Compare commits
3 Commits
c97e80929e
...
0d285db809
Author | SHA1 | Date | |
---|---|---|---|
0d285db809 | |||
1d88c993b9 | |||
1d1f2c22f7 |
@ -1,5 +1,6 @@
|
|||||||
#include "curvature.h"
|
#include "curvature.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include <OpenMesh/Core/Utils/PropertyManager.hh>
|
||||||
|
|
||||||
|
|
||||||
void Courbures::normales_locales() {
|
void Courbures::normales_locales() {
|
||||||
@ -9,7 +10,7 @@ void Courbures::normales_locales() {
|
|||||||
MyMesh::Normal normal(0,0,0);
|
MyMesh::Normal normal(0,0,0);
|
||||||
i = 0;
|
i = 0;
|
||||||
for (MyMesh::FaceHandle vf : _mesh.vf_range(vh)) {
|
for (MyMesh::FaceHandle vf : _mesh.vf_range(vh)) {
|
||||||
i++ ;
|
i++;
|
||||||
normal += _mesh.calc_face_normal(vf);
|
normal += _mesh.calc_face_normal(vf);
|
||||||
}
|
}
|
||||||
if (i != 0) {
|
if (i != 0) {
|
||||||
@ -21,43 +22,36 @@ void Courbures::normales_locales() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<MyMesh::VertexHandle> Courbures::get_two_neighborhood(const MyMesh::VertexHandle vh) {
|
void Courbures::get_two_neighborhood(std::vector<MyMesh::VertexHandle> &out,
|
||||||
OpenMesh::VPropHandleT<bool> vprop_flag;
|
const MyMesh::VertexHandle vh) {
|
||||||
_mesh.add_property(vprop_flag, "vprop_flag");
|
auto flag_prop =
|
||||||
|
OpenMesh::getOrMakeProperty<VertexHandle, bool>(_mesh, "vprop_flag");
|
||||||
|
flag_prop.set_range(_mesh.vertices_begin(), _mesh.vertices_end(), false);
|
||||||
|
|
||||||
// Initialisation
|
// Parcours du 1-anneau
|
||||||
for (VertexHandle vh : _mesh.vertices()) {
|
flag_prop[vh] = true;
|
||||||
_mesh.property(vprop_flag, vh) = false;
|
|
||||||
}
|
|
||||||
// Circulateur sur le premier cercle
|
|
||||||
std::vector<MyMesh::VertexHandle> neigh, neigh2;
|
|
||||||
|
|
||||||
_mesh.property(vprop_flag, vh) = true;
|
|
||||||
for(VertexHandle vv : _mesh.vv_range(vh)) {
|
for(VertexHandle vv : _mesh.vv_range(vh)) {
|
||||||
neigh.push_back(vv); // ajout du point à la liste
|
out.push_back(vv); // ajout du point à la liste
|
||||||
_mesh.property(vprop_flag, vv) = true;
|
flag_prop[vv] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parcours du premier cercle et ajout du second cercle par circulateurs
|
// Parcours du 1-anneau de chaque sommet du 1-anneau
|
||||||
for (size_t i = 0; i < neigh.size(); i++) {
|
size_t old_size = out.size();
|
||||||
MyMesh::VertexHandle vh = neigh.at(i) ;
|
for (size_t i = 0; i < old_size; i++) {
|
||||||
for (VertexHandle vv : _mesh.vv_range(vh)) {
|
for (VertexHandle vv : _mesh.vv_range(out[i])) {
|
||||||
if (!_mesh.property(vprop_flag, vv)) {
|
if (!flag_prop[vv]) {
|
||||||
neigh2.push_back(vv);
|
out.push_back(vv);
|
||||||
|
flag_prop[vv] = true;
|
||||||
}
|
}
|
||||||
_mesh.property(vprop_flag, vv) = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Concaténation des deux cercles
|
|
||||||
neigh.insert(neigh.end(), neigh2.begin(), neigh2.end());
|
|
||||||
_mesh.remove_property(vprop_flag);
|
|
||||||
return neigh;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QuadPatch Courbures::fit_quad(MyMesh::VertexHandle vh) {
|
QuadPatch Courbures::fit_quad(MyMesh::VertexHandle vh) {
|
||||||
std::vector<MyMesh::VertexHandle> neigh = get_two_neighborhood(vh);
|
static std::vector<MyMesh::VertexHandle> neigh;
|
||||||
|
neigh.clear();
|
||||||
|
get_two_neighborhood(neigh, vh);
|
||||||
if (neigh.size() < 5) throw "Quad fitting: not enough neighbors";
|
if (neigh.size() < 5) throw "Quad fitting: not enough neighbors";
|
||||||
|
|
||||||
// Calcul de la matrice de changement de base
|
// Calcul de la matrice de changement de base
|
||||||
|
@ -16,12 +16,13 @@ public:
|
|||||||
|
|
||||||
Courbures(MyMesh &mesh) : _mesh(mesh) {}
|
Courbures(MyMesh &mesh) : _mesh(mesh) {}
|
||||||
|
|
||||||
void set_fixed_colors() ;
|
void set_fixed_colors();
|
||||||
void normales_locales() ;
|
void normales_locales();
|
||||||
std::vector<MyMesh::VertexHandle> get_two_neighborhood(MyMesh::VertexHandle vh);
|
void get_two_neighborhood(std::vector<MyMesh::VertexHandle> &out,
|
||||||
|
MyMesh::VertexHandle vh);
|
||||||
QuadPatch fit_quad(MyMesh::VertexHandle vh);
|
QuadPatch fit_quad(MyMesh::VertexHandle vh);
|
||||||
void compute_KH() ;
|
void compute_KH();
|
||||||
void set_K_colors() ;
|
void set_K_colors();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ void MeshViewer::removeMesh(const MyMesh &mesh) {
|
|||||||
|
|
||||||
|
|
||||||
void MeshViewer::mousePressEvent(QMouseEvent *e) {
|
void MeshViewer::mousePressEvent(QMouseEvent *e) {
|
||||||
if (e->button() == Qt::LeftButton) {
|
if (e->button() == Qt::MiddleButton) {
|
||||||
mouse_pos = e->pos();
|
mouse_pos = e->pos();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -116,7 +116,7 @@ void MeshViewer::mouseReleaseEvent(QMouseEvent *e) {
|
|||||||
|
|
||||||
|
|
||||||
void MeshViewer::mouseMoveEvent(QMouseEvent *e) {
|
void MeshViewer::mouseMoveEvent(QMouseEvent *e) {
|
||||||
if (e->buttons() & Qt::LeftButton) {
|
if (e->buttons() & Qt::MiddleButton) {
|
||||||
QPoint delta = e->pos() - mouse_pos;
|
QPoint delta = e->pos() - mouse_pos;
|
||||||
rot = rot_start;
|
rot = rot_start;
|
||||||
rot.rotate(delta.x() / 5., 0, 1, 0);
|
rot.rotate(delta.x() / 5., 0, 1, 0);
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
|
|
||||||
MyMesh tesselate_quad_patch(QuadPatch q, MyMesh mesh, VertexHandle vh) {
|
MyMesh tesselate_quad_patch(QuadPatch q, MyMesh mesh, VertexHandle vh) {
|
||||||
|
const size_t patch_divs = 8;
|
||||||
MyMesh patch;
|
MyMesh patch;
|
||||||
Eigen::Vector3d point
|
Eigen::Vector3d point
|
||||||
(mesh.point(vh)[0], mesh.point(vh)[1], mesh.point(vh)[2]);
|
(mesh.point(vh)[0], mesh.point(vh)[1], mesh.point(vh)[2]);
|
||||||
@ -17,10 +18,10 @@ MyMesh tesselate_quad_patch(QuadPatch q, MyMesh mesh, VertexHandle vh) {
|
|||||||
ymin = std::min(ymin, point[1]);
|
ymin = std::min(ymin, point[1]);
|
||||||
ymax = std::max(ymax, point[1]);
|
ymax = std::max(ymax, point[1]);
|
||||||
}
|
}
|
||||||
double xstep = (xmax-xmin)/64.;
|
double xstep = (xmax-xmin)/static_cast<double>(patch_divs);
|
||||||
double ystep = (ymax-ymin)/64.;
|
double ystep = (ymax-ymin)/static_cast<double>(patch_divs);
|
||||||
for (size_t y = 0; y < 64; y++) {
|
for (size_t y = 0; y < patch_divs; y++) {
|
||||||
for (size_t x = 0; x < 64; x++) {
|
for (size_t x = 0; x < patch_divs; x++) {
|
||||||
double dx = xmin + x * xstep;
|
double dx = xmin + x * xstep;
|
||||||
double dy = ymin + y * ystep;
|
double dy = ymin + y * ystep;
|
||||||
Eigen::Vector3d point(dx, dy, -q(dx, dy));
|
Eigen::Vector3d point(dx, dy, -q(dx, dy));
|
||||||
@ -31,14 +32,14 @@ MyMesh tesselate_quad_patch(QuadPatch q, MyMesh mesh, VertexHandle vh) {
|
|||||||
for (VertexHandle vhi : patch.vertices()) {
|
for (VertexHandle vhi : patch.vertices()) {
|
||||||
patch.set_color(vhi, MyMesh::Color(0, 1, .2));
|
patch.set_color(vhi, MyMesh::Color(0, 1, .2));
|
||||||
size_t i = vhi.idx();
|
size_t i = vhi.idx();
|
||||||
size_t x = i % 64;
|
size_t x = i % patch_divs;
|
||||||
size_t y = i / 64;
|
size_t y = i / patch_divs;
|
||||||
if (x == 63 || y == 63) continue;
|
if (x == patch_divs - 1 || y == patch_divs - 1) continue;
|
||||||
patch.add_face(vhi, patch.vertex_handle(i + 64),
|
patch.add_face(vhi, patch.vertex_handle(i + patch_divs),
|
||||||
patch.vertex_handle(i + 1));
|
patch.vertex_handle(i + 1));
|
||||||
patch.add_face(patch.vertex_handle(i + 1),
|
patch.add_face(patch.vertex_handle(i + 1),
|
||||||
patch.vertex_handle(i + 64),
|
patch.vertex_handle(i + patch_divs),
|
||||||
patch.vertex_handle(i + 65));
|
patch.vertex_handle(i + patch_divs + 1));
|
||||||
}
|
}
|
||||||
return patch;
|
return patch;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user