SoInput Class Reference
[General]

Used to read Open Inventor data files. More...

#include <Inventor/SoInput.h>

Inheritance diagram for SoInput:
CIvfArchiveInput

List of all members.

Public Types

enum  FileType {
  OpenInventor,
  OpenFlight,
  DXF,
  IGES,
  STEP,
  CATIA5,
  ALL
}

Public Member Functions

 SoInput ()
virtual ~SoInput ()
virtual void setFilePointer (FILE *newFP)
virtual FILE * getFilePointer ()
virtual SoNONUNICODE SbBool openFile (const char *fileName, SbBool okIfNotFound=FALSE, SbBool aSync=FALSE)
virtual SbBool openFile (const SbString &fileName, SbBool okIfNotFound=FALSE, SbBool aSync=FALSE)
virtual SoNONUNICODE SbBool pushFile (const char *fileName)
virtual SbBool pushFile (const SbString &fileName)
virtual void closeFile ()
virtual SbBool isValidFile ()
virtual SbBool isValidBuffer ()
virtual FILE * getCurFile () const
virtual SoNONUNICODE const char * getCurFileName () const
virtual SbString getCurStringFileName () const
virtual void setBuffer (void *buffer, size_t bufSize)
virtual int getNumBytesRead () const
virtual SbString getHeader ()
virtual float getIVVersion ()
virtual void updateReadPercent (double readPercentage)
void setInputParameters (SoInputParameters *parameters)
SoInputParametersgetInputParameters () const

Static Public Member Functions

static SoNONUNICODE void addDirectoryFirst (const char *dirName)
static void addDirectoryFirst (const SbString &dirName)
static SoNONUNICODE void addDirectoryLast (const char *dirName)
static void addDirectoryLast (const SbString &dirName)
static SoNONUNICODE void addEnvDirectoriesFirst (const char *envVarName, const char *dirSep=DIRECTORIES_SEPARATOR)
static void addEnvDirectoriesFirst (const SbString &envVarName, const SbString &dirSep=DIRECTORIES_SEPARATOR)
static SoNONUNICODE void addEnvDirectoriesLast (const char *envVarName, const char *dirSep=DIRECTORIES_SEPARATOR)
static void addEnvDirectoriesLast (const SbString &envVarName, const SbString &dirSep=DIRECTORIES_SEPARATOR)
static SoNONUNICODE void removeDirectory (const char *dirName)
static void removeDirectory (const SbString &dirName)
static void clearDirectories ()
static const SbStringListgetDirectories ()
static SbBool findAbsolutePath (const SbString &fileName, SbString &fullName)

Deprecated



virtual SoDEPRECATED FileType getCurFileType () const
virtual SoDEPRECATED void setCurFileType (FileType fileType)

Detailed Description

Used to read Open Inventor data files.

This class is used by the SoDB reading routines when reading Open Inventor (.iv) format data or various geometry data formats that can be converted into an Open Inventor scene graph. The input source can be the standard input stream (default), a file (see openFile) or a buffer in memory (see setBuffer). SoInput can search for a file in a list of directories (see addDirectoryFirst etc). SoInput can report progress during the input operation (see updateReadPercent).

SoInput is typically used with SoDB::read or SoDB::readAll to load data and create a scene graph. There is an example code fragment on the SoDB page.

NOTE: Applications should always check the result of calling the openFile() method. If the call fails, the SoInput object itself is still valid and remains in the default state. Calling SoDB::readAll(), or methods like getHeader() and isValidFile(), with a default SoInput object will make the application appear to "hang" because it is waiting for data on standard input. To check if a file exists, get file properties, etc see SbFileHelper.

File formats

SoInput supports ASCII (default) and binary Open Inventor formats. Since Open Inventor 8.1, both the ASCII and binary formats can be compressed using the gz format (e.g. using gzip). The file extension 'ivz' is recognized for compressed Open Inventor files, but is not mandatory. In fact the initial bytes of the file are checked when the file is opened to automatically determine if it is compressed or not. This feature uses the module IvDLZlib.

SoInput also has built-in support for:

Additional input readers are provided as plugins for:

NOTE: OpenFlight format is not supported in Open Inventor 10.0 and later.

These formats require redistributing the corresponding plugin library with the application.

Open Inventor also supports many standard CAD file formats. See SoCADInputReader for the current list. These formats also require redistributing the corresponding plugin library (fei.inventor.io.cad) with the application.

SoInput can also be extended with custom file format readers. Input readers are defined as new classes inheriting from the SoInputReader class.. See SoInputReader class for more information about defining and loading new readers

