@@ -19,6 +19,7 @@ using Mantid::Kernel::V3D;
19
19
namespace Mantid ::API {
20
20
/* *
21
21
* Given the z axis, define the x and y ones.
22
+ *
22
23
* @param zaxis :: A given vector in 3d space to become the z axis of a
23
24
* coordinate system.
24
25
* @param xaxis :: An output arbitrary vector perpendicular to zaxis.
@@ -41,6 +42,13 @@ void PanelsSurfaceCalculator::setupBasisAxes(const Mantid::Kernel::V3D &zaxis, M
41
42
xaxis = yaxis.cross_prod (zaxis);
42
43
}
43
44
45
+ /* *
46
+ * Returns the four corners of the specified panel
47
+ *
48
+ * @param componentInfo :: ComponentInfo object from the workspace
49
+ * @param rootIndex :: Index of panel
50
+ * @returns :: Panel Corners
51
+ */
44
52
std::vector<Mantid::Kernel::V3D>
45
53
PanelsSurfaceCalculator::retrievePanelCorners (const Mantid::Geometry::ComponentInfo &componentInfo,
46
54
const size_t rootIndex) const {
@@ -97,6 +105,12 @@ PanelsSurfaceCalculator::retrievePanelCorners(const Mantid::Geometry::ComponentI
97
105
return corners;
98
106
}
99
107
108
+ /* *
109
+ * Calculate the normal vector to a panel
110
+ *
111
+ * @param panelCorners :: The four panel corner locations
112
+ * @returns :: Normal vector
113
+ */
100
114
Mantid::Kernel::V3D
101
115
PanelsSurfaceCalculator::calculatePanelNormal (const std::vector<Mantid::Kernel::V3D> &panelCorners) const {
102
116
// find the normal
@@ -106,6 +120,15 @@ PanelsSurfaceCalculator::calculatePanelNormal(const std::vector<Mantid::Kernel::
106
120
return normal;
107
121
}
108
122
123
+ /* *
124
+ * Do all the detectors lie in a plane?
125
+ *
126
+ * @param componentInfo :: ComponentInfo object from the workspace
127
+ * @param bankIndex :: Component index of bank
128
+ * @param tubes :: Tube component indices
129
+ * @param normal :: Panel normal vector
130
+ * @returns Do the detectors lie flat in a plane?
131
+ */
109
132
bool PanelsSurfaceCalculator::isBankFlat (const ComponentInfo &componentInfo, size_t bankIndex,
110
133
const std::vector<size_t > &tubes, const Mantid::Kernel::V3D &normal) {
111
134
for (auto tube : tubes) {
@@ -119,6 +142,13 @@ bool PanelsSurfaceCalculator::isBankFlat(const ComponentInfo &componentInfo, siz
119
142
return true ;
120
143
}
121
144
145
+ /* *
146
+ * Calculate the normal vector of a bank of detectors
147
+ *
148
+ * @param componentInfo :: ComponentInfo object from the workspace
149
+ * @param tubes :: Component indices of the tubes in the bank
150
+ * @returns Bank normal vector
151
+ */
122
152
Mantid::Kernel::V3D PanelsSurfaceCalculator::calculateBankNormal (const ComponentInfo &componentInfo,
123
153
const std::vector<size_t > &tubes) {
124
154
// calculate normal from first two tubes in bank as before
@@ -146,7 +176,13 @@ Mantid::Kernel::V3D PanelsSurfaceCalculator::calculateBankNormal(const Component
146
176
return normal;
147
177
}
148
178
149
- // Recursively set all detectors and subcomponents of a bank as visited
179
+ /* *
180
+ * Recursively set all detectors and subcomponents of a bank as visited
181
+ *
182
+ * @param componentInfo :: ComponentInfo object from the workspace
183
+ * @param bankIndex :: Component index of the bank
184
+ * @param visitedComponents :: Vector keeping track of which components have been visited
185
+ */
150
186
void PanelsSurfaceCalculator::setBankVisited (const ComponentInfo &componentInfo, size_t bankIndex,
151
187
std::vector<bool > &visitedComponents) const {
152
188
const auto &children = componentInfo.children (bankIndex);
@@ -160,6 +196,13 @@ void PanelsSurfaceCalculator::setBankVisited(const ComponentInfo &componentInfo,
160
196
}
161
197
}
162
198
199
+ /* *
200
+ * How many detectors are there in the given list of component indices?
201
+ *
202
+ * @param componentInfo :: ComponentInfo object from the workspace
203
+ * @param components :: Component indices to check
204
+ * @return :: Number of detectors
205
+ */
163
206
size_t PanelsSurfaceCalculator::findNumDetectors (const ComponentInfo &componentInfo,
164
207
const std::vector<size_t > &components) const {
165
208
return std::accumulate (
@@ -173,6 +216,10 @@ size_t PanelsSurfaceCalculator::findNumDetectors(const ComponentInfo &componentI
173
216
*
174
217
* @param detPos :: Position of a detector of the bank.
175
218
* @param normal :: Normal to the bank's plane.
219
+ * @param zAxis :: Direction to the viewer
220
+ * @param yAxis :: Perpendicular axis
221
+ * @param samplePosition :: Sample position
222
+ * @returns :: Rotation
176
223
*/
177
224
Mantid::Kernel::Quat PanelsSurfaceCalculator::calcBankRotation (const V3D &detPos, V3D normal, const V3D &zAxis,
178
225
const V3D &yAxis, const V3D &samplePosition) const {
@@ -213,6 +260,17 @@ Mantid::Kernel::Quat PanelsSurfaceCalculator::calcBankRotation(const V3D &detPos
213
260
return requiredRotation;
214
261
}
215
262
263
+ /* *
264
+ * Transforms bounding box of a detector
265
+ *
266
+ * @param componentInfo :: ComponentInfo object from the workspace
267
+ * @param detectorIndex :: Component index of the detector
268
+ * @param refPos :: Reference position
269
+ * @param rotation :: Rotation to apply
270
+ * @param xaxis :: X axis
271
+ * @param yaxis :: Y axis
272
+ * @returns Transformed bounding box points
273
+ */
216
274
std::vector<Mantid::Kernel::V2D>
217
275
PanelsSurfaceCalculator::transformedBoundingBoxPoints (const ComponentInfo &componentInfo, size_t detectorIndex,
218
276
const V3D &refPos, const Mantid::Kernel::Quat &rotation,
@@ -229,6 +287,13 @@ PanelsSurfaceCalculator::transformedBoundingBoxPoints(const ComponentInfo &compo
229
287
return {bb0, bb1};
230
288
}
231
289
290
+ /* *
291
+ * Perform a specified operation on all the components
292
+ *
293
+ * @param componentInfo :: ComponentInfo object from the workspace
294
+ * @param operation :: Operation to perform on each component
295
+ * @returns Detector IDs for each component
296
+ */
232
297
std::vector<std::vector<size_t >> PanelsSurfaceCalculator::examineAllComponents (
233
298
const ComponentInfo &componentInfo,
234
299
std::function<std::vector<size_t >(const ComponentInfo &, size_t , std::vector<bool > &)> operation) {
@@ -248,6 +313,14 @@ std::vector<std::vector<size_t>> PanelsSurfaceCalculator::examineAllComponents(
248
313
return detectorIDs;
249
314
}
250
315
316
+ /* *
317
+ * Parent indices of tubes
318
+ *
319
+ * @param componentInfo :: ComponentInfo object from the workspace
320
+ * @param rootIndex :: Component index to check
321
+ * @param visited :: Vector tracking which components have been checked
322
+ * @returns Parent IDs
323
+ */
251
324
std::vector<size_t > PanelsSurfaceCalculator::tubeDetectorParentIDs (const ComponentInfo &componentInfo, size_t rootIndex,
252
325
std::vector<bool > &visited) {
253
326
const auto componentType = componentInfo.componentType (rootIndex);
@@ -307,6 +380,14 @@ std::vector<size_t> PanelsSurfaceCalculator::tubeDetectorParentIDs(const Compone
307
380
return tubes;
308
381
}
309
382
383
+ /* *
384
+ * Gives the specified side-by-side view position from the IDF
385
+ *
386
+ * @param componentInfo :: ComponentInfo object from the workspace
387
+ * @param instrument :: Instrument object from the workspace
388
+ * @param componentIndex :: Component index to check
389
+ * @returns :: Side-by-side position from the IDF
390
+ */
310
391
std::optional<Kernel::V2D> PanelsSurfaceCalculator::getSideBySideViewPos (const ComponentInfo &componentInfo,
311
392
const Instrument_const_sptr instrument,
312
393
const size_t componentIndex) const {
0 commit comments