Mantid
Loading...
Searching...
No Matches
CoordTransform.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 +
10#include "MantidKernel/Matrix.h"
11#include "MantidKernel/System.h"
12#include "MantidKernel/VMD.h"
13#include <boost/algorithm/string.hpp>
14#include <boost/format.hpp>
15
16using namespace Mantid::Geometry;
17using namespace Mantid::Kernel;
18
19namespace Mantid::API {
20
21//----------------------------------------------------------------------------------------------
28CoordTransform::CoordTransform(const size_t inD, const size_t outD) : inD(inD), outD(outD) {
29 if (outD > inD)
30 throw std::runtime_error("CoordTransform: Cannot have more output "
31 "dimensions than input dimensions!");
32 if (outD == 0)
33 throw std::runtime_error("CoordTransform: invalid number of output dimensions!");
34 if (inD == 0)
35 throw std::runtime_error("CoordTransform: invalid number of input dimensions!");
36}
37
38//----------------------------------------------------------------------------------------------
46 if (inputVector.getNumDims() != inD)
47 throw std::runtime_error("CoordTransform::apply(): inputVector has the "
48 "wrong number of coordinates!");
49 auto outArray = new coord_t[outD];
50 this->apply(inputVector.getBareArray(), outArray);
51 VMD out(outD, outArray);
52 delete[] outArray;
53 return out;
54}
55
56} // namespace Mantid::API
size_t inD
Input number of dimensions.
Mantid::Kernel::VMD applyVMD(const Mantid::Kernel::VMD &inputVector) const
Wrapper for VMD.
size_t outD
Output number of dimensions.
CoordTransform(const size_t inD, const size_t outD)
Constructor.
virtual void apply(const coord_t *inputVector, coord_t *outVector) const =0
const TYPE * getBareArray() const
Definition: VMD.cpp:248
size_t getNumDims() const
Definition: VMD.cpp:236
float coord_t
Typedef for the data type to use for coordinate axes in MD objects such as MDBox, MDEventWorkspace,...
Definition: MDTypes.h:27