For Open Inventor format files, users can also register additional valid file headers. When reading, SoInput skips over Open Inventor comments (from '#' to end of line) and can stack input files. When EOF is reached, the stack is popped.

Directory List

SoInput maintains a list of directories (initially empty). Generally Open Inventor classes that need to open a named file will search for the file in each of these directories in order. This includes SoInput (the openFile() method), SoTexture2, SoFragmentShader and other nodes that have a "filename" field.

Note: SoInput is not currently used for loading volume data files in VolumeViz. SoDataSet and its subclasses (SoVolumeData etc) do not search the list of directories maintained by SoInput when attempting to open a file. However the directory list is searched to find volume shader files (SoVolumeShader, SoVolumeRenderingQuality, etc).

The SoInput directory list is initialized from the environnment variable OIV_FILE_SEARCH_PATHS. This variable may be set to a semi-colon separated list of directory paths. The specified paths may use variables in $name format, e.g. "$OIVHOME", which will be replaced by the value returned by SoPreferences for that name. Additional directories may be added to the directory list using the static methods addDirectoryLast etc.

Static utility method findAbsolutePath() returns the full path of a file if it can be found in one of the directories in the list.

OpenFlight Input Limitations:

The supported OpenFlight file format release is 15.7. Releases 14.2 up to 15.7 may or may not be converted successfully. Newer OpenFlight opcodes (15.8 or later) may not be converted successfully.

Some opcodes are not converted (or partially converted):

It is anticipated that these lists will be shorter in future releases.

Here is the list of information that may actually be ignored: latitude and longitude, projection type, earth model, UTM zone, group animation flags, object flags and relative priority, face draw type and light mode, degree of freedom min and max (only keep current position), 0% morph vertex indices, external reference flags, several vertex flag bits and normals, name table, texture mapping palette, texture attribute files, road path and zone files, and linkage parameter IDs.

DXF Input Limitations:

The supported DXF file format release is 14.

The limitations are:

VRML Input Limitations:

Not all nodes are supported when reading VRML files. Here is list of supported nodes:

GeoVRML nodes:

Special Group nodes:

Common nodes:

Geometry nodes:

Geometry properties:

Geometry appearance:

Group nodes:

Special nodes:

SEE ALSO

SoDB, SoOutput, SoTranReceiver, SoInputParameters, SoInputReader, SoCADInputReaderParameters

See related examples:

QtCustomViewer, QtLargeModelViewer, QtReadFile, QtTreeView, MFCRenderAreaGuiIntegration, QtRenderAreaGuiIntegration, ToolsIvConvertToIv


Member Enumeration Documentation

File types.

Deprecated:

Deprecated since Open Inventor 9100
No more used.
Enumerator:
OpenInventor 

Open Inventor (Default).

OpenFlight 

OpenFlight.

See OPENFLIGHT_LIMITATIONS.

DXF 

DXF format.

See DXF_LIMITATIONS.

IGES 

IGES format.

STEP 

STEP format.

CATIA5 

CATIA5: Catia V5 format.

ALL 

All supported file types.


Constructor & Destructor Documentation

SoInput::SoInput (  ) 

Constructor.

The default SoInput reads from stdin.

virtual SoInput::~SoInput (  )  [virtual]

The destructor closes any files opened by the SoInput.


Member Function Documentation

static void SoInput::addDirectoryFirst ( const SbString dirName  )  [static]

The SoInput class maintains a global list of directories that is searched to find files when opening them.

Directories are searched in order. This routine adds a directory to the beginning of the list.

static SoNONUNICODE void SoInput::addDirectoryFirst ( const char *  dirName  )  [static]

The SoInput class maintains a global list of directories that is searched to find files when opening them.

Directories are searched in order. This routine adds a directory to the beginning of the list.

Non Unicode List:
This function should not be used in a Unicode application.
static void SoInput::addDirectoryLast ( const SbString dirName  )  [static]

The SoInput class maintains a global list of directories that is searched to find files when opening them.

Directories are searched in order. This routine adds a directory to the end of the list.

static SoNONUNICODE void SoInput::addDirectoryLast ( const char *  dirName  )  [static]

The SoInput class maintains a global list of directories that is searched to find files when opening them.

Directories are searched in order. This routine adds a directory to the end of the list.

Non Unicode List:
This function should not be used in a Unicode application.
static void SoInput::addEnvDirectoriesFirst ( const SbString envVarName,
const SbString dirSep = DIRECTORIES_SEPARATOR 
) [static]

The SoInput class maintains a global list of directories that is searched to find files when opening them.

