Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

gdcm::FileHelper Class Reference

In addition to Dicom header exploration, this class is designed for accessing the image/volume content. One can also use it to write Dicom/ACR-NEMA/RAW files. More...

#include <gdcmFileHelper.h>

Inheritance diagram for gdcm::FileHelper:

gdcm::Base List of all members.

Public Types

enum  FileMode { WMODE_RAW, WMODE_RGB }

Public Member Functions

 FileHelper ()
 Constructor dedicated to deal with the *pixels* area of a ACR/DICOMV3 file (gdcm::File only deals with the ... header) Opens (in read only and when possible) an existing file and checks for DICOM compliance. Returns NULL on failure. It will be up to the user to load the pixels into memory.

 FileHelper (File *header)
 Constructor dedicated to deal with the *pixels* area of a ACR/DICOMV3 file (File only deals with the ... header) Opens (in read only and when possible) an existing file and checks for DICOM compliance. Returns NULL on failure. It will be up to the user to load the pixels into memory.

 FileHelper (std::string const &filename)
 Constructor dedicated to deal with the *pixels* area of a ACR/DICOMV3 file (gdcm::File only deals with the ... header) Opens (in read only and when possible) an existing file and checks for DICOM compliance. Returns NULL on failure. It will be up to the user to load the pixels into memory.

virtual ~FileHelper ()
 canonical destructor

void Print (std::ostream &os=std::cout, std::string const &indent="")
 Print all the object.

FileGetFile ()
 Accessor to File.

bool SetValEntry (std::string const &content, uint16_t group, uint16_t elem)
 Accesses an existing DocEntry (i.e. a Dicom Element) through it's (group, element) and modifies it's content with the given value.

bool SetBinEntry (uint8_t *content, int lgth, uint16_t group, uint16_t elem)
 Accesses an existing DocEntry (i.e. a Dicom Element) through it's (group, element) and modifies it's content with the given value.

ValEntryInsertValEntry (std::string const &content, uint16_t group, uint16_t elem)
 Modifies the value of a given DocEntry (Dicom entry) when it exists. Create it with the given value when unexistant.

BinEntryInsertBinEntry (uint8_t *binArea, int lgth, uint16_t group, uint16_t elem)
 Modifies the value of a given DocEntry (Dicom entry) when it exists. Create it with the given value when unexistant. A copy of the binArea is made to be kept in the Document.

SeqEntryInsertSeqEntry (uint16_t group, uint16_t elem)
 Modifies the value of a given DocEntry (Dicom entry) when it exists. Create it with the given value when unexistant. A copy of the binArea is made to be kept in the Document.

size_t GetImageDataSize ()
 Get the size of the image data If the image can be RGB (with a lut or by default), the size corresponds to the RGB image (use GetImageDataRawSize if you want to be sure to get *only* the size of the pixels).

size_t GetImageDataRawSize ()
 Get the size of the image data If the image could be converted to RGB using a LUT, this transformation is not taken into account by GetImageDataRawSize (use GetImageDataSize if you wish).

uint8_t * GetImageData ()
 
  • Allocates necessary memory, -Reads the pixels from disk (uncompress if necessary), -Transforms YBR pixels, if any, into RGB pixels, -Transforms 3 planes R, G, B, if any, into a single RGB Plane -Transforms single Grey plane + 3 Palettes into a RGB Plane -Copies the pixel data (image[s]/volume[s]) to newly allocated zone.


uint8_t * GetImageDataRaw ()
 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.

size_t GetImageDataIntoVector (void *destination, size_t maxSize)
 Read the pixels from disk (uncompress if necessary), Transforms YBR pixels, if any, into RGB pixels Transforms 3 planes R, G, B, if any, into a single RGB Plane Transforms single Grey plane + 3 Palettes into a RGB Plane Copies at most MaxSize bytes of pixel data to caller allocated memory space.

void SetImageData (uint8_t *data, size_t expectedSize)
 Points the internal pointer to the callers inData image representation, BUT WITHOUT COPYING THE DATA. 'image' Pixels are presented as C-like 2D arrays : line per line. 'volume'Pixels are presented as C-like 3D arrays : plane per plane.

void SetUserData (uint8_t *data, size_t expectedSize)
 Set the image data defined by the user.

uint8_t * GetUserData ()
 Get the image data defined by the user.

size_t GetUserDataSize ()
 Get the image data size defined by the user.

uint8_t * GetRGBData ()
 Get the image data from the file. If a LUT is found, the data are expanded to be RGB.

size_t GetRGBDataSize ()
 Get the image data size from the file. If a LUT is found, the data are expanded to be RGB.

uint8_t * GetRawData ()
 Get the image data from the file. If a LUT is found, the data are not expanded !

size_t GetRawDataSize ()
 Get the image data size from the file. If a LUT is found, the data are not expanded !

uint8_t * GetLutRGBA ()
 Access to the underlying PixelReadConverter RGBA LUT.

void SetWriteModeToRaw ()
 Tells the writer we want to write a Raw File (no header).

void SetWriteModeToRGB ()
 Tells the writer we want to write RGB image when possible (as opposite to 'Grey pixels + Palettes color').

void SetWriteMode (FileMode mode)
 Sets the Write Mode ( ).

FileMode GetWriteMode ()
 Gets the Write Mode ( ).

void SetWriteTypeToDcmImplVR ()
 Tells the writer we want to write as Implicit VR.

void SetWriteTypeToDcmExplVR ()
 Tells the writer we want to write as Explicit VR.

void SetWriteTypeToAcr ()
 Tells the writer we want to write as ACR-NEMA.

void SetWriteTypeToAcrLibido ()
 Tells the writer we want to write as LibIDO.

void SetWriteType (FileType format)
 Tells the writer which format want to write (ImplicitVR, ExplicitVR, ACR, ACR_LIBIDO).

FileType GetWriteType ()
 Gets the format we want to write (ImplicitVR, ExplicitVR, ACR, ACR_LIBIDO).

bool WriteRawData (std::string const &fileName)
 Writes on disk A SINGLE Dicom file NO test is performed on processor "Endiannity". It's up to the user to call his Reader properly.

bool WriteDcmImplVR (std::string const &fileName)
 Writes on disk A SINGLE Dicom file, using the Implicit Value Representation convention NO test is performed on processor "Endiannity".

bool WriteDcmExplVR (std::string const &fileName)
 Writes on disk A SINGLE Dicom file, using the Explicit Value Representation convention NO test is performed on processor "Endiannity".

