Newer
Older
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source
// & Institut Laue - Langevin
// SPDX - License - Identifier: GPL - 3.0 +
Janik Zikovsky
committed
#include "MantidGeometry/MDGeometry/MDTypes.h"
#include "MantidKernel/Exception.h"
Janik Zikovsky
committed
#include "MantidKernel/Matrix.h"
#include "MantidKernel/System.h"
#include <boost/algorithm/string.hpp>
#include <boost/format.hpp>
using namespace Mantid::Geometry;
using namespace Mantid::Kernel;
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
namespace Mantid {
namespace API {
//----------------------------------------------------------------------------------------------
/** Constructor. Validates the inputs
*
* @param inD :: input number of dimensions, >= 1
* @param outD :: output number of dimensions, <= inD
* @throw std::runtime_error if outD > inD
*/
CoordTransform::CoordTransform(const size_t inD, const size_t outD)
: inD(inD), outD(outD) {
if (outD > inD)
throw std::runtime_error("CoordTransform: Cannot have more output "
"dimensions than input dimensions!");
if (outD == 0)
throw std::runtime_error(
"CoordTransform: invalid number of output dimensions!");
if (inD == 0)
throw std::runtime_error(
"CoordTransform: invalid number of input dimensions!");
}
//----------------------------------------------------------------------------------------------
/** Apply the transformation to an input vector (as a VMD type).
* This wraps the apply(in,out) method (and will be slower!)
*
* @param inputVector :: an inD-length vector
* @return the output vector as VMD
*/
Mantid::Kernel::VMD
CoordTransform::applyVMD(const Mantid::Kernel::VMD &inputVector) const {
if (inputVector.getNumDims() != inD)
throw std::runtime_error("CoordTransform::apply(): inputVector has the "
"wrong number of coordinates!");
auto outArray = new coord_t[outD];
this->apply(inputVector.getBareArray(), outArray);
VMD out(outD, outArray);
delete[] outArray;
return out;
}
Janik Zikovsky
committed
} // namespace API