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_DICOM_FILE_READER_
00024 #define _SO_VR_DICOM_FILE_READER_
00025
00026 #ifdef _WIN32
00027 #pragma warning( push )
00028 #pragma warning(disable:4251)
00029 #endif
00030
00031 #include <LDM/readers/SoVolumeReader.h>
00032 #include <VolumeViz/readers/SoVRDicomData.h>
00033 #include <VolumeViz/nodes/SoVolumeData.h>
00034
00035 class SiDicomSliceVector;
00036 class SoDicomSliceCache;
00037
00196 class SoVRDicomFileReader : public SoVolumeReader
00197 {
00198
00199 SO_FIELDCONTAINER_HEADER(SoVRDicomFileReader);
00200
00201 public:
00203 SoVRDicomFileReader ();
00204
00218 virtual int setFilename( const SbString& filename );
00219
00227 int setFilenamePattern( const SbString& pattern );
00228
00241 int setFilenameList(const SbStringList& filenameList);
00242
00258 SbBool setFilenameList(const SbString& format, const int startIndex = 0, const int endIndex = INT_MAX, const int indexStep = 1);
00259
00267 bool setFilenameListFromSeries( const SbString& base );
00268
00282 SbBool setDirectory(const SbString& folder);
00283
00290 virtual ReadError getDataChar (SbBox3f &size, SoDataSet::DataType &type, SbVec3i32 &dim);
00291
00298 virtual SbBool setOutputDataType( SbBool doChange, SoDataSet::DataType type );
00299
00300
00306 virtual void getSubSlice (const SbBox2i32 &subSlice, int sliceNumber, void *data);
00307
00315 int getNumSignificantBits();
00316
00320 virtual ReaderType getReaderType ()
00321 {return DICOM;}
00322
00334 const SoVRDicomData& getDicomData() const;
00335
00343 const SiDicomDataSet* getDicomDataSet( const size_t sliceIdx ) const;
00344
00350 void loadSliceDicomData( int slice, SoVRDicomData& dicomData ) const;
00351
00353 virtual SbBool isThreadSafe() const;
00354
00360 virtual void closeAllHandles();
00361
00367 virtual void restoreAllHandles();
00368
00369 private:
00370
00372 virtual ~SoVRDicomFileReader ();
00373
00374 private:
00375
00376 void release();
00377 int extractFileList (const SbString& headFile);
00378 SbBool isSupported ();
00379 SbBool accept (const SbString& fileName, SoVRDicomData &dicomData);
00380 void adjustHighBit( void* buffer, int highBit, int numElements );
00381 void adjustDataRange( void* buffer, int numElements, float rescaleSlope, float rescaleIntercept ) const;
00382 void extractSlices (SoVRDicomData &dicomData, int fileNumber, int &begin);
00383
00384 bool loadSliceInfo();
00385
00386
00387 private:
00388
00389 bool m_isInitialized;
00390 bool m_hasImage;
00391
00392 SbBox3f m_size;
00393 SbVec3i32 m_dim;
00394 SbDataType m_type;
00395
00396 int m_sizeInBytes;
00397 int m_bytesPerVoxel;
00398 int m_bitsStored;
00399 SbBool m_dataSigned;
00400 int m_highBit;
00401 std::vector<SbString> m_fileList;
00402
00403 SoVRDicomData m_dicomDataRef;
00404 SiDicomSliceVector* m_slices;
00405
00406 SoDicomSliceCache* m_cache;
00407
00408 bool m_changeFormat;
00409 SbDataType m_typeOut;
00410
00415 static std::vector<SbString> s_extensions;
00416 };
00417
00418 #ifdef _WIN32
00419 #pragma warning( pop )
00420 #endif
00421
00422 #endif
00423
00424
00425