diff --git a/src/RWStl/RWStl.cxx b/src/RWStl/RWStl.cxx index 8b703f443e..86eaeb601e 100644 --- a/src/RWStl/RWStl.cxx +++ b/src/RWStl/RWStl.cxx @@ -147,12 +147,6 @@ Handle(Poly_Triangulation) RWStl::ReadFile (const OSD_Path& theFile, Handle(Poly_Triangulation) RWStl::ReadBinary (const OSD_Path& theFile, const Message_ProgressRange& theProgress) { - OSD_File aFile(theFile); - if (!aFile.Exists()) - { - return Handle(Poly_Triangulation)(); - } - TCollection_AsciiString aPath; theFile.SystemName (aPath); @@ -179,31 +173,24 @@ Handle(Poly_Triangulation) RWStl::ReadBinary (const OSD_Path& theFile, Handle(Poly_Triangulation) RWStl::ReadAscii (const OSD_Path& theFile, const Message_ProgressRange& theProgress) { - OSD_File aFile (theFile); - if (!aFile.Exists()) - { - return Handle(Poly_Triangulation)(); - } - TCollection_AsciiString aPath; theFile.SystemName (aPath); - std::filebuf aBuf; - OSD_OpenStream (aBuf, aPath, std::ios::in | std::ios::binary); - if (!aBuf.is_open()) + const Handle(OSD_FileSystem)& aFileSystem = OSD_FileSystem::DefaultFileSystem(); + std::shared_ptr aStream = aFileSystem->OpenIStream (aPath, std::ios::in | std::ios::binary); + if (aStream.get() == NULL) { return Handle(Poly_Triangulation)(); } - Standard_IStream aStream (&aBuf); // get length of file to feed progress indicator - aStream.seekg (0, aStream.end); - std::streampos theEnd = aStream.tellg(); - aStream.seekg (0, aStream.beg); + aStream->seekg (0, aStream->end); + std::streampos theEnd = aStream->tellg(); + aStream->seekg (0, aStream->beg); Reader aReader; Standard_ReadLineBuffer aBuffer (THE_BUFFER_SIZE); - if (!aReader.ReadAscii (aStream, aBuffer, theEnd, theProgress)) + if (!aReader.ReadAscii (*aStream, aBuffer, theEnd, theProgress)) { return Handle(Poly_Triangulation)(); } @@ -351,7 +338,7 @@ Standard_Boolean RWStl::writeBinary (const Handle(Poly_Triangulation)& theMesh, FILE* theFile, const Message_ProgressRange& theProgress) { - char aHeader[80] = "STL Exported by OpenCASCADE [www.opencascade.com]"; + char aHeader[80] = "STL Exported by Open CASCADE Technology [dev.opencascade.org]"; if (fwrite (aHeader, 1, 80, theFile) != 80) { return Standard_False; diff --git a/src/StepFile/StepFile_Read.cxx b/src/StepFile/StepFile_Read.cxx index b2e2a877b7..26319a7c43 100644 --- a/src/StepFile/StepFile_Read.cxx +++ b/src/StepFile/StepFile_Read.cxx @@ -14,22 +14,8 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -// StepFile_Read - -// routine assurant l enchainement des operations de lecture d un fichier -// STEP dans un StepModel, en fonction d une cle de reconnaissance -// Retour de la fonction : -// 0 si OK (le StepModel a ete charge) -// -1 si abandon car fichier pas pu etre ouvert -// 1 si erreur en cours de lecture - -// Compilation conditionnelle : concerne les mesures de performances - -#include -#include - -#include #include + #include #include @@ -49,9 +35,13 @@ #include #include -#include +#include #include +#include "step.tab.hxx" + +#include + #ifdef OCCT_DEBUG #define CHRONOMESURE #endif @@ -73,14 +63,15 @@ static Standard_Integer StepFile_Read (const char* theName, const Handle(StepData_FileRecognizer)& theRecogData) { // if stream is not provided, open file stream here - std::istream *aStreamPtr = theIStream; - std::ifstream aFileStream; - if (!aStreamPtr) { - OSD_OpenStream(aFileStream, theName, std::ios_base::in | std::ios_base::binary); - aStreamPtr = &aFileStream; + std::istream* aStreamPtr = theIStream; + std::shared_ptr aFileStream; + if (aStreamPtr == nullptr) + { + const Handle(OSD_FileSystem)& aFileSystem = OSD_FileSystem::DefaultFileSystem(); + aFileStream = aFileSystem->OpenIStream (theName, std::ios::in | std::ios::binary); + aStreamPtr = aFileStream.get(); } - - if (aStreamPtr->fail()) + if (aStreamPtr == nullptr || aStreamPtr->fail()) { return -1; } diff --git a/src/StepFile/StepFile_Read.hxx b/src/StepFile/StepFile_Read.hxx index 3f51411c5f..56921cbe6e 100644 --- a/src/StepFile/StepFile_Read.hxx +++ b/src/StepFile/StepFile_Read.hxx @@ -17,6 +17,9 @@ #ifndef StepFile_Read_HeaderFile #define StepFile_Read_HeaderFile +#include +#include + #include class StepData_StepModel;