SEGY file format reader. More...
#include <VolumeViz/readers/SoVRSegyFileReader.h>
Public Types | |
enum | SegyScanningResp { SCAN_CONTINUE, SCAN_ABORT } |
enum | SegyByteOrder { SEGY_LITTLE_ENDIAN, SEGY_BIG_ENDIAN } |
enum | SegyAxisOrder { XYZ_AS_SAMPLE_INLINE_CROSSLINE, XYZ_AS_INLINE_CROSSLINE_SAMPLE } |
typedef SegyScanningResp | SoSegyScanningCB (void *data, float percent, SoVRSegyFileReader *reader) |
Public Member Functions | |
virtual SoType | getTypeId () const |
SoVRSegyFileReader () | |
virtual ReadError | getDataChar (SbBox3f &size, SoDataSet::DataType &type, SbVec3i32 &dim) |
virtual void | getSubSlice (const SbBox2i32 &subSlice, int sliceNumber, void *data) |
virtual SbBool | setDirectCoordSysAutoDetection (SbBool autoValue) |
virtual ReaderType | getReaderType () |
virtual int | setFilename (const SbString &filename) |
void | setScanningProgressCallback (SoSegyScanningCB *func, void *data) |
virtual void | setSegyTextHeaderAscii (bool ascii) |
virtual SbString | getSegyTextHeader () |
virtual void | setSegyByteOrder (SegyByteOrder byteOrder) |
virtual SegyByteOrder | getSegyByteOrder () |
virtual SbBool | setSegyFileHeader (const SoVRSegyFileHeader &fileHeader) |
virtual SbBool | getSegyFileHeader (SoVRSegyFileHeader &fileHeader, bool readFile=false) |
virtual void | setSegyTraceHeaderBytePosition (const SoVRSegyTraceHeaderBytePosition &traceHeaderBytePosition) |
virtual SoVRSegyTraceHeaderBytePosition | getSegyTraceHeaderBytePosition () |
virtual int | getNumTraces () |
virtual SbBool | getSegyTraceHeader (int traceNumber, SoVRSegyTraceIdHeader &traceHeader) |
virtual SbBool | isSegyRegular () |
virtual void | setCrosslineRange (int from, int to, int step) |
virtual void | setInlineRange (int from, int to, int step) |
virtual void | setZRange (int from, int to, int step) |
virtual void | getCrosslineRange (int &from, int &to, int &step) |
virtual void | getInlineRange (int &from, int &to, int &step) |
virtual void | getZRange (int &from, int &to, int &step) |
virtual SbBool | getP1P2P3Coordinates (SbVec2d &P1, SbVec2d &P2, SbVec2d &P3, SbVec2d &P4) |
virtual SbBool | setDirectCoorSys (SbBool directCoord) |
virtual void | setSegyAxisOrder (SegyAxisOrder axisOrder) |
virtual SegyAxisOrder | getSegyAxisOrder () |
virtual int | getSegyTraceData (int traceNumber, void *&traceData, int start=0, int size=-1) |
bool | getTraceCoord (const int i, const int j, SbVec2d &P) |
virtual SbBool | setOutputDataType (SbBool doChange, SoDataSet::DataType type) |
virtual SbBool | setInputDataRange (SbBool doChange, double min, double max) |
Static Public Member Functions | |
static SoType | getClassTypeId () |
static void | setVolumeSizeVoxels (SbBool flag) |
Reader for SEGY files (SEG Y revision 1). The following data types are supported: unsigned or signed byte, short, int32, and float.
SEGY is a widely used format for storing seismic trace data, defined by the Society of Exploration Geophysicists publication "Digital Tape Standards" (http://www.seg.org). The VolumeViz reader supports all sizes of integer and float data, and can correctly determine the number of samples per trace in most cases.
The data will be mapped to the Open Inventor axes as follows:
Although in most cases the SEGY reader can automatically detect if the number of traces per line in a SEGY file is not uniform, in some cases it cannot. You can set environment variable IVVR_IRREGULAR_TRACE_NUM to request the use of a more sophisticated file parsing algorithm. However, be aware that the initialization for file reading will take longer when this environment variable is set. Missing data is assigned the value zero.
Although in most cases the SEGY reader can automatically detect if the length of traces in a SEGY data file is not uniform, in some cases it cannot. You can set environment variable IVVR_INCONSTANT_TRACE_LENGTH to request the use of a more sophisticated file parsing algorithm. However, be aware that the initialization for file reading will take significantly longer when this environment variable is set. Missing data is assigned the value zero.
In most cases the SEGY reader can automatically detect if the values in the file need to be "byte swapped", for example if the data was written on a "big-endian" machine (e.g., SPARC) and is being read on a "little-endian" machine (e.g., Intel). If necessary you can force byte swapping on or off using the environment variable IVVR_SEGY_SWAPBYTES.
A value of 1 in the format field of the SEGY header normally means that the data values were written in IBM floating point format. But in some cases the values were actually written in IEEE floating point format (which should be indicated by format = 5). Normally the SEGY reader is able to detect this, but if necessary you can specify that float values are in IEEE format by setting environment variable IVVR_SEGY_FLOATISIEEE.
If the SEGY reader fails to read the file correctly, you can set the following environment variables:
Limitations: In some circontances few first traces might be skipped, typically when the first line contains only one trace (this trace might be skipped). In such a case a message warns the application of how many traces are actually skipped (throught SoDebugError).
See SoPreferences for information on using environment variables.
In some cases information such as line numbers and crossline numbers will be stored in non-standard locations in the header. Applications can specify the byte position of values within the header using the setSegyTraceHeaderBytePosition() method.
Information about the range of inline / crossline numbers and the range of time values can be queried using the getInlineRange(), getCrosslineRange() and getZRange() methods.
Applications can use this class to open a SEGY file and extract information from the file directly (in other words without necessarily creating a volume data node). To get the SEGY text file header call getSegyTextHeader(). To get the SEGY binary file header call getSegyFileHeader(). To get the header of a specific trace call getSegyTraceHeader(). To get the values in a specific trace call getSegyTraceData().
SoVRSegyFileHeader, SoVRSegyTraceIdHeader, SoVRSegyTraceHeaderBytePosition
typedef SegyScanningResp SoVRSegyFileReader::SoSegyScanningCB(void *data, float percent, SoVRSegyFileReader *reader) |
SoSegyScanningCB Callback type.
SoVRSegyFileReader::SoVRSegyFileReader | ( | ) |
Constructor.
static SoType SoVRSegyFileReader::getClassTypeId | ( | ) | [static] |
Returns the type identifier for this class.
Reimplemented from SoVolumeReader.
virtual void SoVRSegyFileReader::getCrosslineRange | ( | int & | from, | |
int & | to, | |||
int & | step | |||
) | [virtual] |
Gets the crossline range.
This method returns the actual values from the file if the corresponding set method has not been called previously. Otherwise, the values previously specified with setCrosslineRange are returned.
virtual ReadError SoVRSegyFileReader::getDataChar | ( | SbBox3f & | size, | |
SoDataSet::DataType & | type, | |||
SbVec3i32 & | dim | |||
) | [virtual] |
Gets the characteristics (file header) of the data volume.
See SoVolumeData. size is the size of the actual volume. type is the type of the data. dim is the dimension of the data.
Implements SoVolumeReader.
virtual void SoVRSegyFileReader::getInlineRange | ( | int & | from, | |
int & | to, | |||
int & | step | |||
) | [virtual] |
Gets the inline range.
This method returns the actual values from the file if the corresponding set method has not been called previously. Otherwise, the values previously specified with setInlineRange are returned.
NOTE: If the inline values are incorrect in the file, or are not retrieved correctly for any reason, getInlineRange returns (1, numLines, 1).
virtual int SoVRSegyFileReader::getNumTraces | ( | ) | [virtual] |
Returns the number of traces.
If the file is not regular (see isSegyRegular()), an approximate number (considering it as regular) is returned (to avoid scanning the whole file).
virtual SbBool SoVRSegyFileReader::getP1P2P3Coordinates | ( | SbVec2d & | P1, | |
SbVec2d & | P2, | |||
SbVec2d & | P3, | |||
SbVec2d & | P4 | |||
) | [virtual] |
Gets the P1, P2, P3 and P4 coordinates.
P1, P2 are on the corners corresponding to the first line. P4, P3 are on the corners corresponding to the last line. If these points do not exist, the crossline and inline values are used instead. Returns TRUE for a right-handed coordinate system (Xline/Inline/Time).
virtual ReaderType SoVRSegyFileReader::getReaderType | ( | ) | [inline, virtual] |
Returns the reader type, in this case, the enum value SoVolumeReader::SEGY.
Reimplemented from SoVolumeReader.
virtual SegyAxisOrder SoVRSegyFileReader::getSegyAxisOrder | ( | ) | [virtual] |
Get the storage order for X, Y, and Z axis.
See setSegyAxisOrder().
virtual SegyByteOrder SoVRSegyFileReader::getSegyByteOrder | ( | ) | [virtual] |
Gets the byte ordering to use when reading the SEGY file.
virtual SbBool SoVRSegyFileReader::getSegyFileHeader | ( | SoVRSegyFileHeader & | fileHeader, | |
bool | readFile = false | |||
) | [virtual] |
Gets the SEGY file header.
If you use this class to read a SEGY file directly, you will have to call the method SoVolumeReader::setFilename() first. Returns FALSE if the operation fails, for example, if SoVolumeReader::setFilename() was not called first. If readFile is true the file header is read from the file, otherwise the value set by setSegyFileHeader() is returned instead. If readFile is false but setSegyFileHeader() was never called, the file header is read from the file anyway.
virtual SbString SoVRSegyFileReader::getSegyTextHeader | ( | ) | [virtual] |
Retreives the textual header (the first 3200-bytes) of the SEGY file.
virtual int SoVRSegyFileReader::getSegyTraceData | ( | int | traceNumber, | |
void *& | traceData, | |||
int | start = 0 , |
|||
int | size = -1 | |||
) | [virtual] |
Gets the SEGY trace data of the specified trace traceNumber.
traceNumber can range from zero to the number of traces minus one. If you want to get a subset of the data, specify the start position in the trace and the number of data values ( size ). The return value is the number of data values read, or 0, if the operation failed.
If you use this class to read a SEGY file directly, you will have to call the method SoVolumeReader::setFilename() first. Additionally your application will be responsible for releasing the memory afterward. Otherwise,VolumeViz will release the memory.
This returns a pointer to an internal buffer, so if you want to call this method twice in order to get two traces, copy the first trace into your own buffer before calling this method for the second trace.
virtual SbBool SoVRSegyFileReader::getSegyTraceHeader | ( | int | traceNumber, | |
SoVRSegyTraceIdHeader & | traceHeader | |||
) | [virtual] |
Gets the SEGY trace header of the given trace traceNumber .
traceNumber can range from zero to the number of traces minus one. If you use this class to read a SEGY file directly, you will have to call the method SoVolumeReader::setFilename() first. Returns FALSE if the operation fails, for example, if SoVolumeReader::setFilename() was not called first.
virtual SoVRSegyTraceHeaderBytePosition SoVRSegyFileReader::getSegyTraceHeaderBytePosition | ( | ) | [virtual] |
Gets the byte positions within the trace header.
virtual void SoVRSegyFileReader::getSubSlice | ( | const SbBox2i32 & | subSlice, | |
int | sliceNumber, | |||
void * | data | |||
) | [virtual] |
New method required by VolumeViz 3.0 when using large volume support.
Must copy a rectangular part of an XY slice to the memory specified by data. Slices will not always be read sequentially.
Implements SoVolumeReader.
bool SoVRSegyFileReader::getTraceCoord | ( | const int | i, | |
const int | j, | |||
SbVec2d & | P | |||
) |
virtual SoType SoVRSegyFileReader::getTypeId | ( | ) | const [virtual] |
Returns the type identifier for this specific instance.
Reimplemented from SoVolumeReader.
virtual void SoVRSegyFileReader::getZRange | ( | int & | from, | |
int & | to, | |||
int & | step | |||
) | [virtual] |
Gets the Z (time axis range.
This method returns the actual values from the file if the corresponding set method has not been called previously. Otherwise, the values previously specified with setZRange are returned.
virtual SbBool SoVRSegyFileReader::isSegyRegular | ( | ) | [virtual] |
Sets the trace header of a specific trace used to read the SEGY file [OPTIONAL].
Indicates if SEGY file is regular. A file with the same number of traces in each inline and with the same number of samples for each trace is considered as regular.
virtual void SoVRSegyFileReader::setCrosslineRange | ( | int | from, | |
int | to, | |||
int | step | |||
) | [virtual] |
Sets the crossline range.
Note that this setting does not limit the amount of data read from the file (although a subclass could do that). It just specifies the range values that will be returned by getCrosslineRange().
Sets whether or not the reader should automatically try to detect if the coordinate system used is direct (right-handed) or not.
Default is FALSE.
Reimplemented from SoVolumeReader.
Specifies if the coordinate system used is direct (right-handed) or not.
Default is TRUE. If the coordinate system is direct, then samples are stored in increasing order along the positive X axis, traces are stored in increasing order along the positive Y axis, and lines are stored in increasing order along the positive Z axis. If the coordinate system in indirect, everything is the same except that lines are stored in decreasing order along the positive Z axis. NOTE: If you pass the value returned by getP1P2P3Coordinates(), the resulting LDM file will be always right handed.
Reimplemented from SoVolumeReader.
virtual int SoVRSegyFileReader::setFilename | ( | const SbString & | filename | ) | [virtual] |
Specifies the path of the file.
Returns 0 for success. Any other return value indicates failure.
Reimplemented from SoVolumeReader.
virtual void SoVRSegyFileReader::setInlineRange | ( | int | from, | |
int | to, | |||
int | step | |||
) | [virtual] |
Sets the inline range.
Note that this setting does not limit the amount of data read from the file (although a subclass could do that). It just specifies the range values that will be returned by getInlineRange().
virtual SbBool SoVRSegyFileReader::setInputDataRange | ( | SbBool | doChange, | |
double | min, | |||
double | max | |||
) | [virtual] |
Requests that the input be converted from the specified range to the range depending on the output data type.
This allows, for instance, if the output data type is unsigned byte, conversion of float data from range [min,max] to range [0,255]. If doChange is FALSE no range conversion is applied. Always returns TRUE.
Reimplemented from SoVolumeReader.
virtual SbBool SoVRSegyFileReader::setOutputDataType | ( | SbBool | doChange, | |
SoDataSet::DataType | type | |||
) | [virtual] |
Requests that the input be converted (if necessary) to the specified data type.
This allows, for instance, conversion of float data to unsigned byte. If doChange is FALSE no type conversion is applied. Always returns TRUE.
Reimplemented from SoVolumeReader.
void SoVRSegyFileReader::setScanningProgressCallback | ( | SoSegyScanningCB * | func, | |
void * | data | |||
) |
Sets a progress callback when the SEGY file is scanned.
The SEGY file is scanned when:
virtual void SoVRSegyFileReader::setSegyAxisOrder | ( | SegyAxisOrder | axisOrder | ) | [virtual] |
Sets the storage order for X, Y, and Z axes.
For example, XYZ_AS_INLINE_CROSSLINE_SAMPLE means lines along X, crosslines along Y, and samples along Z axis.
The default value is XYZ_AS_SAMPLE_INLINE_CROSSLINE, meaning samples along X, lines along Y, and crosslines along Z axis.
Note: You must call this method before:
(Because the last two operations indirectly cause getDataChar() to be called.)
virtual void SoVRSegyFileReader::setSegyByteOrder | ( | SegyByteOrder | byteOrder | ) | [virtual] |
Sets the byte ordering to use when reading the SEGY file.
The default value is SEGY_LITTLE_ENDIAN. In most cases, even when the SEGY file is big endian, the SEGY file reader is able to detect this and read the file accordingly. This method is for the very rare case when the automatic byte order detection fails.
virtual SbBool SoVRSegyFileReader::setSegyFileHeader | ( | const SoVRSegyFileHeader & | fileHeader | ) | [virtual] |
Specifies the header used to read the SEGY file.
If this method is called, the reader uses the binary file header you pass rather than the actual binary file header. The following fields from the binary file header are used:
Returns FALSE if the operation fails, for example, if SoVolumeReader::setFilename() was not called first.
virtual void SoVRSegyFileReader::setSegyTextHeaderAscii | ( | bool | ascii | ) | [virtual] |
Tells whether the textual header format is ASCII or not.
The default value is false, i.e., the textual header format is EBCDIC
virtual void SoVRSegyFileReader::setSegyTraceHeaderBytePosition | ( | const SoVRSegyTraceHeaderBytePosition & | traceHeaderBytePosition | ) | [virtual] |
Tells the file reader where the fields are actually located (i.e., the byte positions) within the trace header.
Only the field SEGY_CDP is used (Xline position).
static void SoVRSegyFileReader::setVolumeSizeVoxels | ( | SbBool | flag | ) | [static] |
If TRUE, the volume extent (bounds in world coordinates) is set to 0 to dimension-1 on each axis.
Else the volume extent is normalized to fit inside a unit cube centered at the origin. In other words, the size will be -.5 to +.5 along the longest dimension. FALSE by default. The application can also set the volume extent to whatever is appropriate by setting the SoVolumeData node's extent field.
virtual void SoVRSegyFileReader::setZRange | ( | int | from, | |
int | to, | |||
int | step | |||
) | [virtual] |
Sets the Z (time axis) range.
Note that this setting does not limit the amount of data read from the file (although a subclass could do that). It just specifies the range values that will be returned by getZRange().