bool WriteAcr (std::string const &fileName)
 Writes on disk A SINGLE Dicom file, using the ACR-NEMA convention NO test is performed on processor "Endiannity". (a l'attention des logiciels cliniques qui ne prennent en entrée QUE des images ACR ...

bool Write (std::string const &fileName)
 Writes on disk A SINGLE Dicom file,.

void SetPrintLevel (int level)
 Sets the print level for the Dicom Header Elements.

int GetPrintLevel ()
 Gets the print level for the Dicom Entries.


Protected Member Functions

bool CheckWriteIntegrity ()
 Check the write integrity.

void SetWriteToRaw ()
 Update the File to write RAW datas.

void SetWriteToRGB ()
 Update the File to write RGB datas.

void RestoreWrite ()
 Restore the File write mode.

void SetWriteFileTypeToACR ()
 Set in the File the write type to ACR.

void SetWriteFileTypeToExplicitVR ()
 Set in the File the write type to Explicit VR.

void SetWriteFileTypeToImplicitVR ()
 Set in the File the write type to Implicit VR.

void RestoreWriteFileType ()
 Restore in the File the write type.

void SetWriteToLibido ()
 Set the Write not to Libido format.

void SetWriteToNoLibido ()
 Set the Write not to No Libido format.

void RestoreWriteOfLibido ()
 Restore the Write format.

ValEntryCopyValEntry (uint16_t group, uint16_t elem)
 Copy a ValEntry content.

BinEntryCopyBinEntry (uint16_t group, uint16_t elem, const std::string &vr)
 Modifies the value of a given Bin Entry (Dicom Element) when it exists. Create it with the given value when unexistant.


Protected Attributes

int PrintLevel
 Amount of printed details for each Dicom Entries : 0 : stands for the least detail level.


Private Member Functions

void Initialize ()
 Factorization for various forms of constructors.

uint8_t * GetRaw ()

Private Attributes

FileFileInternal
 gdcm::File to use to load the file

bool SelfHeader
 Whether the underlying gdcm::File was loaded by the constructor or passed to the constructor. When false the destructor is in charge of deletion.

bool Parsed
 Wether already parsed or not.

PixelReadConvertPixelReadConverter
 Pointer to the PixelReadConverter.

PixelWriteConvertPixelWriteConverter
 Pointer to the PixelWriteConverter.

DocEntryArchiveArchive
 Pointer to the DocEntryArchive (used while writting process).

FileMode WriteMode
 (WMODE_RAW, WMODE_RGB)

FileType WriteType
 (ImplicitVR, ExplicitVR, ACR, ACR_LIBIDO)


Detailed Description

In addition to Dicom header exploration, this class is designed for accessing the image/volume content. One can also use it to write Dicom/ACR-NEMA/RAW files.

Definition at line 40 of file gdcmFileHelper.h.


Member Enumeration Documentation

enum gdcm::FileHelper::FileMode
 

Enumeration values:
WMODE_RAW 
WMODE_RGB 

Definition at line 43 of file gdcmFileHelper.h.

00044    {
00045       WMODE_RAW,
00046       WMODE_RGB
00047    };


Constructor & Destructor Documentation

gdcm::FileHelper::FileHelper  ) 
 

Constructor dedicated to deal with the *pixels* area of a ACR/DICOMV3 file (gdcm::File only deals with the ... header) Opens (in read only and when possible) an existing file and checks for DICOM compliance. Returns NULL on failure. It will be up to the user to load the pixels into memory.

Note:
the in-memory representation of all available tags found in the DICOM header is post-poned to first header information access. This avoid a double parsing of public part of the header when one sets an a posteriori shadow dictionary (efficiency can be seen as a side effect).

Definition at line 51 of file gdcmFileHelper.cxx.

References FileInternal, Initialize(), and SelfHeader.

00052 {
00053    FileInternal = new File( );
00054    SelfHeader = true;
00055    Initialize();
00056 }

gdcm::FileHelper::FileHelper File header  ) 
 

Constructor dedicated to deal with the *pixels* area of a ACR/DICOMV3 file (File only deals with the ... header) Opens (in read only and when possible) an existing file and checks for DICOM compliance. Returns NULL on failure. It will be up to the user to load the pixels into memory.

Note:
the in-memory representation of all available tags found in the DICOM header is post-poned to first header information access. This avoid a double parsing of public part of the header when user sets an a posteriori shadow dictionary (efficiency can be seen as a side effect).
Parameters:
header already built Header

Definition at line 71 of file gdcmFileHelper.cxx.

References FileInternal, Initialize(), and SelfHeader.

00072 {
00073    FileInternal = header;
00074    SelfHeader = false;
00075    Initialize();
00076 }

gdcm::FileHelper::FileHelper std::string const &  filename  ) 
 

Constructor dedicated to deal with the *pixels* area of a ACR/DICOMV3 file (gdcm::File only deals with the ... header) Opens (in read only and when possible) an existing file and checks for DICOM compliance. Returns NULL on failure. It will be up to the user to load the pixels into memory.

Note:
the in-memory representation of all available tags found in the DICOM header is post-poned to first header information access. This avoid a double parsing of public part of the header when one sets an a posteriori shadow dictionary (efficiency can be seen as a side effect).
Parameters:
filename file to be opened for parsing

Definition at line 91 of file gdcmFileHelper.cxx.

References FileInternal, Initialize(), and SelfHeader.

00092 {
00093    FileInternal = new File( filename );
00094    SelfHeader = true;
00095    Initialize();
00096 }

gdcm::FileHelper::~FileHelper  )  [virtual]
 

canonical destructor

Note:
If the header (gdcm::File) was created by the FileHelper constructor, it is destroyed by the FileHelper

Definition at line 103 of file gdcmFileHelper.cxx.

References FileInternal, PixelReadConverter, PixelWriteConverter, and SelfHeader.

00104 { 
00105    if( PixelReadConverter )
00106    {
00107       delete PixelReadConverter;
00108    }
00109    if( PixelWriteConverter )
00110    {
00111       delete PixelWriteConverter;
00112    }
00113    if( Archive )
00114    {
00115       delete Archive;
00116    }
00117 
00118    if( SelfHeader )
00119    {
00120       delete FileInternal;
00121    }
00122    FileInternal = 0;
00123 }


Member Function Documentation

bool gdcm::FileHelper::CheckWriteIntegrity  )  [protected]
 

Check the write integrity.

The tests made are :

  • verify the size of the image to write with the possible write when the user set an image data
    Returns:
    true if check is successfull

Definition at line 614 of file gdcmFileHelper.cxx.

References FileInternal, gdcmWarningMacro, gdcm::File::GetBitsAllocated(), gdcm::File::GetSamplesPerPixel(), gdcm::PixelWriteConvert::GetUserData(), gdcm::PixelWriteConvert::GetUserDataSize(), gdcm::File::GetXSize(), gdcm::File::GetYSize(), gdcm::File::GetZSize(), gdcm::File::HasLUT(), PixelWriteConverter, WMODE_RAW, WMODE_RGB, and WriteMode.

Referenced by Write().

00615 {
00616    if(PixelWriteConverter->GetUserData())
00617    {
00618       int numberBitsAllocated = FileInternal->GetBitsAllocated();
00619       if ( numberBitsAllocated == 0 || numberBitsAllocated == 12 )
00620       {
00621          numberBitsAllocated = 16;
00622       }
00623 
00624       size_t decSize = FileInternal->GetXSize()
00625                     * FileInternal->GetYSize() 
00626                     * FileInternal->GetZSize()
00627                     * ( numberBitsAllocated / 8 )
00628                     * FileInternal->GetSamplesPerPixel();
00629       size_t rgbSize = decSize;
00630       if( FileInternal->HasLUT() )
00631          rgbSize = decSize * 3;
00632 
00633       switch(WriteMode)
00634       {
00635          case WMODE_RAW :
00636             if( decSize!=PixelWriteConverter->GetUserDataSize() )
00637             {
00638                gdcmWarningMacro( "Data size (Raw) is incorrect. Should be " 
00639                            << decSize << " / Found :" 
00640                            << PixelWriteConverter->GetUserDataSize() );
00641                return false;
00642             }
00643             break;
00644          case WMODE_RGB :
00645             if( rgbSize!=PixelWriteConverter->GetUserDataSize() )
00646             {
00647                gdcmWarningMacro( "Data size (RGB) is incorrect. Should be " 
00648                           << decSize << " / Found " 
00649                           << PixelWriteConverter->GetUserDataSize() );
00650                return false;
00651             }
00652             break;
00653       }
00654    }
00655    
00656    return true;
00657 }

BinEntry * gdcm::FileHelper::CopyBinEntry uint16_t  group,
uint16_t  elem,
const std::string &  vr
[protected]
 

Modifies the value of a given Bin Entry (Dicom Element) when it exists. Create it with the given value when unexistant.

