moved ROI definition into seperate file

This commit is contained in:
2026-08-24 14:28:31 +02:00
parent 92ad10f2b6
commit bdb2a762d3
11 changed files with 85 additions and 55 deletions
+4 -3
View File
@@ -345,6 +345,7 @@ set(PUBLICHEADERS
include/aare/hist/PixelHistogramImpl.hpp
include/aare/hist/PedestalTrackingPixelHistogram.hpp
include/aare/GainMap.hpp
include/aare/ROI.hpp
include/aare/ROIGeometry.hpp
include/aare/DetectorGeometry.hpp
include/aare/JungfrauDataFile.hpp
@@ -361,14 +362,14 @@ set(PUBLICHEADERS
include/aare/VarClusterFinder.hpp
include/aare/utils/task.hpp
include/aare/utils/ifstream_helpers.hpp
include/aare/utils/math_helpers.hpp
include/aare/utils/utility_functions.hpp)
include/aare/utils/math_helpers.hpp)
set(SourceFiles
${CMAKE_CURRENT_SOURCE_DIR}/src/calibration.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/CtbRawFile.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/decode.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/defs.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/ROI.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/ROIGeometry.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/DetectorGeometry.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/hist/PedestalTrackingPixelHistogram.cpp
@@ -456,8 +457,8 @@ if(AARE_TESTS)
${CMAKE_CURRENT_SOURCE_DIR}/src/NumpyHelpers.test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/RawFile.test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/RawSubFile.test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/ROI.test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/utils/task.test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/utils/utility_functions.test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/to_string.test.cpp)
target_sources(tests PRIVATE ${TestSources})
endif()
+1 -1
View File
@@ -5,7 +5,7 @@
#include "aare/ClusterVector.hpp"
#include "aare/GainMap.hpp"
#include "aare/NDArray.hpp"
#include "aare/defs.hpp"
#include "aare/ROI.hpp"
#include "aare/logger.hpp"
#include <filesystem>
+1 -1
View File
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: MPL-2.0
#pragma once
#include "aare/ROI.hpp"
#include "aare/ROIGeometry.hpp"
#include "aare/RawMasterFile.hpp" //ROI refactor away
#include "aare/defs.hpp"
#include <iostream>
namespace aare {
@@ -1,13 +1,35 @@
#pragma once
#include "aare/DetectorGeometry.hpp"
#include "aare/defs.hpp"
#include <algorithm>
#include <cstddef>
#include <numeric>
#include <optional>
#include <stdexcept>
#include <vector>
namespace aare {
class ROIGeometry; // forward declaration to avoid circular dependency
class DetectorGeometry; // forward declaration to avoid circular dependency
struct ROI {
ssize_t xmin{};
ssize_t xmax{};
ssize_t ymin{};
ssize_t ymax{};
ssize_t height() const { return ymax - ymin; }
ssize_t width() const { return xmax - xmin; }
bool contains(ssize_t x, ssize_t y) const {
return x >= xmin && x < xmax && y >= ymin && y < ymax;
}
bool operator==(const ROI &other) const {
return xmin == other.xmin && xmax == other.xmax && ymin == other.ymin &&
ymax == other.ymax;
}
};
/**
* @brief Merge all consecutive ROIs in a vector into a single ROI.
* @param rois vector of ROIs to merge
@@ -97,35 +119,14 @@ std::vector<ROI> merge_consecutive_rois(std::vector<ROI> &rois) {
* @param geometry Detector geometry
* @return true if the ROI covers the entire detector geometry, false otherwise
*/
inline bool complete_ROI(const ROI &roi, const DetectorGeometry &geometry) {
return roi.xmin == 0 &&
roi.xmax == static_cast<ssize_t>(geometry.pixels_x()) &&
roi.ymin == 0 &&
roi.ymax == static_cast<ssize_t>(geometry.pixels_y());
}
bool complete_ROI(const ROI &roi, const DetectorGeometry &geometry);
inline bool complete_ROI(const std::vector<ROI> &rois,
const DetectorGeometry &geometry) {
if (rois.empty() or rois.size() > 1) {
return false;
} else {
return complete_ROI(rois[0], geometry);
}
}
bool complete_ROI(const std::vector<ROI> &rois,
const DetectorGeometry &geometry);
inline bool complete_ROI(const ROIGeometry &roi,
const DetectorGeometry &geometry) {
return roi.pixels_x() == geometry.pixels_x() &&
roi.pixels_y() == geometry.pixels_y();
}
bool complete_ROI(const ROIGeometry &roi, const DetectorGeometry &geometry);
inline bool complete_ROI(const std::vector<ROIGeometry> &rois,
const DetectorGeometry &geometry) {
if (rois.empty() or rois.size() > 1) {
return false;
} else {
return complete_ROI(rois[0], geometry);
}
}
bool complete_ROI(const std::vector<ROIGeometry> &rois,
const DetectorGeometry &geometry);
} // namespace aare
+3 -1
View File
@@ -1,6 +1,8 @@
#pragma once
#include "aare/DetectorGeometry.hpp"
#include "aare/defs.hpp"
#include "aare/ROI.hpp"
#include <cstdint>
#include <vector>
namespace aare {
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MPL-2.0
#pragma once
#include "aare/defs.hpp"
#include "aare/ROI.hpp"
#include <algorithm>
#include <chrono>
#include <filesystem>
-18
View File
@@ -94,24 +94,6 @@ template <typename T> struct t_xy {
};
using xy = t_xy<uint32_t>;
struct ROI {
ssize_t xmin{};
ssize_t xmax{};
ssize_t ymin{};
ssize_t ymax{};
ssize_t height() const { return ymax - ymin; }
ssize_t width() const { return xmax - xmin; }
bool contains(ssize_t x, ssize_t y) const {
return x >= xmin && x < xmax && y >= ymin && y < ymax;
}
bool operator==(const ROI &other) const {
return xmin == other.xmin && xmax == other.xmax && ymin == other.ymin &&
ymax == other.ymax;
}
};
/// @brief Chip specifications for Matterhorn1
struct Matterhorn10 {
constexpr static size_t nRows = 256;
+1
View File
@@ -2,6 +2,7 @@
#include "aare/CtbRawFile.hpp"
#include "aare/File.hpp"
#include "aare/Frame.hpp"
#include "aare/ROI.hpp"
#include "aare/RawFile.hpp"
#include "aare/RawMasterFile.hpp"
#include "aare/RawSubFile.hpp"
+43
View File
@@ -0,0 +1,43 @@
#include "aare/ROI.hpp"
#include "aare/DetectorGeometry.hpp"
#include "aare/ROIGeometry.hpp"
namespace aare {
/**
* @brief Check if the ROI covers the entire detector geometry
* @param roi Region of interest
* @param geometry Detector geometry
* @return true if the ROI covers the entire detector geometry, false otherwise
*/
bool complete_ROI(const ROI &roi, const DetectorGeometry &geometry) {
return roi.xmin == 0 &&
roi.xmax == static_cast<ssize_t>(geometry.pixels_x()) &&
roi.ymin == 0 &&
roi.ymax == static_cast<ssize_t>(geometry.pixels_y());
}
bool complete_ROI(const std::vector<ROI> &rois,
const DetectorGeometry &geometry) {
if (rois.empty() or rois.size() > 1) {
return false;
} else {
return complete_ROI(rois[0], geometry);
}
}
bool complete_ROI(const ROIGeometry &roi, const DetectorGeometry &geometry) {
return roi.pixels_x() == geometry.pixels_x() &&
roi.pixels_y() == geometry.pixels_y();
}
bool complete_ROI(const std::vector<ROIGeometry> &rois,
const DetectorGeometry &geometry) {
if (rois.empty() or rois.size() > 1) {
return false;
} else {
return complete_ROI(rois[0], geometry);
}
}
} // namespace aare
@@ -1,4 +1,4 @@
#include "aare/utils/utility_functions.hpp"
#include "aare/ROI.hpp"
#include <catch2/catch_test_macros.hpp>
namespace aare {
+1 -1
View File
@@ -2,11 +2,11 @@
#include "aare/RawFile.hpp"
#include "aare/DetectorGeometry.hpp"
#include "aare/PixelMap.hpp"
#include "aare/ROI.hpp"
#include "aare/ROIGeometry.hpp"
#include "aare/algorithm.hpp"
#include "aare/defs.hpp"
#include "aare/logger.hpp"
#include "aare/utils/utility_functions.hpp"
#include <algorithm>
#include <fmt/format.h>