15uint32_t getNumberTriangles(Kernel::BinaryStreamReader streamReader,
const int header) {
16 uint32_t numberTrianglesLong;
18 streamReader.moveStreamToPosition(header);
20 streamReader >> numberTrianglesLong;
21 return numberTrianglesLong;
26 Poco::File stlFile = Poco::File(filename);
27 if (!stlFile.exists()) {
31 auto fileSize = stlFile.getSize();
37 uint32_t numberTrianglesLong;
38 std::ifstream myFile(filename.c_str(),
openMode);
40 numberTrianglesLong = getNumberTriangles(streamReader,
HEADER_SIZE);
54 const auto numberTrianglesLong = getNumberTriangles(streamReader,
HEADER_SIZE);
59 g_logstl.debug(
"Began reading " +
std::to_string(numberTrianglesLong) +
" triangles.");
60 uint32_t vertexCount = 0;
61 for (uint32_t i = 0; i < numberTrianglesLong; i++) {
71 g_logstl.debug(
"Read All");
75 g_logstl.information(
"Setting Material");
82 auto retVal = std::make_unique<Geometry::MeshObject>(std::move(
m_triangle), std::move(
m_vertices), material);
88 for (
int i = 0; i < 3; i++) {
97 auto vertexPair = std::pair<Kernel::V3D, uint32_t>(vec, vertexCount);
98 auto emplacementResult =
vertexSet.insert(vertexPair);
101 if (emplacementResult.second) {
104 m_triangle.emplace_back(emplacementResult.first->second);
std::unique_ptr< Geometry::MeshObject > readShape() override
static constexpr int HEADER_SIZE
static constexpr uint32_t VECTOR_DATA_SIZE
static bool isBinarySTL(const std::string &filename)
static constexpr uint32_t TRIANGLE_COUNT_DATA_SIZE
static constexpr uint32_t TRIANGLE_DATA_SIZE
void readTriangle(Kernel::BinaryStreamReader, uint32_t &vertexCount)
static constexpr std::ios_base::openmode openMode
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...
Assists with reading a binary file by providing standard overloads for the istream operators (>>) to ...
void moveStreamToPosition(size_t nbytes)
Move the stream to nbytes past the beginning of the file.
A material is defined as being composed of a given element, defined as a PhysicalConstants::NeutronAt...
std::string to_string(const wide_integer< Bits, Signed > &n)