Mantid
Loading...
Searching...
No Matches
MeshFileIO.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2019 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 +
7#include <utility>
8
9#include "MantidDataHandling/DllConfig.h"
11#include "MantidKernel/Logger.h"
12#include "MantidKernel/Matrix.h"
13#include "MantidKernel/V3D.h"
14
15#pragma once
16namespace {
17Mantid::Kernel::Logger g_log("MeshFileIO");
18}
19namespace Mantid {
20namespace DataHandling {
22
23class MANTID_DATAHANDLING_DLL MeshFileIO {
24public:
25 std::shared_ptr<Geometry::MeshObject> rotate(std::shared_ptr<Geometry::MeshObject> environmentMesh, double xRotation,
26 double yRotation, double zRotation);
27
28 std::shared_ptr<Geometry::MeshObject> translate(std::shared_ptr<Geometry::MeshObject> environmentMesh,
29 const std::vector<double> &translationVector);
30
31 Kernel::V3D createScaledV3D(double xVal, double yVal, double zVal);
32 ScaleUnits getScaleType() { return m_scaleType; }
33
34protected:
35 MeshFileIO(ScaleUnits scaleType) : m_scaleType(scaleType) {}
36 MeshFileIO(ScaleUnits scaleType, std::vector<uint32_t> triangles, std::vector<Kernel::V3D> vertices)
37 : m_scaleType(scaleType), m_triangle(std::move(std::move(triangles))),
38 m_vertices(std::move(std::move(vertices))) {}
39 double scaleValue(double val) {
40 switch (m_scaleType) {
41 case ScaleUnits::centimetres:
42 return val / 100;
43 case ScaleUnits::millimetres:
44 return val / 1000;
45 default:
46 return val;
47 }
48 }
49
50 float removeScale(double value) {
51 switch (m_scaleType) {
52 case ScaleUnits::centimetres:
53 value = value * 100;
54 break;
55 case ScaleUnits::millimetres:
56 value = value * 1000;
57 break;
58 default:; // do nothing
59 }
60 return float(value);
61 };
62
64 std::vector<uint32_t> m_triangle;
65 std::vector<Kernel::V3D> m_vertices;
66
67 void setScaleType(const ScaleUnits scaleType) {
68 if (m_scaleType == ScaleUnits::undefined) {
69 m_scaleType = scaleType;
70 }
71 }
72};
73inline ScaleUnits getScaleTypeFromStr(const std::string &scaleProperty) {
74 ScaleUnits scaleType;
75 if (scaleProperty == "m") {
76 scaleType = ScaleUnits::metres;
77 } else if (scaleProperty == "cm") {
78 scaleType = ScaleUnits::centimetres;
79 } else if (scaleProperty == "mm") {
80 scaleType = ScaleUnits::millimetres;
81 } else {
82 throw std::invalid_argument(scaleProperty + " is not an accepted scale of stl or 3mf file.");
83 }
84 return scaleType;
85}
86
87} // namespace DataHandling
88} // namespace Mantid
double value
The value of the point.
Definition: FitMW.cpp:51
MeshFileIO(ScaleUnits scaleType)
Definition: MeshFileIO.h:35
float removeScale(double value)
Definition: MeshFileIO.h:50
MeshFileIO(ScaleUnits scaleType, std::vector< uint32_t > triangles, std::vector< Kernel::V3D > vertices)
Definition: MeshFileIO.h:36
std::vector< uint32_t > m_triangle
Definition: MeshFileIO.h:64
double scaleValue(double val)
Definition: MeshFileIO.h:39
std::vector< Kernel::V3D > m_vertices
Definition: MeshFileIO.h:65
void setScaleType(const ScaleUnits scaleType)
Definition: MeshFileIO.h:67
The Logger class is in charge of the publishing messages from the framework through various channels.
Definition: Logger.h:52
Class for 3D vectors.
Definition: V3D.h:34
Kernel::Logger g_log("ExperimentInfo")
static logger object
ScaleUnits getScaleTypeFromStr(const std::string &scaleProperty)
Definition: MeshFileIO.h:73
Helper class which provides the Collimation Length for SANS instruments.
STL namespace.