From 40ae325995bf048edff43caa55a430b264123bf1 Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Fri, 29 May 2026 16:56:18 +0200 Subject: [PATCH] IndexAndRefine: Dedicated function to add image to rotation indexer --- image_analysis/IndexAndRefine.cpp | 14 +++++++++++--- image_analysis/IndexAndRefine.h | 4 +++- receiver/JFJochReceiver.cpp | 2 +- tools/jfjoch_process.cpp | 2 +- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/image_analysis/IndexAndRefine.cpp b/image_analysis/IndexAndRefine.cpp index 7112016e..18a58e1b 100644 --- a/image_analysis/IndexAndRefine.cpp +++ b/image_analysis/IndexAndRefine.cpp @@ -26,11 +26,19 @@ IndexAndRefine::IndexAndRefine(const DiffractionExperiment &x, IndexerThreadPool unit_cells.resize(x.GetImageNum()); } -IndexAndRefine::IndexingOutcome IndexAndRefine::DetermineLatticeAndSymmetryRotation(DataMessage &msg) { - auto result = rotation_indexer->GetLattice(); +void IndexAndRefine::AddImageToRotationIndexer(DataMessage &msg) { + if (rotation_indexer) + rotation_indexer->ProcessImage(msg.number, msg.spots); +} +IndexAndRefine::IndexingOutcome IndexAndRefine::DetermineLatticeAndSymmetryRotation(DataMessage &msg) { IndexingOutcome outcome(experiment); + if (!rotation_indexer) + return outcome; + + auto result = rotation_indexer->GetLattice(); + if (!result.has_value()) { auto rot_cnt = rotation_indexer_counter.Process(msg.number); if (rot_cnt.first) @@ -301,7 +309,7 @@ void IndexAndRefine::ProcessImage(DataMessage &msg, QuickPredictAndIntegrate(msg, spot_finding_settings, image, prediction, outcome); } -std::optional IndexAndRefine::Finalize() { +std::optional IndexAndRefine::FinalizeRotationIndexing() { if (rotation_indexer) { if (const auto latt = rotation_indexer->GetLattice()) return latt; diff --git a/image_analysis/IndexAndRefine.h b/image_analysis/IndexAndRefine.h index eae44e80..ac4d7cd7 100644 --- a/image_analysis/IndexAndRefine.h +++ b/image_analysis/IndexAndRefine.h @@ -66,12 +66,14 @@ class IndexAndRefine { void ScaleImage(DataMessage &msg, IntegrationOutcome& outcome); public: IndexAndRefine(const DiffractionExperiment &x, IndexerThreadPool *indexer); + + void AddImageToRotationIndexer(DataMessage &msg); void ProcessImage(DataMessage &msg, const SpotFindingSettings &settings, const CompressedImage &image, BraggPrediction &prediction); IndexAndRefine& ReferenceIntensities(std::vector &reference); ScalingResult ScaleAllImages(const std::vector &reference, size_t nthreads = 0); - std::optional Finalize(); + std::optional FinalizeRotationIndexing(); std::optional GetConsensusUnitCell() const; diff --git a/receiver/JFJochReceiver.cpp b/receiver/JFJochReceiver.cpp index 8997ef9e..ba6d05f4 100644 --- a/receiver/JFJochReceiver.cpp +++ b/receiver/JFJochReceiver.cpp @@ -161,7 +161,7 @@ void JFJochReceiver::SendEndMessage() { message.az_int_result["dataset"] = plots.GetAzIntProfile(); - const auto rotation_indexer_ret = indexer.Finalize(); + const auto rotation_indexer_ret = indexer.FinalizeRotationIndexing(); if (rotation_indexer_ret.has_value()) { message.rotation_lattice = rotation_indexer_ret->lattice; message.rotation_lattice_type = LatticeMessage{ diff --git a/tools/jfjoch_process.cpp b/tools/jfjoch_process.cpp index a03c263b..4c9dec13 100644 --- a/tools/jfjoch_process.cpp +++ b/tools/jfjoch_process.cpp @@ -683,7 +683,7 @@ int main(int argc, char **argv) { // Finalize Indexing (Global) to get rotation lattice // We create a temporary IndexAndRefine to call Finalize() which aggregates pool results - const auto rotation_indexer_ret = indexer.Finalize(); + const auto rotation_indexer_ret = indexer.FinalizeRotationIndexing(); if (rotation_indexer_ret.has_value()) { end_msg.rotation_lattice = rotation_indexer_ret->lattice;