Mantid
Loading...
Searching...
No Matches
ConvertToDiffractionMDWorkspace2.cpp
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 +
8
10
14
18
22
23#include <algorithm>
24#include <limits>
25
26using namespace Mantid::API;
27using namespace Mantid::Kernel;
28using namespace Mantid::DataObjects;
29using namespace Mantid::Geometry;
30
31namespace Mantid::MDAlgorithms {
32
33// Register the algorithm into the AlgorithmFactory
34DECLARE_ALGORITHM(ConvertToDiffractionMDWorkspace2)
35
36//----------------------------------------------------------------------------------------------
40 // initilise common properties between versions
42
43 std::vector<double> extents = {-50.0, 50.0};
44 declareProperty(std::make_unique<ArrayProperty<double>>("Extents", std::move(extents)),
45 "A comma separated list of min, max for each dimension,\n"
46 "specifying the extents of each dimension. Optional, default "
47 "+- 50 in each dimension.");
48 setPropertyGroup("Extents", getBoxSettingsGroupName());
49}
50
58void ConvertToDiffractionMDWorkspace2::convertExtents(const std::vector<double> &Extents, std::vector<double> &minVal,
59 std::vector<double> &maxVal) {
60 minVal.resize(3);
61 maxVal.resize(3);
62 if (Extents.size() == 2) {
63 for (size_t d = 0; d < 3; d++) {
64 minVal[d] = Extents[0];
65 maxVal[d] = Extents[1];
66 }
67 } else if (Extents.size() == 6) {
68 for (size_t d = 0; d < 3; d++) {
69 minVal[d] = Extents[2 * d + 0];
70 maxVal[d] = Extents[2 * d + 1];
71 }
72 } else
73 throw std::invalid_argument("You must specify either 2 or 6 extents (min,max).");
74}
75
76} // namespace Mantid::MDAlgorithms
#define DECLARE_ALGORITHM(classname)
Definition Algorithm.h:538
Support for a property that holds an array of values.
ConvertToDiffractionMDWorkspace2 : Create a MDEventWorkspace with events in reciprocal space (Qx,...
void convertExtents(const std::vector< double > &Extents, std::vector< double > &minVal, std::vector< double > &maxVal) override
Splits extents accepted by convertToDiffreactionMD workspace in the form min1,max1 or min1,...