Newer
Older
// ************************************************************************************************
// BornAgain: simulate and fit reflection and scattering
//! @brief Implements class DetectorMask.
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2018
//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
// ************************************************************************************************
MaskPattern::MaskPattern(IShape2D* shape_, bool doMask_)
: shape(shape_)
, doMask(doMask_)
{
}
MaskPattern::~MaskPattern()
{
delete shape;
}
MaskPattern* MaskPattern::clone() const
{
return new MaskPattern(shape->clone(), doMask);
}
DetectorMask::DetectorMask(const Scale& xAxis, const Scale& yAxis)

Wuttke, Joachim
committed
: m_xAxis(xAxis.clone())
, m_yAxis(yAxis.clone())
, m_masked(xAxis.size() * yAxis.size(), false)
DetectorMask::~DetectorMask() = default;
DetectorMask::DetectorMask(const DetectorMask& other)

Wuttke, Joachim
committed
: m_xAxis(other.m_xAxis->clone())
, m_yAxis(other.m_yAxis->clone())
, m_stack(other.m_stack)
void DetectorMask::addMask(const IShape2D& shape, bool mask_value)
{
m_stack.emplace_back(new MaskPattern(shape.clone(), mask_value));
bool DetectorMask::isMasked(size_t i_flat) const
size_t DetectorMask::numberOfMasks() const
{
const MaskPattern* DetectorMask::patternAt(size_t iMask) const
{
return m_stack.at(iMask);
}
void DetectorMask::process_masks()
{
m_masked.clear();
m_masked.resize(m_xAxis->size() * m_yAxis->size(), false);
for (size_t i_flat = 0; i_flat < m_masked.size(); ++i_flat) {

Wuttke, Joachim
committed
Bin1D binx = m_xAxis->bin(i_flat % m_xAxis->size());
Bin1D biny = m_yAxis->bin(i_flat / m_xAxis->size());
// setting mask to the data starting from last shape added
for (int k = m_stack.size() - 1; k >= 0; --k) {
const MaskPattern* const pat = m_stack[k];

Wuttke, Joachim
committed
break; // i_flat is covered by the shape, stop looking further