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
61void ConvertToDiffractionMDWorkspace2::convertExtents(const std::vector<double> &Extents, std::vector<double> &minVal,
62 std::vector<double> &maxVal) {
63 minVal.resize(3);
64 maxVal.resize(3);
65 if (Extents.size() == 2) {
66 for (size_t d = 0; d < 3; d++) {
67 minVal[d] = Extents[0];
68 maxVal[d] = Extents[1];
69 }
70 } else if (Extents.size() == 6) {
71 for (size_t d = 0; d < 3; d++) {
72 minVal[d] = Extents[2 * d + 0];
73 maxVal[d] = Extents[2 * d + 1];
74 }
75 } else
76 throw std::invalid_argument("You must specify either 2 or 6 extents (min,max).");
77}
78
79} // namespace Mantid::MDAlgorithms
#define DECLARE_ALGORITHM(classname)
Definition: Algorithm.h:576
Support for a property that holds an array of values.
Definition: ArrayProperty.h:28
void init() override
Initialize the algorithm's properties.
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,...