Added option -stream to ReadStep command (similar to testreadstep command).
//=======================================================================
//function : ReadFile
-//purpose :
+//purpose :
//=======================================================================
-
-IFSelect_ReturnStatus STEPCAFControl_Reader::ReadFile(const Standard_CString filename)
+IFSelect_ReturnStatus STEPCAFControl_Reader::ReadFile (const Standard_CString theFileName)
{
- return myReader.ReadFile(filename);
+ return myReader.ReadFile (theFileName);
}
+//=======================================================================
+//function : ReadStream
+//purpose :
+//=======================================================================
+IFSelect_ReturnStatus STEPCAFControl_Reader::ReadStream (const Standard_CString theName,
+ std::istream& theIStream)
+{
+ return myReader.ReadStream (theName, theIStream);
+}
//=======================================================================
//function : NbRootsForTransfer
//! Clears the internal data structures and attaches to a new session
//! Clears the session if it was not yet set for STEP
Standard_EXPORT void Init (const Handle(XSControl_WorkSession)& WS, const Standard_Boolean scratch = Standard_True);
-
+
//! Loads a file and returns the read status
- //! Provided for use like single-file reader
- Standard_EXPORT IFSelect_ReturnStatus ReadFile (const Standard_CString filename);
-
+ //! Provided for use like single-file reader.
+ //! @param theFileName [in] file to open
+ //! @return read status
+ Standard_EXPORT IFSelect_ReturnStatus ReadFile (const Standard_CString theFileName);
+
+ //! Loads a file from stream and returns the read status.
+ //! @param theName [in] auxiliary stream name
+ //! @param theIStream [in] stream to read from
+ //! @return read status
+ Standard_EXPORT IFSelect_ReturnStatus ReadStream (const Standard_CString theName,
+ std::istream& theIStream);
+
//! Returns number of roots recognized for transfer
//! Shortcut for Reader().NbRootsForTransfer()
Standard_EXPORT Standard_Integer NbRootsForTransfer();
#include <IGESCAFControl_Writer.hxx>
#include <IGESControl_Controller.hxx>
#include <Interface_Macros.hxx>
+#include <OSD_OpenFile.hxx>
+#include <OSD_Path.hxx>
#include <STEPCAFControl_ExternFile.hxx>
#include <STEPCAFControl_Reader.hxx>
#include <STEPCAFControl_Writer.hxx>
Standard_CString aDocName = NULL;
TCollection_AsciiString aFilePath, aModeStr;
+ bool toTestStream = false;
for (Standard_Integer anArgIter = 1; anArgIter < argc; ++anArgIter)
{
TCollection_AsciiString anArgCase (argv[anArgIter]);
anArgCase.LowerCase();
- if (aDocName == NULL)
+ if (anArgCase == "-stream")
+ {
+ toTestStream = true;
+ }
+ else if (aDocName == NULL)
{
aDocName = argv[anArgIter];
}
{
Message_ProgressScope aReadScope (aRootScope.Next(), "File reading", 1);
aReadScope.Show();
- readstat = reader.ReadFile (fnom.ToCString());
+ if (toTestStream)
+ {
+ std::ifstream aStream;
+ OSD_OpenStream (aStream, fnom.ToCString(), std::ios::in | std::ios::binary);
+ TCollection_AsciiString aFolder, aFileName;
+ OSD_Path::FolderAndFileFromPath (fnom, aFolder, aFileName);
+ readstat = reader.ReadStream (aFileName.ToCString(), aStream);
+ }
+ else
+ {
+ readstat = reader.ReadFile (fnom.ToCString());
+ }
}
else if (XSDRAW::Session()->NbStartingEntities() > 0)
{
di.Add("ReadIges" , "Doc filename: Read IGES file to DECAF document" ,__FILE__, ReadIges, g);
di.Add("WriteIges" , "Doc filename: Write DECAF document to IGES file" ,__FILE__, WriteIges, g);
di.Add("ReadStep" ,
- "Doc filename [mode]"
- "\n\t\t: Read STEP file to a document.",
+ "Doc filename [mode] [-stream]"
+ "\n\t\t: Read STEP file to a document."
+ "\n\t\t: -stream read using istream reading interface (testing)",
__FILE__, ReadStep, g);
di.Add("WriteStep" , "Doc filename [mode=a [multifile_prefix] [label]]: Write DECAF document to STEP file" ,__FILE__, WriteStep, g);
#include <Message.hxx>
#include <Message_Messenger.hxx>
#include <Message_ProgressScope.hxx>
+#include <OSD_OpenFile.hxx>
+#include <OSD_Path.hxx>
#include <STEPControl_ActorWrite.hxx>
#include <STEPControl_Controller.hxx>
#include <STEPControl_Reader.hxx>
IFSelect_ReturnStatus readstat;
if (useStream)
{
- std::ifstream aStream (filename);
- readstat = Reader.ReadStream(filename, aStream);
+ std::ifstream aStream;
+ OSD_OpenStream (aStream, filename, std::ios::in | std::ios::binary);
+ TCollection_AsciiString aFolder, aFileNameShort;
+ OSD_Path::FolderAndFileFromPath (filename, aFolder, aFileNameShort);
+ readstat = Reader.ReadStream (aFileNameShort.ToCString(), aStream);
}
else
{