Mantid
Loading...
Searching...
No Matches
MDBoxIterator.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
15
16namespace Mantid {
17namespace DataObjects {
18// Forward declaration.
19class SkippingPolicy;
20
28class MANTID_DATAOBJECTS_DLL MDBoxIterator : public Mantid::API::IMDIterator {
29public:
30 MDBoxIterator(API::IMDNode *topBox, size_t maxDepth, bool leafOnly,
31 Mantid::Geometry::MDImplicitFunction *function = nullptr);
32 MDBoxIterator(API::IMDNode *topBox, size_t maxDepth, bool leafOnly, SkippingPolicy *skippingPolicy,
33 Mantid::Geometry::MDImplicitFunction *function = nullptr);
34 MDBoxIterator(std::vector<API::IMDNode *> &boxes, size_t begin, size_t end);
35 void init(std::vector<API::IMDNode *> &boxes, size_t begin, size_t end);
36 ~MDBoxIterator() override;
37
39 MDBoxBase<MDE, nd> *getBox() const { return (m_current); }
40
42 size_t getDataSize() const override;
43
44 bool valid() const override;
45
46 void jumpTo(size_t index) override;
47
48 bool next() override;
49
50 bool next(size_t skip) override;
51
52 signal_t getNormalizedSignal() const override;
53
54 signal_t getNormalizedError() const override;
55
56 signal_t getSignal() const override;
57
58 signal_t getError() const override;
59
60 std::unique_ptr<coord_t[]> getVertexesArray(size_t &numVertices, const size_t outDimensions,
61 const bool *maskDim) const override;
62
63 std::unique_ptr<coord_t[]> getVertexesArray(size_t &numVertices) const override;
64
66
67 size_t getNumEvents() const override;
68
69 uint16_t getInnerExpInfoIndex(size_t index) const override;
70
71 uint16_t getInnerGoniometerIndex(size_t index) const override;
72
73 int32_t getInnerDetectorID(size_t index) const override;
74
75 coord_t getInnerPosition(size_t index, size_t dimension) const override;
76
77 signal_t getInnerSignal(size_t index) const override;
78
79 signal_t getInnerError(size_t index) const override;
80
81 bool getIsMasked() const override;
82
84 size_t getPosition() const { return m_pos; }
85
86 std::vector<size_t> findNeighbourIndexes() const override;
87
88 std::vector<size_t> findNeighbourIndexesFaceTouching() const override;
89
90 size_t getLinearIndex() const override;
91
92 bool isWithinBounds(size_t index) const override;
93
94private:
96 void commonConstruct(API::IMDNode *topBox, size_t maxDepth, bool leafOnly,
98
99 void getEvents() const;
100
101 void releaseEvents() const;
102
104 size_t m_pos;
105
107 size_t m_max;
108
110 std::vector<API::IMDNode *> m_boxes;
111
114
117
119 mutable const std::vector<MDE> *m_events;
120
121 // Skipping policy, controlls recursive calls to next().
123};
124
125} // namespace DataObjects
126} // namespace Mantid
std::map< DeltaEMode::Type, std::string > index
Definition: DeltaEMode.cpp:19
#define TMDE_CLASS
Macro to make declaring template classes faster.
Definition: MDTypes.h:58
This is an interface to an iterator of an IMDWorkspace.
Definition: IMDIterator.h:39
Templated super-class of a multi-dimensional event "box".
Definition: MDBoxBase.h:50
MDBoxIterator: iterate through MDBoxBase hierarchy down to a given maximum depth.
Definition: MDBoxIterator.h:28
signal_t getInnerError(size_t index) const override
Returns the error of a given event.
bool next() override
Advance to the next cell.
MDBox< MDE, nd > * m_currentMDBox
MDBox currently pointed to.
std::unique_ptr< coord_t[]> getVertexesArray(size_t &numVertices) const override
Return a list of vertexes defining the volume pointed to.
uint16_t getInnerExpInfoIndex(size_t index) const override
For a given event/point in this box, return the associated experiment-info index.
std::vector< size_t > findNeighbourIndexes() const override
Find neighbouring indexes vertex touching.
size_t m_pos
Current position in the vector of boxes.
signal_t getInnerSignal(size_t index) const override
Returns the signal of a given event.
uint16_t getInnerGoniometerIndex(size_t index) const override
For a given event/point in this box, return the goniometer index.
MDBoxIterator(API::IMDNode *topBox, size_t maxDepth, bool leafOnly, Mantid::Geometry::MDImplicitFunction *function=nullptr)
SkippingPolicy_scptr m_skippingPolicy
size_t getPosition() const
Getter for the position of the iterator.
Definition: MDBoxIterator.h:84
bool isWithinBounds(size_t index) const override
Is index reachable by the iterator.
std::vector< size_t > findNeighbourIndexesFaceTouching() const override
Find neighbouring indexes face touching.
void jumpTo(size_t index) override
Jump to the index^th cell.
bool next(size_t skip) override
Advance, skipping a certain number of cells.
size_t getLinearIndex() const override
Get the linear index.
coord_t getInnerPosition(size_t index, size_t dimension) const override
Returns the position of a given event for a given dimension.
int32_t getInnerDetectorID(size_t index) const override
For a given event/point in this box, return the detector ID.
bool getIsMasked() const override
Returns true if masking is used.
MDBoxBase< MDE, nd > * m_current
Box currently pointed to.
signal_t getSignal() const override
Returns the total signal for this box.
Mantid::Kernel::VMD getCenter() const override
Returns the position of the center of the box pointed to.
signal_t getError() const override
Returns the total error for this box.
size_t getDataSize() const override
---------— IMDIterator Methods ---------------------------—
signal_t getNormalizedError() const override
Returns the normalized error for this box.
std::unique_ptr< coord_t[]> getVertexesArray(size_t &numVertices, const size_t outDimensions, const bool *maskDim) const override
Return a list of vertexes defining the volume pointed to, enable masking of dimensions.
MDBoxBase< MDE, nd > * getBox() const
Return a pointer to the current box pointed to by the iterator.
Definition: MDBoxIterator.h:39
void commonConstruct(API::IMDNode *topBox, size_t maxDepth, bool leafOnly, Mantid::Geometry::MDImplicitFunction *function)
Common code run my a few of the constructors.
MDBoxIterator(std::vector< API::IMDNode * > &boxes, size_t begin, size_t end)
const std::vector< MDE > * m_events
Pointer to the const events vector. Only initialized when needed.
signal_t getNormalizedSignal() const override
Returns the normalized signal for this box.
bool valid() const override
Is the current position of the iterator valid?
std::vector< API::IMDNode * > m_boxes
Vector of all the boxes that will be iterated.
void init(std::vector< API::IMDNode * > &boxes, size_t begin, size_t end)
MDBoxIterator(API::IMDNode *topBox, size_t maxDepth, bool leafOnly, SkippingPolicy *skippingPolicy, Mantid::Geometry::MDImplicitFunction *function=nullptr)
size_t m_max
Max pos = length of the boxes vector.
size_t getNumEvents() const override
Returns the number of events/points contained in this box.
Templated class for a multi-dimensional event "box".
Definition: MDBox.h:45
SkippingPolicy : Policy types for skipping in MDiterators.
An "ImplicitFunction" defining a hyper-cuboid-shaped region in N dimensions.
boost::scoped_ptr< SkippingPolicy > SkippingPolicy_scptr
Helper class which provides the Collimation Length for SANS instruments.
float coord_t
Typedef for the data type to use for coordinate axes in MD objects such as MDBox, MDEventWorkspace,...
Definition: MDTypes.h:27
double signal_t
Typedef for the signal recorded in a MDBox, etc.
Definition: MDTypes.h:36