Mantid
Loading...
Searching...
No Matches
MeshFileIO.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2020 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 +
9
10namespace Mantid::DataHandling {
11
20std::shared_ptr<Geometry::MeshObject> MeshFileIO::rotate(std::shared_ptr<Geometry::MeshObject> environmentMesh,
21 double xRotation, double yRotation, double zRotation) {
22 const std::vector<double> rotationMatrix = Geometry::ShapeFactory::generateMatrix(xRotation, yRotation, zRotation);
23 environmentMesh->rotate(rotationMatrix);
24 return environmentMesh;
25}
26
33std::shared_ptr<Geometry::MeshObject> MeshFileIO::translate(std::shared_ptr<Geometry::MeshObject> environmentMesh,
34 const std::vector<double> &translationVector) {
35 std::vector<double> checkVector = std::vector<double>(3, 0.0);
36 if (translationVector != checkVector) {
37 if (translationVector.size() != 3) {
38 throw std::invalid_argument("Invalid Translation vector, must have exactly 3 dimensions");
39 }
40 Kernel::V3D translate = createScaledV3D(translationVector[0], translationVector[1], translationVector[2]);
41 environmentMesh->translate(translate);
42 }
43 return environmentMesh;
44}
45
53Kernel::V3D MeshFileIO::createScaledV3D(double xVal, double yVal, double zVal) {
54 xVal = scaleValue(xVal);
55 yVal = scaleValue(yVal);
56 zVal = scaleValue(zVal);
57 return Kernel::V3D(double(xVal), double(yVal), double(zVal));
58}
59
60} // namespace Mantid::DataHandling
Kernel::V3D createScaledV3D(double xVal, double yVal, double zVal)
scales a 3D point according the units defined in the MeshFileIO class
Definition: MeshFileIO.cpp:53
double scaleValue(double val)
Definition: MeshFileIO.h:39
std::shared_ptr< Geometry::MeshObject > translate(std::shared_ptr< Geometry::MeshObject > environmentMesh, const std::vector< double > &translationVector)
translates the environment by a provided matrix
Definition: MeshFileIO.cpp:33
std::shared_ptr< Geometry::MeshObject > rotate(std::shared_ptr< Geometry::MeshObject > environmentMesh, double xRotation, double yRotation, double zRotation)
Rotates the environment by a generated matrix.
Definition: MeshFileIO.cpp:20
static Kernel::Matrix< double > generateMatrix(double xRotation, double yRotation, double zRotation)
Generates a rotate Matrix applying the x rotate then y rotate, then z rotate.
Class for 3D vectors.
Definition: V3D.h:34