add noise filtering
This commit is contained in:
parent
3035ffacb8
commit
940ba1be7f
@ -25,6 +25,8 @@ static MeshProcessor *create_mesh_processor(const QString &path,
|
|||||||
mesh_processor, &MeshProcessor::setImplicitHoleFillingScale);
|
mesh_processor, &MeshProcessor::setImplicitHoleFillingScale);
|
||||||
QObject::connect(&main_window, &MainWindow::fillHolesImplicitDiscrChanged,
|
QObject::connect(&main_window, &MainWindow::fillHolesImplicitDiscrChanged,
|
||||||
mesh_processor, &MeshProcessor::setImplicitHoleFillingDiscr);
|
mesh_processor, &MeshProcessor::setImplicitHoleFillingDiscr);
|
||||||
|
QObject::connect(&main_window, &MainWindow::filterNoiseClicked,
|
||||||
|
mesh_processor, &MeshProcessor::removeNoise);
|
||||||
return mesh_processor;
|
return mesh_processor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QSlider>
|
#include <QSlider>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
#include <qnamespace.h>
|
||||||
|
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent)
|
MainWindow::MainWindow(QWidget *parent)
|
||||||
@ -113,4 +114,19 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
this, &MainWindow::patchViewToggled);
|
this, &MainWindow::patchViewToggled);
|
||||||
curvature_layout->addWidget(patch_mode);
|
curvature_layout->addWidget(patch_mode);
|
||||||
toolbar.addWidget(curvature_box);
|
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);
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,7 @@ signals:
|
|||||||
void smoothUniformClicked();
|
void smoothUniformClicked();
|
||||||
void smoothCotangentClicked(double factor);
|
void smoothCotangentClicked(double factor);
|
||||||
void patchViewToggled(bool checked);
|
void patchViewToggled(bool checked);
|
||||||
|
void filterNoiseClicked(int value);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MeshViewer mesh_viewer;
|
MeshViewer mesh_viewer;
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "hole_filling.h"
|
#include "hole_filling.h"
|
||||||
#include "smoothing.h"
|
#include "smoothing.h"
|
||||||
#include "curvature.h"
|
#include "curvature.h"
|
||||||
|
#include "noise_removal.h"
|
||||||
#include <QGenericMatrix>
|
#include <QGenericMatrix>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
|
||||||
@ -131,3 +132,12 @@ void MeshProcessor::click(QVector3D position) {
|
|||||||
mesh_viewer.addMesh(patch);
|
mesh_viewer.addMesh(patch);
|
||||||
mesh_viewer.updateForReal();
|
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();
|
||||||
|
}
|
||||||
|
@ -38,6 +38,7 @@ public slots:
|
|||||||
void smoothUniform();
|
void smoothUniform();
|
||||||
void setPatchView(bool on);
|
void setPatchView(bool on);
|
||||||
void click(QVector3D position);
|
void click(QVector3D position);
|
||||||
|
void removeNoise(int value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#define WIREFRAME_COLOR 0, 0, 0
|
#define WIREFRAME_COLOR 0, 0, 0
|
||||||
#define FOV 70
|
#define FOV 40
|
||||||
|
|
||||||
|
|
||||||
using namespace OpenMesh;
|
using namespace OpenMesh;
|
||||||
|
@ -14,9 +14,10 @@ struct MyTraits : public OpenMesh::DefaultTraits {
|
|||||||
using Point = Eigen::Vector3<qreal>;
|
using Point = Eigen::Vector3<qreal>;
|
||||||
using Normal = Eigen::Vector3<qreal>;
|
using Normal = Eigen::Vector3<qreal>;
|
||||||
using Color = Eigen::Vector3<qreal>;
|
using Color = Eigen::Vector3<qreal>;
|
||||||
VertexAttributes(OpenMesh::Attributes::Normal | OpenMesh::Attributes::Color);
|
VertexAttributes(OpenMesh::Attributes::Normal | OpenMesh::Attributes::Color | OpenMesh::Attributes::Status);
|
||||||
|
EdgeAttributes(OpenMesh::Attributes::Status);
|
||||||
HalfedgeAttributes(OpenMesh::Attributes::PrevHalfedge);
|
HalfedgeAttributes(OpenMesh::Attributes::PrevHalfedge);
|
||||||
FaceAttributes(OpenMesh::Attributes::Normal);
|
FaceAttributes(OpenMesh::Attributes::Normal | OpenMesh::Attributes::Status);
|
||||||
// EdgeAttributes(OpenMesh::Attributes::Color);
|
// EdgeAttributes(OpenMesh::Attributes::Color);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2,7 +2,14 @@
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
|
||||||
void remove_noise(MyMesh &mesh) {
|
void remove_noise(MyMesh &mesh, unsigned threshold) {
|
||||||
auto connected_components = find_connected_components(mesh);
|
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();
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include "my_mesh.h"
|
#include "my_mesh.h"
|
||||||
|
|
||||||
|
|
||||||
void remove_noise(MyMesh &mesh);
|
void remove_noise(MyMesh &mesh, unsigned threshold=20);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
Reference in New Issue
Block a user