1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-09-03 14:10:33 +03:00

0033474: Data Exchange - Implement stream reading into RWMesh interface

Stream usage as parameter
This commit is contained in:
ichesnok
2023-09-12 11:58:55 +01:00
committed by dpasukhi
parent bd651bbbd9
commit 0435edfe54
11 changed files with 149 additions and 88 deletions

View File

@@ -89,14 +89,13 @@ namespace
// function : performMesh
// purpose :
//=======================================================================
bool VrmlAPI_CafReader::performMesh(const TCollection_AsciiString& theFile,
bool VrmlAPI_CafReader::performMesh(std::istream& theStream,
const TCollection_AsciiString& theFile,
const Message_ProgressRange& theProgress,
const Standard_Boolean theToProbe)
{
(void)theProgress;
Handle(OSD_FileSystem) aFile = OSD_FileSystem::DefaultFileSystem();
std::shared_ptr<std::istream> aFileStream = aFile->OpenIStream(theFile, std::ios::in | std::ios::binary);
if (aFileStream.get() == nullptr || !aFileStream->good())
if (!theStream.good())
{
Message::SendFail() << "Error in VrmlAPI_CafReader: file '" << theFile << "' is not found";
return false;
@@ -115,7 +114,7 @@ bool VrmlAPI_CafReader::performMesh(const TCollection_AsciiString& theFile,
VrmlData_Scene aScene;
aScene.SetLinearScale(FileLengthUnit());
aScene.SetVrmlDir(aFolder);
aScene << *aFileStream;
aScene << theStream;
VrmlData_DataMapOfShapeAppearance aShapeAppMap;
TopoDS_Shape aShape = aScene.GetShape(aShapeAppMap);

View File

@@ -24,13 +24,15 @@ class VrmlAPI_CafReader : public RWMesh_CafReader
protected:
//! Read the mesh data from specified file.
//! @param theFile file to read
//! @param theStream input stream
//! @param theFile path of additional files
//! @param theProgress progress indicator
//! @param theToProbe flag for probing file without complete reading. Not supported.
//! @return false when theToProbe is set to true or reading has completed with error.
Standard_EXPORT virtual Standard_Boolean performMesh(const TCollection_AsciiString& theFile,
const Message_ProgressRange& theProgress,
const Standard_Boolean theToProbe) Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean performMesh (std::istream& theStream,
const TCollection_AsciiString& theFile,
const Message_ProgressRange& theProgress,
const Standard_Boolean theToProbe) Standard_OVERRIDE;
};