mirror of
https://gitlab.ethz.ch/gfattori/glocalize.git
synced 2026-05-03 21:54:23 +02:00
trying a code refactoring
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
#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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user