mirror of
https://gitlab.ethz.ch/gfattori/glocalize.git
synced 2026-05-03 21:54:23 +02:00
41 lines
1.0 KiB
C++
41 lines
1.0 KiB
C++
#include "LocalizationWorker.h"
|
|
#include "LocalizationService.h"
|
|
|
|
#include <vtkImageData.h>
|
|
|
|
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) {
|
|
// Keep behavior consistent with legacy code: treat as aborted.
|
|
// (UI can be extended to show the exception message.)
|
|
(void)e;
|
|
emit aborted();
|
|
}
|
|
}
|