// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute // SPDX-License-Identifier: GPL-3.0-only #include "RotationIndexerCounter.h" RotationIndexerCounter::RotationIndexerCounter(const DiffractionExperiment &x) { const auto axis = x.GetGoniometer(); if (x.IsRotationIndexing() && axis.has_value()) { float angle_norm_deg = std::fabs(axis->GetIncrement_deg()); if (angle_norm_deg >= 1e-6) { if (x.GetImageNum() < min_images_for_indexing) { // For short measurements - no trying to index during the measurement image_to_try_indexing = x.GetImageNum(); image_stride = 1; } else { image_to_try_indexing = std::max(min_images_for_indexing, x.GetIndexingSettings(). GetRotationIndexingMinAngularRange_deg() / angle_norm_deg); image_stride = std::ceil( x.GetIndexingSettings().GetRotationIndexingAngularStride_deg() / angle_norm_deg); if (image_stride == 0) image_stride = 1; } } } } std::pair RotationIndexerCounter::Process(int64_t image) { std::unique_lock ul(m); std::pair ret = {false, false}; if (image_stride == 0) return ret; accumulated_images++; ret.first = (image_stride == 1) || (image % image_stride == 0); if (accumulated_images >= image_to_try_indexing) { image_to_try_indexing += 10; ret.second = true; } return ret; }