Directories are searched in order. This routine adds directories named in the value of the given environment variable to the beginning of the list.

NOTE: On Microsoft Windows systems the default dirSep value causes a problem. For example, the string "C:/myDir" will be interpreted as two different directories "C/" and "/myDir".. To avoid this problem explicitly set dirSep to ";" (semicolon).

Parameters:
envVarName The name of the environment variable.
dirSep A string containing zero or more directory separator characters.
static SoNONUNICODE void SoInput::addEnvDirectoriesFirst ( const char *  envVarName,
const char *  dirSep = DIRECTORIES_SEPARATOR 
) [static]

The SoInput class maintains a global list of directories that is searched to find files when opening them.

Directories are searched in order. This routine adds directories named in the value of the given environment variable to the beginning of the list.

Parameters:
envVarName The name of the environment variable.
dirSep A string containing zero or more directory separator characters.

The default value of dirSep is ":;", in other words either a colon or an a semicolon character will be interpreted as separating directory paths. Directory paths in an environment variable are normally separated by semicolon characters on Microsoft Windows platforms and by colon (or whitespace) on UNIX/Linux systems.

NOTE: On Microsoft Windows systems the default dirSep value causes a problem. For example, the string "C:/myDir" will be interpreted as two different directories "C/" and "/myDir".. To avoid this problem explicitly set dirSep to ";" (semicolon).

Non Unicode List:
This function should not be used in a Unicode application.
static void SoInput::addEnvDirectoriesLast ( const SbString envVarName,
const SbString dirSep = DIRECTORIES_SEPARATOR 
) [static]

The SoInput class maintains a global list of directories that is searched to find files when opening them.

Directories are searched in order. This routine adds directories named in the value of the given environment variable to the end of the list.

NOTE: On Microsoft Windows systems the default dirSep value causes a problem. For example, the string "C:/myDir" will be interpreted as two different directories "C/" and "/myDir".. To avoid this problem explicitly set dirSep to ";" (semicolon).

Parameters:
envVarName The name of the environment variable.
dirSep A string containing zero or more directory separator characters.
static SoNONUNICODE void SoInput::addEnvDirectoriesLast ( const char *  envVarName,
const char *  dirSep = DIRECTORIES_SEPARATOR 
) [static]

The SoInput class maintains a global list of directories that is searched to find files when opening them.

Directories are searched in order. This routine adds directories named in the value of the given environment variable to the end of the list.

NOTE: On Microsoft Windows systems the default dirSep value causes a problem. For example, the string "C:/myDir" will be interpreted as two different directories "C/" and "/myDir".. To avoid this problem explicitly set dirSep to ";" (semicolon).

Parameters:
envVarName The name of the environment variable.
dirSep A string containing zero or more directory separator characters.
Non Unicode List:
This function should not be used in a Unicode application.
static void SoInput::clearDirectories (  )  [static]

Clears the list of directories (including the current directory).

virtual void SoInput::closeFile (  )  [virtual]

Closes all files on stack opened with openFile() or pushFile().

static SbBool SoInput::findAbsolutePath ( const SbString fileName,
SbString fullName 
) [static]

Returns absolute path of given file by looking in SoInput standard directories.

Returns true on success.

The file name may contain variables in $name format, e.g. "$OIVHOME", which will be replaced by the value returned by SoPreferences for that name.

virtual FILE* SoInput::getCurFile (  )  const [virtual]

Returns the current file.

Returns standard input (stdin) if no file or buffer is open. Returns NULL if reading from a buffer.

virtual SoNONUNICODE const char* SoInput::getCurFileName (  )  const [virtual]

Returns full name (including directory path) of current file.

Returns NULL if no file is open or if reading from a buffer.

Non Unicode List:
This function should not be used in a Unicode application.
virtual SoDEPRECATED FileType SoInput::getCurFileType (  )  const [virtual]

If no type has been specified, the default type is Open Inventor.

Returns the type of the current file.

Deprecated:

Deprecated since Open Inventor 9100
No longer used.
virtual SbString SoInput::getCurStringFileName (  )  const [virtual]

Returns full name (including directory path) of current file.

Returns an empty string (isEmpty() will be true) if no file is open or if reading from a buffer.

static const SbStringList& SoInput::getDirectories (  )  [static]

Returns the list of directories as an SbStringList.

virtual FILE* SoInput::getFilePointer (  )  [virtual]

Gets the file pointer read.

virtual SbString SoInput::getHeader (  )  [virtual]

Returns the header of the file being read.

Note that by default (when no file or buffer is open), SoInput reads from standard input, which may make the application appear to "hang".