Parameters:
group Group number of the Entry
elem Element number of the Entry
vr Value Representation of the Entry
Returns:
pointer to the modified/created Bin Entry (NULL when creation failed).

Definition at line 941 of file gdcmFileHelper.cxx.

References gdcm::ContentEntry::Copy(), FileInternal, gdcm::DocEntry::GetDictEntry(), gdcm::ElementSet::GetDocEntry(), GetFile(), gdcm::DocEntry::GetVR(), and gdcm::DocEntrySet::NewBinEntry().

Referenced by SetWriteToRaw(), and SetWriteToRGB().

00943 {
00944    DocEntry *oldE = FileInternal->GetDocEntry(group, elem);
00945    BinEntry *newE;
00946 
00947    if( oldE )
00948       if( oldE->GetVR()!=vr )
00949          oldE = NULL;
00950 
00951    if( oldE )
00952    {
00953       newE = new BinEntry(oldE->GetDictEntry());
00954       newE->Copy(oldE);
00955    }
00956    else
00957    {
00958       newE = GetFile()->NewBinEntry(group,elem,vr);
00959    }
00960 
00961    return newE;
00962 }

ValEntry * gdcm::FileHelper::CopyValEntry uint16_t  group,
uint16_t  elem
[protected]
 

Copy a ValEntry content.

Parameters:
group Group number of the Entry
elem Element number of the Entry
Returns:
pointer to the modified/created Val Entry (NULL when creation failed).

Definition at line 914 of file gdcmFileHelper.cxx.

References gdcm::ContentEntry::Copy(), FileInternal, gdcm::DocEntry::GetDictEntry(), gdcm::ElementSet::GetDocEntry(), GetFile(), and gdcm::DocEntrySet::NewValEntry().

Referenced by SetWriteFileTypeToExplicitVR(), SetWriteFileTypeToImplicitVR(), SetWriteToLibido(), SetWriteToNoLibido(), SetWriteToRaw(), and SetWriteToRGB().

00915 {
00916    DocEntry *oldE = FileInternal->GetDocEntry(group, elem);
00917    ValEntry *newE;
00918 
00919    if( oldE )
00920    {
00921       newE = new ValEntry(oldE->GetDictEntry());
00922       newE->Copy(oldE);
00923    }
00924    else
00925    {
00926       newE = GetFile()->NewValEntry(group,elem);
00927    }
00928 
00929    return newE;
00930 }

File* gdcm::FileHelper::GetFile  )  [inline]
 

Accessor to File.

Definition at line 59 of file gdcmFileHelper.h.

Referenced by CopyBinEntry(), CopyValEntry(), vtkGdcmReader::LoadImageInMemory(), RestoreWrite(), SetWriteToRaw(), and SetWriteToRGB().

00059 { return FileInternal; }

uint8_t * gdcm::FileHelper::GetImageData  ) 
 

  • Allocates necessary memory, -Reads the pixels from disk (uncompress if necessary), -Transforms YBR pixels, if any, into RGB pixels, -Transforms 3 planes R, G, B, if any, into a single RGB Plane -Transforms single Grey plane + 3 Palettes into a RGB Plane -Copies the pixel data (image[s]/volume[s]) to newly allocated zone.

Returns:
Pointer to newly allocated pixel data. NULL if alloc fails

Definition at line 248 of file gdcmFileHelper.cxx.

References gdcm::PixelReadConvert::BuildRGBImage(), FileInternal, gdcm::PixelReadConvert::GetRaw(), GetRaw(), gdcm::PixelReadConvert::GetRGB(), gdcm::PixelWriteConvert::GetUserData(), gdcm::File::HasLUT(), PixelReadConverter, and PixelWriteConverter.

Referenced by vtkGdcmReader::LoadImageInMemory().

00249 {
00250    if ( PixelWriteConverter->GetUserData() )
00251    {
00252       return PixelWriteConverter->GetUserData();
00253    }
00254 
00255    if ( ! GetRaw() )
00256    {
00257       // If the decompression failed nothing can be done.
00258       return 0;
00259    }
00260 
00261    if ( FileInternal->HasLUT() && PixelReadConverter->BuildRGBImage() )
00262    {
00263       return PixelReadConverter->GetRGB();
00264    }
00265    else
00266    {
00267       // When no LUT or LUT conversion fails, return the Raw
00268       return PixelReadConverter->GetRaw();
00269    }
00270 }

size_t gdcm::FileHelper::GetImageDataIntoVector void *  destination,
size_t  maxSize
 

Read the pixels from disk (uncompress if necessary), Transforms YBR pixels, if any, into RGB pixels Transforms 3 planes R, G, B, if any, into a single RGB Plane Transforms single Grey plane + 3 Palettes into a RGB Plane Copies at most MaxSize bytes of pixel data to caller allocated memory space.

Warning:
This function allows people that want to build a volume from an image stack *not to* have, first to get the image pixels, and then move them to the volume area. It's absolutely useless for any VTK user since vtk chooses to invert the lines of an image, that is the last line comes first (for some axis related reasons?). Hence he will have to load the image line by line, starting from the end. VTK users have to call GetImageData
Parameters:
destination Address (in caller's memory space) at which the pixel data should be copied
maxSize Maximum number of bytes to be copied. When MaxSize is not sufficient to hold the pixel data the copy is not executed (i.e. no partial copy).
Returns:
On success, the number of bytes actually copied. Zero on failure e.g. MaxSize is lower than necessary.

Definition at line 311 of file gdcmFileHelper.cxx.

References gdcm::PixelReadConvert::BuildRGBImage(), FileInternal, gdcmWarningMacro, gdcm::PixelReadConvert::GetRaw(), GetRaw(), gdcm::PixelReadConvert::GetRawSize(), gdcm::PixelReadConvert::GetRGB(), gdcm::PixelReadConvert::GetRGBSize(), gdcm::File::HasLUT(), and PixelReadConverter.

00312 {
00313    if ( ! GetRaw() )
00314    {
00315       // If the decompression failed nothing can be done.
00316       return 0;
00317    }
00318 
00319    if ( FileInternal->HasLUT() && PixelReadConverter->BuildRGBImage() )
00320    {
00321       if ( PixelReadConverter->GetRGBSize() > maxSize )
00322       {
00323          gdcmWarningMacro( "Pixel data bigger than caller's expected MaxSize");
00324          return 0;
00325       }
00326       memcpy( destination,
00327               (void*)PixelReadConverter->GetRGB(),
00328               PixelReadConverter->GetRGBSize() );
00329       return PixelReadConverter->GetRGBSize();
00330    }
00331 
00332    // Either no LUT conversion necessary or LUT conversion failed
00333    if ( PixelReadConverter->GetRawSize() > maxSize )
00334    {
00335       gdcmWarningMacro( "Pixel data bigger than caller's expected MaxSize");
00336       return 0;
00337    }
00338    memcpy( destination,
00339            (void*)PixelReadConverter->GetRaw(),
00340            PixelReadConverter->GetRawSize() );
00341    return PixelReadConverter->GetRawSize();
00342 }

uint8_t * gdcm::FileHelper::GetImageDataRaw  ) 
 

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.

Returns:
Pointer to newly allocated pixel data. \ NULL if alloc fails

Definition at line 281 of file gdcmFileHelper.cxx.

References GetRaw().

Referenced by vtkGdcmReader::LoadImageInMemory().

00282 {
00283    return GetRaw();
00284 }

size_t gdcm::FileHelper::GetImageDataRawSize  ) 
 

Get the size of the image data If the image could be converted to RGB using a LUT, this transformation is not taken into account by GetImageDataRawSize (use GetImageDataSize if you wish).

Returns:
The raw image size

