mirror of
https://gitlab.ethz.ch/gfattori/glocalize.git
synced 2026-05-03 21:54:23 +02:00
adding service worker structure for dicomscan skullremoval and volumepreparation
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
#include "SkullRemovalWorker.h"
|
||||
#include "SkullRemovalService.h"
|
||||
|
||||
#include <vtkImageData.h>
|
||||
|
||||
#include <QString>
|
||||
|
||||
SkullRemovalWorker::SkullRemovalWorker(QObject* parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void SkullRemovalWorker::run(vtkImageData* inputVolume, double thr_low, double thr_up)
|
||||
{
|
||||
m_abort.store(false);
|
||||
emit skull_mask_upd("Skull masking...", 0.0);
|
||||
|
||||
SkullRemovalService svc;
|
||||
try {
|
||||
vtkImageData* out = svc.run(
|
||||
inputVolume, thr_low, thr_up, &m_abort,
|
||||
[&](const std::string& msg, double p) { emit skull_mask_upd(QString::fromStdString(msg), p * 100.0); });
|
||||
|
||||
if (m_abort.load()) {
|
||||
if (out) out->Delete();
|
||||
emit aborted();
|
||||
return;
|
||||
}
|
||||
|
||||
emit skull_mask_upd("Skull masking done", 100.0);
|
||||
emit skull_mask_end(out); // receiver should Delete() if needed (or deep copy)
|
||||
} catch (const std::exception& e) {
|
||||
if (m_abort.load()) {
|
||||
emit aborted();
|
||||
return;
|
||||
}
|
||||
emit errMsg(QString(e.what()));
|
||||
}
|
||||
}
|
||||
|
||||
void SkullRemovalWorker::abort()
|
||||
{
|
||||
m_abort.store(true);
|
||||
}
|
||||
Reference in New Issue
Block a user