mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-21 10:13:43 +03:00
0032826: Data Exchange - use OSD_FileSystem within RWStl::ReadAscii() and StepFile_Read()
This commit is contained in:
parent
e2d60d0f7f
commit
2922a73ea7
@ -147,12 +147,6 @@ Handle(Poly_Triangulation) RWStl::ReadFile (const OSD_Path& theFile,
|
|||||||
Handle(Poly_Triangulation) RWStl::ReadBinary (const OSD_Path& theFile,
|
Handle(Poly_Triangulation) RWStl::ReadBinary (const OSD_Path& theFile,
|
||||||
const Message_ProgressRange& theProgress)
|
const Message_ProgressRange& theProgress)
|
||||||
{
|
{
|
||||||
OSD_File aFile(theFile);
|
|
||||||
if (!aFile.Exists())
|
|
||||||
{
|
|
||||||
return Handle(Poly_Triangulation)();
|
|
||||||
}
|
|
||||||
|
|
||||||
TCollection_AsciiString aPath;
|
TCollection_AsciiString aPath;
|
||||||
theFile.SystemName (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,
|
Handle(Poly_Triangulation) RWStl::ReadAscii (const OSD_Path& theFile,
|
||||||
const Message_ProgressRange& theProgress)
|
const Message_ProgressRange& theProgress)
|
||||||
{
|
{
|
||||||
OSD_File aFile (theFile);
|
|
||||||
if (!aFile.Exists())
|
|
||||||
{
|
|
||||||
return Handle(Poly_Triangulation)();
|
|
||||||
}
|
|
||||||
|
|
||||||
TCollection_AsciiString aPath;
|
TCollection_AsciiString aPath;
|
||||||
theFile.SystemName (aPath);
|
theFile.SystemName (aPath);
|
||||||
|
|
||||||
std::filebuf aBuf;
|
const Handle(OSD_FileSystem)& aFileSystem = OSD_FileSystem::DefaultFileSystem();
|
||||||
OSD_OpenStream (aBuf, aPath, std::ios::in | std::ios::binary);
|
std::shared_ptr<std::istream> aStream = aFileSystem->OpenIStream (aPath, std::ios::in | std::ios::binary);
|
||||||
if (!aBuf.is_open())
|
if (aStream.get() == NULL)
|
||||||
{
|
{
|
||||||
return Handle(Poly_Triangulation)();
|
return Handle(Poly_Triangulation)();
|
||||||
}
|
}
|
||||||
Standard_IStream aStream (&aBuf);
|
|
||||||
|
|
||||||
// get length of file to feed progress indicator
|
// get length of file to feed progress indicator
|
||||||
aStream.seekg (0, aStream.end);
|
aStream->seekg (0, aStream->end);
|
||||||
std::streampos theEnd = aStream.tellg();
|
std::streampos theEnd = aStream->tellg();
|
||||||
aStream.seekg (0, aStream.beg);
|
aStream->seekg (0, aStream->beg);
|
||||||
|
|
||||||
Reader aReader;
|
Reader aReader;
|
||||||
Standard_ReadLineBuffer aBuffer (THE_BUFFER_SIZE);
|
Standard_ReadLineBuffer aBuffer (THE_BUFFER_SIZE);
|
||||||
if (!aReader.ReadAscii (aStream, aBuffer, theEnd, theProgress))
|
if (!aReader.ReadAscii (*aStream, aBuffer, theEnd, theProgress))
|
||||||
{
|
{
|
||||||
return Handle(Poly_Triangulation)();
|
return Handle(Poly_Triangulation)();
|
||||||
}
|
}
|
||||||
@ -351,7 +338,7 @@ Standard_Boolean RWStl::writeBinary (const Handle(Poly_Triangulation)& theMesh,
|
|||||||
FILE* theFile,
|
FILE* theFile,
|
||||||
const Message_ProgressRange& theProgress)
|
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)
|
if (fwrite (aHeader, 1, 80, theFile) != 80)
|
||||||
{
|
{
|
||||||
return Standard_False;
|
return Standard_False;
|
||||||
|
@ -14,22 +14,8 @@
|
|||||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||||
// commercial license or contractual agreement.
|
// 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 <stdio.h>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#include <step.tab.hxx>
|
|
||||||
#include <StepFile_Read.hxx>
|
#include <StepFile_Read.hxx>
|
||||||
|
|
||||||
#include <StepFile_ReadData.hxx>
|
#include <StepFile_ReadData.hxx>
|
||||||
|
|
||||||
#include <Interface_Check.hxx>
|
#include <Interface_Check.hxx>
|
||||||
@ -49,9 +35,13 @@
|
|||||||
#include <Message.hxx>
|
#include <Message.hxx>
|
||||||
#include <Message_Messenger.hxx>
|
#include <Message_Messenger.hxx>
|
||||||
|
|
||||||
#include <OSD_OpenFile.hxx>
|
#include <OSD_FileSystem.hxx>
|
||||||
#include <OSD_Timer.hxx>
|
#include <OSD_Timer.hxx>
|
||||||
|
|
||||||
|
#include "step.tab.hxx"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#ifdef OCCT_DEBUG
|
#ifdef OCCT_DEBUG
|
||||||
#define CHRONOMESURE
|
#define CHRONOMESURE
|
||||||
#endif
|
#endif
|
||||||
@ -74,13 +64,14 @@ static Standard_Integer StepFile_Read (const char* theName,
|
|||||||
{
|
{
|
||||||
// if stream is not provided, open file stream here
|
// if stream is not provided, open file stream here
|
||||||
std::istream* aStreamPtr = theIStream;
|
std::istream* aStreamPtr = theIStream;
|
||||||
std::ifstream aFileStream;
|
std::shared_ptr<std::istream> aFileStream;
|
||||||
if (!aStreamPtr) {
|
if (aStreamPtr == nullptr)
|
||||||
OSD_OpenStream(aFileStream, theName, std::ios_base::in | std::ios_base::binary);
|
{
|
||||||
aStreamPtr = &aFileStream;
|
const Handle(OSD_FileSystem)& aFileSystem = OSD_FileSystem::DefaultFileSystem();
|
||||||
|
aFileStream = aFileSystem->OpenIStream (theName, std::ios::in | std::ios::binary);
|
||||||
|
aStreamPtr = aFileStream.get();
|
||||||
}
|
}
|
||||||
|
if (aStreamPtr == nullptr || aStreamPtr->fail())
|
||||||
if (aStreamPtr->fail())
|
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,9 @@
|
|||||||
#ifndef StepFile_Read_HeaderFile
|
#ifndef StepFile_Read_HeaderFile
|
||||||
#define StepFile_Read_HeaderFile
|
#define StepFile_Read_HeaderFile
|
||||||
|
|
||||||
|
#include <Standard_CString.hxx>
|
||||||
|
#include <Standard_Type.hxx>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
class StepData_StepModel;
|
class StepData_StepModel;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user