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