Skip to content

Commit dea2ccb

Browse files
committed
Add comments to PanelsSurfaceCalculator
1 parent 7fcfe35 commit dea2ccb

File tree

1 file changed

+82
-1
lines changed

1 file changed

+82
-1
lines changed

Framework/API/src/PanelsSurfaceCalculator.cpp

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ using Mantid::Kernel::V3D;
1919
namespace Mantid::API {
2020
/**
2121
* Given the z axis, define the x and y ones.
22+
*
2223
* @param zaxis :: A given vector in 3d space to become the z axis of a
2324
* coordinate system.
2425
* @param xaxis :: An output arbitrary vector perpendicular to zaxis.
@@ -41,6 +42,13 @@ void PanelsSurfaceCalculator::setupBasisAxes(const Mantid::Kernel::V3D &zaxis, M
4142
xaxis = yaxis.cross_prod(zaxis);
4243
}
4344

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+
*/
4452
std::vector<Mantid::Kernel::V3D>
4553
PanelsSurfaceCalculator::retrievePanelCorners(const Mantid::Geometry::ComponentInfo &componentInfo,
4654
const size_t rootIndex) const {
@@ -97,6 +105,12 @@ PanelsSurfaceCalculator::retrievePanelCorners(const Mantid::Geometry::ComponentI
97105
return corners;
98106
}
99107

108+
/**
109+
* Calculate the normal vector to a panel
110+
*
111+
* @param panelCorners :: The four panel corner locations
112+
* @returns :: Normal vector
113+
*/
100114
Mantid::Kernel::V3D
101115
PanelsSurfaceCalculator::calculatePanelNormal(const std::vector<Mantid::Kernel::V3D> &panelCorners) const {
102116
// find the normal
@@ -106,6 +120,15 @@ PanelsSurfaceCalculator::calculatePanelNormal(const std::vector<Mantid::Kernel::
106120
return normal;
107121
}
108122

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+
*/
109132
bool PanelsSurfaceCalculator::isBankFlat(const ComponentInfo &componentInfo, size_t bankIndex,
110133
const std::vector<size_t> &tubes, const Mantid::Kernel::V3D &normal) {
111134
for (auto tube : tubes) {
@@ -119,6 +142,13 @@ bool PanelsSurfaceCalculator::isBankFlat(const ComponentInfo &componentInfo, siz
119142
return true;
120143
}
121144

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+
*/
122152
Mantid::Kernel::V3D PanelsSurfaceCalculator::calculateBankNormal(const ComponentInfo &componentInfo,
123153
const std::vector<size_t> &tubes) {
124154
// calculate normal from first two tubes in bank as before
@@ -146,7 +176,13 @@ Mantid::Kernel::V3D PanelsSurfaceCalculator::calculateBankNormal(const Component
146176
return normal;
147177
}
148178

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+
*/
150186
void PanelsSurfaceCalculator::setBankVisited(const ComponentInfo &componentInfo, size_t bankIndex,
151187
std::vector<bool> &visitedComponents) const {
152188
const auto &children = componentInfo.children(bankIndex);
@@ -160,6 +196,13 @@ void PanelsSurfaceCalculator::setBankVisited(const ComponentInfo &componentInfo,
160196
}
161197
}
162198

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+
*/
163206
size_t PanelsSurfaceCalculator::findNumDetectors(const ComponentInfo &componentInfo,
164207
const std::vector<size_t> &components) const {
165208
return std::accumulate(
@@ -173,6 +216,10 @@ size_t PanelsSurfaceCalculator::findNumDetectors(const ComponentInfo &componentI
173216
*
174217
* @param detPos :: Position of a detector of the bank.
175218
* @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
176223
*/
177224
Mantid::Kernel::Quat PanelsSurfaceCalculator::calcBankRotation(const V3D &detPos, V3D normal, const V3D &zAxis,
178225
const V3D &yAxis, const V3D &samplePosition) const {
@@ -213,6 +260,17 @@ Mantid::Kernel::Quat PanelsSurfaceCalculator::calcBankRotation(const V3D &detPos
213260
return requiredRotation;
214261
}
215262

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+
*/
216274
std::vector<Mantid::Kernel::V2D>
217275
PanelsSurfaceCalculator::transformedBoundingBoxPoints(const ComponentInfo &componentInfo, size_t detectorIndex,
218276
const V3D &refPos, const Mantid::Kernel::Quat &rotation,
@@ -229,6 +287,13 @@ PanelsSurfaceCalculator::transformedBoundingBoxPoints(const ComponentInfo &compo
229287
return {bb0, bb1};
230288
}
231289

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+
*/
232297
std::vector<std::vector<size_t>> PanelsSurfaceCalculator::examineAllComponents(
233298
const ComponentInfo &componentInfo,
234299
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(
248313
return detectorIDs;
249314
}
250315

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+
*/
251324
std::vector<size_t> PanelsSurfaceCalculator::tubeDetectorParentIDs(const ComponentInfo &componentInfo, size_t rootIndex,
252325
std::vector<bool> &visited) {
253326
const auto componentType = componentInfo.componentType(rootIndex);
@@ -307,6 +380,14 @@ std::vector<size_t> PanelsSurfaceCalculator::tubeDetectorParentIDs(const Compone
307380
return tubes;
308381
}
309382

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+
*/
310391
std::optional<Kernel::V2D> PanelsSurfaceCalculator::getSideBySideViewPos(const ComponentInfo &componentInfo,
311392
const Instrument_const_sptr instrument,
312393
const size_t componentIndex) const {

0 commit comments

Comments
 (0)