Class SoInput
- java.lang.Object
-
- com.openinventor.inventor.Inventor
-
- com.openinventor.inventor.SoInput
-
public class SoInput extends Inventor
Used to read Open Inventor data files. This class is used by theSoDBreading 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).SoInputcan search for a file in a list of directories (see addDirectoryFirst etc).SoInputcan report progress during the input operation (see updateReadPercent).SoInputis typically used withSoDB.readorSoDB.readAllto load data and create a scene graph. There is an example code fragment on theSoDBpage.NOTE: Applications should always check the result of calling the
openFile()method. If the call fails, theSoInputobject itself is still valid and remains in the default state. CallingSoDB.readAll(), or methods likegetHeader()andisValidFile(), with a defaultSoInputobject 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 seeSbFileHelper.File formats
SoInputsupports 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.SoInputalso has built-in support for:- VRML97 format (.wrl)
- X3D Classic VRML format (.x3dv) See VRML_LIMITATIONS for details.
Additional input readers are provided as plugins for:
- DXF format (.dxf)
- STL format (.stl)
These formats require redistributing the corresponding plugin library with the application.
- DXF : fei_inventor_io_dxf (e.g. fei_inventor_io_dxf.dll on Windows).
- STL : fei_inventor_io_stl (e.g. fei_inventor_io_stl.dll on Windows).
Open Inventor also supports many standard CAD file formats. See
SoCADInputReaderfor the current list. These formats also require redistributing the corresponding plugin library (fei_inventor_io_cad) with the application.SoInputcan also be extended with custom file format readers. Input readers are defined as new classes inheriting from theSoInputReaderclass.. SeeSoInputReaderclass for more information about defining and loading new readersFor Open Inventor format files, users can also register additional valid file headers. When reading,
SoInputskips over Open Inventor comments (from '#' to end of line) and can stack input files. When EOF is reached, the stack is popped.Directory List
SoInputmaintains 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 includesSoInput(theopenFile()method),SoTexture2,SoFragmentShaderand other nodes that have a "filename" field.Note:
SoInputis not currently used for loading volume data files in VolumeViz.SoDataSetand its subclasses (SoVolumeDataetc) do not search the list of directories maintained bySoInputwhen attempting to open a file. However the directory list is searched to find volume shader files (SoVolumeShader,SoVolumeRenderingQuality, etc).The
SoInputdirectory 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 bySoPreferencesfor 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.DXF Input Limitations: The supported DXF file format release is 14.
The limitations are:
- CLASSES, OBJECTS and THUMBNAILIMAGE sections are ignored.
- TABLES section: APPID, BLOCK_RECORD,DIMSTYLE, LTYPE, LAYER, STYLE, UCS, VIEW, VIEWPORT are ignored.
- ENTITIES section: ARCALIGNEDTEXT, DIMENSION, IMAGE, REGION, WIPEOUT are ignored.
VRML Input Limitations: Starting from OIV10, it is no more possible to create VRML nodes. However, import of .vrml file is till supported but node are automatically converted to OIV nodes. Not all nodes are supported when reading VRML files. Here is list of supported nodes and their corresponding OIV nodes. Some VRML nodes will be converter to more or less complexe scenegraph. In this case, VRML node may be converted to an
SoSeparatoror anSoGroupcontaining scene graph.GeoVRML nodes:
- SoVRMLGeoLOD ->
SoGeoLOD - SoVRMLGeoElevationGrid ->
SoSeparator - SoVRMLGeoOrigin ->
SoGeoOrigin - SoVRMLGeoLocation ->
SoSeparator - SoVRMLGeoCoordinate ->
SoGeoCoordinate
Special Group nodes:
- SoVRMLInline ->
SoSeparator - SoVRMLLOD ->
SoLevelOfDetail - SoVRMLSwitch ->
SoSwitch
Common nodes:
- SoVRMLDirectionalLight ->
SoDirectionalLight - SoVRMLPointLight ->
SoPointLight - SoVRMLSpotLight ->
SoSpotLight - SoVRMLWorldInfo ->
SoInfo
Geometry nodes:
- SoVRMLElevationGrid ->
SoSeparator - SoVRMLExtrusion ->
SoGroup - SoVRMLIndexedFaceSet ->
SoGroup - SoVRMLIndexedLineSet ->
SoGroup - SoVRMLPointSet ->
SoGroup - SoVRMLBox ->
SoCube - SoVRMLCone ->
SoCone - SoVRMLCylinder ->
SoCylinder - SoVRMLSphere ->
SoSphere - SoVRMLText ->
SoSeparator - SoVRMLShape ->
SoSeparator
Geometry properties:
- SoVRMLCoordinate ->
SoCoordinate3 - SoVRMLColor ->
SoMaterial - SoVRMLTextureCoordinate ->
SoTextureCoordinate2 - SoVRMLNormal ->
SoNormal
Geometry appearance:
- SoVRMLMaterial ->
SoMaterial - SoVRMLImageTexture ->
SoTexture2 - SoVRMLPixelTexture ->
SoTexture2 - SoVRMLTextureTransform ->
SoTexture2Transform - SoVRMLFontStyle ->
SoFontStyle - SoVRMLAppearance ->
SoGroup
Group nodes:
- SoVRMLTransform ->
SoSeparator - SoVRMLAnchor ->
SoSeparator - SoVRMLBillboard ->
SoBillboard - SoVRMLCollision ->
SoSeparator - SoVRMLParent ->
SoGroup - SoVRMLGroup ->
SoSeparator - SoVRMLStaticGroup ->
SoSeparator
Special nodes:
- SoVRMLPROTOInstance ->
SoSeparator
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.openinventor.inventor.Inventor
Inventor.ConstructorCommand
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDIRECTORIES_SEPARATOR-
Fields inherited from class com.openinventor.inventor.Inventor
VERBOSE_LEVEL, ZeroHandle
-
-
Constructor Summary
Constructors Constructor Description SoInput()Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidaddDirectoryFirst(java.lang.String dirName)TheSoInputclass maintains a global list of directories that is searched to find files when opening them.static voidaddDirectoryLast(java.lang.String dirName)TheSoInputclass maintains a global list of directories that is searched to find files when opening them.static voidaddEnvDirectoriesFirst(java.lang.String envVarName)Calls addEnvDirectoriesFirst(envVarName, DIRECTORIES_SEPARATOR).static voidaddEnvDirectoriesFirst(java.lang.String envVarName, java.lang.String dirSep)TheSoInputclass maintains a global list of directories that is searched to find files when opening them.static voidaddEnvDirectoriesLast(java.lang.String envVarName)Calls addEnvDirectoriesLast(envVarName, DIRECTORIES_SEPARATOR).static voidaddEnvDirectoriesLast(java.lang.String envVarName, java.lang.String dirSep)TheSoInputclass maintains a global list of directories that is searched to find files when opening them.static voidclearDirectories()Clears the list of directories (including the current directory).voidcloseFile()Closes all files on stack opened withopenFile()orpushFile().static java.lang.StringfindAbsolutePath(java.lang.String fileName)Returns absolute path of given file by looking inSoInputstandard directories.java.lang.StringgetCurFileName()Returns full name (including directory path) of current file.java.lang.StringgetCurStringFileName()Returns full name (including directory path) of current file.java.lang.StringgetHeader()Returns the header of the file being read.SoInputParametersgetInputParameters()Return the currentSoInputParameters.floatgetIVVersion()Returns the Open Inventor file version of the file being read (2.1).intgetNumBytesRead()Returns the number of bytes read.booleanisValidBuffer()Returns true if the current buffer is valid.booleanisValidFile()Returns true if the currently open file is a valid Open Inventor file.booleanopenFile(java.lang.String fileName)Calls openFile(fileName, false, false).booleanopenFile(java.lang.String fileName, boolean okIfNotFound)Calls openFile(fileName, okIfNotFound, false).booleanopenFile(java.lang.String fileName, boolean okIfNotFound, boolean aSync)Opens named file.booleanopenURL(java.net.URL fileURL)Using a java URL, open an IV file.booleanpushFile(java.lang.String fileName)Opens named file.static voidremoveDirectory(java.lang.String dirName)Removes named directory from the list.voidsetBuffer(byte[] buffer)Set up buffer to read from.voidsetBuffer(byte[] buffer, int size)Set up buffer to read from.voidsetBuffer(java.lang.String buffer, int size)Set up buffer to read from.voidsetInputParameters(SoInputParameters parameters)Specify parameters to modify/control actions during the read of a file.voidupdateReadPercent(double readPercentage)Reports the percentage of bytes read from the file.-
Methods inherited from class com.openinventor.inventor.Inventor
dispose, getNativeResourceHandle
-
-
-
-
Constructor Detail
-
SoInput
public SoInput()
Constructor. The defaultSoInputreads from stdin.
-
-
Method Detail
-
setBuffer
public void setBuffer(byte[] buffer)
Set up buffer to read from.- Parameters:
buffer- contains the binary iv representation
-
setBuffer
public void setBuffer(byte[] buffer, int size)Set up buffer to read from.- Parameters:
buffer- contains the binary iv representationsize- indicates how many bytes should be read from buffer
-
setBuffer
public void setBuffer(java.lang.String buffer, int size)Set up buffer to read from.- Parameters:
buffer- contains the iv representation in a string.size- indicates how many characters should be read from buffer
-
openURL
public boolean openURL(java.net.URL fileURL)
Using a java URL, open an IV file. If the URL indicates an address through the net, be sure that your machine is connected.- Returns:
- false if the URL is not correct or if it could not be opened ; true if the resulting buffer is valid.
-
openFile
public boolean openFile(java.lang.String fileName)
Calls openFile(fileName, false, false).
-
openFile
public boolean openFile(java.lang.String fileName, boolean okIfNotFound)Calls openFile(fileName, okIfNotFound, false).
-
addEnvDirectoriesLast
public static void addEnvDirectoriesLast(java.lang.String envVarName)
Calls addEnvDirectoriesLast(envVarName, DIRECTORIES_SEPARATOR).
-
addEnvDirectoriesFirst
public static void addEnvDirectoriesFirst(java.lang.String envVarName)
Calls addEnvDirectoriesFirst(envVarName, DIRECTORIES_SEPARATOR).
-
pushFile
public boolean pushFile(java.lang.String fileName)
Opens named file. 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
SoPreferencesfor that name.
-
addDirectoryFirst
public static void addDirectoryFirst(java.lang.String dirName)
TheSoInputclass 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.
-
isValidFile
public boolean isValidFile()
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),SoInputreads from standard input, which may make the application appear to "hang".
-
closeFile
public void closeFile()
Closes all files on stack opened withopenFile()orpushFile().
-
openFile
public boolean openFile(java.lang.String fileName, boolean okIfNotFound, boolean aSync)Opens named file. 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
SoPreferencesfor that name.
-
addEnvDirectoriesFirst
public static void addEnvDirectoriesFirst(java.lang.String envVarName, java.lang.String dirSep)TheSoInputclass 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.
-
addEnvDirectoriesLast
public static void addEnvDirectoriesLast(java.lang.String envVarName, java.lang.String dirSep)TheSoInputclass 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.
-
addDirectoryLast
public static void addDirectoryLast(java.lang.String dirName)
TheSoInputclass 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.
-
clearDirectories
public static void clearDirectories()
Clears the list of directories (including the current directory).
-
findAbsolutePath
public static java.lang.String findAbsolutePath(java.lang.String fileName)
Returns absolute path of given file by looking inSoInputstandard 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
SoPreferencesfor that name.
-
removeDirectory
public static void removeDirectory(java.lang.String dirName)
Removes named directory from the list.
-
getNumBytesRead
public int getNumBytesRead()
Returns the number of bytes read.
-
getHeader
public java.lang.String getHeader()
Returns the header of the file being read. Note that by default (when no file or buffer is open),SoInputreads from standard input, which may make the application appear to "hang".
-
getCurStringFileName
public java.lang.String getCurStringFileName()
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.
-
isValidBuffer
public boolean isValidBuffer()
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),SoInputreads from standard input, which may make the application appear to "hang".
-
getCurFileName
public java.lang.String getCurFileName()
Returns full name (including directory path) of current file. Returns NULL if no file is open or if reading from a buffer.
-
getInputParameters
public SoInputParameters getInputParameters()
Return the currentSoInputParameters.
-
setInputParameters
public void setInputParameters(SoInputParameters parameters)
Specify parameters to modify/control actions during the read of a file. For example, use an instance ofSoCADInputReaderParametersfor file formats handled by theSoCADFileFormatmodule (IGES, STEP, CATIA, ...).
-
getIVVersion
public float getIVVersion()
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.
-
updateReadPercent
public void updateReadPercent(double readPercentage)
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.
-
-