Definition at line 228 of file gdcmFileHelper.cxx.

References gdcm::PixelReadConvert::GetRawSize(), gdcm::PixelWriteConvert::GetUserData(), gdcm::PixelWriteConvert::GetUserDataSize(), PixelReadConverter, and PixelWriteConverter.

00229 {
00230    if ( PixelWriteConverter->GetUserData() )
00231    {
00232       return PixelWriteConverter->GetUserDataSize();
00233    }
00234 
00235    return PixelReadConverter->GetRawSize();
00236 }

size_t gdcm::FileHelper::GetImageDataSize  ) 
 

Get the size of the image data If the image can be RGB (with a lut or by default), the size corresponds to the RGB image (use GetImageDataRawSize if you want to be sure to get *only* the size of the pixels).

Returns:
The image size

Definition at line 211 of file gdcmFileHelper.cxx.

References gdcm::PixelReadConvert::GetRGBSize(), gdcm::PixelWriteConvert::GetUserData(), gdcm::PixelWriteConvert::GetUserDataSize(), PixelReadConverter, and PixelWriteConverter.

Referenced by vtkGdcmReader::LoadImageInMemory().

00212 {
00213    if ( PixelWriteConverter->GetUserData() )
00214    {
00215       return PixelWriteConverter->GetUserDataSize();
00216    }
00217 
00218    return PixelReadConverter->GetRGBSize();
00219 }

uint8_t * gdcm::FileHelper::GetLutRGBA  ) 
 

Access to the underlying PixelReadConverter RGBA LUT.

Definition at line 435 of file gdcmFileHelper.cxx.

References gdcm::PixelReadConvert::GetLutRGBA(), and PixelReadConverter.

Referenced by vtkGdcmReader::LoadImageInMemory().

00436 {
00437    return PixelReadConverter->GetLutRGBA();
00438 }

int gdcm::Base::GetPrintLevel  )  [inline, inherited]
 

Gets the print level for the Dicom Entries.

Definition at line 48 of file gdcmBase.h.

00048 { return PrintLevel; };

uint8_t * gdcm::FileHelper::GetRaw  )  [private]
 

Definition at line 987 of file gdcmFileHelper.cxx.

References gdcm::Document::CloseFile(), FileInternal, gdcmWarningMacro, gdcm::PixelReadConvert::GetRaw(), gdcm::Document::OpenFile(), PixelReadConverter, and gdcm::PixelReadConvert::ReadAndDecompressPixelData().

Referenced by GetImageData(), GetImageDataIntoVector(), and GetImageDataRaw().

00988 {
00989    uint8_t *raw = PixelReadConverter->GetRaw();
00990    if ( ! raw )
00991    {
00992       // The Raw image migth not be loaded yet:
00993       std::ifstream *fp = FileInternal->OpenFile();
00994       PixelReadConverter->ReadAndDecompressPixelData( fp );
00995       if(fp) 
00996          FileInternal->CloseFile();
00997 
00998       raw = PixelReadConverter->GetRaw();
00999       if ( ! raw )
01000       {
01001          gdcmWarningMacro( "Read/decompress of pixel data apparently went wrong.");
01002          return 0;
01003       }
01004    }
01005 
01006    return raw;
01007 }

uint8_t * gdcm::FileHelper::GetRawData  ) 
 

Get the image data from the file. If a LUT is found, the data are not expanded !

Definition at line 418 of file gdcmFileHelper.cxx.

References gdcm::PixelReadConvert::GetRaw(), and PixelReadConverter.

00419 {
00420    return PixelReadConverter->GetRaw();
00421 }

size_t gdcm::FileHelper::GetRawDataSize  ) 
 

Get the image data size from the file. If a LUT is found, the data are not expanded !

Definition at line 427 of file gdcmFileHelper.cxx.

References gdcm::PixelReadConvert::GetRawSize(), and PixelReadConverter.

00428 {
00429    return PixelReadConverter->GetRawSize();
00430 }

uint8_t * gdcm::FileHelper::GetRGBData  ) 
 

Get the image data from the file. If a LUT is found, the data are expanded to be RGB.

Definition at line 400 of file gdcmFileHelper.cxx.

References gdcm::PixelReadConvert::GetRGB(), and PixelReadConverter.

00401 {
00402    return PixelReadConverter->GetRGB();
00403 }

size_t gdcm::FileHelper::GetRGBDataSize  ) 
 

Get the image data size from the file. If a LUT is found, the data are expanded to be RGB.

Definition at line 409 of file gdcmFileHelper.cxx.

References gdcm::PixelReadConvert::GetRGBSize(), and PixelReadConverter.

00410 {
00411    return PixelReadConverter->GetRGBSize();
00412 }

uint8_t * gdcm::FileHelper::GetUserData  ) 
 

Get the image data defined by the user.

Warning:
When writting the file, this data are get as default data to write

Definition at line 382 of file gdcmFileHelper.cxx.

References gdcm::PixelWriteConvert::GetUserData(), and PixelWriteConverter.

Referenced by vtkGdcmWriter::WriteDcmFile().

00383 {
00384    return PixelWriteConverter->GetUserData();
00385 }

size_t gdcm::FileHelper::GetUserDataSize  ) 
 

Get the image data size defined by the user.

Warning:
When writting the file, this data are get as default data to write

Definition at line 391 of file gdcmFileHelper.cxx.

References gdcm::PixelWriteConvert::GetUserDataSize(), and PixelWriteConverter.

Referenced by vtkGdcmWriter::WriteDcmFile().

00392 {
00393    return PixelWriteConverter->GetUserDataSize();
00394 }

FileMode gdcm::FileHelper::GetWriteMode  )  [inline]
 

Gets the Write Mode ( ).

Definition at line 107 of file gdcmFileHelper.h.

00107 { return WriteMode;         };

FileType gdcm::FileHelper::GetWriteType  )  [inline]
 

Gets the format we want to write (ImplicitVR, ExplicitVR, ACR, ACR_LIBIDO).

Definition at line 124 of file gdcmFileHelper.h.

References gdcm::FileType.

00124 { return WriteType;         };

void gdcm::FileHelper::Initialize  )  [private]
 

Factorization for various forms of constructors.

Definition at line 969 of file gdcmFileHelper.cxx.

References gdcm::ExplicitVR, FileInternal, gdcm::PixelReadConvert::GrabInformationsFromFile(), gdcm::File::IsReadable(), PixelReadConverter, PixelWriteConverter, WMODE_RAW, WriteMode, and WriteType.

Referenced by FileHelper().

00970 {
00971    WriteMode = WMODE_RAW;
00972    WriteType = ExplicitVR;
00973 
00974    PixelReadConverter = new PixelReadConvert;
00975    PixelWriteConverter = new PixelWriteConvert;
00976    Archive = new DocEntryArchive( FileInternal );
00977 
00978    if ( FileInternal->IsReadable() )
00979    {
00980       PixelReadConverter->GrabInformationsFromFile( FileInternal );
00981    }
00982 }

BinEntry * gdcm::FileHelper::InsertBinEntry uint8_t *  binArea,
int  lgth,
uint16_t  group,
uint16_t  elem
 

Modifies the value of a given DocEntry (Dicom entry) when it exists. Create it with the given value when unexistant. A copy of the binArea is made to be kept in the Document.

Parameters:
binArea (binary) value to be set
lgth new value length
group Group number of the Entry
elem Element number of the Entry
Returns:
pointer to the modified/created Dicom entry (NULL when creation failed).

Definition at line 183 of file gdcmFileHelper.cxx.

References FileInternal, and gdcm::DocEntrySet::InsertBinEntry().

