Mantid
Loading...
Searching...
No Matches
MDHistoWorkspaceIterator.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2011 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
13#include <boost/tuple/tuple.hpp>
14#include <map>
15#include <vector>
16
17namespace Mantid {
18namespace DataObjects {
19
20// Typedef for a map for mapping width of neighbours (key) to permutations
21// needed in the calcualtion.
22using PermutationsMap = std::map<std::vector<int>, std::vector<int64_t>>;
23// Typedef for extents
24using MDExtentPair = boost::tuple<Mantid::coord_t, Mantid::coord_t>; // Min/Max pair
25// Typedef for vector of extents
26using VecMDExtents = std::vector<MDExtentPair>;
27
36class MANTID_DATAOBJECTS_DLL MDHistoWorkspaceIterator : public Mantid::API::IMDIterator {
37public:
39 Mantid::Geometry::MDImplicitFunction *function = nullptr, size_t beginPos = 0,
40 size_t endPos = size_t(-1));
42 Mantid::Geometry::MDImplicitFunction *function = nullptr, size_t beginPos = 0,
43 size_t endPos = size_t(-1));
45 Mantid::Geometry::MDImplicitFunction *function = nullptr, size_t beginPos = 0,
46 size_t endPos = size_t(-1));
48 size_t beginPos = 0, size_t endPos = size_t(-1));
50
51 void init(const MDHistoWorkspace *workspace, Mantid::Geometry::MDImplicitFunction *function, size_t beginPos = 0,
52 size_t endPos = size_t(-1));
53
54 size_t getDataSize() const override;
55
56 bool valid() const override;
57
58 bool next() override;
59
60 bool next(size_t skip) override;
61
62 void jumpTo(size_t index) override;
63
64 virtual coord_t jumpToNearest(const Mantid::Kernel::VMD &fromLocation);
65
66 signal_t getNormalizedSignal() const override;
67
68 signal_t getNormalizedError() const override;
69
70 signal_t getSignal() const override;
71
72 signal_t getError() const override;
73
74 std::unique_ptr<coord_t[]> getVertexesArray(size_t &numVertices) const override;
75
76 std::unique_ptr<coord_t[]> getVertexesArray(size_t &numVertices, const size_t outDimensions,
77 const bool *maskDim) const override;
78
79 Mantid::Kernel::VMD getCenter() const override;
80
81 size_t getNumEvents() const override;
82
83 virtual signal_t getNumEventsFraction() const;
84
85 uint16_t getInnerExpInfoIndex(size_t index) const override;
86
87 uint16_t getInnerGoniometerIndex(size_t index) const override;
88
89 int32_t getInnerDetectorID(size_t index) const override;
90
91 coord_t getInnerPosition(size_t index, size_t dimension) const override;
92
93 signal_t getInnerSignal(size_t index) const override;
94
95 signal_t getInnerError(size_t index) const override;
96
97 bool getIsMasked() const override;
98
99 size_t getLinearIndex() const override;
100
101 std::vector<size_t> findNeighbourIndexes() const override;
102
103 std::vector<size_t> findNeighbourIndexesFaceTouching() const override;
104
105 std::vector<size_t> findNeighbourIndexesByWidth(const int &width) const;
106
107 std::pair<std::vector<size_t>, std::vector<bool>> findNeighbourIndexesByWidth1D(const int &width,
108 const int &width_dimension) const;
109
110 std::vector<size_t> findNeighbourIndexesByWidth(const std::vector<int> &widths) const;
111
112 bool isWithinBounds(size_t index) const override;
113
114 size_t permutationCacheSize() const;
115
116 VecMDExtents getBoxExtents() const;
117
118protected:
121
123 uint64_t m_pos;
124
126 uint64_t m_begin;
127
129 uint64_t m_max;
130
132 std::unique_ptr<Mantid::Geometry::MDImplicitFunction> m_function;
133
135 size_t m_nd;
136
139
142
145
147 size_t *m_index;
148
150 size_t *m_indexMax;
151
154
156 mutable std::vector<int64_t> m_permutationsFaceTouching;
157
161
164
166 std::vector<int64_t> createPermutations(const std::vector<int> &widths) const;
167};
168
169} // namespace DataObjects
170} // namespace Mantid
IPeaksWorkspace_sptr workspace
Definition: IndexPeaks.cpp:114
std::map< DeltaEMode::Type, std::string > index
Definition: DeltaEMode.cpp:19
This is an interface to an iterator of an IMDWorkspace.
Definition: IMDIterator.h:39
An implementation of IMDIterator that iterates through a MDHistoWorkspace.
coord_t * m_binWidth
Width of each bin in each dimension.
uint64_t m_pos
The linear position/index into the MDHistoWorkspace.
std::vector< int64_t > m_permutationsFaceTouching
Neigbour finding permutations for face touching neighbours (3 by 3 width).
uint64_t m_max
The maximum linear index in the workspace.
std::unique_ptr< Mantid::Geometry::MDImplicitFunction > m_function
Implicit function to limit volume searched.
PermutationsMap m_permutationsVertexTouchingMap
Neighbour finding permutations map for vertex touching.
coord_t * m_origin
Origin (index 0,0,0) in the space = the minimum of each dimension.
size_t * m_indexMaker
Array to find indices from linear indices.
coord_t * m_center
Center of the current box. Not set until getCenter() is called.
SkippingPolicy_scptr m_skippingPolicy
Skipping policy.
const MDHistoWorkspace * m_ws
The MDHistoWorkspace being iterated.
uint64_t m_begin
The beginning linear index in the workspace.
SkippingPolicy : Policy types for skipping in MDiterators.
An "ImplicitFunction" defining a hyper-cuboid-shaped region in N dimensions.
boost::scoped_ptr< SkippingPolicy > SkippingPolicy_scptr
boost::tuple< Mantid::coord_t, Mantid::coord_t > MDExtentPair
std::map< std::vector< int >, std::vector< int64_t > > PermutationsMap
std::shared_ptr< const MDHistoWorkspace > MDHistoWorkspace_const_sptr
A shared pointer to a const MDHistoWorkspace.
std::vector< MDExtentPair > VecMDExtents
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