19 DetectorMask::DetectorMask() : m_number_of_masked_channels(0) {}
22 : m_shapes(other.m_shapes), m_mask_of_shape(other.m_mask_of_shape),
23 m_number_of_masked_channels(other.m_number_of_masked_channels)
25 m_mask_data.copyFrom(other.m_mask_data);
31 m_shapes = other.m_shapes;
32 m_mask_of_shape = other.m_mask_of_shape;
33 m_mask_data.copyFrom(other.m_mask_data);
34 m_number_of_masked_channels = other.m_number_of_masked_channels;
43 m_shapes.push_back(shape.clone());
44 m_mask_of_shape.push_back(mask_value);
46 m_number_of_masked_channels = 0;
53 "to add masks to uninitialized detector.");
55 ASSERT(m_shapes.size() == m_mask_of_shape.size());
58 for (
size_t dim = 0; dim < detector.
dimension(); ++dim) {
59 const IAxis& axis = detector.getAxis(dim);
60 m_mask_data.addAxis(axis);
68 ASSERT(m_shapes.size() == m_mask_of_shape.size());
71 for (
size_t dim = 0; dim < data.
getRank(); ++dim)
72 m_mask_data.addAxis(data.
getAxis(dim));
77 bool DetectorMask::isMasked(
size_t index)
const
79 return m_number_of_masked_channels == 0 ? false : m_mask_data[index];
85 data.copyShapeFrom(m_mask_data);
87 data[i] =
static_cast<double>(m_mask_data[i]);
88 return dynamic_cast<Histogram2D*
>(IHistogram::createHistogram(data));
94 m_mask_of_shape.clear();
98 size_t DetectorMask::numberOfMasks()
const
100 return m_shapes.size();
103 const IShape2D* DetectorMask::getMaskShape(
size_t mask_index,
bool& mask_value)
const
105 if (mask_index >= numberOfMasks())
107 mask_value = m_mask_of_shape[mask_index];
108 return m_shapes[mask_index];
111 void DetectorMask::process_masks()
114 if (!!m_shapes.empty())
117 m_number_of_masked_channels = 0;
122 bool is_masked(
false);
123 for (
size_t i_shape = m_shapes.size(); i_shape > 0; --i_shape) {
124 const IShape2D* shape = m_shapes[i_shape - 1];
126 if (m_mask_of_shape[i_shape - 1])
128 m_mask_data[index] = m_mask_of_shape[i_shape - 1];
133 ++m_number_of_masked_channels;
Defines class Histogram2D.
Defines interface IDetector2D.
Defines class RegionOfInterest.
Collection of detector masks.
void removeMasks()
remove all masks and return object to initial state
void addMask(const IShape2D &shape, bool mask_value)
Add mask to the stack of detector masks.
void initMaskData(const IDetector2D &detector)
Init the map of masks for the given detector plane.
Two dimensional histogram.
Interface for one-dimensional axes.
Abstract 2D detector interface.
size_t dimension() const
Returns actual dimensionality of the detector (number of defined axes)
Basic class for all shapes in 2D.
virtual bool contains(double x, double y) const =0
Returns true if point with given coordinates is inside or on border of the shape.
void setAllTo(const T &value)
Sets content of output data to specific value.
size_t getRank() const
Returns number of dimensions.
Bin1D getAxisBin(size_t global_index, size_t i_selected_axis) const
Returns bin of selected axis for given global_index.
const IAxis & getAxis(size_t serial_number) const
returns axis with given serial number
size_t getAllocatedSize() const
Returns total size of data buffer (product of bin number in every dimension).
void clear()
Sets object into initial state (no dimensions, data)