00185 {
00186    return FileInternal->InsertBinEntry(binArea,lgth,group,elem);
00187 }

SeqEntry * gdcm::FileHelper::InsertSeqEntry uint16_t  group,
uint16_t  elem
 

Modifies the value of a given DocEntry (Dicom entry) when it exists. Create it with the given value when unexistant. A copy of the binArea is made to be kept in the Document.

Parameters:
group Group number of the Entry
elem Element number of the Entry
Returns:
pointer to the modified/created Dicom entry (NULL when creation failed).

Definition at line 198 of file gdcmFileHelper.cxx.

References FileInternal, and gdcm::DocEntrySet::InsertSeqEntry().

00199 {
00200    return FileInternal->InsertSeqEntry(group,elem);
00201 }

ValEntry * gdcm::FileHelper::InsertValEntry std::string const &  content,
uint16_t  group,
uint16_t  elem
 

Modifies the value of a given DocEntry (Dicom entry) when it exists. Create it with the given value when unexistant.

Parameters:
content (string) Value to be set
group Group number of the Entry
elem Element number of the Entry
Returns:
pointer to the modified/created Dicom entry (NULL when creation failed).

Definition at line 166 of file gdcmFileHelper.cxx.

References FileInternal, and gdcm::DocEntrySet::InsertValEntry().

Referenced by SetImageInformation(), and vtkGdcmWriter::WriteDcmFile().

00168 {
00169    return FileInternal->InsertValEntry(content,group,elem);
00170 }

void gdcm::FileHelper::Print std::ostream &  os = std::cout,
std::string const &  indent = ""
[virtual]
 

Print all the object.

Parameters:
os The output stream to be written to.
indent Indentation string to be prepended during printing

Reimplemented from gdcm::Base.

Definition at line 1011 of file gdcmFileHelper.cxx.

References FileInternal, PixelReadConverter, gdcm::PixelReadConvert::Print(), gdcm::ElementSet::Print(), and gdcm::Base::SetPrintLevel().

01012 {
01013    FileInternal->SetPrintLevel(PrintLevel);
01014    FileInternal->Print(os);
01015 
01016    PixelReadConverter->SetPrintLevel(PrintLevel);
01017    PixelReadConverter->Print(os);
01018 }

void gdcm::FileHelper::RestoreWrite  )  [protected]
 

Restore the File write mode.

Definition at line 781 of file gdcmFileHelper.cxx.

References GetFile(), and gdcm::DocEntryArchive::Restore().

Referenced by Write().

00782 {
00783    Archive->Restore(0x0028,0x0002);
00784    Archive->Restore(0x0028,0x0004);
00785    Archive->Restore(0x0028,0x0006);
00786    Archive->Restore(GetFile()->GetGrPixel(),GetFile()->GetNumPixel());
00787 
00788    // For old ACR-NEMA (24 bits problem)
00789    Archive->Restore(0x0028,0x0100);
00790    Archive->Restore(0x0028,0x0101);
00791    Archive->Restore(0x0028,0x0102);
00792 
00793    // For the LUT
00794    Archive->Restore(0x0028,0x1101);
00795    Archive->Restore(0x0028,0x1102);
00796    Archive->Restore(0x0028,0x1103);
00797    Archive->Restore(0x0028,0x1201);
00798    Archive->Restore(0x0028,0x1202);
00799    Archive->Restore(0x0028,0x1203);
00800 }

void gdcm::FileHelper::RestoreWriteFileType  )  [protected]
 

Restore in the File the write type.

Definition at line 842 of file gdcmFileHelper.cxx.

References gdcm::DocEntryArchive::Restore().

Referenced by Write().

00843 {
00844    Archive->Restore(0x0002,0x0010);
00845 }

void gdcm::FileHelper::RestoreWriteOfLibido  )  [protected]
 

Restore the Write format.

Definition at line 900 of file gdcmFileHelper.cxx.

References gdcm::DocEntryArchive::Restore().

Referenced by Write().

00901 {
00902    Archive->Restore(0x0028,0x0010);
00903    Archive->Restore(0x0028,0x0011);
00904    Archive->Restore(0x0008,0x0010);
00905 }

bool gdcm::FileHelper::SetBinEntry uint8_t *  content,
int  lgth,
uint16_t  group,
uint16_t  elem
 

Accesses an existing DocEntry (i.e. a Dicom Element) through it's (group, element) and modifies it's content with the given value.

Parameters:
content new value (void* -> uint8_t*) to substitute with
lgth new value length
group group number of the Dicom Element to modify
elem element number of the Dicom Element to modify

Definition at line 151 of file gdcmFileHelper.cxx.

References FileInternal, and gdcm::DocEntrySet::SetBinEntry().

00153 {
00154    return FileInternal->SetBinEntry(content,lgth,group,elem);
00155 }

void gdcm::FileHelper::SetImageData uint8_t *  inData,
size_t  expectedSize
 

Points the internal pointer to the callers inData image representation, BUT WITHOUT COPYING THE DATA. 'image' Pixels are presented as C-like 2D arrays : line per line. 'volume'Pixels are presented as C-like 3D arrays : plane per plane.

Warning:
Since the pixels are not copied, it is the caller's responsability not to deallocate its data before gdcm uses them (e.g. with the Write() method )
Parameters:
inData user supplied pixel area (uint8_t* is just for the compiler. user is allowed to pass any kind of pixelsn since the size is given in bytes)
expectedSize total image size, *in Bytes*
Returns:
boolean

Definition at line 359 of file gdcmFileHelper.cxx.

References SetUserData().

00360 {
00361    SetUserData(inData,expectedSize);
00362 }

void gdcm::Base::SetPrintLevel int  level  )  [inline, inherited]
 

Sets the print level for the Dicom Header Elements.

Note:
0 for Light Print; 1 for 'medium' Print, 2 for Heavy

Definition at line 45 of file gdcmBase.h.

Referenced by gdcm::SQItem::Print(), gdcm::SeqEntry::Print(), Print(), gdcm::ElementSet::Print(), and gdcm::DicomDir::Print().

00045 { PrintLevel = level; };

void gdcm::FileHelper::SetUserData uint8_t *  inData,
size_t  expectedSize
 

Set the image data defined by the user.

Warning:
When writting the file, this data are get as default data to write
Parameters:
inData user supplied pixel area (uint8_t* is just for the compiler. user is allowed to pass any kind of pixelsn since the size is given in bytes)
expectedSize total image size, *in Bytes*

Definition at line 373 of file gdcmFileHelper.cxx.

References PixelWriteConverter, and gdcm::PixelWriteConvert::SetUserData().

Referenced by SetImageData(), and SetImageInformation().

00374 {
00375    PixelWriteConverter->SetUserData(inData,expectedSize);
00376 }

bool gdcm::FileHelper::SetValEntry std::string const &  content,
uint16_t  group,
uint16_t  elem
 

Accesses an existing DocEntry (i.e. a Dicom Element) through it's (group, element) and modifies it's content with the given value.

Parameters:
content new value (string) to substitute with
group group number of the Dicom Element to modify
elem element number of the Dicom Element to modify

Definition at line 135 of file gdcmFileHelper.cxx.

References FileInternal, and gdcm::DocEntrySet::SetValEntry().

00137 { 
00138    return FileInternal->SetValEntry(content,group,elem);
00139 }

void gdcm::FileHelper::SetWriteFileTypeToACR  )  [protected]
 

Set in the File the write type to ACR.

Definition at line 805 of file gdcmFileHelper.cxx.

References gdcm::DocEntryArchive::Push().

Referenced by Write().

00806 {
00807    Archive->Push(0x0002,0x0010);
00808 }

void gdcm::FileHelper::SetWriteFileTypeToExplicitVR  )  [protected]
 

