forked from npshub/mantid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MDBoxIterator.h
127 lines (87 loc) · 3.91 KB
/
MDBoxIterator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source,
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
#pragma once
#include "MantidAPI/IMDIterator.h"
#include "MantidDataObjects/MDBox.h"
#include "MantidDataObjects/MDBoxBase.h"
#include "MantidDataObjects/MDLeanEvent.h"
#include "MantidDataObjects/SkippingPolicy.h"
#include "MantidGeometry/MDGeometry/MDImplicitFunction.h"
#include "MantidKernel/System.h"
namespace Mantid {
namespace DataObjects {
// Forward declaration.
class SkippingPolicy;
/** MDBoxIterator: iterate through MDBoxBase
* hierarchy down to a given maximum depth.
*
* @author Janik Zikovsky
* @date 2011-06-03
*/
TMDE_CLASS
class DLLExport MDBoxIterator : public Mantid::API::IMDIterator {
public:
MDBoxIterator(API::IMDNode *topBox, size_t maxDepth, bool leafOnly,
Mantid::Geometry::MDImplicitFunction *function = nullptr);
MDBoxIterator(API::IMDNode *topBox, size_t maxDepth, bool leafOnly, SkippingPolicy *skippingPolicy,
Mantid::Geometry::MDImplicitFunction *function = nullptr);
MDBoxIterator(std::vector<API::IMDNode *> &boxes, size_t begin, size_t end);
void init(std::vector<API::IMDNode *> &boxes, size_t begin, size_t end);
~MDBoxIterator() override;
/// Return a pointer to the current box pointed to by the iterator.
MDBoxBase<MDE, nd> *getBox() const { return (m_current); }
/// ------------ IMDIterator Methods ------------------------------
size_t getDataSize() const override;
bool valid() const override;
void jumpTo(size_t index) override;
bool next() override;
bool next(size_t skip) override;
signal_t getNormalizedSignal() const override;
signal_t getNormalizedError() const override;
signal_t getSignal() const override;
signal_t getError() const override;
std::unique_ptr<coord_t[]> getVertexesArray(size_t &numVertices, const size_t outDimensions,
const bool *maskDim) const override;
std::unique_ptr<coord_t[]> getVertexesArray(size_t &numVertices) const override;
Mantid::Kernel::VMD getCenter() const override;
size_t getNumEvents() const override;
uint16_t getInnerExpInfoIndex(size_t index) const override;
uint16_t getInnerGoniometerIndex(size_t index) const override;
int32_t getInnerDetectorID(size_t index) const override;
coord_t getInnerPosition(size_t index, size_t dimension) const override;
signal_t getInnerSignal(size_t index) const override;
signal_t getInnerError(size_t index) const override;
bool getIsMasked() const override;
/// Getter for the position of the iterator.
size_t getPosition() const { return m_pos; }
std::vector<size_t> findNeighbourIndexes() const override;
std::vector<size_t> findNeighbourIndexesFaceTouching() const override;
size_t getLinearIndex() const override;
bool isWithinBounds(size_t index) const override;
private:
/// Common code run my a few of the constructors.
void commonConstruct(API::IMDNode *topBox, size_t maxDepth, bool leafOnly,
Mantid::Geometry::MDImplicitFunction *function);
void getEvents() const;
void releaseEvents() const;
/// Current position in the vector of boxes
size_t m_pos;
/// Max pos = length of the boxes vector.
size_t m_max;
/// Vector of all the boxes that will be iterated.
std::vector<API::IMDNode *> m_boxes;
/// Box currently pointed to
MDBoxBase<MDE, nd> *m_current;
/// MDBox currently pointed to
mutable MDBox<MDE, nd> *m_currentMDBox;
/// Pointer to the const events vector. Only initialized when needed.
mutable const std::vector<MDE> *m_events;
// Skipping policy, controlls recursive calls to next().
SkippingPolicy_scptr m_skippingPolicy;
};
} // namespace DataObjects
} // namespace Mantid