9#include <boost/algorithm/string.hpp>
14 std::ifstream file(filename.c_str());
22 return (line.size() >= 5 && line.substr(0, 5) ==
"solid");
30 uint32_t vertexCount = 0;
34 auto vertexPair = std::pair<Kernel::V3D, uint32_t>(t1, vertexCount);
35 auto emplacementResult =
vertexSet.insert(vertexPair);
36 if (emplacementResult.second) {
39 m_triangle.emplace_back(emplacementResult.first->second);
40 vertexPair = std::pair<Kernel::V3D, uint32_t>(t2, vertexCount);
41 emplacementResult =
vertexSet.insert(vertexPair);
42 if (emplacementResult.second) {
45 m_triangle.emplace_back(emplacementResult.first->second);
46 vertexPair = std::pair<Kernel::V3D, uint32_t>(t3, vertexCount);
47 emplacementResult =
vertexSet.insert(vertexPair);
48 if (emplacementResult.second) {
51 m_triangle.emplace_back(emplacementResult.first->second);
57 g_logstl.information(
"Setting Material");
64 auto retVal = std::make_unique<Geometry::MeshObject>(std::move(
m_triangle), std::move(
m_vertices), material);
82 if (getline(file, line)) {
84 std::vector<std::string> tokens;
85 boost::split(tokens, line, boost::is_any_of(
" "), boost::token_compress_on);
86 if (tokens.size() == 4 && tokens[0] ==
"vertex") {
87 double xVal = std::stod(tokens[1]);
88 double yVal = std::stod(tokens[2]);
89 double zVal = std::stod(tokens[3]);
103 if (getline(file, line)) {
105 if (line.size() < type.size() || line.substr(0, type.size()) != type) {
107 const std::string type2 =
"endsolid";
108 if (line.size() < type2.size() || line.substr(0, type2.size()) != type2) {
std::unique_ptr< Geometry::MeshObject > readShape() override
bool readSTLVertex(std::ifstream &file, Kernel::V3D &vertex)
static bool isAsciiSTL(const std::string &filename)
bool readSTLLine(std::ifstream &file, std::string const &type)
bool readSTLTriangle(std::ifstream &file, Kernel::V3D &v1, Kernel::V3D &v2, Kernel::V3D &v3)
const std::string m_filename
bool areEqualVertices(Kernel::V3D const &v1, Kernel::V3D const &v2) const
ReadMaterial::MaterialParameters m_params
std::unordered_set< std::pair< Kernel::V3D, uint32_t >, HashV3DPair, V3DTrueComparator > vertexSet
std::vector< uint32_t > m_triangle
Kernel::V3D createScaledV3D(double xVal, double yVal, double zVal)
scales a 3D point according the units defined in the MeshFileIO class
std::vector< Kernel::V3D > m_vertices
This class contains code for interpreting a material input for SetSampleMaterial, validating the para...
std::unique_ptr< Kernel::Material > buildMaterial()
Construct the material,.
void setMaterialParameters(const MaterialParameters ¶ms)
Set the parameters to build the material to the builder, taking into account which values were and we...
Records the filename, the description of failure and the line on which it happened.
A material is defined as being composed of a given element, defined as a PhysicalConstants::NeutronAt...