mirror of
https://gitlab.ethz.ch/gfattori/glocalize.git
synced 2026-05-03 13:44:26 +02:00
42 lines
1012 B
C++
42 lines
1012 B
C++
#include "LocalizationWorker.h"
|
|
#include "LocalizationService.h"
|
|
|
|
#include <vtkImageData.h>
|
|
|
|
#include <QString>
|
|
|
|
LocalizationWorker::LocalizationWorker(QObject* parent)
|
|
: QObject(parent)
|
|
{
|
|
}
|
|
|
|
void LocalizationWorker::abort()
|
|
{
|
|
m_abort.store(true, std::memory_order_relaxed);
|
|
}
|
|
|
|
void LocalizationWorker::run(vtkImageData* volume, LocalizationParams params)
|
|
{
|
|
m_abort.store(false, std::memory_order_relaxed);
|
|
|
|
try {
|
|
MarkerList markers = LocalizationService::localize(
|
|
volume,
|
|
params,
|
|
[this](double p) { emit progress(p); },
|
|
[this]() { return m_abort.load(std::memory_order_relaxed); }
|
|
);
|
|
|
|
if (m_abort.load(std::memory_order_relaxed)) {
|
|
emit aborted();
|
|
return;
|
|
}
|
|
|
|
emit finished(std::move(markers));
|
|
} catch (const std::exception& e) {
|
|
emit failed(QString::fromUtf8(e.what()));
|
|
} catch (...) {
|
|
emit failed(QStringLiteral("Unknown error in localization"));
|
|
}
|
|
}
|