BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
SimulationArea.cpp
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Device/Detector/SimulationArea.cpp
6 //! @brief Implements class SimulationArea.
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************** //
14 
19 #include "Device/Mask/Rectangle.h"
20 #include <sstream>
21 
22 SimulationArea::SimulationArea(const IDetector* detector) : m_detector(detector), m_max_index(0)
23 {
24  if (m_detector == nullptr)
25  throw std::runtime_error("SimulationArea::SimulationArea: null pointer passed"
26  " as detector");
27 
28  if (m_detector->dimension() == 0)
29  throw std::runtime_error(
30  "SimulationArea::SimulationArea: detector of unspecified dimensionality");
31 
34  else
36 }
37 
39 {
40  return SimulationAreaIterator(this, 0);
41 }
42 
44 {
45  return SimulationAreaIterator(this, totalSize());
46 }
47 
48 bool SimulationArea::isMasked(size_t index) const
49 {
50  auto masks = m_detector->detectorMask();
51  return (masks && masks->hasMasks() && masks->isMasked(detectorIndex(index)));
52 }
53 
54 size_t SimulationArea::roiIndex(size_t index) const
55 {
56  return index;
57 }
58 
59 size_t SimulationArea::detectorIndex(size_t index) const
60 {
62  return index;
63 
64  return m_detector->regionOfInterest()->detectorIndex(index);
65 }
66 
67 // --------------------------------------------------------------------------------------
68 
70 
71 bool SimulationRoiArea::isMasked(size_t) const
72 {
73  return false;
74 }
Defines class DetectorMask.
Defines common detector interface.
Defines class Rectangle.
Defines class RegionOfInterest.
Defines class SimulationArea.
Abstract detector interface.
Definition: IDetector.h:36
virtual const DetectorMask * detectorMask() const =0
Returns detector masks container.
size_t dimension() const
Returns actual dimensionality of the detector (number of defined axes)
Definition: IDetector.cpp:44
size_t totalSize() const
Returns total number of pixels.
Definition: IDetector.cpp:87
virtual const RegionOfInterest * regionOfInterest() const =0
Returns region of interest if exists.
size_t detectorIndex(size_t roiIndex) const
Converts roi index to the detector index.
size_t roiSize() const
Number of detector bins in ROI area.
An iterator for SimulationArea.
Holds iteration logic over active detector channels in the presence of masked areas and RegionOfInter...
size_t totalSize() const
virtual bool isMasked(size_t index) const
returns true if given iterator index correspond to masked detector channel
size_t detectorIndex(size_t index) const
Return detector index from iterator index.
SimulationAreaIterator begin()
SimulationAreaIterator end()
SimulationArea(const IDetector *detector)
size_t roiIndex(size_t index) const
Return index in ROI map from iterator index.
const IDetector * m_detector
virtual bool isMasked(size_t) const
returns true if given iterator index correspond to masked detector channel
SimulationRoiArea(const IDetector *detector)