9e57219b31
ROIAzimuthal can now be restricted to an azimuthal-angle sector in addition to its Q/d range, enabling STXM-style directional ROIs. phi bounds are optional (both-or-neither); absent means a full 360 ring, so existing Q-only azimuthal ROIs are unchanged. - ROIElement::CheckROI gains a phi_deg argument; box/circle ignore it. - MarkROI gains an optional phi_map; ROIMap builds it from Phi_rad alongside the resolution map only when azimuthal ROIs are present. - phi bounds are normalized to [0,360) and wrap-around sectors are supported (phi_min > phi_max). - ROIConfigAzim carries phi_min/phi_max (kept trivially copyable for the union; phi_min == phi_max means full ring). No phi crosses the wire yet (CBOR/API wiring follows separately). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
39 lines
1.6 KiB
C++
39 lines
1.6 KiB
C++
// SPDX-FileCopyrightText: 2024 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#include "ROIElement.h"
|
|
#include "JFJochException.h"
|
|
|
|
ROIElement::ROIElement(const std::string &in_name)
|
|
: name(in_name) {}
|
|
|
|
std::string ROIElement::GetName() const {
|
|
return name;
|
|
}
|
|
|
|
void ROIElement::MarkROI(std::vector<uint16_t> &v, uint16_t value_to_mark, int64_t xpixel, int64_t ypixel,
|
|
const std::vector<float> &resolution_map, const std::vector<float> &phi_map) const {
|
|
|
|
if (resolution_map.size() != xpixel * ypixel)
|
|
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
|
"ROIRectangle: MarkROI mismatch in resolution array size");
|
|
|
|
if (v.size() < xpixel * ypixel)
|
|
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
|
"ROICircle::MarkROI mismatch in input array size");
|
|
|
|
if (value_to_mark >= 16)
|
|
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
|
"ROICircle: Only 16 selections available for ROI");
|
|
|
|
// phi_map is only supplied (and only consulted by azimuthal ROIs) when an
|
|
// azimuthal ROI is present; an empty map means the angle is unconstrained.
|
|
for (int64_t y = 0; y < ypixel; y++) {
|
|
for (int64_t x = 0; x < xpixel; x++) {
|
|
int64_t idx = y * xpixel + x;
|
|
float phi = phi_map.empty() ? 0.0f : phi_map[idx];
|
|
if (CheckROI(x, y, resolution_map[idx], phi))
|
|
v[idx] |= (1<<value_to_mark);
|
|
}
|
|
}
|
|
} |