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 scaledTranslationVector =
41 createScaledV3D(translationVector[0], translationVector[1], translationVector[2]);
42 environmentMesh->translate(scaledTranslationVector);
43 }
44 return environmentMesh;
45}
46
54Kernel::V3D MeshFileIO::createScaledV3D(double xVal, double yVal, double zVal) {
55 xVal = scaleValue(xVal);
56 yVal = scaleValue(yVal);
57 zVal = scaleValue(zVal);
58 return Kernel::V3D(double(xVal), double(yVal), double(zVal));
59}
60
61} // namespace Mantid::DataHandling
Kernel::V3D createScaledV3D(double xVal, double yVal, double zVal)
scales a 3D point according the units defined in the MeshFileIO class
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
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.
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