Dev/multiple rois in aare (#263)
Build on RHEL8 / build (push) Successful in 2m23s
Build on RHEL9 / build (push) Successful in 2m32s
Run tests using data on local RHEL8 / build (push) Failing after 3m14s

Reading multiple ROI's for aare 

- read_frame, read_n etc throws for multiple ROIs
- new functions read_ROIs, read_n_ROIs 
-  read_roi_into (used for python bindings - to not copy) 

all these functions use get_frame or get_frame_into where one passes the
roi_index
## Refactoring:
- each roi keeps track of its subfiles that one has to open e.g.
subfiles can be opened several times
- refactored class DetectorGeometry - keep track of the updated module
geometries in new class ROIGeometry.
- ModuleGeometry updates based on ROI

## ROIGeometry: 
- stores number of modules overlapping with ROI and its indices
- size of ROI 

Note: only tested size of the resulting frames not the actual values

---------

Co-authored-by: Erik Fröjdh <erik.frojdh@psi.ch>
Co-authored-by: Erik Fröjdh <erik.frojdh@gmail.com>
This commit is contained in:
2026-02-18 10:57:56 +01:00
committed by GitHub
co-authored by GitHub Erik Fröjdh Erik Fröjdh
parent 7f64b9a616
commit 218f31ce60
17 changed files with 1239 additions and 418 deletions
+42
View File
@@ -0,0 +1,42 @@
#include "aare/ROIGeometry.hpp"
#include <vector>
namespace aare {
ROIGeometry::ROIGeometry(const ROI &roi, DetectorGeometry &geometry)
: m_pixels_x(roi.width()), m_pixels_y(roi.height()), m_geometry(geometry) {
m_module_indices_in_roi.reserve(m_geometry.n_modules());
// determine which modules are in the roi
for (size_t i = 0; i < m_geometry.n_modules(); ++i) {
auto &module_geometry = m_geometry.get_module_geometries(i);
if (module_geometry.module_in_roi(roi)) {
module_geometry.update_geometry_with_roi(roi);
m_module_indices_in_roi.push_back(i);
}
}
};
ROIGeometry::ROIGeometry(DetectorGeometry &geometry)
: m_pixels_x(geometry.pixels_x()), m_pixels_y(geometry.pixels_y()),
m_geometry(geometry) {
m_module_indices_in_roi.resize(m_geometry.n_modules());
std::iota(m_module_indices_in_roi.begin(), m_module_indices_in_roi.end(),
0);
};
size_t ROIGeometry::num_modules_in_roi() const {
return m_module_indices_in_roi.size();
}
const std::vector<size_t> &ROIGeometry::module_indices_in_roi() const {
return m_module_indices_in_roi;
}
size_t ROIGeometry::module_indices_in_roi(const size_t module_index) const {
return m_module_indices_in_roi.at(module_index);
}
size_t ROIGeometry::pixels_x() const { return m_pixels_x; }
size_t ROIGeometry::pixels_y() const { return m_pixels_y; }
} // namespace aare