24void writeNumberTriangles(Kernel::BinaryStreamWriter streamWriter, uint32_t numberTrianglesLong) {
27 streamWriter << numberTrianglesLong;
36void writeNormal(Kernel::BinaryStreamWriter StreamWriter) {
38 StreamWriter << normal;
39 StreamWriter << normal;
40 StreamWriter << normal;
53 const std::string headerStart =
"Binary STL File created using Mantid Environment:";
54 const auto timeString = Types::Core::DateAndTime::getCurrentTime().toFormattedString(
"%Y-%b-%dT%H:%M:%S") +
":";
55 std::string unitString;
70 const size_t emptySize = 80 - size_t(headerStart.size() + timeString.size() + 4 + unitString.size());
71 streamWriter << headerStart + timeString + unitString + std::string(emptySize,
' ');
81 throw std::runtime_error(
"Invalid mesh, could not save.");
83 std::ofstream myFile(
m_filename.c_str(), std::ios::out | std::ios::binary);
84 const auto numberOfTriangles = uint32_t(
m_triangle.size() / 3);
87 writeNumberTriangles(streamWriter, numberOfTriangles);
88 const uint16_t attributeByte = 0;
89 for (uint32_t i = 0; i < numberOfTriangles; ++i) {
90 writeNormal(streamWriter);
93 streamWriter << attributeByte;
106 for (
int i = 0; i < 3; ++i) {
113 streamWriter << xVal;
114 streamWriter << yVal;
115 streamWriter << zVal;
std::map< DeltaEMode::Type, std::string > index
float removeScale(double value)
std::vector< uint32_t > m_triangle
std::vector< Kernel::V3D > m_vertices
void writeStl()
Function to write out the full mesh to an stl binary file.
void writeHeader(Kernel::BinaryStreamWriter streamWriter)
Function to write the header of the STL file, the header has no requirements other than it being 80 b...
void writeTriangle(Kernel::BinaryStreamWriter streamWriter, uint32_t triangle)
Function to write out an individual triangle with the scale removed.
const std::string m_filename
Assists with writing a binary file by providing standard overloads for the ostream operators (<<) to ...
constexpr double X() const noexcept
Get x.
constexpr double Y() const noexcept
Get y.
constexpr double Z() const noexcept
Get z.