smoothing tweaks
This commit is contained in:
parent
a15cb96e2e
commit
068dede832
@ -42,8 +42,9 @@ Point laplace_beltrami(const MyMesh &mesh, VertexHandle vert) {
|
|||||||
area += triangle_area(p, pi, pb);
|
area += triangle_area(p, pi, pb);
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
area /= 3.;
|
// area /= 3.;
|
||||||
return sum / (2.*count);
|
// return sum / (2.*area);
|
||||||
|
return sum / count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -73,46 +74,48 @@ Eigen::SparseMatrix<qreal> laplacian_matrix(const MyMesh &mesh) {
|
|||||||
area += triangle_area(p, pi, pb);
|
area += triangle_area(p, pi, pb);
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
area /= 3.;
|
// area /= 3.;
|
||||||
cotangent.insert(vert.idx(), vert.idx()) = -sum;
|
cotangent.insert(vert.idx(), vert.idx()) = -sum;
|
||||||
mass.insert(vert.idx(), vert.idx()) = 1. / area;
|
mass.insert(vert.idx(), vert.idx()) = 1. / (4. * area);
|
||||||
|
// mass.insert(vert.idx(), vert.idx()) = 1. / count;
|
||||||
}
|
}
|
||||||
return mass * cotangent;
|
return mass * cotangent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void smooth(MyMesh &mesh) {
|
void smooth(MyMesh &mesh) {
|
||||||
// auto new_pos = OpenMesh::makeTemporaryProperty<VertexHandle, Point>(mesh);
|
auto new_pos = OpenMesh::makeTemporaryProperty<VertexHandle, Point>(mesh);
|
||||||
// for (VertexHandle v : mesh.vertices()) {
|
for (VertexHandle v : mesh.vertices()) {
|
||||||
// if (!mesh.is_boundary(v)) {
|
if (!mesh.is_boundary(v)) {
|
||||||
// new_pos[v] = mesh.point(v) - laplace_beltrami(mesh, v);
|
new_pos[v] = mesh.point(v) - laplace_beltrami(mesh, v);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// for (VertexHandle v : mesh.vertices()) {
|
for (VertexHandle v : mesh.vertices()) {
|
||||||
// if (!mesh.is_boundary(v)) {
|
if (!mesh.is_boundary(v)) {
|
||||||
// mesh.set_point(v, new_pos[v]);
|
mesh.set_point(v, new_pos[v]);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// Approche matricielle
|
// // Approche matricielle
|
||||||
Eigen::SparseMatrix<qreal> laplacian = laplacian_matrix(mesh);
|
// Eigen::SparseMatrix<qreal> laplacian = laplacian_matrix(mesh);
|
||||||
size_t n_verts = mesh.n_vertices();
|
// // laplacian = laplacian * laplacian;
|
||||||
Eigen::VectorX<qreal> X(n_verts), Y(n_verts), Z(n_verts);
|
// size_t n_verts = mesh.n_vertices();
|
||||||
for (VertexHandle vert : mesh.vertices()) {
|
// Eigen::VectorX<qreal> X(n_verts), Y(n_verts), Z(n_verts);
|
||||||
if (mesh.is_boundary(vert)) continue;
|
// for (VertexHandle vert : mesh.vertices()) {
|
||||||
size_t id = vert.idx();
|
// if (mesh.is_boundary(vert)) continue;
|
||||||
Point p = mesh.point(vert);
|
// size_t id = vert.idx();
|
||||||
X(id) = p[0];
|
// Point p = mesh.point(vert);
|
||||||
Y(id) = p[1];
|
// X(id) = p[0];
|
||||||
Z(id) = p[2];
|
// Y(id) = p[1];
|
||||||
}
|
// Z(id) = p[2];
|
||||||
X = laplacian * X;
|
// }
|
||||||
Y = laplacian * Y;
|
// X = laplacian * X;
|
||||||
Z = laplacian * Z;
|
// Y = laplacian * Y;
|
||||||
for (VertexHandle vert : mesh.vertices()) {
|
// Z = laplacian * Z;
|
||||||
if (mesh.is_boundary(vert)) continue;
|
// for (VertexHandle vert : mesh.vertices()) {
|
||||||
size_t id = vert.idx();
|
// if (mesh.is_boundary(vert)) continue;
|
||||||
Point offset {X(id), Y(id), Z(id)};
|
// size_t id = vert.idx();
|
||||||
mesh.set_point(vert, mesh.point(vert) - offset);
|
// Point offset {X(id), Y(id), Z(id)};
|
||||||
}
|
// mesh.set_point(vert, mesh.point(vert) - offset);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user