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 = 0;
34 boost::hash_combine(seed, v.first.X());
35 boost::hash_combine(seed, v.first.Y());
36 boost::hash_combine(seed, v.first.Z());
37 return seed;
38 }
39};
40
42 bool operator()(const std::pair<Kernel::V3D, uint32_t> &v1, const std::pair<Kernel::V3D, uint32_t> &v2) const {
43 const Kernel::V3D diff = v1.first - v2.first;
44 const double nanoMetre = 1e-9;
45 return diff.norm() < nanoMetre;
46 }
47};
48
49class MANTID_DATAHANDLING_DLL LoadStl : public LoadSingleMesh {
50public:
51 LoadStl(std::string filename, std::ios_base::openmode mode, ScaleUnits scaleType)
52 : LoadSingleMesh(std::move(filename), mode, scaleType), m_setMaterial(false) {}
53 LoadStl(std::string filename, std::ios_base::openmode mode, ScaleUnits scaleType,
55 : LoadSingleMesh(std::move(filename), mode, scaleType), m_setMaterial(true), m_params(std::move(params)) {}
56 virtual ~LoadStl() override = default;
57
58protected:
59 bool areEqualVertices(Kernel::V3D const &v1, Kernel::V3D const &v2) const;
60 void changeToVector();
63 std::unordered_set<std::pair<Kernel::V3D, uint32_t>, HashV3DPair, V3DTrueComparator> vertexSet;
64};
65
66} // namespace DataHandling
67} // namespace Mantid
std::map< double, EigenVector > m_params
Actual storage.
LoadStl(std::string filename, std::ios_base::openmode mode, ScaleUnits scaleType)
Definition LoadStl.h:51
LoadStl(std::string filename, std::ios_base::openmode mode, ScaleUnits scaleType, ReadMaterial::MaterialParameters params)
Definition LoadStl.h:53
ReadMaterial::MaterialParameters m_params
Definition LoadStl.h:62
virtual ~LoadStl() override=default
std::unordered_set< std::pair< Kernel::V3D, uint32_t >, HashV3DPair, V3DTrueComparator > vertexSet
Definition LoadStl.h:63
The Logger class is in charge of the publishing messages from the framework through various channels.
Definition Logger.h:51
Class for 3D vectors.
Definition V3D.h:34
double norm() const noexcept
Definition V3D.h:269
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...
bool operator()(const std::pair< Kernel::V3D, uint32_t > &v1, const std::pair< Kernel::V3D, uint32_t > &v2) const
Definition LoadStl.h:42