static const Standard_Integer THE_STL_SIZEOF_FACET = 50;
static const Standard_Integer IND_THRESHOLD = 1000; // increment the indicator every 1k triangles
+ static const size_t THE_BUFFER_SIZE = 1024; // The length of buffer to read (in bytes)
//! Writing a Little Endian 32 bits integer
inline static void convertInteger (const Standard_Integer theValue,
aStream.seekg (0, aStream.beg);
Reader aReader;
- if (!aReader.ReadAscii (aStream, theEnd, theProgress))
+ Standard_ReadLineBuffer aBuffer (THE_BUFFER_SIZE);
+ if (!aReader.ReadAscii (aStream, aBuffer, theEnd, theProgress))
{
return Handle(Poly_Triangulation)();
}
#include <OSD_Timer.hxx>
#include <Precision.hxx>
#include <Standard_CLocaleSentry.hxx>
-#include <Standard_ReadLineBuffer.hxx>
#include <algorithm>
#include <limits>
// The length of buffer to read (in bytes)
static const size_t THE_BUFFER_SIZE = 1024;
- // Buffer to read
- Standard_ReadLineBuffer THE_BUFFER (THE_BUFFER_SIZE);
-
//! Auxiliary tool for merging nodes during STL reading.
class MergeNodeTool
{
// (probing may bring stream to fail state if EOF is reached)
bool isAscii = ((size_t)theEnd < THE_STL_MIN_FILE_SIZE || IsAscii (aStream));
+ Standard_ReadLineBuffer aBuffer (THE_BUFFER_SIZE);
+
while (aStream.good())
{
if (isAscii)
{
- if (!ReadAscii (aStream, theEnd, theProgress))
+ if (!ReadAscii (aStream, aBuffer, theEnd, theProgress))
{
break;
}
//purpose :
//==============================================================================
Standard_Boolean RWStl_Reader::ReadAscii (Standard_IStream& theStream,
+ Standard_ReadLineBuffer& theBuffer,
const std::streampos theUntilPos,
const Handle(Message_ProgressIndicator)& theProgress)
{
const char* aLine;
// skip header "solid ..."
- aLine = THE_BUFFER.ReadLine (theStream, aLineLen);
+ aLine = theBuffer.ReadLine (theStream, aLineLen);
if (aLine == NULL)
{
Message::DefaultMessenger()->Send ("Error: premature end of file", Message_Fail);
aProgressPos += aStepB;
}
- aLine = THE_BUFFER.ReadLine (theStream, aLineLen); // "facet normal nx ny nz"
+ aLine = theBuffer.ReadLine (theStream, aLineLen); // "facet normal nx ny nz"
if (aLine == NULL)
{
Message::DefaultMessenger()->Send ("Error: premature end of file", Message_Fail);
return false;
}
- aLine = THE_BUFFER.ReadLine (theStream, aLineLen); // "outer loop"
+ aLine = theBuffer.ReadLine (theStream, aLineLen); // "outer loop"
if (aLine == NULL || !str_starts_with (aLine, "outer", 5))
{
TCollection_AsciiString aStr ("Error: unexpected format of facet at line ");
Standard_Boolean isEOF = false;
for (Standard_Integer i = 0; i < 3; i++)
{
- aLine = THE_BUFFER.ReadLine (theStream, aLineLen);
+ aLine = theBuffer.ReadLine (theStream, aLineLen);
if (aLine == NULL)
{
isEOF = true;
AddTriangle (n1, n2, n3);
}
- THE_BUFFER.ReadLine (theStream, aLineLen); // skip "endloop"
- THE_BUFFER.ReadLine (theStream, aLineLen); // skip "endfacet"
+ theBuffer.ReadLine (theStream, aLineLen); // skip "endloop"
+ theBuffer.ReadLine (theStream, aLineLen); // skip "endfacet"
aNbLine += 2;
}
#ifndef _RWStl_Reader_HeaderFile
#define _RWStl_Reader_HeaderFile
-#include <Message_ProgressIndicator.hxx>
#include <gp_XYZ.hxx>
+#include <Message_ProgressIndicator.hxx>
+#include <Standard_ReadLineBuffer.hxx>
//! An abstract class implementing procedure to read STL file.
//!
//! If theUntilPos is non-zero, reads not more than until that position.
//! Returns true if success, false on error or user break.
Standard_EXPORT Standard_Boolean ReadAscii (Standard_IStream& theStream,
+ Standard_ReadLineBuffer& theBuffer,
const std::streampos theUntilPos,
const Handle(Message_ProgressIndicator)& theProgress);