Set in the File the write type to Explicit VR.

Definition at line 813 of file gdcmFileHelper.cxx.

References CopyValEntry(), gdcm::DocEntryArchive::Push(), and gdcm::ValEntry::SetValue().

Referenced by Write().

00814 {
00815    std::string ts = Util::DicomString( 
00816       Global::GetTS()->GetSpecialTransferSyntax(TS::ExplicitVRLittleEndian) );
00817 
00818    ValEntry *tss = CopyValEntry(0x0002,0x0010);
00819    tss->SetValue(ts);
00820 
00821    Archive->Push(tss);
00822 }

void gdcm::FileHelper::SetWriteFileTypeToImplicitVR  )  [protected]
 

Set in the File the write type to Implicit VR.

Definition at line 827 of file gdcmFileHelper.cxx.

References CopyValEntry(), gdcm::DocEntryArchive::Push(), and gdcm::ValEntry::SetValue().

Referenced by Write().

00828 {
00829    std::string ts = Util::DicomString(
00830       Global::GetTS()->GetSpecialTransferSyntax(TS::ImplicitVRLittleEndian) );
00831 
00832    ValEntry *tss = CopyValEntry(0x0002,0x0010);
00833    tss->SetValue(ts);
00834 
00835    Archive->Push(tss);
00836 }

void gdcm::FileHelper::SetWriteMode FileMode  mode  )  [inline]
 

Sets the Write Mode ( ).

Definition at line 105 of file gdcmFileHelper.h.

00105 { WriteMode = mode;         };

void gdcm::FileHelper::SetWriteModeToRaw  )  [inline]
 

Tells the writer we want to write a Raw File (no header).

Definition at line 100 of file gdcmFileHelper.h.

00100 { SetWriteMode(WMODE_RAW);  };

void gdcm::FileHelper::SetWriteModeToRGB  )  [inline]
 

Tells the writer we want to write RGB image when possible (as opposite to 'Grey pixels + Palettes color').

Definition at line 103 of file gdcmFileHelper.h.

00103 { SetWriteMode(WMODE_RGB);  };

void gdcm::FileHelper::SetWriteToLibido  )  [protected]
 

Set the Write not to Libido format.

Definition at line 850 of file gdcmFileHelper.cxx.

References gdcm::ContentEntry::Copy(), CopyValEntry(), FileInternal, gdcm::DocEntry::GetDictEntry(), gdcm::ElementSet::GetDocEntry(), gdcm::ContentEntry::GetValue(), gdcm::DocEntryArchive::Push(), and gdcm::ValEntry::SetValue().

Referenced by Write().

00851 {
00852    ValEntry *oldRow = dynamic_cast<ValEntry *>
00853                 (FileInternal->GetDocEntry(0x0028, 0x0010));
00854    ValEntry *oldCol = dynamic_cast<ValEntry *>
00855                 (FileInternal->GetDocEntry(0x0028, 0x0011));
00856    
00857    if( oldRow && oldCol )
00858    {
00859       std::string rows, columns; 
00860 
00861       ValEntry *newRow=new ValEntry(oldRow->GetDictEntry());
00862       ValEntry *newCol=new ValEntry(oldCol->GetDictEntry());
00863 
00864       newRow->Copy(oldCol);
00865       newCol->Copy(oldRow);
00866 
00867       newRow->SetValue(oldCol->GetValue());
00868       newCol->SetValue(oldRow->GetValue());
00869 
00870       Archive->Push(newRow);
00871       Archive->Push(newCol);
00872    }
00873 
00874    ValEntry *libidoCode = CopyValEntry(0x0008,0x0010);
00875    libidoCode->SetValue("ACRNEMA_LIBIDO_1.1");
00876    Archive->Push(libidoCode);
00877 }

void gdcm::FileHelper::SetWriteToNoLibido  )  [protected]
 

Set the Write not to No Libido format.

Definition at line 882 of file gdcmFileHelper.cxx.

References CopyValEntry(), FileInternal, gdcm::ElementSet::GetDocEntry(), gdcm::ContentEntry::GetValue(), gdcm::DocEntryArchive::Push(), and gdcm::ValEntry::SetValue().

Referenced by Write().

00883 {
00884    ValEntry *recCode = dynamic_cast<ValEntry *>
00885                 (FileInternal->GetDocEntry(0x0008,0x0010));
00886    if( recCode )
00887    {
00888       if( recCode->GetValue() == "ACRNEMA_LIBIDO_1.1" )
00889       {
00890          ValEntry *libidoCode = CopyValEntry(0x0008,0x0010);
00891          libidoCode->SetValue("");
00892          Archive->Push(libidoCode);
00893       }
00894    }
00895 }

void gdcm::FileHelper::SetWriteToRaw  )  [protected]
 

Update the File to write RAW datas.

Definition at line 662 of file gdcmFileHelper.cxx.

References CopyBinEntry(), CopyValEntry(), FileInternal, gdcm::GDCM_BINLOADED, gdcm::File::GetBitsAllocated(), gdcm::PixelWriteConvert::GetData(), gdcm::PixelWriteConvert::GetDataSize(), GetFile(), gdcm::File::GetNumberOfScalarComponents(), gdcm::PixelReadConvert::GetRaw(), gdcm::PixelReadConvert::GetRawSize(), gdcm::File::HasLUT(), PixelReadConverter, PixelWriteConverter, gdcm::DocEntryArchive::Push(), gdcm::BinEntry::SetBinArea(), gdcm::DocEntry::SetLength(), gdcm::PixelWriteConvert::SetReadData(), gdcm::ContentEntry::SetValue(), gdcm::ValEntry::SetValue(), and SetWriteToRGB().

Referenced by SetWriteToRGB(), and Write().

00663 {
00664    if( FileInternal->GetNumberOfScalarComponents() == 3 
00665     && !FileInternal->HasLUT())
00666    {
00667       SetWriteToRGB();
00668    } 
00669    else
00670    {
00671       ValEntry *photInt = CopyValEntry(0x0028,0x0004);
00672       if(FileInternal->HasLUT())
00673       {
00674          photInt->SetValue("PALETTE COLOR ");
00675       }
00676       else
00677       {
00678          photInt->SetValue("MONOCHROME1 ");
00679       }
00680 
00681       PixelWriteConverter->SetReadData(PixelReadConverter->GetRaw(),
00682                                        PixelReadConverter->GetRawSize());
00683 
00684       std::string vr = "OB";
00685       if( FileInternal->GetBitsAllocated()>8 )
00686          vr = "OW";
00687       if( FileInternal->GetBitsAllocated()==24 ) // For RGB ACR files 
00688          vr = "OB";
00689       BinEntry *pixel = 
00690          CopyBinEntry(GetFile()->GetGrPixel(),GetFile()->GetNumPixel(),vr);
00691       pixel->SetValue(GDCM_BINLOADED);
00692       pixel->SetBinArea(PixelWriteConverter->GetData(),false);
00693       pixel->SetLength(PixelWriteConverter->GetDataSize());
00694 
00695       Archive->Push(photInt);
00696       Archive->Push(pixel);
00697    }
00698 }

void gdcm::FileHelper::SetWriteToRGB  )  [protected]
 

Update the File to write RGB datas.

Definition at line 703 of file gdcmFileHelper.cxx.

