diff --git a/src/RWStl/RWStl_Reader.cxx b/src/RWStl/RWStl_Reader.cxx index 84082bc4cf..ca2e28dcee 100644 --- a/src/RWStl/RWStl_Reader.cxx +++ b/src/RWStl/RWStl_Reader.cxx @@ -132,18 +132,31 @@ Standard_Boolean RWStl_Reader::Read (const char* theFile, } Standard_IStream aStream (&aBuf); - if (IsAscii (aStream)) + + // get length of file to feed progress indicator in Ascii mode + aStream.seekg (0, aStream.end); + std::streampos theEnd = aStream.tellg(); + aStream.seekg (0, aStream.beg); + + while (!aStream.eof() && !aStream.bad()) { - // get length of file to feed progress indicator - aStream.seekg (0, aStream.end); - std::streampos theEnd = aStream.tellg(); - aStream.seekg (0, aStream.beg); - return ReadAscii (aStream, theEnd, theProgress); - } - else - { - return ReadBinary (aStream, theProgress); + if (IsAscii (aStream)) + { + if (!ReadAscii (aStream, theEnd, theProgress)) + { + break; + } + } + else + { + if (!ReadBinary (aStream, theProgress)) + { + break; + } + } + aStream >> std::ws; // skip any white spaces } + return !aStream.bad(); } //============================================================================== diff --git a/src/RWStl/RWStl_Reader.hxx b/src/RWStl/RWStl_Reader.hxx index c8f3cc5476..9687093900 100644 --- a/src/RWStl/RWStl_Reader.hxx +++ b/src/RWStl/RWStl_Reader.hxx @@ -33,6 +33,8 @@ class RWStl_Reader : public Standard_Transient public: //! Reads data from STL file (either binary or Ascii). + //! This function supports reading multi-domain STL files formed by concatenation of several "plain" files. + //! The mesh nodes are not merged between domains. //! Unicode paths can be given in UTF-8 encoding. //! Format is recognized automatically by analysis of the file header. //! Returns true if success, false on error or user break. diff --git a/tests/bugs/stlvrml/bug28680 b/tests/bugs/stlvrml/bug28680 new file mode 100644 index 0000000000..03d360b01e --- /dev/null +++ b/tests/bugs/stlvrml/bug28680 @@ -0,0 +1,8 @@ +readstl m [locate_data_file bug28680_sample01b.stl] triangulation + +# Number of triangles check +checktrinfo m -tri 62075 -nod 31879 + +# Visual check +checkview -display m -3d -vdispmode 0 -path ${imagedir}/${test_image}_edges.png +checkview -display m -3d -vdispmode 1 -path ${imagedir}/${test_image}_shading.png