add hole detection and visualization
This commit is contained in:
parent
0dd3d434f6
commit
f1d632bdb6
@ -1,4 +1,5 @@
|
||||
#include "main_window.h"
|
||||
#include "mesh_processing.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QFileDialog>
|
||||
@ -33,14 +34,17 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
|
||||
|
||||
void MainWindow::open(const QString &path) {
|
||||
if (!OpenMesh::IO::read_mesh(mesh, path.toUtf8().constData())) {
|
||||
OpenMesh::IO::Options options;
|
||||
options.set(OpenMesh::IO::Options::VertexColor);
|
||||
if (!OpenMesh::IO::read_mesh(mesh, path.toUtf8().constData(), options)) {
|
||||
qWarning() << "Failed to read" << path;
|
||||
return;
|
||||
}
|
||||
for (const VertexHandle &vh : mesh.vertices()) {
|
||||
mesh.set_color(vh, MyMesh::Color(.5, .5, .5));
|
||||
mesh.set_color(vh, MyMesh::Color(0, 0, 0));
|
||||
}
|
||||
if (glm != nullptr) mesh_viewer.removeOpenGLMesh(glm);
|
||||
findHoles(mesh);
|
||||
glm = mesh_viewer.addOpenGLMeshFromOpenMesh(&mesh);
|
||||
for (QAction *a : toolbar_actions) {
|
||||
a->setEnabled(true);
|
||||
|
11
src/mesh_processing.cpp
Normal file
11
src/mesh_processing.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
#include "mesh_processing.h"
|
||||
|
||||
|
||||
void findHoles(MyMesh &mesh) {
|
||||
for (const MyMesh::HalfedgeHandle &eh : mesh.halfedges()) {
|
||||
if (mesh.is_boundary(eh)) {
|
||||
MyMesh::VertexHandle vh = mesh.to_vertex_handle(eh);
|
||||
mesh.set_color(vh, {.8, .2, .7});
|
||||
}
|
||||
}
|
||||
}
|
10
src/mesh_processing.h
Normal file
10
src/mesh_processing.h
Normal file
@ -0,0 +1,10 @@
|
||||
#ifndef MESH_PROCESSING_H
|
||||
#define MESH_PROCESSING_H
|
||||
|
||||
#include "my_mesh.h"
|
||||
|
||||
|
||||
void findHoles(MyMesh &mesh);
|
||||
|
||||
|
||||
#endif
|
@ -28,8 +28,9 @@ uniform bool wireframe;
|
||||
uniform float alpha;
|
||||
|
||||
void main() {
|
||||
if (wireframe)
|
||||
gl_FragColor = vec4(wf_col, alpha);
|
||||
if (!wireframe)
|
||||
// gl_FragColor = vec4(wf_col, alpha);
|
||||
gl_FragColor = vec4(.5, .5, .5, 1);
|
||||
else
|
||||
gl_FragColor = vec4(frag_col, alpha);
|
||||
}
|
||||
@ -169,7 +170,7 @@ void MeshViewer::paintGL() {
|
||||
glUniform1f(wireframe_attr, 1);
|
||||
glDrawArrays(GL_TRIANGLES, 0, m.nverts);
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
glLineWidth(1);
|
||||
glLineWidth(3);
|
||||
glUniform1f(wireframe_attr, 0);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user