SoInputParameters* SoInput::getInputParameters (  )  const

Return the current SoInputParameters.

virtual float SoInput::getIVVersion (  )  [inline, virtual]

Returns the Open Inventor file version of the file being read (2.1).

If the file has a header registered through SoDB::registerHeader(), the returned version is the Open Inventor version registered with the header. Returns 0.0 if no file or buffer is open.

virtual int SoInput::getNumBytesRead (  )  const [virtual]

Returns the number of bytes read.

virtual SbBool SoInput::isValidBuffer (  )  [virtual]

Returns TRUE if the current buffer is valid.

Buffer must begin with a standard Open Inventor header or one that has been registered with SoDB::registerHeader(). Note that by default (when no file or buffer is open), SoInput reads from standard input, which may make the application appear to "hang".

virtual SbBool SoInput::isValidFile (  )  [virtual]

Returns TRUE if the currently open file is a valid Open Inventor file.

File must begin with a standard Open Inventor header or one that has been registered with SoDB::registerHeader(). Note that by default (when no file or buffer is open), SoInput reads from standard input, which may make the application appear to "hang".

virtual SbBool SoInput::openFile ( const SbString fileName,
SbBool  okIfNotFound = FALSE,
SbBool  aSync = FALSE 
) [virtual]

Opens named file, sets file pointer to result.

Clears the stack of input files if necessary.

If okIfNotFound is FALSE (the default), prints an error message if the file could not be found. If aSync is true (FALSE by default) the file is read asynchronously (the reading starts immediately although it isn't fully buffered).

The file name may contain variables in $name format, e.g. "$OIVHOME", which will be replaced by the value returned by SoPreferences for that name.

virtual SoNONUNICODE SbBool SoInput::openFile ( const char *  fileName,
SbBool  okIfNotFound = FALSE,
SbBool  aSync = FALSE 
) [virtual]

Opens named file, sets file pointer to result.

Clears the stack of input files if necessary.

Returns FALSE on error. If okIfNotFound is FALSE (the default), prints an error message if the file could not be found. If aSync is true (FALSE by default) the file is read asynchronously (the reading starts immediately although it isn't fully buffered).

The file name may contain variables in $name format, e.g. "$OIVHOME", which will be replaced by the value returned by SoPreferences for that name.

Non Unicode List:
This function should not be used in a Unicode application.
virtual SbBool SoInput::pushFile ( const SbString fileName  )  [virtual]

Opens named file, pushing the resulting file pointer onto the stack.

Returns FALSE on error. When EOF is reached, the stack is popped.

The file name may contain variables in $name format, e.g. "$OIVHOME", which will be replaced by the value returned by SoPreferences for that name.

virtual SoNONUNICODE SbBool SoInput::pushFile ( const char *  fileName  )  [virtual]

Opens named file, pushing the resulting file pointer onto the stack.

Returns FALSE on error. When EOF is reached, the stack is popped.

The file name may contain variables in $name format, e.g. "$OIVHOME", which will be replaced by the value returned by SoPreferences for that name.

Non Unicode List:
This function should not be used in a Unicode application.
static void SoInput::removeDirectory ( const SbString dirName  )  [static]

Removes named directory from the list.

static SoNONUNICODE void SoInput::removeDirectory ( const char *  dirName  )  [static]

Removes named directory from the list.

Non Unicode List:
This function should not be used in a Unicode application.
virtual void SoInput::setBuffer ( void *  buffer,
size_t  bufSize 
) [virtual]

Sets an in-memory buffer to read from, along with its size.

virtual SoDEPRECATED void SoInput::setCurFileType ( FileType  fileType  )  [virtual]

Sets the type of the current file.

Deprecated:

Deprecated since Open Inventor 9100
No longer used.
virtual void SoInput::setFilePointer ( FILE *  newFP  )  [virtual]

Sets file pointer to read from.

Clears the stack of input files if necessary.

void SoInput::setInputParameters ( SoInputParameters parameters  ) 

Specify parameters to modify/control actions during the read of a file.

For example, use an instance of SoCADInputReaderParameters for file formats handled by the SoCADFileFormat module (IGES, STEP, CATIA, ...).

virtual void SoInput::updateReadPercent ( double  readPercentage  )  [virtual]

Reports the percentage of bytes read from the file.


Derive a new class and override this method if you want to implement a progress bar.


The documentation for this class was generated from the following file:

Open Inventor Toolkit reference manual, generated on 12 Feb 2024
Copyright © Thermo Fisher Scientific All rights reserved.
http://www.openinventor.com/