References gdcm::PixelReadConvert::BuildRGBImage(), CopyBinEntry(), CopyValEntry(), FileInternal, gdcm::GDCM_BINLOADED, gdcm::File::GetBitsAllocated(), gdcm::PixelWriteConvert::GetData(), gdcm::PixelWriteConvert::GetDataSize(), GetFile(), gdcm::File::GetNumberOfScalarComponents(), gdcm::PixelReadConvert::GetRaw(), gdcm::PixelReadConvert::GetRawSize(), gdcm::PixelReadConvert::GetRGB(), gdcm::PixelReadConvert::GetRGBSize(), PixelReadConverter, PixelWriteConverter, gdcm::DocEntryArchive::Push(), gdcm::BinEntry::SetBinArea(), gdcm::DocEntry::SetLength(), gdcm::PixelWriteConvert::SetReadData(), gdcm::ContentEntry::SetValue(), gdcm::ValEntry::SetValue(), and SetWriteToRaw().

Referenced by SetWriteToRaw(), and Write().

00704 {
00705    if(FileInternal->GetNumberOfScalarComponents()==3)
00706    {
00707       PixelReadConverter->BuildRGBImage();
00708       
00709       ValEntry *spp = CopyValEntry(0x0028,0x0002);
00710       spp->SetValue("3 ");
00711 
00712       ValEntry *planConfig = CopyValEntry(0x0028,0x0006);
00713       planConfig->SetValue("0 ");
00714 
00715       ValEntry *photInt = CopyValEntry(0x0028,0x0004);
00716       photInt->SetValue("RGB ");
00717 
00718       if(PixelReadConverter->GetRGB())
00719       {
00720          PixelWriteConverter->SetReadData(PixelReadConverter->GetRGB(),
00721                                           PixelReadConverter->GetRGBSize());
00722       }
00723       else // Raw data
00724       {
00725          PixelWriteConverter->SetReadData(PixelReadConverter->GetRaw(),
00726                                           PixelReadConverter->GetRawSize());
00727       }
00728 
00729       std::string vr = "OB";
00730       if( FileInternal->GetBitsAllocated()>8 )
00731          vr = "OW";
00732       if( FileInternal->GetBitsAllocated()==24 ) // For RGB ACR files 
00733          vr = "OB";
00734       BinEntry *pixel = 
00735          CopyBinEntry(GetFile()->GetGrPixel(),GetFile()->GetNumPixel(),vr);
00736       pixel->SetValue(GDCM_BINLOADED);
00737       pixel->SetBinArea(PixelWriteConverter->GetData(),false);
00738       pixel->SetLength(PixelWriteConverter->GetDataSize());
00739 
00740       Archive->Push(spp);
00741       Archive->Push(planConfig);
00742       Archive->Push(photInt);
00743       Archive->Push(pixel);
00744 
00745       // Remove any LUT
00746       Archive->Push(0x0028,0x1101);
00747       Archive->Push(0x0028,0x1102);
00748       Archive->Push(0x0028,0x1103);
00749       Archive->Push(0x0028,0x1201);
00750       Archive->Push(0x0028,0x1202);
00751       Archive->Push(0x0028,0x1203);
00752 
00753       // For old ACR-NEMA
00754       // Thus, we have a RGB image and the bits allocated = 24 and 
00755       // samples per pixels = 1 (in the read file)
00756       if(FileInternal->GetBitsAllocated()==24) 
00757       {
00758          ValEntry *bitsAlloc = CopyValEntry(0x0028,0x0100);
00759          bitsAlloc->SetValue("8 ");
00760 
00761          ValEntry *bitsStored = CopyValEntry(0x0028,0x0101);
00762          bitsStored->SetValue("8 ");
00763 
00764          ValEntry *highBit = CopyValEntry(0x0028,0x0102);
00765          highBit->SetValue("7 ");
00766 
00767          Archive->Push(bitsAlloc);
00768          Archive->Push(bitsStored);
00769          Archive->Push(highBit);
00770       }
00771    }
00772    else
00773    {
00774       SetWriteToRaw();
00775    }
00776 }

void gdcm::FileHelper::SetWriteType FileType  format  )  [inline]
 

Tells the writer which format want to write (ImplicitVR, ExplicitVR, ACR, ACR_LIBIDO).

Definition at line 121 of file gdcmFileHelper.h.

00121 { WriteType = format;       };

void gdcm::FileHelper::SetWriteTypeToAcr  )  [inline]
 

Tells the writer we want to write as ACR-NEMA.

Definition at line 116 of file gdcmFileHelper.h.

References gdcm::ACR.

Referenced by WriteAcr(), and vtkGdcmWriter::WriteDcmFile().

00116 { SetWriteType(ACR);        };

void gdcm::FileHelper::SetWriteTypeToAcrLibido  )  [inline]
 

Tells the writer we want to write as LibIDO.

Definition at line 118 of file gdcmFileHelper.h.

References gdcm::ACR_LIBIDO.

Referenced by vtkGdcmWriter::WriteDcmFile().

00118 { SetWriteType(ACR_LIBIDO); };

void gdcm::FileHelper::SetWriteTypeToDcmExplVR  )  [inline]
 

Tells the writer we want to write as Explicit VR.

Definition at line 114 of file gdcmFileHelper.h.

References gdcm::ExplicitVR.

Referenced by WriteDcmExplVR(), and vtkGdcmWriter::WriteDcmFile().

00114 { SetWriteType(ExplicitVR); };

void gdcm::FileHelper::SetWriteTypeToDcmImplVR  )  [inline]
 

Tells the writer we want to write as Implicit VR.

Definition at line 112 of file gdcmFileHelper.h.

References gdcm::ImplicitVR.

Referenced by vtkGdcmWriter::WriteDcmFile(), and WriteDcmImplVR().

00112 { SetWriteType(ImplicitVR); };

bool gdcm::FileHelper::Write std::string const &  fileName  ) 
 

Writes on disk A SINGLE Dicom file,.

Parameters:
fileName name of the file to be created (any already existing file is overwritten)
Returns:
false if write fails

Todo:
the best trick would be *change* the recognition code but pb expected if user deals with, e.g. COMPLEX images

Definition at line 538 of file gdcmFileHelper.cxx.

References gdcm::ACR, gdcm::ACR_LIBIDO, CheckWriteIntegrity(), gdcm::ExplicitVR, FileInternal, gdcm::ImplicitVR, RestoreWrite(), RestoreWriteFileType(), RestoreWriteOfLibido(), SetWriteFileTypeToACR(), SetWriteFileTypeToExplicitVR(), SetWriteFileTypeToImplicitVR(), SetWriteToLibido(), SetWriteToNoLibido(), SetWriteToRaw(), SetWriteToRGB(), WMODE_RAW, WMODE_RGB, gdcm::File::Write(), WriteMode, and WriteType.

Referenced by WriteAcr(), WriteDcmExplVR(), vtkGdcmWriter::WriteDcmFile(), and WriteDcmImplVR().

00539 {
00540    switch(WriteType)
00541    {
00542       case ImplicitVR:
00543          SetWriteFileTypeToImplicitVR();
00544          break;
00545       case ExplicitVR:
00546          SetWriteFileTypeToExplicitVR();
00547          break;
00548       case ACR:
00549       case ACR_LIBIDO:
00550          SetWriteFileTypeToACR();
00551          break;
00552       default:
00553          SetWriteFileTypeToExplicitVR();
00554    }
00555 
00556    // --------------------------------------------------------------
00557    // Special Patch to allow gdcm to re-write ACR-LibIDO formated images
00558    //
00559    // if recognition code tells us we dealt with a LibIDO image
00560    // we reproduce on disk the switch between lineNumber and columnNumber
00561    // just before writting ...
00564    if( WriteType == ACR_LIBIDO )
00565    {
00566       SetWriteToLibido();
00567    }
00568    else
00569    {
00570       SetWriteToNoLibido();
00571    }
00572    // ----------------- End of Special Patch ----------------
00573   
00574    switch(WriteMode)
00575    {
00576       case WMODE_RAW :
00577          SetWriteToRaw();
00578          break;
00579       case WMODE_RGB :
00580          SetWriteToRGB();
00581          break;
00582    }
00583 
00584    bool check = CheckWriteIntegrity();
00585    if(check)
00586    {
00587       check = FileInternal->Write(fileName,WriteType);
00588    }
00589 
00590    RestoreWrite();
00591    RestoreWriteFileType();
00592 
00593    // --------------------------------------------------------------
00594    // Special Patch to allow gdcm to re-write ACR-LibIDO formated images
00595    // 
00596    // ...and we restore the header to be Dicom Compliant again 
00597    // just after writting
00598    RestoreWriteOfLibido();
00599    // ----------------- End of Special Patch ----------------
00600 
00601    return check;
00602 }

