From: regrain Date: Fri, 10 Dec 2004 13:49:05 +0000 (+0000) Subject: * src/gdcmFile.[h|cxx], gdcmPixelReadConvert.[h|cxx] : change the API. X-Git-Tag: Version1.0.bp~512 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=922095a0dd56f24d651b36f62256690020937d9a;p=gdcm.git * src/gdcmFile.[h|cxx], gdcmPixelReadConvert.[h|cxx] : change the API. Rename Decompressed to Raw * Use the API changes in gdcm::File. * vtk/vtkGdcmWriter.[h|cxx] : add the possibility to write in other modes Memory leaks fixed -- BeNours --- diff --git a/ChangeLog b/ChangeLog index 1e2662ac..73d5112a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2004-12-10 Benoit Regrain + * src/gdcmFile.[h|cxx], gdcmPixelReadConvert.[h|cxx] : change the API. + Rename Decompressed to Raw + * Use the API changes in gdcm::File. + * vtk/vtkGdcmWriter.[h|cxx] : add the possibility to write in other modes + Memory leaks fixed + 2004-12-10 Benoit Regrain * vtk/vtkGdcmWriter.cxx, Example/WriteDicomSimple.cxx : add comments for each added entry in the header. Replace the 'Planes' field by the 'Number diff --git a/Example/WriteDicomSimple.cxx b/Example/WriteDicomSimple.cxx index 8ffbade3..f426800e 100644 --- a/Example/WriteDicomSimple.cxx +++ b/Example/WriteDicomSimple.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: WriteDicomSimple.cxx,v $ Language: C++ - Date: $Date: 2004/12/10 08:34:07 $ - Version: $Revision: 1.2 $ + Date: $Date: 2004/12/10 13:49:06 $ + Version: $Revision: 1.3 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -130,7 +130,7 @@ int main(int argc, char* argv[]) std::string fileName = argv[1]; std::string mode = argv[2]; - file->SetWriteModeToDecompressed(); + file->SetWriteModeToRaw(); switch (mode[0]) { case 'a' : // Write an ACR file diff --git a/Testing/TestAllEntryVerify.cxx b/Testing/TestAllEntryVerify.cxx index 3eacef55..ee2420f1 100644 --- a/Testing/TestAllEntryVerify.cxx +++ b/Testing/TestAllEntryVerify.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestAllEntryVerify.cxx,v $ Language: C++ - Date: $Date: 2004/12/04 08:57:20 $ - Version: $Revision: 1.16 $ + Date: $Date: 2004/12/10 13:49:06 $ + Version: $Revision: 1.17 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -669,7 +669,7 @@ int TestAllEntryVerify(int argc, char* argv[]) } Parser.SetDataPath(referenceDir); // Parser.Print(); - std::cout << "Reference fil loaded -->\n" + std::cout << "Reference file loaded -->\n" << "Check files : \n"; int ret; diff --git a/src/gdcmDocument.cxx b/src/gdcmDocument.cxx index 62d542d2..e5e627e4 100644 --- a/src/gdcmDocument.cxx +++ b/src/gdcmDocument.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocument.cxx,v $ Language: C++ - Date: $Date: 2004/12/07 13:39:33 $ - Version: $Revision: 1.149 $ + Date: $Date: 2004/12/10 13:49:07 $ + Version: $Revision: 1.150 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -2639,7 +2639,6 @@ void Document::HandleBrokenEndian(uint16_t group, uint16_t elem) reversedEndian--; SwitchSwapToBigEndian(); } - } /** diff --git a/src/gdcmFile.cxx b/src/gdcmFile.cxx index 03df5b70..9974b256 100644 --- a/src/gdcmFile.cxx +++ b/src/gdcmFile.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmFile.cxx,v $ Language: C++ - Date: $Date: 2004/12/07 17:28:50 $ - Version: $Revision: 1.174 $ + Date: $Date: 2004/12/10 13:49:07 $ + Version: $Revision: 1.175 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -96,24 +96,6 @@ File::File(std::string const & filename ) Initialise(); } -/** - * \brief Factorization for various forms of constructors. - */ -void File::Initialise() -{ - WriteMode = WMODE_DECOMPRESSED; - WriteType = ExplicitVR; - - PixelReadConverter = new PixelReadConvert; - PixelWriteConverter = new PixelWriteConvert; - Archive = new DocEntryArchive( HeaderInternal ); - - if ( HeaderInternal->IsReadable() ) - { - PixelReadConverter->GrabInformationsFromHeader( HeaderInternal ); - } -} - /** * \brief canonical destructor * \note If the Header was created by the File constructor, @@ -155,6 +137,11 @@ File::~File() */ size_t File::GetImageDataSize() { + if ( PixelWriteConverter->GetUserData() ) + { + return PixelWriteConverter->GetUserDataSize(); + } + return PixelReadConverter->GetRGBSize(); } @@ -167,7 +154,12 @@ size_t File::GetImageDataSize() */ size_t File::GetImageDataRawSize() { - return PixelReadConverter->GetDecompressedSize(); + if ( PixelWriteConverter->GetUserData() ) + { + return PixelWriteConverter->GetUserDataSize(); + } + + return PixelReadConverter->GetRawSize(); } /** @@ -182,7 +174,12 @@ size_t File::GetImageDataRawSize() */ uint8_t* File::GetImageData() { - if ( ! GetDecompressed() ) + if ( PixelWriteConverter->GetUserData() ) + { + return PixelWriteConverter->GetUserData(); + } + + if ( ! GetRaw() ) { // If the decompression failed nothing can be done. return 0; @@ -194,11 +191,25 @@ uint8_t* File::GetImageData() } else { - // When no LUT or LUT conversion fails, return the decompressed - return PixelReadConverter->GetDecompressed(); + // When no LUT or LUT conversion fails, return the Raw + return PixelReadConverter->GetRaw(); } } +/** + * \brief Allocates necessary memory, + * Transforms YBR pixels (if any) into RGB pixels + * Transforms 3 planes R, G, B (if any) into a single RGB Plane + * Copies the pixel data (image[s]/volume[s]) to newly allocated zone. + * DOES NOT transform Grey plane + 3 Palettes into a RGB Plane + * @return Pointer to newly allocated pixel data. + * \ NULL if alloc fails + */ +uint8_t* File::GetImageDataRaw () +{ + return GetRaw(); +} + /** * \brief * Read the pixels from disk (uncompress if necessary), @@ -226,7 +237,7 @@ uint8_t* File::GetImageData() */ size_t File::GetImageDataIntoVector (void* destination, size_t maxSize) { - if ( ! GetDecompressed() ) + if ( ! GetRaw() ) { // If the decompression failed nothing can be done. return 0; @@ -247,53 +258,16 @@ size_t File::GetImageDataIntoVector (void* destination, size_t maxSize) } // Either no LUT conversion necessary or LUT conversion failed - if ( PixelReadConverter->GetDecompressedSize() > maxSize ) + if ( PixelReadConverter->GetRawSize() > maxSize ) { dbg.Verbose(0, "File::GetImageDataIntoVector: pixel data bigger" "than caller's expected MaxSize"); return 0; } memcpy( destination, - (void*)PixelReadConverter->GetDecompressed(), - PixelReadConverter->GetDecompressedSize() ); - return PixelReadConverter->GetDecompressedSize(); -} - -/** - * \brief Allocates necessary memory, - * Transforms YBR pixels (if any) into RGB pixels - * Transforms 3 planes R, G, B (if any) into a single RGB Plane - * Copies the pixel data (image[s]/volume[s]) to newly allocated zone. - * DOES NOT transform Grey plane + 3 Palettes into a RGB Plane - * @return Pointer to newly allocated pixel data. - * \ NULL if alloc fails - */ -uint8_t* File::GetImageDataRaw () -{ - return GetDecompressed(); -} - -uint8_t* File::GetDecompressed() -{ - uint8_t* decompressed = PixelReadConverter->GetDecompressed(); - if ( ! decompressed ) - { - // The decompressed image migth not be loaded yet: - std::ifstream* fp = HeaderInternal->OpenFile(); - PixelReadConverter->ReadAndDecompressPixelData( fp ); - if(fp) - HeaderInternal->CloseFile(); - - decompressed = PixelReadConverter->GetDecompressed(); - if ( ! decompressed ) - { - dbg.Verbose(0, "File::GetDecompressed: read/decompress of " - "pixel data apparently went wrong."); - return 0; - } - } - - return decompressed; + (void*)PixelReadConverter->GetRaw(), + PixelReadConverter->GetRawSize() ); + return PixelReadConverter->GetRawSize(); } /** @@ -309,11 +283,72 @@ uint8_t* File::GetDecompressed() * * @return boolean */ -bool File::SetImageData(uint8_t* inData, size_t expectedSize) +void File::SetImageData(uint8_t* inData, size_t expectedSize) { - PixelWriteConverter->SetUserData(inData,expectedSize); + SetUserData(inData,expectedSize); +} - return true; +/** + * \brief Set the image datas defined by the user + * \warning When writting the file, this datas are get as default datas to write + */ +void File::SetUserData(uint8_t* data, size_t expectedSize) +{ + PixelWriteConverter->SetUserData(data,expectedSize); +} + +/** + * \brief Get the image datas defined by the user + * \warning When writting the file, this datas are get as default datas to write + */ +uint8_t* File::GetUserData() +{ + return PixelWriteConverter->GetUserData(); +} + +/** + * \brief Get the image data size defined by the user + * \warning When writting the file, this datas are get as default datas to write + */ +size_t File::GetUserDataSize() +{ + return PixelWriteConverter->GetUserDataSize(); +} + +/** + * \brief Get the image datas from the file. + * If a LUT is found, the datas are expanded to be RGB + */ +uint8_t* File::GetRGBData() +{ + return PixelReadConverter->GetRGB(); +} + +/** + * \brief Get the image data size from the file. + * If a LUT is found, the datas are expanded to be RGB + */ +size_t File::GetRGBDataSize() +{ + return PixelReadConverter->GetRGBSize(); +} + +/** + * \brief Get the image datas from the file. + * If a LUT is found, the datas are not expanded ! + */ +uint8_t* File::GetRawData() +{ + return PixelReadConverter->GetRaw(); +} + +/** + * \brief Get the image data size from the file. + * If a LUT is found, the datas are not expanded ! + */ +size_t File::GetRawDataSize() +{ + return PixelReadConverter->GetRawSize(); } /** @@ -338,8 +373,8 @@ bool File::WriteRawData(std::string const & fileName) fp1.write((char*)PixelWriteConverter->GetUserData(), PixelWriteConverter->GetUserDataSize()); else if(PixelReadConverter->GetRGB()) fp1.write((char*)PixelReadConverter->GetRGB(), PixelReadConverter->GetRGBSize()); - else if(PixelReadConverter->GetDecompressed()) - fp1.write((char*)PixelReadConverter->GetDecompressed(), PixelReadConverter->GetDecompressedSize()); + else if(PixelReadConverter->GetRaw()) + fp1.write((char*)PixelReadConverter->GetRaw(), PixelReadConverter->GetRawSize()); fp1.close(); @@ -474,8 +509,8 @@ bool File::WriteBase (std::string const & fileName) switch(WriteMode) { - case WMODE_DECOMPRESSED : - SetWriteToDecompressed(); + case WMODE_RAW : + SetWriteToRaw(); break; case WMODE_RGB : SetWriteToRGB(); @@ -531,17 +566,21 @@ bool File::CheckWriteIntegrity() switch(WriteMode) { - case WMODE_DECOMPRESSED : + case WMODE_RAW : if( decSize!=PixelWriteConverter->GetUserDataSize() ) { - dbg.Verbose(0, "File::CheckWriteIntegrity: Data size is incorrect"); + dbg.Verbose(0, "File::CheckWriteIntegrity: Data size is incorrect (Raw)"); + //std::cerr << "File::CheckWriteIntegrity: Data size is incorrect (Raw)\n" + // << decSize << " / " << PixelWriteConverter->GetUserDataSize() << "\n"; return false; } break; case WMODE_RGB : if( rgbSize!=PixelWriteConverter->GetUserDataSize() ) { - dbg.Verbose(0, "File::CheckWriteIntegrity: Data size is incorrect"); + dbg.Verbose(0, "File::CheckWriteIntegrity: Data size is incorrect (RGB)"); + //std::cerr << "File::CheckWriteIntegrity: Data size is incorrect (RGB)\n" + // << decSize << " / " << PixelWriteConverter->GetUserDataSize() << "\n"; return false; } break; @@ -551,7 +590,7 @@ bool File::CheckWriteIntegrity() return true; } -void File::SetWriteToDecompressed() +void File::SetWriteToRaw() { if(HeaderInternal->GetNumberOfScalarComponents()==3 && !HeaderInternal->HasLUT()) { @@ -569,8 +608,8 @@ void File::SetWriteToDecompressed() photInt->SetValue("MONOCHROME1 "); } - PixelWriteConverter->SetReadData(PixelReadConverter->GetDecompressed(), - PixelReadConverter->GetDecompressedSize()); + PixelWriteConverter->SetReadData(PixelReadConverter->GetRaw(), + PixelReadConverter->GetRawSize()); BinEntry* pixel = CopyBinEntry(GetHeader()->GetGrPixel(),GetHeader()->GetNumPixel()); pixel->SetValue(GDCM_BINLOADED); @@ -602,10 +641,10 @@ void File::SetWriteToRGB() PixelWriteConverter->SetReadData(PixelReadConverter->GetRGB(), PixelReadConverter->GetRGBSize()); } - else // Decompressed data + else // Raw data { - PixelWriteConverter->SetReadData(PixelReadConverter->GetDecompressed(), - PixelReadConverter->GetDecompressedSize()); + PixelWriteConverter->SetReadData(PixelReadConverter->GetRaw(), + PixelReadConverter->GetRawSize()); } BinEntry* pixel = CopyBinEntry(GetHeader()->GetGrPixel(),GetHeader()->GetNumPixel()); @@ -647,7 +686,7 @@ void File::SetWriteToRGB() } else { - SetWriteToDecompressed(); + SetWriteToRaw(); } } @@ -786,6 +825,49 @@ BinEntry* File::CopyBinEntry(uint16_t group,uint16_t element) return(newE); } +//----------------------------------------------------------------------------- +// Protected +/** + * \brief Factorization for various forms of constructors. + */ +void File::Initialise() +{ + WriteMode = WMODE_RAW; + WriteType = ExplicitVR; + + PixelReadConverter = new PixelReadConvert; + PixelWriteConverter = new PixelWriteConvert; + Archive = new DocEntryArchive( HeaderInternal ); + + if ( HeaderInternal->IsReadable() ) + { + PixelReadConverter->GrabInformationsFromHeader( HeaderInternal ); + } +} + +uint8_t* File::GetRaw() +{ + uint8_t* raw = PixelReadConverter->GetRaw(); + if ( ! raw ) + { + // The Raw image migth not be loaded yet: + std::ifstream* fp = HeaderInternal->OpenFile(); + PixelReadConverter->ReadAndDecompressPixelData( fp ); + if(fp) + HeaderInternal->CloseFile(); + + raw = PixelReadConverter->GetRaw(); + if ( ! raw ) + { + dbg.Verbose(0, "File::GetRaw: read/decompress of " + "pixel data apparently went wrong."); + return 0; + } + } + + return raw; +} + //----------------------------------------------------------------------------- // Private diff --git a/src/gdcmFile.h b/src/gdcmFile.h index 23f87ff6..2cfd69f7 100644 --- a/src/gdcmFile.h +++ b/src/gdcmFile.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmFile.h,v $ Language: C++ - Date: $Date: 2004/12/07 17:28:50 $ - Version: $Revision: 1.85 $ + Date: $Date: 2004/12/10 13:49:07 $ + Version: $Revision: 1.86 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -40,7 +40,7 @@ class GDCM_EXPORT File public: enum FileMode { - WMODE_DECOMPRESSED, + WMODE_RAW, WMODE_RGB }; @@ -61,7 +61,18 @@ public: uint8_t* GetImageDataRaw(); size_t GetImageDataIntoVector(void* destination, size_t maxSize); - bool SetImageData (uint8_t* data, size_t expectedSize); + void SetImageData(uint8_t* data, size_t expectedSize); + + // User datas + void SetUserData(uint8_t* data, size_t expectedSize); + uint8_t* GetUserData(); + size_t GetUserDataSize(); + // RBG datas (from file + uint8_t* GetRGBData(); + size_t GetRGBDataSize(); + // RAW datas (from file + uint8_t* GetRawData(); + size_t GetRawDataSize(); // Write pixels of ONE image on hard drive // No test is made on processor "endianity" @@ -84,7 +95,7 @@ public: uint8_t* GetLutRGBA(); // Write mode - void SetWriteModeToDecompressed() { SetWriteMode(WMODE_DECOMPRESSED); }; + void SetWriteModeToRaw() { SetWriteMode(WMODE_RAW); }; void SetWriteModeToRGB() { SetWriteMode(WMODE_RGB); }; void SetWriteMode(FileMode mode) { WriteMode = mode; }; FileMode GetWriteMode() { return WriteMode; }; @@ -101,7 +112,7 @@ protected: bool WriteBase(std::string const& fileName); bool CheckWriteIntegrity(); - void SetWriteToDecompressed(); + void SetWriteToRaw(); void SetWriteToRGB(); void RestoreWrite(); @@ -120,8 +131,7 @@ protected: private: void Initialise(); - uint8_t* GetDecompressed(); - int ComputeDecompressedPixelDataSizeFromHeader(); + uint8_t* GetRaw(); private: // members variables: diff --git a/src/gdcmHeader.cxx b/src/gdcmHeader.cxx index e15c9c28..f3201f45 100644 --- a/src/gdcmHeader.cxx +++ b/src/gdcmHeader.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmHeader.cxx,v $ Language: C++ - Date: $Date: 2004/12/07 17:28:50 $ - Version: $Revision: 1.214 $ + Date: $Date: 2004/12/10 13:49:07 $ + Version: $Revision: 1.215 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -106,7 +106,7 @@ bool Header::Write(std::string fileName,FileType filetype) { std::ofstream* fp = new std::ofstream(fileName.c_str(), std::ios::out | std::ios::binary); - if (fp == NULL) + if (*fp == NULL) { dbg.Verbose(2, "Failed to open (write) File: " , fileName.c_str()); return false; diff --git a/src/gdcmPixelReadConvert.cxx b/src/gdcmPixelReadConvert.cxx index 840465ab..79ab4e44 100644 --- a/src/gdcmPixelReadConvert.cxx +++ b/src/gdcmPixelReadConvert.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmPixelReadConvert.cxx,v $ Language: C++ - Date: $Date: 2004/12/09 10:11:38 $ - Version: $Revision: 1.4 $ + Date: $Date: 2004/12/10 13:49:07 $ + Version: $Revision: 1.5 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -57,8 +57,8 @@ PixelReadConvert::PixelReadConvert() { RGB = 0; RGBSize = 0; - Decompressed = 0; - DecompressedSize = 0; + Raw = 0; + RawSize = 0; LutRGBA = 0; LutRedData = 0; LutGreenData = 0; @@ -73,11 +73,11 @@ void PixelReadConvert::Squeeze() } RGB = 0; - if ( Decompressed ) + if ( Raw ) { - delete [] Decompressed; + delete [] Raw; } - Decompressed = 0; + Raw = 0; if ( LutRGBA ) { @@ -99,12 +99,12 @@ void PixelReadConvert::AllocateRGB() RGB = new uint8_t[ RGBSize ]; } -void PixelReadConvert::AllocateDecompressed() +void PixelReadConvert::AllocateRaw() { - if ( Decompressed ) { - delete [] Decompressed; + if ( Raw ) { + delete [] Raw; } - Decompressed = new uint8_t[ DecompressedSize ]; + Raw = new uint8_t[ RawSize ]; } /** @@ -115,7 +115,7 @@ void PixelReadConvert::ReadAndDecompress12BitsTo16Bits( std::ifstream* fp ) throw ( FormatError ) { int nbPixels = XSize * YSize; - uint16_t* localDecompres = (uint16_t*)Decompressed; + uint16_t* localDecompres = (uint16_t*)Raw; for( int p = 0; p < nbPixels; p += 2 ) { @@ -158,7 +158,7 @@ void PixelReadConvert::ReadAndDecompress12BitsTo16Bits( std::ifstream* fp ) /** * \brief Try to deal with RLE 16 Bits. * We assume the RLE has allready been parsed and loaded in - * Decompressed (through \ref ReadAndDecompressJPEGFile ). + * Raw (through \ref ReadAndDecompressJPEGFile ). * We here need to make 16 Bits Pixels from Low Byte and * High Byte 'Planes'...(for what it may mean) * @return Boolean @@ -166,18 +166,18 @@ void PixelReadConvert::ReadAndDecompress12BitsTo16Bits( std::ifstream* fp ) bool PixelReadConvert::DecompressRLE16BitsFromRLE8Bits( int NumberOfFrames ) { size_t PixelNumber = XSize * YSize; - size_t decompressedSize = XSize * YSize * NumberOfFrames; + size_t RawSize = XSize * YSize * NumberOfFrames; - // We assumed Decompressed contains the decoded RLE pixels but as + // We assumed Raw contains the decoded RLE pixels but as // 8 bits per pixel. In order to convert those pixels to 16 bits - // per pixel we cannot work in place within Decompressed and hence - // we copy it in a safe place, say copyDecompressed. + // per pixel we cannot work in place within Raw and hence + // we copy it in a safe place, say copyRaw. - uint8_t* copyDecompressed = new uint8_t[ decompressedSize * 2 ]; - memmove( copyDecompressed, Decompressed, decompressedSize * 2 ); + uint8_t* copyRaw = new uint8_t[ RawSize * 2 ]; + memmove( copyRaw, Raw, RawSize * 2 ); - uint8_t* x = Decompressed; - uint8_t* a = copyDecompressed; + uint8_t* x = Raw; + uint8_t* a = copyRaw; uint8_t* b = a + PixelNumber; for ( int i = 0; i < NumberOfFrames; i++ ) @@ -189,7 +189,7 @@ bool PixelReadConvert::DecompressRLE16BitsFromRLE8Bits( int NumberOfFrames ) } } - delete[] copyDecompressed; + delete[] copyRaw; /// \todo check that operator new []didn't fail, and sometimes return false return true; @@ -198,24 +198,24 @@ bool PixelReadConvert::DecompressRLE16BitsFromRLE8Bits( int NumberOfFrames ) /** * \brief Implementation of the RLE decoding algorithm for decompressing * a RLE fragment. [refer to PS 3.5-2003, section G.3.2 p 86] - * @param subDecompressed Sub region of \ref Decompressed where the de + * @param subRaw Sub region of \ref Raw where the de * decoded fragment should be placed. * @param fragmentSize The length of the binary fragment as found on the disk. - * @param decompressedSegmentSize The expected length of the fragment ONCE - * decompressed. + * @param RawSegmentSize The expected length of the fragment ONCE + * Raw. * @param fp File Pointer: on entry the position should be the one of * the fragment to be decoded. */ -bool PixelReadConvert::ReadAndDecompressRLEFragment( uint8_t* subDecompressed, +bool PixelReadConvert::ReadAndDecompressRLEFragment( uint8_t* subRaw, long fragmentSize, - long decompressedSegmentSize, + long RawSegmentSize, std::ifstream* fp ) { int8_t count; long numberOfOutputBytes = 0; long numberOfReadBytes = 0; - while( numberOfOutputBytes < decompressedSegmentSize ) + while( numberOfOutputBytes < RawSegmentSize ) { fp->read( (char*)&count, 1 ); numberOfReadBytes += 1; @@ -225,9 +225,9 @@ bool PixelReadConvert::ReadAndDecompressRLEFragment( uint8_t* subDecompressed, // signed integer of width N is 2^(N-1) - 1, which for int8_t // is 127]. { - fp->read( (char*)subDecompressed, count + 1); + fp->read( (char*)subRaw, count + 1); numberOfReadBytes += count + 1; - subDecompressed += count + 1; + subRaw += count + 1; numberOfOutputBytes += count + 1; } else @@ -239,9 +239,9 @@ bool PixelReadConvert::ReadAndDecompressRLEFragment( uint8_t* subDecompressed, numberOfReadBytes += 1; for( int i = 0; i < -count + 1; i++ ) { - subDecompressed[i] = newByte; + subRaw[i] = newByte; } - subDecompressed += -count + 1; + subRaw += -count + 1; numberOfOutputBytes += -count + 1; } } @@ -266,8 +266,8 @@ bool PixelReadConvert::ReadAndDecompressRLEFragment( uint8_t* subDecompressed, */ bool PixelReadConvert::ReadAndDecompressRLEFile( std::ifstream* fp ) { - uint8_t* subDecompressed = Decompressed; - long decompressedSegmentSize = XSize * YSize; + uint8_t* subRaw = Raw; + long RawSegmentSize = XSize * YSize; // Loop on the frame[s] for( RLEFramesInfo::RLEFrameList::iterator @@ -279,11 +279,11 @@ bool PixelReadConvert::ReadAndDecompressRLEFile( std::ifstream* fp ) for( unsigned int k = 1; k <= (*it)->NumberFragments; k++ ) { fp->seekg( (*it)->Offset[k] , std::ios::beg ); - (void)ReadAndDecompressRLEFragment( subDecompressed, + (void)ReadAndDecompressRLEFragment( subRaw, (*it)->Length[k], - decompressedSegmentSize, + RawSegmentSize, fp ); - subDecompressed += decompressedSegmentSize; + subRaw += RawSegmentSize; } } @@ -305,7 +305,7 @@ void PixelReadConvert::ConvertSwapZone() if( BitsAllocated == 16 ) { - uint16_t* im16 = (uint16_t*)Decompressed; + uint16_t* im16 = (uint16_t*)Raw; switch( SwapCode ) { case 0: @@ -316,7 +316,7 @@ void PixelReadConvert::ConvertSwapZone() case 3412: case 2143: case 4321: - for( i = 0; i < DecompressedSize / 2; i++ ) + for( i = 0; i < RawSize / 2; i++ ) { im16[i]= (im16[i] >> 8) | (im16[i] << 8 ); } @@ -331,14 +331,14 @@ void PixelReadConvert::ConvertSwapZone() uint32_t s32; uint16_t high; uint16_t low; - uint32_t* im32 = (uint32_t*)Decompressed; + uint32_t* im32 = (uint32_t*)Raw; switch ( SwapCode ) { case 0: case 1234: break; case 4321: - for( i = 0; i < DecompressedSize / 4; i++ ) + for( i = 0; i < RawSize / 4; i++ ) { low = im32[i] & 0x0000ffff; // 4321 high = im32[i] >> 16; @@ -349,7 +349,7 @@ void PixelReadConvert::ConvertSwapZone() } break; case 2143: - for( i = 0; i < DecompressedSize / 4; i++ ) + for( i = 0; i < RawSize / 4; i++ ) { low = im32[i] & 0x0000ffff; // 2143 high = im32[i] >> 16; @@ -360,7 +360,7 @@ void PixelReadConvert::ConvertSwapZone() } break; case 3412: - for( i = 0; i < DecompressedSize / 4; i++ ) + for( i = 0; i < RawSize / 4; i++ ) { low = im32[i] & 0x0000ffff; // 3412 high = im32[i] >> 16; @@ -390,8 +390,8 @@ void PixelReadConvert::ConvertReorderEndianity() && ( BitsStored < BitsAllocated ) && ( ! PixelSign ) ) { - int l = (int)( DecompressedSize / ( BitsAllocated / 8 ) ); - uint16_t *deb = (uint16_t *)Decompressed; + int l = (int)( RawSize / ( BitsAllocated / 8 ) ); + uint16_t *deb = (uint16_t *)Raw; for(int i = 0; iFragments.begin(); @@ -422,7 +422,7 @@ bool PixelReadConvert::ReadAndDecompressJPEGFile( std::ifstream* fp ) if ( IsJPEG2000 ) { - if ( ! gdcm_read_JPEG2000_file( fp,localDecompressed ) ) + if ( ! gdcm_read_JPEG2000_file( fp,localRaw ) ) { return false; } @@ -430,7 +430,7 @@ bool PixelReadConvert::ReadAndDecompressJPEGFile( std::ifstream* fp ) else if ( BitsStored == 8) { // JPEG Lossy : call to IJG 6b - if ( ! gdcm_read_JPEG_file8( fp, localDecompressed ) ) + if ( ! gdcm_read_JPEG_file8( fp, localRaw ) ) { return false; } @@ -438,7 +438,7 @@ bool PixelReadConvert::ReadAndDecompressJPEGFile( std::ifstream* fp ) else if ( BitsStored <= 12) { // Reading Fragment pixels - if ( ! gdcm_read_JPEG_file12 ( fp, localDecompressed ) ) + if ( ! gdcm_read_JPEG_file12 ( fp, localRaw ) ) { return false; } @@ -446,7 +446,7 @@ bool PixelReadConvert::ReadAndDecompressJPEGFile( std::ifstream* fp ) else if ( BitsStored <= 16) { // Reading Fragment pixels - if ( ! gdcm_read_JPEG_file16 ( fp, localDecompressed ) ) + if ( ! gdcm_read_JPEG_file16 ( fp, localRaw ) ) { return false; } @@ -460,12 +460,12 @@ bool PixelReadConvert::ReadAndDecompressJPEGFile( std::ifstream* fp ) return false; } - // Advance to next free location in Decompressed + // Advance to next free location in Raw // for next fragment decompression (if any) int length = XSize * YSize * SamplesPerPixel; int numberBytes = BitsAllocated / 8; - localDecompressed += length * numberBytes; + localRaw += length * numberBytes; } return true; } @@ -478,12 +478,12 @@ bool PixelReadConvert::ConvertReArrangeBits() throw ( FormatError ) { if ( BitsStored != BitsAllocated ) { - int l = (int)( DecompressedSize / ( BitsAllocated / 8 ) ); + int l = (int)( RawSize / ( BitsAllocated / 8 ) ); if ( BitsAllocated == 16 ) { uint16_t mask = 0xffff; mask = mask >> ( BitsAllocated - BitsStored ); - uint16_t* deb = (uint16_t*)Decompressed; + uint16_t* deb = (uint16_t*)Raw; for(int i = 0; i> (BitsStored - HighBitPosition - 1)) & mask; @@ -494,7 +494,7 @@ bool PixelReadConvert::ConvertReArrangeBits() throw ( FormatError ) { uint32_t mask = 0xffffffff; mask = mask >> ( BitsAllocated - BitsStored ); - uint32_t* deb = (uint32_t*)Decompressed; + uint32_t* deb = (uint32_t*)Raw; for(int i = 0; i> (BitsStored - HighBitPosition - 1)) & mask; @@ -517,9 +517,9 @@ bool PixelReadConvert::ConvertReArrangeBits() throw ( FormatError ) */ void PixelReadConvert::ConvertYcBcRPlanesToRGBPixels() { - uint8_t* localDecompressed = Decompressed; - uint8_t* copyDecompressed = new uint8_t[ DecompressedSize ]; - memmove( copyDecompressed, localDecompressed, DecompressedSize ); + uint8_t* localRaw = Raw; + uint8_t* copyRaw = new uint8_t[ RawSize ]; + memmove( copyRaw, localRaw, RawSize ); // to see the tricks about YBR_FULL, YBR_FULL_422, // YBR_PARTIAL_422, YBR_ICT, YBR_RCT have a look at : @@ -529,9 +529,9 @@ void PixelReadConvert::ConvertYcBcRPlanesToRGBPixels() int l = XSize * YSize; int nbFrames = ZSize; - uint8_t* a = copyDecompressed; - uint8_t* b = copyDecompressed + l; - uint8_t* c = copyDecompressed + l + l; + uint8_t* a = copyRaw; + uint8_t* b = copyRaw + l; + uint8_t* c = copyRaw + l + l; double R, G, B; /// \todo : Replace by the 'well known' integer computation @@ -554,15 +554,15 @@ void PixelReadConvert::ConvertYcBcRPlanesToRGBPixels() if (G > 255.0) G = 255.0; if (B > 255.0) B = 255.0; - *(localDecompressed++) = (uint8_t)R; - *(localDecompressed++) = (uint8_t)G; - *(localDecompressed++) = (uint8_t)B; + *(localRaw++) = (uint8_t)R; + *(localRaw++) = (uint8_t)G; + *(localRaw++) = (uint8_t)B; a++; b++; c++; } } - delete[] copyDecompressed; + delete[] copyRaw; } /** @@ -571,28 +571,28 @@ void PixelReadConvert::ConvertYcBcRPlanesToRGBPixels() */ void PixelReadConvert::ConvertRGBPlanesToRGBPixels() { - uint8_t* localDecompressed = Decompressed; - uint8_t* copyDecompressed = new uint8_t[ DecompressedSize ]; - memmove( copyDecompressed, localDecompressed, DecompressedSize ); + uint8_t* localRaw = Raw; + uint8_t* copyRaw = new uint8_t[ RawSize ]; + memmove( copyRaw, localRaw, RawSize ); int l = XSize * YSize * ZSize; - uint8_t* a = copyDecompressed; - uint8_t* b = copyDecompressed + l; - uint8_t* c = copyDecompressed + l + l; + uint8_t* a = copyRaw; + uint8_t* b = copyRaw + l; + uint8_t* c = copyRaw + l + l; for (int j = 0; j < l; j++) { - *(localDecompressed++) = *(a++); - *(localDecompressed++) = *(b++); - *(localDecompressed++) = *(c++); + *(localRaw++) = *(a++); + *(localRaw++) = *(b++); + *(localRaw++) = *(c++); } - delete[] copyDecompressed; + delete[] copyRaw; } bool PixelReadConvert::ReadAndDecompressPixelData( std::ifstream* fp ) { - // ComputeDecompressedAndRGBSizes is already made by + // ComputeRawAndRGBSizes is already made by // ::GrabInformationsFromHeader. So, the structure sizes are // correct Squeeze(); @@ -614,7 +614,7 @@ bool PixelReadConvert::ReadAndDecompressPixelData( std::ifstream* fp ) return false; } - AllocateDecompressed(); + AllocateRaw(); ////////////////////////////////////////////////// //// Second stage: read from disk dans decompress. @@ -622,30 +622,30 @@ bool PixelReadConvert::ReadAndDecompressPixelData( std::ifstream* fp ) { ReadAndDecompress12BitsTo16Bits( fp); } - else if ( IsDecompressed ) + else if ( IsRaw ) { // This problem can be found when some obvious informations are found // after the field containing the image datas. In this case, these // bad datas are added to the size of the image (in the PixelDataLength - // variable). But DecompressedSize is the right size of the image ! - if( PixelDataLength != DecompressedSize) + // variable). But RawSize is the right size of the image ! + if( PixelDataLength != RawSize) { dbg.Verbose( 0, "PixelReadConvert::ReadAndDecompressPixelData: " - "Mismatch between PixelReadConvert and DecompressedSize." ); + "Mismatch between PixelReadConvert and RawSize." ); } - if( PixelDataLength > DecompressedSize) + if( PixelDataLength > RawSize) { - fp->read( (char*)Decompressed, DecompressedSize); + fp->read( (char*)Raw, RawSize); } else { - fp->read( (char*)Decompressed, PixelDataLength); + fp->read( (char*)Raw, PixelDataLength); } if ( fp->fail() || fp->eof())//Fp->gcount() == 1 { dbg.Verbose( 0, "PixelReadConvert::ReadAndDecompressPixelData: " - "reading of decompressed pixel data failed." ); + "reading of Raw pixel data failed." ); return false; } } @@ -718,7 +718,7 @@ void PixelReadConvert::ConvertHandleColor() // - [Planar 1] AND [Photo C] handled with ConvertYcBcRPlanesToRGBPixels() // - [Planar 2] OR [Photo D] requires LUT intervention. - if ( ! IsDecompressedRGB() ) + if ( ! IsRawRGB() ) { // [Planar 2] OR [Photo D]: LUT intervention done outside return; @@ -749,10 +749,10 @@ void PixelReadConvert::ConvertHandleColor() } /** - * \brief Predicate to know wether the image[s] (once decompressed) is RGB. + * \brief Predicate to know wether the image[s] (once Raw) is RGB. * \note See comments of \ref ConvertHandleColor */ -bool PixelReadConvert::IsDecompressedRGB() +bool PixelReadConvert::IsRawRGB() { if ( IsMonochrome || PlanarConfiguration == 2 @@ -763,7 +763,7 @@ bool PixelReadConvert::IsDecompressedRGB() return true; } -void PixelReadConvert::ComputeDecompressedAndRGBSizes() +void PixelReadConvert::ComputeRawAndRGBSizes() { int bitsAllocated = BitsAllocated; // Number of "Bits Allocated" is fixed to 16 when it's 12, since @@ -774,16 +774,16 @@ void PixelReadConvert::ComputeDecompressedAndRGBSizes() bitsAllocated = 16; } - DecompressedSize = XSize * YSize * ZSize + RawSize = XSize * YSize * ZSize * ( bitsAllocated / 8 ) * SamplesPerPixel; if ( HasLUT ) { - RGBSize = 3 * DecompressedSize; + RGBSize = 3 * RawSize; } else { - RGBSize = DecompressedSize; + RGBSize = RawSize; } } @@ -820,7 +820,7 @@ void PixelReadConvert::GrabInformationsFromHeader( Header* header ) PixelSign = header->IsSignedPixelData(); SwapCode = header->GetSwapCode(); TransferSyntaxType ts = header->GetTransferSyntax(); - IsDecompressed = + IsRaw = ( ! header->IsDicomV3() ) || ts == ImplicitVRLittleEndian || ts == ImplicitVRLittleEndianDLXGE @@ -893,7 +893,7 @@ void PixelReadConvert::GrabInformationsFromHeader( Header* header ) } } - ComputeDecompressedAndRGBSizes(); + ComputeRawAndRGBSizes(); } /** @@ -1032,7 +1032,7 @@ void PixelReadConvert::BuildLUTRGBA() } /** - * \brief Build the RGB image from the Decompressed imagage and the LUTs. + * \brief Build the RGB image from the Raw imagage and the LUTs. */ bool PixelReadConvert::BuildRGBImage() { @@ -1042,7 +1042,7 @@ bool PixelReadConvert::BuildRGBImage() return true; } - if ( ! Decompressed ) + if ( ! Raw ) { // The job can't be done return false; @@ -1058,9 +1058,9 @@ bool PixelReadConvert::BuildRGBImage() // Build RGB Pixels AllocateRGB(); uint8_t* localRGB = RGB; - for (size_t i = 0; i < DecompressedSize; ++i ) + for (size_t i = 0; i < RawSize; ++i ) { - int j = Decompressed[i] * 4; + int j = Raw[i] * 4; *localRGB++ = LutRGBA[j]; *localRGB++ = LutRGBA[j+1]; *localRGB++ = LutRGBA[j+2]; diff --git a/src/gdcmPixelReadConvert.h b/src/gdcmPixelReadConvert.h index 743d1ef5..29d895d1 100644 --- a/src/gdcmPixelReadConvert.h +++ b/src/gdcmPixelReadConvert.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmPixelReadConvert.h,v $ Language: C++ - Date: $Date: 2004/12/03 20:16:58 $ - Version: $Revision: 1.3 $ + Date: $Date: 2004/12/10 13:49:07 $ + Version: $Revision: 1.4 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -41,12 +41,12 @@ public: //// Getter accessors: uint8_t* GetRGB() { return RGB; } size_t GetRGBSize() { return RGBSize; } - uint8_t* GetDecompressed() { return Decompressed; } - size_t GetDecompressedSize() { return DecompressedSize; } + uint8_t* GetRaw() { return Raw; } + size_t GetRawSize() { return RawSize; } uint8_t* GetLutRGBA() { return LutRGBA; } //// Predicates: - bool IsDecompressedRGB(); + bool IsRawRGB(); void Print( std::string indent = "", std::ostream &os = std::cout ); @@ -79,9 +79,9 @@ private: void ConvertYcBcRPlanesToRGBPixels(); void ConvertHandleColor(); - void ComputeDecompressedAndRGBSizes(); + void ComputeRawAndRGBSizes(); void AllocateRGB(); - void AllocateDecompressed(); + void AllocateRaw(); // Variables /// Pixel data represented as RGB after LUT color interpretation. @@ -89,9 +89,9 @@ private: /// Size of \ref RGB image. size_t RGBSize; /// Pixel data after decompression and bit/byte rearrangement. - uint8_t* Decompressed; + uint8_t* Raw; /// Size of \ref Decompressed image. - size_t DecompressedSize; + size_t RawSize; /// \brief Red/Green/Blue/Alpha LookUpTable build out of the /// Red/Green/Blue LUT descriptors (see \ref BuildLUTRGBA ). uint8_t* LutRGBA; @@ -109,7 +109,7 @@ private: bool PixelSign; int SwapCode; - bool IsDecompressed; + bool IsRaw; bool IsJPEG2000; bool IsJPEGLossless; bool IsRLELossless; diff --git a/vtk/vtkGdcmWriter.cxx b/vtk/vtkGdcmWriter.cxx index 7d6a697c..7f452654 100644 --- a/vtk/vtkGdcmWriter.cxx +++ b/vtk/vtkGdcmWriter.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: vtkGdcmWriter.cxx,v $ Language: C++ - Date: $Date: 2004/12/10 08:34:08 $ - Version: $Revision: 1.7 $ + Date: $Date: 2004/12/10 13:49:08 $ + Version: $Revision: 1.8 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -26,7 +26,7 @@ #include #include -vtkCxxRevisionMacro(vtkGdcmWriter, "$Revision: 1.7 $"); +vtkCxxRevisionMacro(vtkGdcmWriter, "$Revision: 1.8 $"); vtkStandardNewMacro(vtkGdcmWriter); //----------------------------------------------------------------------------- @@ -35,6 +35,7 @@ vtkGdcmWriter::vtkGdcmWriter() { this->LookupTable = NULL; this->FileDimensionality = 3; + this->WriteType = VTK_GDCM_WRITE_TYPE_EXPLICIT_VR; } vtkGdcmWriter::~vtkGdcmWriter() @@ -46,10 +47,28 @@ vtkGdcmWriter::~vtkGdcmWriter() void vtkGdcmWriter::PrintSelf(ostream& os, vtkIndent indent) { this->Superclass::PrintSelf(os,indent); + + os << indent << "Write type : " << this->GetWriteTypeAsString(); } //----------------------------------------------------------------------------- // Public +const char *vtkGdcmWriter::GetWriteTypeAsString() +{ + switch(WriteType) + { + case VTK_GDCM_WRITE_TYPE_EXPLICIT_VR : + return "Explicit VR"; + case VTK_GDCM_WRITE_TYPE_IMPLICIT_VR : + return "Implicit VR"; + case VTK_GDCM_WRITE_TYPE_ACR : + return "ACR"; + case VTK_GDCM_WRITE_TYPE_ACR_LIBIDO : + return "ACR Libido"; + default : + return "Unknow type"; + } +} //----------------------------------------------------------------------------- // Protected @@ -70,22 +89,29 @@ size_t ReverseData(vtkImageData *image,unsigned char **data) size_t planeSize = dim[1] * lineSize; size_t size = dim[2] * planeSize; - *data = new unsigned char[size]; - - image->GetIncrements(inc); - unsigned char *src = (unsigned char *)image->GetScalarPointerForExtent(extent); - unsigned char *dst = *data + planeSize - lineSize; - for (int plane = extent[4]; plane <= extent[5]; plane++) + if( size>0 ) { - for (int line = extent[2]; line <= extent[3]; line++) + *data = new unsigned char[size]; + + image->GetIncrements(inc); + unsigned char *src = (unsigned char *)image->GetScalarPointerForExtent(extent); + unsigned char *dst = *data + planeSize - lineSize; + for (int plane = extent[4]; plane <= extent[5]; plane++) { - // Copy one line at proper destination: - memcpy((void*)dst, (void*)src, lineSize); + for (int line = extent[2]; line <= extent[3]; line++) + { + // Copy one line at proper destination: + memcpy((void*)dst, (void*)src, lineSize); - src += inc[1]*image->GetScalarSize(); - dst -= lineSize; + src += inc[1] * image->GetScalarSize(); + dst -= lineSize; + } + dst += 2 * planeSize; } - dst += 2 * planeSize; + } + else + { + *data = NULL; } return size; @@ -182,7 +208,7 @@ void SetImageInformation(gdcm::File *file,vtkImageData *image) // Pixels unsigned char *data; size_t size = ReverseData(image,&data); - file->SetImageData(data,size); + file->SetUserData(data,size); } /** @@ -292,6 +318,24 @@ void vtkGdcmWriter::WriteDcmFile(char *fileName,vtkImageData *image) SetImageInformation(dcmFile,image); // Write the image + switch(this->WriteType) + { + case VTK_GDCM_WRITE_TYPE_EXPLICIT_VR : + dcmFile->SetWriteTypeToDcmExplVR(); + break; + case VTK_GDCM_WRITE_TYPE_IMPLICIT_VR : + dcmFile->SetWriteTypeToDcmImplVR(); + break; + case VTK_GDCM_WRITE_TYPE_ACR : + dcmFile->SetWriteTypeToAcr(); + break; + case VTK_GDCM_WRITE_TYPE_ACR_LIBIDO : + dcmFile->SetWriteTypeToAcrLibido(); + break; + default : + dcmFile->SetWriteTypeToDcmExplVR(); + } + if(!dcmFile->Write(fileName)) { vtkErrorMacro( << "File " << this->FileName << "couldn't be written by " @@ -299,6 +343,11 @@ void vtkGdcmWriter::WriteDcmFile(char *fileName,vtkImageData *image) std::cerr << "not written \n"; } + // Clean up + if( dcmFile->GetUserData() && dcmFile->GetUserDataSize()>0 ) + { + delete[] dcmFile->GetUserData(); + } delete dcmFile; } diff --git a/vtk/vtkGdcmWriter.h b/vtk/vtkGdcmWriter.h index 79e8edb8..1124a58a 100644 --- a/vtk/vtkGdcmWriter.h +++ b/vtk/vtkGdcmWriter.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: vtkGdcmWriter.h,v $ Language: C++ - Date: $Date: 2004/12/09 10:59:59 $ - Version: $Revision: 1.3 $ + Date: $Date: 2004/12/10 13:49:08 $ + Version: $Revision: 1.4 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -26,6 +26,12 @@ #include #include +//----------------------------------------------------------------------------- +#define VTK_GDCM_WRITE_TYPE_EXPLICIT_VR 1 +#define VTK_GDCM_WRITE_TYPE_IMPLICIT_VR 2 +#define VTK_GDCM_WRITE_TYPE_ACR 3 +#define VTK_GDCM_WRITE_TYPE_ACR_LIBIDO 4 + //----------------------------------------------------------------------------- class VTK_EXPORT vtkGdcmWriter : public vtkImageWriter { @@ -38,6 +44,14 @@ public: vtkSetObjectMacro(LookupTable,vtkLookupTable); vtkGetObjectMacro(LookupTable,vtkLookupTable); + void SetWriteTypeToDcmImplVR() { SetWriteType(VTK_GDCM_WRITE_TYPE_EXPLICIT_VR); }; + void SetWriteTypeToDcmExplVR() { SetWriteType(VTK_GDCM_WRITE_TYPE_IMPLICIT_VR); }; + void SetWriteTypeToAcr() { SetWriteType(VTK_GDCM_WRITE_TYPE_ACR); }; + void SetWriteTypeToAcrLibido() { SetWriteType(VTK_GDCM_WRITE_TYPE_ACR_LIBIDO); }; + vtkSetMacro(WriteType,int); + vtkGetMacro(WriteType,int); + const char *GetWriteTypeAsString(); + protected: vtkGdcmWriter(); ~vtkGdcmWriter(); @@ -50,6 +64,7 @@ protected: private: // Variables vtkLookupTable *LookupTable; + int WriteType; }; //-----------------------------------------------------------------------------