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 139468f
Showing 1 changed file with 13 additions and 27 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

0 comments on commit 139468f

Please sign in to comment.