BornAgain  1.18.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 scattering at grazing incidence
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 #ifndef BORNAGAIN_CORE_DETECTOR_SIMULATIONAREAITERATOR_H
16 #define BORNAGAIN_CORE_DETECTOR_SIMULATIONAREAITERATOR_H
17 
18 #include <cstdlib>
19 class SimulationArea;
20 
21 //! An iterator for SimulationArea.
22 //! @ingroup detector
23 
25 {
26 public:
27  explicit SimulationAreaIterator(const SimulationArea* area, size_t start_at_index);
28 
29  size_t index() const { return m_index; }
30  size_t elementIndex() const { return m_element_index; }
31  size_t roiIndex() const;
32  size_t detectorIndex() const;
33 
34  bool operator==(const SimulationAreaIterator& other) const;
35  bool operator!=(const SimulationAreaIterator& other) const;
36 
37  //! prefix increment
39 
40  //! postfix increment
42 
43 private:
44  size_t nextIndex(size_t currentIndex);
46  size_t m_index; //!< global index in detector plane defined by its axes
47  size_t m_element_index; //!< sequential number for SimulationElementVector
48 };
49 
51 {
52  return m_area == other.m_area && m_index == other.m_index;
53 }
54 
56 {
57  return !(*this == right);
58 }
59 
60 #endif // BORNAGAIN_CORE_DETECTOR_SIMULATIONAREAITERATOR_H
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...