0031213: Coding Rules, RWStl_Reader - misnamed variable THE_BUFFER
authormzernova <mzernova@opencascade.com>
Tue, 3 Dec 2019 10:51:02 +0000 (13:51 +0300)
committerbugmaster <bugmaster@opencascade.com>
Fri, 6 Dec 2019 16:32:35 +0000 (19:32 +0300)
Renamed THE_BUFFER variable.

src/RWStl/RWStl.cxx
src/RWStl/RWStl_Reader.cxx
src/RWStl/RWStl_Reader.hxx

index 0d05334..505b6f6 100644 (file)
@@ -26,6 +26,7 @@ namespace
 
   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,
@@ -199,7 +200,8 @@ Handle(Poly_Triangulation) RWStl::ReadAscii (const OSD_Path& theFile,
   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)();
   }
index b490704..7638b9d 100644 (file)
@@ -26,7 +26,6 @@
 #include <OSD_Timer.hxx>
 #include <Precision.hxx>
 #include <Standard_CLocaleSentry.hxx>
-#include <Standard_ReadLineBuffer.hxx>
 
 #include <algorithm>
 #include <limits>
@@ -43,9 +42,6 @@ namespace
   // 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
   {
@@ -155,11 +151,13 @@ Standard_Boolean RWStl_Reader::Read (const char* theFile,
   // (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;
       }
@@ -275,6 +273,7 @@ static bool ReadVertex (const char* theStr, double& theX, double& theY, double&
 //purpose  :
 //==============================================================================
 Standard_Boolean RWStl_Reader::ReadAscii (Standard_IStream& theStream,
+                                          Standard_ReadLineBuffer& theBuffer,
                                           const std::streampos theUntilPos,
                                           const Handle(Message_ProgressIndicator)& theProgress)
 {
@@ -285,7 +284,7 @@ Standard_Boolean RWStl_Reader::ReadAscii (Standard_IStream& theStream,
   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);
@@ -312,7 +311,7 @@ Standard_Boolean RWStl_Reader::ReadAscii (Standard_IStream& theStream,
       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);
@@ -331,7 +330,7 @@ Standard_Boolean RWStl_Reader::ReadAscii (Standard_IStream& theStream,
       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 ");
@@ -344,7 +343,7 @@ Standard_Boolean RWStl_Reader::ReadAscii (Standard_IStream& theStream,
     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;
@@ -379,8 +378,8 @@ Standard_Boolean RWStl_Reader::ReadAscii (Standard_IStream& theStream,
       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;
   }
index 9687093..a27113d 100644 (file)
@@ -16,8 +16,9 @@
 #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.
 //!
@@ -61,6 +62,7 @@ public:
   //! 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);