improve mesh view handling
This commit is contained in:
parent
940ba1be7f
commit
228096c1a6
@ -32,6 +32,7 @@ MeshProcessor::MeshProcessor(const QString &path, MeshViewer &mesh_viewer,
|
|||||||
qWarning() << "Curvature computation failed";
|
qWarning() << "Curvature computation failed";
|
||||||
}
|
}
|
||||||
connect(&mesh_viewer, &MeshViewer::clicked, this, &MeshProcessor::click);
|
connect(&mesh_viewer, &MeshViewer::clicked, this, &MeshProcessor::click);
|
||||||
|
|
||||||
updateView();
|
updateView();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,7 +45,7 @@ MeshProcessor::~MeshProcessor() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MeshProcessor::updateView() const {
|
void MeshProcessor::updateView() {
|
||||||
if (mesh_viewer.isInitialized()) {
|
if (mesh_viewer.isInitialized()) {
|
||||||
mesh_viewer.removeMesh(mesh);
|
mesh_viewer.removeMesh(mesh);
|
||||||
mesh_viewer.addMesh(mesh);
|
mesh_viewer.addMesh(mesh);
|
||||||
|
@ -18,7 +18,7 @@ class MeshProcessor : public QObject {
|
|||||||
double implicit_hole_filling_discr;
|
double implicit_hole_filling_discr;
|
||||||
std::vector<MyMesh> fillings;
|
std::vector<MyMesh> fillings;
|
||||||
|
|
||||||
void updateView() const;
|
void updateView();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MyMesh mesh;
|
MyMesh mesh;
|
||||||
|
@ -89,9 +89,10 @@ void MeshViewer::paintGL() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MeshViewer::addMesh(const MyMesh &mesh) {
|
void MeshViewer::addMesh(MyMesh &mesh) {
|
||||||
Q_ASSERT(isValid());
|
Q_ASSERT(isValid());
|
||||||
makeCurrent();
|
makeCurrent();
|
||||||
|
mesh.viewer_id = meshes.size();
|
||||||
meshes.emplace_back(mesh, program);
|
meshes.emplace_back(mesh, program);
|
||||||
doneCurrent();
|
doneCurrent();
|
||||||
update();
|
update();
|
||||||
@ -100,9 +101,14 @@ void MeshViewer::addMesh(const MyMesh &mesh) {
|
|||||||
|
|
||||||
void MeshViewer::removeMesh(const MyMesh &mesh) {
|
void MeshViewer::removeMesh(const MyMesh &mesh) {
|
||||||
makeCurrent();
|
makeCurrent();
|
||||||
meshes.remove_if([&](const MeshView &mv) {
|
size_t i = 0;
|
||||||
return &mv.mesh == &mesh;
|
for (auto it = meshes.begin(); it != meshes.end(); ++it) {
|
||||||
});
|
if (i == mesh.viewer_id) {
|
||||||
|
meshes.erase(it);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
doneCurrent();
|
doneCurrent();
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ public:
|
|||||||
constexpr bool isInitialized() { return is_initialized; }
|
constexpr bool isInitialized() { return is_initialized; }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void addMesh(const MyMesh &mesh);
|
void addMesh(MyMesh &mesh);
|
||||||
void removeMesh(const MyMesh &mesh);
|
void removeMesh(const MyMesh &mesh);
|
||||||
void updateForReal();
|
void updateForReal();
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ class MyMesh : public OpenMesh::TriMesh_ArrayKernelT<MyTraits> {
|
|||||||
public:
|
public:
|
||||||
Color default_color {.5, .5, .5};
|
Color default_color {.5, .5, .5};
|
||||||
QMatrix4x4 transform;
|
QMatrix4x4 transform;
|
||||||
|
size_t viewer_id;
|
||||||
std::vector<std::vector<HalfedgeHandle>> holes;
|
std::vector<std::vector<HalfedgeHandle>> holes;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user