00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _SO_VR_SEGY_FILE_READER_
00024 #define _SO_VR_SEGY_FILE_READER_
00025
00026 #include <LDM/readers/SoVolumeReader.h>
00027 #include <VolumeViz/readers/SoVRSegyReader.h>
00028 #include <Inventor/STL/vector>
00029 #include <VolumeViz/nodes/SoVolumeData.h>
00030
00031 #ifdef _WIN32
00032 #pragma warning( push )
00033 #pragma warning(disable:4251)
00034 #endif
00035
00123 class SoVRSegyFileReader : public SoVolumeReader
00124 {
00125 SO_FIELDCONTAINER_HEADER(SoVRSegyFileReader);
00126
00127 public:
00131 SoVRSegyFileReader();
00132
00139 virtual ReadError getDataChar( SbBox3f &size, SoDataSet::DataType &type, SbVec3i32 &dim );
00140
00147 virtual void getSubSlice( const SbBox2i32& subSlice, int sliceNumber, void * data );
00148
00154 virtual SbBool setDirectCoordSysAutoDetection(SbBool autoValue);
00155
00163 static void setVolumeSizeVoxels(SbBool flag);
00164
00168 virtual ReaderType getReaderType ()
00169 {return SEGY;};
00170
00171
00174
00175
00176
00181 virtual int setFilename( const SbString& filename );
00182
00184 enum SegyScanningResp {
00185 SCAN_CONTINUE,
00186 SCAN_ABORT
00187 };
00188
00192 typedef SegyScanningResp SoSegyScanningCB( void *data, float percent, SoVRSegyFileReader *reader );
00193
00202 void setScanningProgressCallback( SoSegyScanningCB *func, void *data );
00203
00206
00207
00208
00213 virtual void setSegyTextHeaderAscii( bool ascii );
00214
00218 virtual SbString getSegyTextHeader();
00219
00222
00223
00224
00226 enum SegyByteOrder {
00228 SEGY_LITTLE_ENDIAN,
00230 SEGY_BIG_ENDIAN
00231 };
00240 virtual void setSegyByteOrder( SegyByteOrder byteOrder );
00244 virtual SegyByteOrder getSegyByteOrder();
00245
00259 virtual SbBool setSegyFileHeader( const SoVRSegyFileHeader &fileHeader );
00260
00272 virtual SbBool getSegyFileHeader( SoVRSegyFileHeader& fileHeader, bool readFile = false );
00273
00276
00277
00278
00283 virtual void setSegyTraceHeaderBytePosition( const SoVRSegyTraceHeaderBytePosition &traceHeaderBytePosition );
00287 virtual SoVRSegyTraceHeaderBytePosition getSegyTraceHeaderBytePosition();
00288
00295 virtual int getNumTraces();
00296
00305 virtual SbBool getSegyTraceHeader( int traceNumber, SoVRSegyTraceIdHeader& traceHeader );
00306
00310
00311
00312
00315
00316
00317
00323 virtual SbBool isSegyRegular();
00324
00331 virtual void setCrosslineRange( int from, int to, int step );
00338 virtual void setInlineRange( int from, int to, int step );
00345 virtual void setZRange( int from, int to, int step );
00352 virtual void getCrosslineRange( int &from, int &to, int &step );
00361 virtual void getInlineRange( int &from, int &to, int &step );
00368 virtual void getZRange( int &from, int &to, int &step );
00369
00372
00373
00374
00382 virtual SbBool getP1P2P3Coordinates( SbVec2d &P1, SbVec2d &P2, SbVec2d &P3, SbVec2d &P4 );
00383
00394 virtual SbBool setDirectCoorSys( SbBool directCoord );
00395
00397 enum SegyAxisOrder {
00399 XYZ_AS_SAMPLE_INLINE_CROSSLINE,
00401 XYZ_AS_INLINE_CROSSLINE_SAMPLE
00402 };
00403
00418 virtual void setSegyAxisOrder( SegyAxisOrder axisOrder );
00419
00424 virtual SegyAxisOrder getSegyAxisOrder();
00425
00428
00429
00430
00448 virtual int getSegyTraceData( int traceNumber, void* &traceData, int start = 0, int size = -1 );
00449
00450
00451
00452
00453 bool getTraceCoord(const int i, const int j, SbVec2d & P );
00454
00457
00458
00459
00466 virtual SbBool setOutputDataType( SbBool doChange, SoDataSet::DataType type );
00467
00476 virtual SbBool setInputDataRange( SbBool doChange, double min, double max );
00477
00478
00479
00482
00483 private:
00484
00485
00486
00487
00488 static void ibm2ieee( int numValues, void* ibm2ieeeBuffer );
00489
00490 #if 1 SoDEPRECATED
00493 virtual SbBool setOutputDataRange( SbBool doChange, double min, double max )
00494 {
00495 return setInputDataRange( doChange, min, max );
00496 };
00497 SoDEPRECATED
00499 void getDataChar( SbBox3f &size, SoDataSet::DataType &type, SbVec3s &dim )
00500 {
00501 SbVec3i32 dimI32;
00502 getDataChar( size, type, dimI32 );
00503 dim.setValue( (short)dimI32[0], (short)dimI32[1], (short)dimI32[2] );
00504 };
00505 SoDEPRECATED
00507 virtual void getSubSlice( const SbBox2s& subSlice, int sliceNumber, void * data )
00508 {
00509 SbBox2i32 subSliceI32( subSlice.getMin()[0], subSlice.getMin()[1], subSlice.getMax()[0], subSlice.getMax()[1] );
00510 getSubSlice( subSliceI32, sliceNumber, data );
00511 };
00512
00513 #endif
00515 private:
00516
00517 SoSegyScanningCB *m_scanningCBfunc;
00518 void *m_scanningCBdata;
00519
00520
00521 bool m_textHeaderAscii;
00522
00523
00524 SegyByteOrder m_byteOrder;
00525 bool m_byteOrderSet;
00526 bool m_swapBytes;
00527 bool m_swapBytesData;
00528 SoVRSegyFileHeader m_binHeader;
00529 bool m_binHeaderSet;
00530
00531
00532 SoVRSegyTraceHeaderBytePosition m_trHdrBytePos;
00533 bool m_trHdrBytePosSet;
00534
00535
00536 bool m_crosslineRangeSet;
00537 int m_crosslineFrom, m_crosslineTo, m_crosslineStep;
00538 bool m_inlineRangeSet;
00539 int m_inlineFrom, m_inlineTo, m_inlineStep;
00540 bool m_zRangeSet;
00541 int m_zFrom, m_zTo, m_zStep;
00542
00543
00544 SegyAxisOrder m_axisOrder;
00545
00546
00547 bool m_changeFormat;
00548 SoDataSet::DataType m_typeOut;
00549 bool m_dataRangeSet;
00550 double m_dataRangeMin, m_dataRangeMax;
00551
00552
00553 SoVolumeReader::ReadError getDataChar1();
00554 bool m_dataChar1;
00555 SoVRSegyFileHeader m_wkHeader;
00556 int m_headerSize;
00557 int m_format;
00558 SbString m_typeStr;
00559 SoDataSet::DataType m_type;
00560 int m_bytesPerVoxel;
00561 bool m_constantTraceLength;
00562 unsigned int m_numSamplesPerTrace;
00563 unsigned int m_numTracesPerLine;
00564 unsigned int m_numLines;
00565 int64_t m_numTraces;
00566
00567
00568 SoVolumeReader::ReadError getDataChar2(int t = -1);
00569 bool m_dataChar2;
00570 std::vector<int64_t> m_traceOffset;
00571 std::vector<int> m_traceLength;
00572
00573
00574 SbVec3i32 m_dim;
00575
00576
00577 SoVolumeReader::ReadError getDataChar3();
00578 bool m_dataChar3;
00579 bool m_regularTraceNum;
00580
00581
00582
00583 std::vector<int> m_lineTraceStart;
00584 std::vector<int> m_lineTraceMin;
00585 std::vector<int> m_lineTraceMax;
00586
00587 private:
00588 using SoVolumeReader::getDataChar;
00589 using SoVolumeReader::getSubSlice;
00590
00591
00592
00593 SbBool m_floatIsIEEE;
00594 static bool m_isVolumeSizeVoxels ;
00595
00596 int getTraceNum( const int, const int );
00597 void resetObject();
00598 bool searchForPoint( const int which, int & i, int & j, SbVec2d & P );
00599 void extrapolatePoint( SbVec2d & P0, int & i0, int & j0,
00600 const SbVec2d & Px, int ix, int jx,
00601 const SbVec2d & Py, int iy, int jy,
00602 int newi0, int newj0 );
00603 float evaluateValuesValidity( const int num_values, const float *values );
00604 float evaluateValuesCorrelation( const int trace, const int format1, const bool swap1, const int format2, const bool swap2 );
00605
00606 };
00607
00608 #ifdef _WIN32
00609 #pragma warning( pop )
00610 #endif
00611
00612 #endif // _SO_VR_SEGY_FILE_READER_
00613
00614
00615