Compare commits

..

No commits in common. "940ba1be7fe67c87bb8d588f8b89629c0c1bb08b" and "6cb0dbc21e61c7954a384d4d87cdd7c8018414e3" have entirely different histories.

15 changed files with 28 additions and 121 deletions

View File

@ -36,9 +36,7 @@ target_sources(${PROJECT_NAME} PRIVATE
src/hole_filling.cpp
src/hole_filling.h
src/double_input.cpp
src/double_input.h
src/noise_removal.cpp
src/noise_removal.h)
src/double_input.h)
target_link_libraries(${PROJECT_NAME} PRIVATE
Qt5::Core Qt5::Gui Qt5::Widgets
OpenMeshCore

View File

@ -1,7 +1,6 @@
#include "MeshReconstruction.h"
#include "Cube.h"
#include "Triangulation.h"
#include <iostream>
using namespace MeshReconstruction;
using namespace std;
@ -45,9 +44,8 @@ Mesh MeshReconstruction::MarchCube(
auto const NumY = static_cast<int>(ceil(domain.size.y / cubeSize.y));
auto const NumZ = static_cast<int>(ceil(domain.size.z / cubeSize.z));
auto const CubeDiag = cubeSize.Norm();
// auto const HalfCubeDiag = cubeSize.Norm() * 0.5;
// auto const HalfCubeSize = cubeSize * 0.5;
auto const HalfCubeDiag = cubeSize.Norm() / 2.0;
auto const HalfCubeSize = cubeSize * 0.5;
Mesh mesh;
@ -63,10 +61,9 @@ Mesh MeshReconstruction::MarchCube(
Vec3 min{ x, y, z };
// Process only if cube lies within narrow band around surface.
// auto cubeCenter = min + HalfCubeSize;
// double dist = std::abs(sdf(cubeCenter) - isoLevel);
double dist = std::abs(sdf(min) - isoLevel);
// if (dist > CubeDiag) continue;
auto cubeCenter = min + HalfCubeSize;
double dist = std::fabs(sdf(cubeCenter) - isoLevel);
if (dist > HalfCubeDiag) continue;
Cube cube({ min, cubeSize }, sdf);
auto intersect = cube.Intersect(isoLevel);

View File

@ -308,12 +308,12 @@ MyMesh fillHoleImplicit(MyMesh &mesh, Hole_Filling &hf,
for (HalfedgeHandle hh : hole) {
verts.push_back(mesh.to_vertex_handle(hh));
}
auto bb = hf.estimate_BB(verts) ;
verts = hf.next_neighbors(verts);
auto [system, pts_list] = hf.compute_approx_mat(verts);
auto [alpha, beta] = hf.solve_approx(system, pts_list.size(), 10);
Implicit_RBF rbf(alpha, beta, pts_list);
auto bb = hf.estimate_BB(verts) ;
Mesh filling = hf.poly_n_out(rbf, bb);
MyMesh ret;
for (const Vec3 &v : filling.vertices) {
@ -331,11 +331,27 @@ MyMesh fillHoleImplicit(MyMesh &mesh, Hole_Filling &hf,
std::vector<MyMesh> fillHolesImplicit(MyMesh &mesh,
float scale, float discr) {
Hole_Filling hf(mesh, scale, discr);
mesh.holes = findHoles(mesh);
std::vector<MyMesh> fillings;
for (auto hole : mesh.holes) {
Hole_Filling hf(mesh, scale, discr);
fillings.push_back(fillHoleImplicit(mesh, hf, hole));
}
return fillings;
// auto sdf = [&](Vec3 const& v) { return v.Norm() - 10.; };
// Rect3 domain {{-10, -10, -10}, {20, 20, 20}};
// auto filling = MarchCube(sdf, domain);
// WriteObjFile(filling, "out.obj");
// MyMesh ret;
// for (const Vec3 &v : filling.vertices) {
// VertexHandle vh = ret.new_vertex({v.x, v.y, v.z});
// ret.set_color(vh, ret.default_color);
// }
// for (const Triangle &t : filling.triangles) {
// ret.add_face(ret.vertex_handle(t[0]),
// ret.vertex_handle(t[1]),
// ret.vertex_handle(t[2]));
// }
// return {ret};
}

View File

@ -25,8 +25,6 @@ static MeshProcessor *create_mesh_processor(const QString &path,
mesh_processor, &MeshProcessor::setImplicitHoleFillingScale);
QObject::connect(&main_window, &MainWindow::fillHolesImplicitDiscrChanged,
mesh_processor, &MeshProcessor::setImplicitHoleFillingDiscr);
QObject::connect(&main_window, &MainWindow::filterNoiseClicked,
mesh_processor, &MeshProcessor::removeNoise);
return mesh_processor;
}

View File

@ -9,7 +9,6 @@
#include <QPushButton>
#include <QSlider>
#include <QLabel>
#include <qnamespace.h>
MainWindow::MainWindow(QWidget *parent)
@ -114,19 +113,4 @@ MainWindow::MainWindow(QWidget *parent)
this, &MainWindow::patchViewToggled);
curvature_layout->addWidget(patch_mode);
toolbar.addWidget(curvature_box);
// Noise cleaning
QGroupBox *noise_box = new QGroupBox("Élagage");
QLayout *noise_layout = new QVBoxLayout();
noise_box->setLayout(noise_layout);
QSlider *noise_slider = new QSlider(Qt::Horizontal);
QPushButton *noise_button = new QPushButton("Élaguer");
connect(noise_button, &QPushButton::clicked,
[=]() {
emit filterNoiseClicked(noise_slider->value());
});
noise_layout->addWidget(noise_slider);
noise_layout->addWidget(noise_button);
toolbar.addWidget(noise_box);
}

View File

@ -32,7 +32,6 @@ signals:
void smoothUniformClicked();
void smoothCotangentClicked(double factor);
void patchViewToggled(bool checked);
void filterNoiseClicked(int value);
public:
MeshViewer mesh_viewer;

View File

@ -4,7 +4,6 @@
#include "hole_filling.h"
#include "smoothing.h"
#include "curvature.h"
#include "noise_removal.h"
#include <QGenericMatrix>
#include <unordered_set>
@ -132,12 +131,3 @@ void MeshProcessor::click(QVector3D position) {
mesh_viewer.addMesh(patch);
mesh_viewer.updateForReal();
}
void MeshProcessor::removeNoise(int value) {
std::cout << value << std::endl;
::remove_noise(mesh, value);
mesh_viewer.removeMesh(mesh);
mesh_viewer.addMesh(mesh);
mesh_viewer.updateForReal();
}

View File

@ -38,7 +38,6 @@ public slots:
void smoothUniform();
void setPatchView(bool on);
void click(QVector3D position);
void removeNoise(int value);
};

View File

@ -15,7 +15,7 @@
#define WIREFRAME_COLOR 0, 0, 0
#define FOV 40
#define FOV 70
using namespace OpenMesh;

View File

@ -14,10 +14,9 @@ struct MyTraits : public OpenMesh::DefaultTraits {
using Point = Eigen::Vector3<qreal>;
using Normal = Eigen::Vector3<qreal>;
using Color = Eigen::Vector3<qreal>;
VertexAttributes(OpenMesh::Attributes::Normal | OpenMesh::Attributes::Color | OpenMesh::Attributes::Status);
EdgeAttributes(OpenMesh::Attributes::Status);
VertexAttributes(OpenMesh::Attributes::Normal | OpenMesh::Attributes::Color);
HalfedgeAttributes(OpenMesh::Attributes::PrevHalfedge);
FaceAttributes(OpenMesh::Attributes::Normal | OpenMesh::Attributes::Status);
FaceAttributes(OpenMesh::Attributes::Normal);
// EdgeAttributes(OpenMesh::Attributes::Color);
};

View File

@ -1,15 +0,0 @@
#include "noise_removal.h"
#include "util.h"
void remove_noise(MyMesh &mesh, unsigned threshold) {
auto components = find_connected_components(mesh);
for (auto component : components) {
if (component.size() < threshold) {
for (VertexHandle vh : component) {
mesh.delete_vertex(vh);
}
}
}
mesh.garbage_collection();
}

View File

@ -1,10 +0,0 @@
#ifndef NOISE_REMOVAL_H
#define NOISE_REMOVAL_H
#include "my_mesh.h"
void remove_noise(MyMesh &mesh, unsigned threshold=20);
#endif

View File

@ -132,7 +132,7 @@ void smooth(MyMesh &mesh, SmoothingMethod method, double cotan_factor) {
laplacian = laplacian_matrix(mesh, uniform_weight, uniform_mass);
}
// laplacian = laplacian * laplacian; // Mise au carré.
laplacian = laplacian * laplacian; // Mise au carré.
// Transfert des coordonées de chaque point dans une matrice.
size_t n_verts = mesh.n_vertices();

View File

@ -1,8 +1,5 @@
#include "util.h"
#include <stack>
#include <OpenMesh/Core/Utils/PropertyManager.hh>
QDebug operator<<(QDebug dbg, const Point &p) {
return dbg << p[0] << p[1] << p[2];
@ -12,44 +9,3 @@ QDebug operator<<(QDebug dbg, const Point &p) {
qreal cotan(const qreal x) {
return 1. / qTan(x);
}
static void traverse_connected(MyMesh &mesh, std::vector<VertexHandle> &out,
VertexHandle start) {
auto prop =
OpenMesh::makeTemporaryProperty<MyMesh::VertexHandle, bool>(mesh);
for (VertexHandle vh : mesh.vertices()) {
prop[vh] = false;
}
std::stack<VertexHandle> stack;
stack.push(start);
prop[start] = true;
while (!stack.empty()) {
VertexHandle v = stack.top();
stack.pop();
out.emplace_back(v);
for (VertexHandle v2 : mesh.vv_range(v)) {
if (!prop[v2]) {
stack.push(v2);
prop[v2] = true;
}
}
}
}
std::vector<std::vector<VertexHandle>> find_connected_components(
MyMesh &mesh) {
auto prop =
OpenMesh::makeTemporaryProperty<MyMesh::VertexHandle, bool>(mesh);
for (VertexHandle vh : mesh.vertices()) {
prop[vh] = false;
}
std::vector<std::vector<VertexHandle>> connected_components;
for (VertexHandle vh : mesh.vertices()) {
if (prop[vh]) continue;
connected_components.push_back({});
traverse_connected(mesh, connected_components.back(), vh);
}
return connected_components;
}

View File

@ -101,8 +101,4 @@ standard_deviation(const ForwardIt first,
}
std::vector<std::vector<VertexHandle>> find_connected_components(
MyMesh &mesh);
#endif