Skip to content

Commit

Permalink
inline extraneous function in write stl
Browse files Browse the repository at this point in the history
  • Loading branch information
nyoungbq authored and imikejackson committed Dec 18, 2023
1 parent 0f7f0a1 commit ef9f88b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,6 @@

using namespace complex;

namespace
{
int32_t writeHeader(FILE* f, const std::string& header, int32_t triCount)
{
if(nullptr == f)
{
return -1;
}

char h[80];
size_t headLength = 80;
if(header.length() < 80)
{
headLength = static_cast<size_t>(header.length());
}

std::string c_str = header;
::memset(h, 0, 80);
::memcpy(h, c_str.data(), headLength);
// Return the number of bytes written - which should be 80
fwrite(h, 1, 80, f);
fwrite(&triCount, 1, 4, f);
return 0;
}
} // namespace

// -----------------------------------------------------------------------------
WriteStlFile::WriteStlFile(DataStructure& dataStructure, const IFilter::MessageHandler& mesgHandler, const std::atomic_bool& shouldCancel, WriteStlFileInputValues* inputValues)
: m_DataStructure(dataStructure)
Expand Down Expand Up @@ -142,7 +116,19 @@ Result<> WriteStlFile::operator()()
return {MakeWarningVoidResult(-27874, fmt::format("Error Writing STL File '{}'. Header was over the 80 characters supported by STL. Length of header: {}.", filename, header.length()))};
}

writeHeader(f, header, 0);
char h[80];
size_t headLength = 80;
if(header.length() < 80)
{
headLength = static_cast<size_t>(header.length());
}

std::string c_str = header;
::memset(h, 0, 80);
::memcpy(h, c_str.data(), headLength);
// Return the number of bytes written - which should be 80
fwrite(h, 1, 80, f);
fwrite(&triCount, 1, 4, f);
triCount = 0; // Reset this to Zero. Increment for every triangle written

// Loop over all the triangles for this spin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#include "complex/Pipeline/Pipeline.hpp"
#include "complex/Pipeline/PipelineFilter.hpp"
#include "complex/Utilities/Parsing/DREAM3D/Dream3dIO.hpp"
#include "complex/Utilities/SIMPLConversion.hpp"
#include "complex/Utilities/Parsing/HDF5/Writers/FileWriter.hpp"
#include "complex/Utilities/SIMPLConversion.hpp"

#include <filesystem>
namespace fs = std::filesystem;
Expand Down

0 comments on commit ef9f88b

Please sign in to comment.