Mantid
Loading...
Searching...
No Matches
LoadStl.h
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 +
7#pragma once
11#include "MantidKernel/Logger.h"
12#include "MantidKernel/V3D.h"
13
14#include <boost/functional/hash.hpp>
15#include <functional>
16#include <unordered_set>
17#include <utility>
18
19#include <utility>
20
21namespace {
22Mantid::Kernel::Logger g_logstl("LoadStl");
23}
24namespace Mantid {
25
26namespace Geometry {
27class MeshObject;
28}
29namespace DataHandling {
30
32 size_t operator()(const std::pair<Kernel::V3D, uint32_t> &v) const {
33 size_t seed = std::hash<double>{}(v.first.X());
34 boost::hash_combine(seed, v.first.Y());
35 boost::hash_combine(seed, v.first.Z());
36 return seed;
37 }
38};
39
41 bool operator()(const std::pair<Kernel::V3D, uint32_t> &v1, const std::pair<Kernel::V3D, uint32_t> &v2) const {
42 const Kernel::V3D diff = v1.first - v2.first;
43 const double nanoMetre = 1e-9;
44 return diff.norm() < nanoMetre;
45 }
46};
47
48class MANTID_DATAHANDLING_DLL LoadStl : public LoadSingleMesh {
49public:
50 LoadStl(std::string filename, std::ios_base::openmode mode, ScaleUnits scaleType)
51 : LoadSingleMesh(std::move(filename), mode, scaleType), m_setMaterial(false) {}
52 LoadStl(std::string filename, std::ios_base::openmode mode, ScaleUnits scaleType,
54 : LoadSingleMesh(std::move(filename), mode, scaleType), m_setMaterial(true), m_params(std::move(params)) {}
55 virtual ~LoadStl() = default;
56
57protected:
58 bool areEqualVertices(Kernel::V3D const &v1, Kernel::V3D const &v2) const;
59 void changeToVector();
62 std::unordered_set<std::pair<Kernel::V3D, uint32_t>, HashV3DPair, V3DTrueComparator> vertexSet;
63};
64
65} // namespace DataHandling
66} // namespace Mantid
std::map< double, EigenVector > m_params
Actual storage.
LoadStl(std::string filename, std::ios_base::openmode mode, ScaleUnits scaleType)
Definition: LoadStl.h:50
LoadStl(std::string filename, std::ios_base::openmode mode, ScaleUnits scaleType, ReadMaterial::MaterialParameters params)
Definition: LoadStl.h:52
virtual ~LoadStl()=default
ReadMaterial::MaterialParameters m_params
Definition: LoadStl.h:61
std::unordered_set< std::pair< Kernel::V3D, uint32_t >, HashV3DPair, V3DTrueComparator > vertexSet
Definition: LoadStl.h:62
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
double norm() const noexcept
Definition: V3D.h:263
Helper class which provides the Collimation Length for SANS instruments.
STL namespace.
size_t operator()(const std::pair< Kernel::V3D, uint32_t > &v) const
Definition: LoadStl.h:32
This struct contains the parameters for constructing a material, and gives them a default value for e...
Definition: ReadMaterial.h:32
bool operator()(const std::pair< Kernel::V3D, uint32_t > &v1, const std::pair< Kernel::V3D, uint32_t > &v2) const
Definition: LoadStl.h:41