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
00151 class SoVRSegyFileReader : public SoVolumeReader
00152 {
00153 SO_FIELDCONTAINER_HEADER(SoVRSegyFileReader);
00154
00155 public:
00159 SoVRSegyFileReader();
00160
00167 virtual ReadError getDataChar( SbBox3f &size, SoDataSet::DataType &type, SbVec3i32 &dim );
00168
00175 virtual void getSubSlice( const SbBox2i32& subSlice, int sliceNumber, void * data );
00176
00182 virtual SbBool setDirectCoordSysAutoDetection(SbBool autoValue);
00183
00191 static void setVolumeSizeVoxels(SbBool flag);
00192
00196 virtual SoVolumeReader::ReaderType getReaderType ()
00197 {return SEGY;};
00198
00199
00202
00203
00204
00209 virtual int setFilename( const SbString& filename );
00210
00212 enum SegyScanningResp {
00213 SCAN_CONTINUE,
00214 SCAN_ABORT
00215 };
00216
00220 typedef SegyScanningResp SoSegyScanningCB( void *data, float percent, SoVRSegyFileReader *reader );
00221
00230 void setScanningProgressCallback( SoSegyScanningCB *func, void *data );
00231
00234
00235
00236
00241 virtual void setSegyTextHeaderAscii( bool ascii );
00242
00246 virtual SbString getSegyTextHeader();
00247
00250
00251
00252
00254 enum SegyByteOrder {
00256 SEGY_LITTLE_ENDIAN,
00258 SEGY_BIG_ENDIAN
00259 };
00268 virtual void setSegyByteOrder( SegyByteOrder byteOrder );
00272 virtual SegyByteOrder getSegyByteOrder();
00273
00287 virtual SbBool setSegyFileHeader( const SoVRSegyFileHeader &fileHeader );
00288
00300 virtual SbBool getSegyFileHeader( SoVRSegyFileHeader& fileHeader, bool readFile = false );
00301
00304
00305
00306
00311 virtual void setSegyTraceHeaderBytePosition( const SoVRSegyTraceHeaderBytePosition &traceHeaderBytePosition );
00315 virtual SoVRSegyTraceHeaderBytePosition getSegyTraceHeaderBytePosition();
00316
00323 virtual int getNumTraces();
00324
00333 virtual SbBool getSegyTraceHeader( int traceNumber, SoVRSegyTraceIdHeader& traceHeader );
00334
00338
00339
00340
00343
00344
00345
00351 virtual SbBool isSegyRegular();
00352
00359 virtual void setCrosslineRange( int from, int to, int step );
00366 virtual void setInlineRange( int from, int to, int step );
00373 virtual void setZRange( int from, int to, int step );
00380 virtual void getCrosslineRange( int &from, int &to, int &step );
00389 virtual void getInlineRange( int &from, int &to, int &step );
00396 virtual void getZRange( int &from, int &to, int &step );
00397
00400
00401
00402
00410 virtual SbBool getP1P2P3Coordinates( SbVec2d &P1, SbVec2d &P2, SbVec2d &P3, SbVec2d &P4 );
00411
00422 virtual SbBool setDirectCoorSys( SbBool directCoord );
00423
00425 enum SegyAxisOrder {
00427 XYZ_AS_SAMPLE_INLINE_CROSSLINE,
00429 XYZ_AS_INLINE_CROSSLINE_SAMPLE
00430 };
00431
00446 virtual void setSegyAxisOrder( SegyAxisOrder axisOrder );
00447
00452 virtual SegyAxisOrder getSegyAxisOrder();
00453
00456
00457
00458
00476 virtual int getSegyTraceData( int traceNumber, void* &traceData, int start = 0, int size = -1 );
00477
00478
00479
00480
00481 bool getTraceCoord(const int i, const int j, SbVec2d & P );
00482
00485
00486
00487
00494 virtual SbBool setOutputDataType( SbBool doChange, SoDataSet::DataType type );
00495
00504 virtual SbBool setInputDataRange( SbBool doChange, double min, double max );
00505
00506
00507
00510
00511 private:
00512
00513
00514
00515
00516 static void ibm2ieee( int numValues, void* ibm2ieeeBuffer );
00517
00518 private:
00519
00520 SoSegyScanningCB *m_scanningCBfunc;
00521 void *m_scanningCBdata;
00522
00523
00524 bool m_textHeaderAscii;
00525
00526
00527 SegyByteOrder m_byteOrder;
00528 bool m_byteOrderSet;
00529 bool m_swapBytes;
00530 bool m_swapBytesData;
00531 SoVRSegyFileHeader m_binHeader;
00532 bool m_binHeaderSet;
00533
00534
00535 SoVRSegyTraceHeaderBytePosition m_trHdrBytePos;
00536 bool m_trHdrBytePosSet;
00537
00538
00539 bool m_crosslineRangeSet;
00540 int m_crosslineFrom, m_crosslineTo, m_crosslineStep;
00541 bool m_inlineRangeSet;
00542 int m_inlineFrom, m_inlineTo, m_inlineStep;
00543 bool m_zRangeSet;
00544 int m_zFrom, m_zTo, m_zStep;
00545
00546
00547 SegyAxisOrder m_axisOrder;
00548
00549
00550 bool m_changeFormat;
00551 SoDataSet::DataType m_typeOut;
00552 bool m_dataRangeSet;
00553 double m_dataRangeMin, m_dataRangeMax;
00554
00555
00556 SoVolumeReader::ReadError getDataChar1();
00557 bool m_dataChar1;
00558 SoVRSegyFileHeader m_wkHeader;
00559 int m_headerSize;
00560 int m_format;
00561 SbString m_typeStr;
00562 SoDataSet::DataType m_type;
00563 bool m_constantTraceLength;
00564 unsigned int m_numSamplesPerTrace;
00565 unsigned int m_numTracesPerLine;
00566 unsigned int m_numLines;
00567 int64_t m_numTraces;
00568
00569
00570 SoVolumeReader::ReadError getDataChar2(int t = -1);
00571 bool m_dataChar2;
00572 std::vector<int64_t> m_traceOffset;
00573 std::vector<int> m_traceLength;
00574
00575
00576 SbVec3i32 m_dim;
00577
00578
00579 SoVolumeReader::ReadError getDataChar3();
00580 bool m_dataChar3;
00581 bool m_regularTraceNum;
00582
00583
00584
00585 std::vector<int> m_lineTraceStart;
00586 std::vector<int> m_lineTraceMin;
00587 std::vector<int> m_lineTraceMax;
00588
00589 private:
00590 using SoVolumeReader::getDataChar;
00591 using SoVolumeReader::getSubSlice;
00592
00593
00594
00595 SbBool m_floatIsIEEE;
00596 static bool m_isVolumeSizeVoxels ;
00597
00598 int getTraceNum( const int, const int );
00599 void resetObject();
00600 bool searchForPoint( const int which, int & i, int & j, SbVec2d & P );
00601 void extrapolatePoint( SbVec2d & P0, int & i0, int & j0,
00602 const SbVec2d & Px, int ix, int jx,
00603 const SbVec2d & Py, int iy, int jy,
00604 int newi0, int newj0 );
00605 float evaluateValuesValidity( const int num_values, const float *values );
00606 float evaluateValuesCorrelation( const int trace, const int format1, const bool swap1, const int format2, const bool swap2 );
00607
00608 };
00609
00610 #ifdef _WIN32
00611 #pragma warning( pop )
00612 #endif
00613
00614 #endif // _SO_VR_SEGY_FILE_READER_
00615
00616
00617