public class SoInput extends Inventor
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:
<font color="#0000FF">NOTE:</font> 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.
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.
The supported DXF file format release is 14.
The limitations are:
Not all nodes are supported when reading VRML files. Here is list of supported nodes:
GeoVRML nodes:
Special Group nodes:
Common nodes:
Geometry nodes:
SoVRMLElevationGrid
SoVRMLExtrusion
SoVRMLIndexedFaceSet
SoVRMLIndexedLineSet
SoVRMLPointSet
SoVRMLBox
SoVRMLCone
SoVRMLCylinder
SoVRMLSphere
SoVRMLText
SoVRMLShape
Geometry properties:
Geometry appearance:
SoVRMLMaterial
SoVRMLImageTexture
SoVRMLPixelTexture
SoVRMLTextureTransform
SoVRMLFontStyle
SoVRMLAppearance
Group nodes:
SoVRMLTransform
SoVRMLAnchor
SoVRMLBillboard
SoVRMLCollision
SoVRMLParent
SoVRMLGroup
SoVRMLStaticGroup
Special nodes:
See also:
SoDB
, SoOutput
, SoTranReceiver
, SoInputParameters
, SoInputReader
, SoCADInputReaderParameters
Modifier and Type | Class and Description |
---|---|
static class |
SoInput.FileTypes
Deprecated.
|
Inventor.ConstructorCommand
Modifier and Type | Field and Description |
---|---|
static int |
ALL
Deprecated.
Use
SoInput.FileTypes.ALL instead. |
static int |
CATIA5
Deprecated.
Use
SoInput.FileTypes.CATIA5 instead. |
static java.lang.String |
DIRECTORIES_SEPARATOR |
static int |
DXF
Deprecated.
Use
SoInput.FileTypes.DXF instead. |
static int |
IGES
Deprecated.
Use
SoInput.FileTypes.IGES instead. |
static int |
OpenFlight
Deprecated.
Use
SoInput.FileTypes.OpenFlight instead. |
static int |
OpenInventor
Deprecated.
Use
SoInput.FileTypes.OpenInventor instead. |
static int |
STEP
Deprecated.
Use
SoInput.FileTypes.STEP instead. |
VERBOSE_LEVEL, ZeroHandle
Constructor and Description |
---|
SoInput()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
static void |
addDirectoryFirst(java.lang.String dirName)
The
SoInput class maintains a global list of directories that is searched to find files when opening them. |
static void |
addDirectoryLast(java.lang.String dirName)
The
SoInput class maintains a global list of directories that is searched to find files when opening them. |
static void |
addEnvDirectoriesFirst(java.lang.String envVarName)
Calls addEnvDirectoriesFirst(envVarName, DIRECTORIES_SEPARATOR).
|
static void |
addEnvDirectoriesFirst(java.lang.String envVarName,
java.lang.String dirSep)
The
SoInput class maintains a global list of directories that is searched to find files when opening them. |
static void |
addEnvDirectoriesLast(java.lang.String envVarName)
Calls addEnvDirectoriesLast(envVarName, DIRECTORIES_SEPARATOR).
|
static void |
addEnvDirectoriesLast(java.lang.String envVarName,
java.lang.String dirSep)
The
SoInput class maintains a global list of directories that is searched to find files when opening them. |
static void |
clearDirectories()
Clears the list of directories (including the current directory).
|
void |
closeFile()
Closes all files on stack opened with
openFile() or pushFile() . |
static java.lang.String |
findAbsolutePath(java.lang.String fileName)
Returns absolute path of given file by looking in
SoInput standard directories. |
java.lang.String |
getCurFileName()
Returns full name (including directory path) of current file.
|
SoInput.FileTypes |
getCurFileType()
Deprecated.
As of Open Inventor 9100 See documentation for more details
|
java.lang.String |
getCurStringFileName()
Returns full name (including directory path) of current file.
|
java.lang.String |
getHeader()
Returns the header of the file being read.
|
SoInputParameters |
getInputParameters()
Return the current
SoInputParameters . |
float |
getIVVersion()
Returns the Open Inventor file version of the file being read (2.1).
|
int |
getNumBytesRead()
Returns the number of bytes read.
|
boolean |
isValidBuffer()
Returns true if the current buffer is valid.
|
boolean |
isValidFile()
Returns true if the currently open file is a valid Open Inventor file.
|
boolean |
openFile(java.lang.String fileName)
Calls openFile(fileName, false, false).
|
boolean |
openFile(java.lang.String fileName,
boolean okIfNotFound)
Calls openFile(fileName, okIfNotFound, false).
|
boolean |
openFile(java.lang.String fileName,
boolean okIfNotFound,
boolean aSync)
Opens named file.
|
boolean |
openURL(java.net.URL fileURL)
Using a java URL, open an IV file.
|
boolean |
pushFile(java.lang.String fileName)
Opens named file.
|
static void |
removeDirectory(java.lang.String dirName)
Removes named directory from the list.
|
void |
setBuffer(byte[] buffer)
Set up buffer to read from.
|
void |
setBuffer(byte[] buffer,
int size)
Set up buffer to read from.
|
void |
setBuffer(java.lang.String buffer,
int size)
Set up buffer to read from.
|
void |
setCurFileType(SoInput.FileTypes fileType)
Deprecated.
As of Open Inventor 9100 See documentation for more details
|
void |
setInputParameters(SoInputParameters parameters)
Specify parameters to modify/control actions during the read of a file.
|
void |
updateReadPercent(double readPercentage)
Reports the percentage of bytes read from the file.
|
dispose, getAddress, getNativeResourceHandle, startInternalThreads, stopInternalThreads
public static final java.lang.String DIRECTORIES_SEPARATOR
@Deprecated public static final int OpenInventor
SoInput.FileTypes.OpenInventor
instead.@Deprecated public static final int OpenFlight
SoInput.FileTypes.OpenFlight
instead.@Deprecated public static final int DXF
SoInput.FileTypes.DXF
instead.@Deprecated public static final int IGES
SoInput.FileTypes.IGES
instead.@Deprecated public static final int STEP
SoInput.FileTypes.STEP
instead.@Deprecated public static final int CATIA5
SoInput.FileTypes.CATIA5
instead.@Deprecated public static final int ALL
SoInput.FileTypes.ALL
instead.public SoInput()
SoInput
reads from stdin.public void setBuffer(byte[] buffer)
buffer
- contains the binary iv representationpublic void setBuffer(byte[] buffer, int size)
buffer
- contains the binary iv representationsize
- indicates how many bytes should be read from bufferpublic void setBuffer(java.lang.String buffer, int size)
buffer
- contains the iv representation in a string.size
- indicates how many characters should be read from bufferpublic boolean openURL(java.net.URL fileURL)
public boolean openFile(java.lang.String fileName)
public boolean openFile(java.lang.String fileName, boolean okIfNotFound)
public static void addEnvDirectoriesLast(java.lang.String envVarName)
public static void addEnvDirectoriesFirst(java.lang.String envVarName)
public void closeFile()
openFile()
or pushFile()
.public boolean isValidFile()
SoInput
reads from standard input, which may make the application appear to "hang".@Deprecated public void setCurFileType(SoInput.FileTypes fileType)
public boolean isValidBuffer()
SoInput
reads from standard input, which may make the application appear to "hang".public boolean openFile(java.lang.String fileName, boolean okIfNotFound, boolean aSync)
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.
public boolean pushFile(java.lang.String fileName)
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.
public static void addEnvDirectoriesFirst(java.lang.String envVarName, java.lang.String dirSep)
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).
envVarName
- The name of the environment variable.
dirSep
- A string containing zero or more directory separator characters.public static void addEnvDirectoriesLast(java.lang.String envVarName, java.lang.String dirSep)
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).
envVarName
- The name of the environment variable.
dirSep
- A string containing zero or more directory separator characters.public static void addDirectoryLast(java.lang.String dirName)
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.public static void clearDirectories()
public static java.lang.String findAbsolutePath(java.lang.String fileName)
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.
public static void removeDirectory(java.lang.String dirName)
public static void addDirectoryFirst(java.lang.String dirName)
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.public java.lang.String getHeader()
SoInput
reads from standard input, which may make the application appear to "hang".public float getIVVersion()
public int getNumBytesRead()
public java.lang.String getCurFileName()
public java.lang.String getCurStringFileName()
@Deprecated public SoInput.FileTypes getCurFileType()
public SoInputParameters getInputParameters()
SoInputParameters
.public void updateReadPercent(double readPercentage)
public void setInputParameters(SoInputParameters parameters)
Generated on January 23, 2025, Copyright © Thermo Fisher Scientific. All rights reserved. http://www.openinventor.com