bool gdcm::FileHelper::WriteAcr std::string const &  fileName  ) 
 

Writes on disk A SINGLE Dicom file, using the ACR-NEMA convention NO test is performed on processor "Endiannity". (a l'attention des logiciels cliniques qui ne prennent en entrée QUE des images ACR ...

Warning:
if a DICOM_V3 header is supplied, groups < 0x0008 and shadow groups are ignored

NO TEST is performed on processor "Endiannity".

Parameters:
fileName name of the file to be created (any already existing file is overwritten)
Returns:
false if write fails

Definition at line 526 of file gdcmFileHelper.cxx.

References SetWriteTypeToAcr(), and Write().

00527 {
00528    SetWriteTypeToAcr();
00529    return Write(fileName);
00530 }

bool gdcm::FileHelper::WriteDcmExplVR std::string const &  fileName  ) 
 

Writes on disk A SINGLE Dicom file, using the Explicit Value Representation convention NO test is performed on processor "Endiannity".

Parameters:
fileName name of the file to be created (any already existing file is overwritten)
Returns:
false if write fails

Definition at line 506 of file gdcmFileHelper.cxx.

References SetWriteTypeToDcmExplVR(), and Write().

00507 {
00508    SetWriteTypeToDcmExplVR();
00509    return Write(fileName);
00510 }

bool gdcm::FileHelper::WriteDcmImplVR std::string const &  fileName  ) 
 

Writes on disk A SINGLE Dicom file, using the Implicit Value Representation convention NO test is performed on processor "Endiannity".

Parameters:
fileName name of the file to be created (any already existing file is overwritten)
Returns:
false if write fails

Definition at line 491 of file gdcmFileHelper.cxx.

References SetWriteTypeToDcmImplVR(), and Write().

00492 {
00493    SetWriteTypeToDcmImplVR();
00494    return Write(fileName);
00495 }

bool gdcm::FileHelper::WriteRawData std::string const &  fileName  ) 
 

Writes on disk A SINGLE Dicom file NO test is performed on processor "Endiannity". It's up to the user to call his Reader properly.

Parameters:
fileName name of the file to be created (any already existing file is over written)
Returns:
false if write fails

Definition at line 448 of file gdcmFileHelper.cxx.

References gdcmErrorMacro, gdcmWarningMacro, gdcm::PixelReadConvert::GetRaw(), gdcm::PixelReadConvert::GetRawSize(), gdcm::PixelReadConvert::GetRGB(), gdcm::PixelReadConvert::GetRGBSize(), gdcm::PixelWriteConvert::GetUserData(), gdcm::PixelWriteConvert::GetUserDataSize(), PixelReadConverter, and PixelWriteConverter.

00449 {
00450   std::ofstream fp1(fileName.c_str(), std::ios::out | std::ios::binary );
00451    if (!fp1)
00452    {
00453       gdcmWarningMacro( "Fail to open (write) file:" << fileName.c_str());
00454       return false;
00455    }
00456 
00457    if( PixelWriteConverter->GetUserData() )
00458    {
00459       fp1.write( (char*)PixelWriteConverter->GetUserData(), 
00460                  PixelWriteConverter->GetUserDataSize() );
00461    }
00462    else if ( PixelReadConverter->GetRGB() )
00463    {
00464       fp1.write( (char*)PixelReadConverter->GetRGB(), 
00465                  PixelReadConverter->GetRGBSize());
00466    }
00467    else if ( PixelReadConverter->GetRaw() )
00468    {
00469       fp1.write( (char*)PixelReadConverter->GetRaw(), 
00470                  PixelReadConverter->GetRawSize());
00471    }
00472    else
00473    {
00474       gdcmErrorMacro( "Nothing written." );
00475    }
00476 
00477    fp1.close();
00478 
00479    return true;
00480 }


Member Data Documentation

DocEntryArchive* gdcm::FileHelper::Archive [private]
 

Pointer to the DocEntryArchive (used while writting process).

Definition at line 180 of file gdcmFileHelper.h.

File* gdcm::FileHelper::FileInternal [private]
 

gdcm::File to use to load the file

Definition at line 162 of file gdcmFileHelper.h.

Referenced by CheckWriteIntegrity(), CopyBinEntry(), CopyValEntry(), FileHelper(), GetImageData(), GetImageDataIntoVector(), GetRaw(), Initialize(), InsertBinEntry(), InsertSeqEntry(), InsertValEntry(), Print(), SetBinEntry(), SetValEntry(), SetWriteToLibido(), SetWriteToNoLibido(), SetWriteToRaw(), SetWriteToRGB(), Write(), and ~FileHelper().

bool gdcm::FileHelper::Parsed [private]
 

Wether already parsed or not.

Definition at line 170 of file gdcmFileHelper.h.

PixelReadConvert* gdcm::FileHelper::PixelReadConverter [private]
 

Pointer to the PixelReadConverter.

Definition at line 174 of file gdcmFileHelper.h.

Referenced by GetImageData(), GetImageDataIntoVector(), GetImageDataRawSize(), GetImageDataSize(), GetLutRGBA(), GetRaw(), GetRawData(), GetRawDataSize(), GetRGBData(), GetRGBDataSize(), Initialize(), Print(), SetWriteToRaw(), SetWriteToRGB(), WriteRawData(), and ~FileHelper().

PixelWriteConvert* gdcm::FileHelper::PixelWriteConverter [private]
 

Pointer to the PixelWriteConverter.

Definition at line 176 of file gdcmFileHelper.h.

Referenced by CheckWriteIntegrity(), GetImageData(), GetImageDataRawSize(), GetImageDataSize(), GetUserData(), GetUserDataSize(), Initialize(), SetUserData(), SetWriteToRaw(), SetWriteToRGB(), WriteRawData(), and ~FileHelper().

int gdcm::Base::PrintLevel [protected, inherited]
 

Amount of printed details for each Dicom Entries : 0 : stands for the least detail level.

Definition at line 53 of file gdcmBase.h.

Referenced by gdcm::Base::Base().

bool gdcm::FileHelper::SelfHeader [private]
 

Whether the underlying gdcm::File was loaded by the constructor or passed to the constructor. When false the destructor is in charge of deletion.

Definition at line 167 of file gdcmFileHelper.h.

Referenced by FileHelper(), and ~FileHelper().

FileMode gdcm::FileHelper::WriteMode [private]
 

(WMODE_RAW, WMODE_RGB)

Definition at line 184 of file gdcmFileHelper.h.

Referenced by CheckWriteIntegrity(), Initialize(), and Write().

FileType gdcm::FileHelper::WriteType [private]
 

(ImplicitVR, ExplicitVR, ACR, ACR_LIBIDO)

Definition at line 186 of file gdcmFileHelper.h.

Referenced by Initialize(), and Write().


The documentation for this class was generated from the following files:
Generated on Thu Feb 10 22:18:10 2005 for gdcm by doxygen 1.3.6