BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
SimulationAreaIterator.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Device/Detector/SimulationAreaIterator.h
6 //! @brief Defines class SimulationAreaIterator.
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 
15 #ifdef SWIG
16 #error no need to expose this header to Swig
17 #endif
18 
19 #ifndef USER_API
20 #ifndef BORNAGAIN_DEVICE_DETECTOR_SIMULATIONAREAITERATOR_H
21 #define BORNAGAIN_DEVICE_DETECTOR_SIMULATIONAREAITERATOR_H
22 
23 #include <cstdlib>
24 class SimulationArea;
25 
26 //! An iterator for SimulationArea.
27 //! @ingroup detector
28 
30 public:
31  explicit SimulationAreaIterator(const SimulationArea* area, size_t start_at_index);
32 
33  size_t index() const { return m_index; }
34  size_t elementIndex() const { return m_element_index; }
35  size_t roiIndex() const;
36  size_t detectorIndex() const;
37 
38  bool operator==(const SimulationAreaIterator& other) const;
39  bool operator!=(const SimulationAreaIterator& other) const;
40 
41  //! prefix increment
43 
44  //! postfix increment
46 
47 private:
48  size_t nextIndex(size_t currentIndex);
50  size_t m_index; //!< global index in detector plane defined by its axes
51  size_t m_element_index; //!< sequential number for SimulationElementVector
52 };
53 
55 {
56  return m_area == other.m_area && m_index == other.m_index;
57 }
58 
60 {
61  return !(*this == right);
62 }
63 
64 #endif // BORNAGAIN_DEVICE_DETECTOR_SIMULATIONAREAITERATOR_H
65 #endif // USER_API
An iterator for SimulationArea.
size_t nextIndex(size_t currentIndex)
const SimulationArea * m_area
SimulationAreaIterator(const SimulationArea *area, size_t start_at_index)
SimulationAreaIterator & operator++()
prefix increment
bool operator!=(const SimulationAreaIterator &other) const
size_t m_index
global index in detector plane defined by its axes
bool operator==(const SimulationAreaIterator &other) const
size_t m_element_index
sequential number for SimulationElementVector
Holds iteration logic over active detector channels in the presence of masked areas and RegionOfInter...