Compare commits
No commits in common. "940ba1be7fe67c87bb8d588f8b89629c0c1bb08b" and "6cb0dbc21e61c7954a384d4d87cdd7c8018414e3" have entirely different histories.
940ba1be7f
...
6cb0dbc21e
@ -36,9 +36,7 @@ target_sources(${PROJECT_NAME} PRIVATE
|
|||||||
src/hole_filling.cpp
|
src/hole_filling.cpp
|
||||||
src/hole_filling.h
|
src/hole_filling.h
|
||||||
src/double_input.cpp
|
src/double_input.cpp
|
||||||
src/double_input.h
|
src/double_input.h)
|
||||||
src/noise_removal.cpp
|
|
||||||
src/noise_removal.h)
|
|
||||||
target_link_libraries(${PROJECT_NAME} PRIVATE
|
target_link_libraries(${PROJECT_NAME} PRIVATE
|
||||||
Qt5::Core Qt5::Gui Qt5::Widgets
|
Qt5::Core Qt5::Gui Qt5::Widgets
|
||||||
OpenMeshCore
|
OpenMeshCore
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#include "MeshReconstruction.h"
|
#include "MeshReconstruction.h"
|
||||||
#include "Cube.h"
|
#include "Cube.h"
|
||||||
#include "Triangulation.h"
|
#include "Triangulation.h"
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
using namespace MeshReconstruction;
|
using namespace MeshReconstruction;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@ -45,9 +44,8 @@ Mesh MeshReconstruction::MarchCube(
|
|||||||
auto const NumY = static_cast<int>(ceil(domain.size.y / cubeSize.y));
|
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 NumZ = static_cast<int>(ceil(domain.size.z / cubeSize.z));
|
||||||
|
|
||||||
auto const CubeDiag = cubeSize.Norm();
|
auto const HalfCubeDiag = cubeSize.Norm() / 2.0;
|
||||||
// auto const HalfCubeDiag = cubeSize.Norm() * 0.5;
|
auto const HalfCubeSize = cubeSize * 0.5;
|
||||||
// auto const HalfCubeSize = cubeSize * 0.5;
|
|
||||||
|
|
||||||
Mesh mesh;
|
Mesh mesh;
|
||||||
|
|
||||||
@ -63,10 +61,9 @@ Mesh MeshReconstruction::MarchCube(
|
|||||||
Vec3 min{ x, y, z };
|
Vec3 min{ x, y, z };
|
||||||
|
|
||||||
// Process only if cube lies within narrow band around surface.
|
// Process only if cube lies within narrow band around surface.
|
||||||
// auto cubeCenter = min + HalfCubeSize;
|
auto cubeCenter = min + HalfCubeSize;
|
||||||
// double dist = std::abs(sdf(cubeCenter) - isoLevel);
|
double dist = std::fabs(sdf(cubeCenter) - isoLevel);
|
||||||
double dist = std::abs(sdf(min) - isoLevel);
|
if (dist > HalfCubeDiag) continue;
|
||||||
// if (dist > CubeDiag) continue;
|
|
||||||
|
|
||||||
Cube cube({ min, cubeSize }, sdf);
|
Cube cube({ min, cubeSize }, sdf);
|
||||||
auto intersect = cube.Intersect(isoLevel);
|
auto intersect = cube.Intersect(isoLevel);
|
||||||
|
@ -308,12 +308,12 @@ MyMesh fillHoleImplicit(MyMesh &mesh, Hole_Filling &hf,
|
|||||||
for (HalfedgeHandle hh : hole) {
|
for (HalfedgeHandle hh : hole) {
|
||||||
verts.push_back(mesh.to_vertex_handle(hh));
|
verts.push_back(mesh.to_vertex_handle(hh));
|
||||||
}
|
}
|
||||||
auto bb = hf.estimate_BB(verts) ;
|
|
||||||
verts = hf.next_neighbors(verts);
|
verts = hf.next_neighbors(verts);
|
||||||
auto [system, pts_list] = hf.compute_approx_mat(verts);
|
auto [system, pts_list] = hf.compute_approx_mat(verts);
|
||||||
auto [alpha, beta] = hf.solve_approx(system, pts_list.size(), 10);
|
auto [alpha, beta] = hf.solve_approx(system, pts_list.size(), 10);
|
||||||
Implicit_RBF rbf(alpha, beta, pts_list);
|
Implicit_RBF rbf(alpha, beta, pts_list);
|
||||||
|
|
||||||
|
auto bb = hf.estimate_BB(verts) ;
|
||||||
Mesh filling = hf.poly_n_out(rbf, bb);
|
Mesh filling = hf.poly_n_out(rbf, bb);
|
||||||
MyMesh ret;
|
MyMesh ret;
|
||||||
for (const Vec3 &v : filling.vertices) {
|
for (const Vec3 &v : filling.vertices) {
|
||||||
@ -331,11 +331,27 @@ MyMesh fillHoleImplicit(MyMesh &mesh, Hole_Filling &hf,
|
|||||||
|
|
||||||
std::vector<MyMesh> fillHolesImplicit(MyMesh &mesh,
|
std::vector<MyMesh> fillHolesImplicit(MyMesh &mesh,
|
||||||
float scale, float discr) {
|
float scale, float discr) {
|
||||||
|
Hole_Filling hf(mesh, scale, discr);
|
||||||
mesh.holes = findHoles(mesh);
|
mesh.holes = findHoles(mesh);
|
||||||
std::vector<MyMesh> fillings;
|
std::vector<MyMesh> fillings;
|
||||||
for (auto hole : mesh.holes) {
|
for (auto hole : mesh.holes) {
|
||||||
Hole_Filling hf(mesh, scale, discr);
|
|
||||||
fillings.push_back(fillHoleImplicit(mesh, hf, hole));
|
fillings.push_back(fillHoleImplicit(mesh, hf, hole));
|
||||||
}
|
}
|
||||||
return fillings;
|
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};
|
||||||
}
|
}
|
||||||
|
@ -25,8 +25,6 @@ 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,7 +9,6 @@
|
|||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QSlider>
|
#include <QSlider>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <qnamespace.h>
|
|
||||||
|
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent)
|
MainWindow::MainWindow(QWidget *parent)
|
||||||
@ -114,19 +113,4 @@ 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,7 +32,6 @@ 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,7 +4,6 @@
|
|||||||
#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>
|
||||||
|
|
||||||
@ -132,12 +131,3 @@ 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,7 +38,6 @@ 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 40
|
#define FOV 70
|
||||||
|
|
||||||
|
|
||||||
using namespace OpenMesh;
|
using namespace OpenMesh;
|
||||||
|
@ -14,10 +14,9 @@ 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 | OpenMesh::Attributes::Status);
|
VertexAttributes(OpenMesh::Attributes::Normal | OpenMesh::Attributes::Color);
|
||||||
EdgeAttributes(OpenMesh::Attributes::Status);
|
|
||||||
HalfedgeAttributes(OpenMesh::Attributes::PrevHalfedge);
|
HalfedgeAttributes(OpenMesh::Attributes::PrevHalfedge);
|
||||||
FaceAttributes(OpenMesh::Attributes::Normal | OpenMesh::Attributes::Status);
|
FaceAttributes(OpenMesh::Attributes::Normal);
|
||||||
// EdgeAttributes(OpenMesh::Attributes::Color);
|
// EdgeAttributes(OpenMesh::Attributes::Color);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -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();
|
|
||||||
}
|
|
@ -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
|
|
@ -132,7 +132,7 @@ void smooth(MyMesh &mesh, SmoothingMethod method, double cotan_factor) {
|
|||||||
laplacian = laplacian_matrix(mesh, uniform_weight, uniform_mass);
|
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.
|
// Transfert des coordonées de chaque point dans une matrice.
|
||||||
size_t n_verts = mesh.n_vertices();
|
size_t n_verts = mesh.n_vertices();
|
||||||
|
44
src/util.cpp
44
src/util.cpp
@ -1,8 +1,5 @@
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
#include <stack>
|
|
||||||
#include <OpenMesh/Core/Utils/PropertyManager.hh>
|
|
||||||
|
|
||||||
|
|
||||||
QDebug operator<<(QDebug dbg, const Point &p) {
|
QDebug operator<<(QDebug dbg, const Point &p) {
|
||||||
return dbg << p[0] << p[1] << p[2];
|
return dbg << p[0] << p[1] << p[2];
|
||||||
@ -12,44 +9,3 @@ QDebug operator<<(QDebug dbg, const Point &p) {
|
|||||||
qreal cotan(const qreal x) {
|
qreal cotan(const qreal x) {
|
||||||
return 1. / qTan(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;
|
|
||||||
}
|
|
||||||
|
@ -101,8 +101,4 @@ standard_deviation(const ForwardIt first,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<std::vector<VertexHandle>> find_connected_components(
|
|
||||||
MyMesh &mesh);
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user