GDCM_NAME_SPACE::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_NAME_SPACE::FileHelper:

Inheritance graph
[legend]
Collaboration diagram for GDCM_NAME_SPACE::FileHelper:

Collaboration graph
[legend]
List of all members.

Public Types

enum  FileMode { WMODE_RAW, WMODE_RGB }

Public Member Functions

void Print (std::ostream &os=std::cout, std::string const &indent="")
 Prints the FileInternal + info on PixelReadConvertor.
FileGetFile ()
 Accessor to File.
void SetLoadMode (int loadMode)
 Sets the LoadMode of the internal gdcm::File as a boolean string. NO_SEQ, NO_SHADOW, NO_SHADOWSEQ ... (nothing more, right now) WARNING : before using NO_SHADOW, be sure *all* your files contain accurate values in the 0x0000 element (if any) of *each* Shadow Group. The parser will fail if the size is wrong !
void SetFileName (std::string const &fileName)
 Sets the LoadMode of the internal gdcm::File.
bool Load ()
 Loader.
void SetUserFunction (VOID_FUNCTION_PUINT8_PFILE_POINTER userFunc)
 to allow user to modify pixel order (e.g. Mirror, UpsideDown,...)
bool SetEntryString (std::string const &content, uint16_t group, uint16_t elem)
 Accesses an existing DataEntry through its (group, element) and modifies its content with the given value.
bool SetEntryBinArea (uint8_t *content, int lgth, uint16_t group, uint16_t elem)
 Accesses an existing DataEntry through its (group, element) and modifies its content with the given value.
DataEntryInsertEntryString (std::string const &content, uint16_t group, uint16_t elem, const VRKey &vr)
 Modifies the value of a given DataEntry when it exists. Creates it with the given value when unexistant.
DataEntryInsertEntryBinArea (uint8_t *binArea, int lgth, uint16_t group, uint16_t elem, const VRKey &vr)
 Modifies the value of a given DataEntry when it exists. Creates 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)
 Adds an empty SeqEntry (remove any existing entry with same group,elem).
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 ()
 brings pixels into memory :
  • 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 ()
 brings pixels into memory :
  • 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

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. Even when a LUT is found, the data are not expanded to RGB!
size_t GetRawDataSize ()
 Get the image data size from the file. Even when a LUT is found, the data are not expanded to RGB!
void ConvertFixGreyLevels (uint8_t *data, size_t size)
 Deal with Grey levels i.e. re-arange them to have low values = dark, high values = bright.
uint8_t * GetLutRGBA ()
 Access to the underlying PixelReadConverter RGBA LUT.
int GetLutItemNumber ()
 Access to the underlying PixelReadConverter RGBA LUT Item Number.
int GetLutItemSize ()
 Access to the underlying PixelReadConverter RGBA LUT Item Size.
void SetWriteModeToRaw ()
 Tells the writer we want to keep 'Grey pixels + Palettes color' when possible (as opposed to convert 'Palettes color' to RGB).
void SetWriteModeToRGB ()
 Tells the writer we want to write RGB image when possible (as opposed 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 SetWriteTypeToJPEG ()
 Tells the writer we want to write as JPEG.
void SetWriteTypeToJPEG2000 ()
 Tells the writer we want to write as JPEG2000.
void SetWriteType (FileType format)
 Tells the writer which format we want to write (ImplicitVR, ExplicitVR, ACR, ACR_LIBIDO).
FileType GetWriteType ()
 Gets the format we talled the write we wanted to write (ImplicitVR, ExplicitVR, ACR, ACR_LIBIDO).
void SetPhotometricInterpretationToMonochrome1 ()
 1 : white=0, black=high value
void SetPhotometricInterpretationToMonochrome2 ()
 2 : black=0, white=high value (default)
int GetPhotometricInterpretation ()
 1 : white=0, black=high value
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 "Endianity".
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 SetContentType (ImageContentType c)
 We have to deal with 4 *very* different cases : -1) user created ex nihilo his own image and wants to write it as a Dicom image. USER_OWN_IMAGE -2) user modified the pixels of an existing image. FILTERED_IMAGE -3) user created a new image, using existing images (eg MIP, MPR, cartography image) CREATED_IMAGE -4) user modified/added some tags *without processing* the pixels (anonymization... UNMODIFIED_PIXELS_IMAGE.
void CallStartMethod ()
 CallStartMethod.
void CallProgressMethod ()
 CallProgressMethod.
void CallEndMethod ()
 CallEndMethod.
void Delete ()
 Delete the object.
void Register ()
 Register the object.
void Unregister ()
 Unregister the object.
const unsigned long & GetRefCount () const
 Get the reference counting.
void SetPrintLevel (int level)
 Sets the print level for the Dicom Header Elements.
int GetPrintLevel ()
 Gets the print level for the Dicom Entries.

Static Public Member Functions

static FileHelperNew ()
 Constructs a FileHelper with a RefCounter.
static FileHelperNew (File *header)
 Constructs a FileHelper with a RefCounter from a fileHelper.

Protected 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 ( GetImageDataSize() + GetImageData() methods).
 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 ( GetImageDataSize() + GetImageData() methods).
 ~FileHelper ()
 canonical destructor
bool CheckWriteIntegrity ()
 Verifies the size of the user given PixelData.
void SetWriteToRaw ()
 Updates the File to write RAW data (as opposed to RGB data) (modifies, when necessary, photochromatic interpretation, bits allocated, Pixels element VR) WARNING : if SetPhotometricInterpretationToMonochrome1() was called before Pixel Elements if modified :-(.
void SetWriteToRGB ()
 Updates the File to write RGB data (as opposed to RAW data) (modifies, when necessary, photochromatic interpretation, samples per pixel, Planar configuration, bits allocated, bits stored, high bit -ACR 24 bits- Pixels element VR, pushes out the LUT, ).
void RestoreWrite ()
 Restore the File write mode.
void SetWriteFileTypeToACR ()
 Pushes out the whole group 0002 FIXME : better, set a flag to tell the writer not to write it ... FIXME : method should probably have an other name ! SetWriteFileTypeToACR is NOT opposed to SetWriteFileTypeToExplicitVR and SetWriteFileTypeToImplicitVR.
void SetWriteFileTypeToJPEG ()
 Sets in the File the TransferSyntax to 'JPEG'.
void SetWriteFileTypeToJPEG2000 ()
 Sets in the File the TransferSyntax to 'JPEG2000'.
void SetWriteFileTypeToExplicitVR ()
 Sets in the File the TransferSyntax to 'Explicit VR Little Endian".
void SetWriteFileTypeToImplicitVR ()
 Sets in the File the TransferSyntax to 'Implicit VR Little Endian".
void RestoreWriteFileType ()
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.
DataEntryCopyDataEntry (uint16_t group, uint16_t elem, const VRKey &vr=GDCM_VRUNKNOWN)
 Duplicates a DataEntry or creates it.
void CheckMandatoryElements ()
 This method is called automatically, just before writting in order to produce a 'True Dicom V3' image.
void CheckMandatoryEntry (uint16_t group, uint16_t elem, std::string value, const VRKey &vr=GDCM_VRUNKNOWN)
void SetMandatoryEntry (uint16_t group, uint16_t elem, std::string value, const VRKey &vr=GDCM_VRUNKNOWN)
void CopyMandatoryEntry (uint16_t group, uint16_t elem, std::string value, const VRKey &vr=GDCM_VRUNKNOWN)
void RestoreWriteMandatory ()
 Restore in the File the initial group 0002.

Protected Attributes

float Progress
 value of the ??? for any progress bar
bool Abort
int PrintLevel
 Amount of printed details for each Dicom Entries : 0 : stands for the least detail level.

Private Member Functions

 gdcmTypeMacro (FileHelper)
void Initialize ()
 Factorization for various forms of constructors.
uint8_t * GetRaw ()
 Reads/[decompresses] the pixels, *without* making RGB from Palette Colors.

Private Attributes

FileFileInternal
 gdcm::File to use to load the file
bool Parsed
 Whether 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)
VOID_FUNCTION_PUINT8_PFILE_POINTER UserFunction
 Pointer to a user supplied function to allow modification of pixel order (e.g. : Mirror, UpsideDown, 90°Rotation, ...) use as : void userSuppliedFunction(uint8_t *im, gdcm::File *f) NB : the "uint8_t *" type of first param is just for prototyping. User will Cast it according what he founds with f->GetPixelType() See vtkgdcmSerieViewer for an example.
ImageContentType ContentType
 only user knows what he did before asking the image to be written
  • he created ex nihilo his own image
  • he just applied a mathematical process on the pixels
  • he created a new image, using existing images (eg MIP, MPR,cartography)
  • he anonymized and image (*no* modif on the pixels)

int PhotometricInterpretation
 1 : white=0, black=high value 2 : black=0, white=high value (default)

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 44 of file gdcmFileHelper.h.


Member Enumeration Documentation

enum GDCM_NAME_SPACE::FileHelper::FileMode
 

Enumerator:
WMODE_RAW 
WMODE_RGB 

Definition at line 49 of file gdcmFileHelper.h.

00050    {
00051       WMODE_RAW,
00052       WMODE_RGB
00053    };


Constructor & Destructor Documentation

GDCM_NAME_SPACE::FileHelper::FileHelper  )  [protected]
 

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 ( GetImageDataSize() + GetImageData() methods).

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 175 of file gdcmFileHelper.cxx.

References FileInternal, Initialize(), and GDCM_NAME_SPACE::File::New().

00176 { 
00177    FileInternal = File::New( );
00178    Initialize();
00179 }

GDCM_NAME_SPACE::FileHelper::FileHelper File header  )  [protected]
 

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 ( GetImageDataSize() + GetImageData() methods).

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 195 of file gdcmFileHelper.cxx.

References FileInternal, gdcmAssertMacro, GDCM_NAME_SPACE::PixelReadConvert::GrabInformationsFromFile(), Initialize(), GDCM_NAME_SPACE::File::IsReadable(), PixelReadConverter, and GDCM_NAME_SPACE::RefCounter::Register().

00196 {
00197    gdcmAssertMacro(header);
00198 
00199    FileInternal = header;
00200    FileInternal->Register();
00201    Initialize();
00202    if ( FileInternal->IsReadable() )
00203    {
00204       PixelReadConverter->GrabInformationsFromFile( FileInternal, this );
00205    }
00206 }

GDCM_NAME_SPACE::FileHelper::~FileHelper  )  [protected]
 

canonical destructor

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

Definition at line 213 of file gdcmFileHelper.cxx.

References Archive, FileInternal, PixelReadConverter, PixelWriteConverter, and GDCM_NAME_SPACE::RefCounter::Unregister().

00214 { 
00215    if ( PixelReadConverter )
00216    {
00217       delete PixelReadConverter;
00218    }
00219    if ( PixelWriteConverter )
00220    {
00221       delete PixelWriteConverter;
00222    }
00223    if ( Archive )
00224    {
00225       delete Archive;
00226    }
00227 
00228    FileInternal->Unregister();
00229 }


Member Function Documentation

void GDCM_NAME_SPACE::FileHelper::CallEndMethod  ) 
 

CallEndMethod.

Definition at line 1964 of file gdcmFileHelper.cxx.

References GDCM_NAME_SPACE::CMD_ENDPROGRESS, GDCM_NAME_SPACE::CommandManager::ExecuteCommand(), and Progress.

01965 {
01966    Progress = 1.0f;
01967    CommandManager::ExecuteCommand(this,CMD_ENDPROGRESS);
01968 }

void GDCM_NAME_SPACE::FileHelper::CallProgressMethod  ) 
 

CallProgressMethod.

Definition at line 1956 of file gdcmFileHelper.cxx.

References GDCM_NAME_SPACE::CMD_PROGRESS, and GDCM_NAME_SPACE::CommandManager::ExecuteCommand().

01957 {
01958    CommandManager::ExecuteCommand(this,CMD_PROGRESS);
01959 }

void GDCM_NAME_SPACE::FileHelper::CallStartMethod  ) 
 

CallStartMethod.

Definition at line 1946 of file gdcmFileHelper.cxx.

References Abort, GDCM_NAME_SPACE::CMD_STARTPROGRESS, GDCM_NAME_SPACE::CommandManager::ExecuteCommand(), and Progress.

01947 {
01948    Progress = 0.0f;
01949    Abort    = false;
01950    CommandManager::ExecuteCommand(this,CMD_STARTPROGRESS);
01951 }

void GDCM_NAME_SPACE::FileHelper::CheckMandatoryElements  )  [protected]
 

This method is called automatically, just before writting in order to produce a 'True Dicom V3' image.

We cannot know *how* the user made the File : (reading an old ACR-NEMA file or a not very clean DICOM file ...) Just before writting :

  • we check the Entries
  • we create the mandatory entries if they are missing
  • we modify the values if necessary
  • we push the sensitive entries to the Archive The writing process will restore the entries as they where before entering FileHelper::CheckMandatoryElements, so the user will always see the entries just as they were before he decided to write.

Note:
  • Entries whose type is 1 are mandatory, with a mandatory value
  • Entries whose type is 1c are mandatory-inside-a-Sequence, with a mandatory value
  • Entries whose type is 2 are mandatory, with an optional value
  • Entries whose type is 2c are mandatory-inside-a-Sequence, with an optional value
  • Entries whose type is 3 are optional
Todo:
  • warn the user if we had to add some entries : even if a mandatory entry is missing, we add it, with a default value (we don't want to give up the writting process if user forgot to specify Lena's Patient ID, for instance ...)
  • read the whole PS 3.3 Part of DICOM (890 pages) and write a *full* checker (probably one method per Modality ...) Any contribution is welcome.
  • write a user callable full checker, to allow post reading and/or pre writting image consistency check.
Todo:
: find if there is a rule!

Definition at line 1448 of file gdcmFileHelper.cxx.

References GDCM_NAME_SPACE::ACR, GDCM_NAME_SPACE::ACR_LIBIDO, GDCM_NAME_SPACE::SQItem::AddEntry(), GDCM_NAME_SPACE::SeqEntry::AddSQItem(), Archive, CheckMandatoryEntry(), ContentType, CopyDataEntry(), CopyMandatoryEntry(), GDCM_NAME_SPACE::Util::CreateUniqueUID(), GDCM_NAME_SPACE::RefCounter::Delete(), FileInternal, GDCM_NAME_SPACE::FILTERED_IMAGE, gdcmDebugMacro, GDCM_NAME_SPACE::DocEntrySet::GetDataEntry(), GDCM_NAME_SPACE::DocEntrySet::GetEntryString(), GDCM_NAME_SPACE::Util::GetFileMetaInformationVersion(), GDCM_NAME_SPACE::DataEntry::GetString(), GDCM_NAME_SPACE::Util::GetVersion(), GDCM_NAME_SPACE::DataEntry::New(), GDCM_NAME_SPACE::SQItem::New(), GDCM_NAME_SPACE::SeqEntry::New(), GDCM_NAME_SPACE::DocEntryArchive::Push(), GDCM_NAME_SPACE::DataEntry::SetBinArea(), GDCM_NAME_SPACE::DocEntry::SetLength(), GDCM_NAME_SPACE::DataEntry::SetString(), GDCM_NAME_SPACE::UNMODIFIED_PIXELS_IMAGE, GDCM_NAME_SPACE::USER_OWN_IMAGE, and WriteType.

Referenced by Write().

01449 {
01450    std::string sop =  Util::CreateUniqueUID();
01451 
01452    // --------------------- For Meta Elements ---------------------
01453    // just to remember : 'official' 0002 group
01454    if ( WriteType != ACR && WriteType != ACR_LIBIDO )
01455    {
01456      // Group 000002 (Meta Elements) already pushed out
01457   
01458    //0002 0000 UL 1 Meta Group Length
01459    //0002 0001 OB 1 File Meta Information Version
01460    //0002 0002 UI 1 Media Storage SOP Class UID
01461    //0002 0003 UI 1 Media Storage SOP Instance UID
01462    //0002 0010 UI 1 Transfer Syntax UID
01463    //0002 0012 UI 1 Implementation Class UID
01464    //0002 0013 SH 1 Implementation Version Name
01465    //0002 0016 AE 1 Source Application Entity Title
01466    //0002 0100 UI 1 Private Information Creator
01467    //0002 0102 OB 1 Private Information
01468 
01469    // Push out 'ACR-NEMA-special' entries, if any
01470       Archive->Push(0x0008,0x0001); // Length to End
01471       Archive->Push(0x0008,0x0010); // Recognition Code
01472       Archive->Push(0x0028,0x0005); // Image Dimension
01473 
01474    // Create them if not found
01475    // Always modify the value
01476    // Push the entries to the archive.
01477       CopyMandatoryEntry(0x0002,0x0000,"0","UL");
01478 
01479       DataEntry *e_0002_0001 = CopyDataEntry(0x0002,0x0001, "OB");
01480       e_0002_0001->SetBinArea((uint8_t*)Util::GetFileMetaInformationVersion(),
01481                                false);
01482       e_0002_0001->SetLength(2);
01483       Archive->Push(e_0002_0001);
01484       e_0002_0001->Delete(); 
01485 
01486       if ( ContentType == FILTERED_IMAGE || ContentType == UNMODIFIED_PIXELS_IMAGE)
01487       {      
01488    // we keep the original 'Media Storage SOP Class UID', we default it if missing
01489          CheckMandatoryEntry(0x0002,0x0002,"1.2.840.10008.5.1.4.1.1.7","UI"); 
01490       }
01491       else
01492       {
01493    // It's *not* an image comming straight from a source. We force
01494    // 'Media Storage SOP Class UID'  --> [Secondary Capture Image Storage]
01495          CopyMandatoryEntry(0x0002,0x0002,"1.2.840.10008.5.1.4.1.1.7","UI");
01496       }
01497 
01498    // 'Media Storage SOP Instance UID'
01499       CopyMandatoryEntry(0x0002,0x0003,sop,"UI");
01500 
01501    // 'Implementation Class UID'
01502    // FIXME : in all examples we have, 0x0002,0x0012 is not so long :
01503    //         seems to be Root UID + 4 digits (?)
01504       CopyMandatoryEntry(0x0002,0x0012,Util::CreateUniqueUID(),"UI");
01505 
01506    // 'Implementation Version Name'
01507       std::string version = "GDCM ";
01508       version += Util::GetVersion();
01509       CopyMandatoryEntry(0x0002,0x0013,version,"SH");
01510    }
01511 
01512    // --------------------- For DataSet ---------------------
01513 
01514    if ( ContentType != USER_OWN_IMAGE) // when it's not a user made image
01515    { 
01516 
01517       gdcmDebugMacro( "USER_OWN_IMAGE (1)");
01518    // If 'SOP Class UID' exists ('true DICOM' image)
01519    // we create the 'Source Image Sequence' SeqEntry
01520    // to hold informations about the Source Image
01521   
01522       DataEntry *e_0008_0016 = FileInternal->GetDataEntry(0x0008, 0x0016);
01523       if ( e_0008_0016 )
01524       {
01525       // Create 'Source Image Sequence' SeqEntry
01526 //     SeqEntry *sis = SeqEntry::New (
01527 //            Global::GetDicts()->GetDefaultPubDict()->GetEntry(0x0008, 0x2112) );
01528       SeqEntry *sis = SeqEntry::New (0x0008, 0x2112);
01529       SQItem *sqi = SQItem::New(1);
01530       // (we assume 'SOP Instance UID' exists too) 
01531       // create 'Referenced SOP Class UID'
01532 //     DataEntry *e_0008_1150 = DataEntry::New(
01533 //            Global::GetDicts()->GetDefaultPubDict()->GetEntry(0x0008, 0x1150) );
01534       DataEntry *e_0008_1150 = DataEntry::New(0x0008, 0x1150, "UI");
01535       e_0008_1150->SetString( e_0008_0016->GetString());
01536       sqi->AddEntry(e_0008_1150);
01537       e_0008_1150->Delete();
01538       
01539       // create 'Referenced SOP Instance UID'
01540       DataEntry *e_0008_0018 = FileInternal->GetDataEntry(0x0008, 0x0018);
01541 //      DataEntry *e_0008_1155 = DataEntry::New(
01542 //            Global::GetDicts()->GetDefaultPubDict()->GetEntry(0x0008, 0x1155) );
01543       DataEntry *e_0008_1155 = DataEntry::New(0x0008, 0x1155, "UI");
01544       e_0008_1155->SetString( e_0008_0018->GetString());
01545       sqi->AddEntry(e_0008_1155);
01546       e_0008_1155->Delete();
01547 
01548       sis->AddSQItem(sqi,1);
01549       sqi->Delete();
01550 
01551       // temporarily replaces any previous 'Source Image Sequence' 
01552       Archive->Push(sis);
01553       sis->Delete();
01554  
01555       // FIXME : is 'Image Type' *really* depending on the presence of 'SOP Class UID'?
01556        if ( ContentType == FILTERED_IMAGE)      
01557       // the user *knows* he just modified the pixels
01558       // the image is no longer an 'Original' one
01559          CopyMandatoryEntry(0x0008,0x0008,"DERIVED\\PRIMARY","CS");    
01560       }
01561    }
01562       
01563    if ( ContentType == FILTERED_IMAGE || ContentType == UNMODIFIED_PIXELS_IMAGE)
01564    {      
01565    // we keep the original 'Media Storage SOP Class UID', we default it if missing (it should be present !)
01566          CheckMandatoryEntry(0x0008,0x0016,"1.2.840.10008.5.1.4.1.1.7","UI");      
01567    }
01568    else
01569    {
01570    // It's *not* an image comming straight from a source. We force
01571    // 'Media Storage SOP Class UID'  --> [Secondary Capture Image Storage]
01572          CopyMandatoryEntry(0x0008,0x0016,"1.2.840.10008.5.1.4.1.1.7", "UI");      
01573    }
01574      
01575    Archive->Push(0x0028,0x005); // [Image Dimensions (RET)
01576    // Push out 'LibIDO-special' entries, if any
01577    Archive->Push(0x0028,0x0015);
01578    Archive->Push(0x0028,0x0016);
01579    Archive->Push(0x0028,0x0017);
01580    Archive->Push(0x0028,0x0198);  // very old versions
01581    Archive->Push(0x0028,0x0199);
01582 
01583    // Replace deprecated 0028 0012 US Planes   
01584    // by new             0028 0008 IS Number of Frames
01585 
01587    DataEntry *e_0028_0012 = FileInternal->GetDataEntry(0x0028, 0x0012);
01588    if ( e_0028_0012 )
01589    {
01590       CopyMandatoryEntry(0x0028, 0x0008,e_0028_0012->GetString(),"IS");
01591       Archive->Push(0x0028,0x0012);      
01592    }
01593 
01594    // Deal with the pb of (Bits Stored = 12)
01595    // - we're gonna write the image as Bits Stored = 16
01596    if ( FileInternal->GetEntryString(0x0028,0x0100) ==  "12")
01597    {
01598       CopyMandatoryEntry(0x0028,0x0100,"16","US");
01599    }
01600 
01601    // Check if user wasn't drunk ;-)
01602 
01603    std::ostringstream s;
01604    // check 'Bits Allocated' vs decent values
01605    int nbBitsAllocated = FileInternal->GetBitsAllocated();
01606    if ( (nbBitsAllocated == 0 || nbBitsAllocated > 32)
01607      || ( nbBitsAllocated > 8 && nbBitsAllocated <16) )
01608    {
01609       CopyMandatoryEntry(0x0028,0x0100,"16","US");
01610       gdcmWarningMacro("(0028,0100) changed from "
01611          << nbBitsAllocated << " to 16 for consistency purpose");
01612       nbBitsAllocated = 16; 
01613    }
01614    // check 'Bits Stored' vs 'Bits Allocated'   
01615    int nbBitsStored = FileInternal->GetBitsStored();
01616    if ( nbBitsStored == 0 || nbBitsStored > nbBitsAllocated )
01617    {
01618       s.str("");
01619       s << nbBitsAllocated;
01620       CopyMandatoryEntry(0x0028,0x0101,s.str(),"US");
01621       gdcmWarningMacro("(0028,0101) changed from "
01622                        << nbBitsStored << " to " << nbBitsAllocated
01623                        << " for consistency purpose" );
01624       nbBitsStored = nbBitsAllocated; 
01625     }
01626    // check 'Hight Bit Position' vs 'Bits Allocated' and 'Bits Stored'
01627    int highBitPosition = FileInternal->GetHighBitPosition();
01628    if ( highBitPosition == 0 || 
01629         highBitPosition > nbBitsAllocated-1 ||
01630         highBitPosition < nbBitsStored-1  )
01631    {
01632       s.str("");
01633       s << nbBitsStored - 1; 
01634       CopyMandatoryEntry(0x0028,0x0102,s.str(),"US");
01635       gdcmWarningMacro("(0028,0102) changed from "
01636                        << highBitPosition << " to " << nbBitsAllocated-1
01637                        << " for consistency purpose");
01638    }
01639 
01640    // check Pixel Representation (default it as 0 -unsigned-)
01641 
01642    DataEntry *e_0028_0103 = FileInternal->GetDataEntry(0x0028, 0x0103);
01643    if ( !e_0028_0103 )
01644    {
01645       gdcmWarningMacro("PixelRepresentation (0028,0103) is supposed to be mandatory");
01646       CopyMandatoryEntry(0x0028, 0x0103,"0","US"); 
01647    }
01648    else
01649    {
01650       int sign = (int)e_0028_0103->GetValue(0);
01651       if (sign !=1 && sign !=0)
01652       {
01653          gdcmWarningMacro("PixelRepresentation (0028,0103) is supposed to be =1 or =0");
01654          CopyMandatoryEntry(0x0028, 0x0103,"0","US");
01655       }
01656    }
01657 
01658    std::string pixelSpacing = FileInternal->GetEntryString(0x0028,0x0030);
01659    if ( pixelSpacing == GDCM_UNFOUND )
01660    {
01661       pixelSpacing = "1.0\\1.0";
01662        // if missing, Pixel Spacing forced to "1.0\1.0"
01663       CopyMandatoryEntry(0x0028,0x0030,pixelSpacing,"DS");
01664    }
01665    
01666    // 'Imager Pixel Spacing' : defaulted to 'Pixel Spacing'
01667    // --> This one is the *legal* one !
01668    if ( ContentType != USER_OWN_IMAGE)
01669    //  we write it only when we are *sure* the image comes from
01670    //         an imager (see also 0008,0x0064)
01671       CheckMandatoryEntry(0x0018,0x1164,pixelSpacing,"DS");
01672 
01673 /*
01675 
01676 // See page 73 of ACR-NEMA_300-1988.pdf !
01677 
01678 // 0020,0020 : Patient Orientation :
01679 Patient direction of the first row and
01680 column of the images. The first entry id the direction of the raws, given by the
01681 direction of the last pixel in the first row from the first pixel in tha row.
01682 the second entry is the direction of the columns, given by the direction of the
01683 last pixel in the first column from the first pixel in that column.
01684 L : Left, F : Feet, A : Anterior, P : Posterior.
01685 Up to 3 letters can be used in combination to indicate oblique planes.
01686 
01687 //0020,0030 Image Position (RET)
01688 x,y,z coordinates im mm of the first pixel in the image
01689 
01690 // 0020,0035 Image Orientation (RET)
01691 Direction cosines of the R axis of the image system with respect to the
01692 equipment coordinate axes x,y,z, followed by direction cosines of the C axis of
01693 the image system with respect to the same axes
01694 
01695 //0020,0050 Location
01696 An image location reference, standard for the modality (such as CT bed position),
01697 used to indicate position. Calculation of position for other purposes
01698 is only from (0020,0030) and (0020,0035)
01699 */
01700 
01701 /*
01702 // if imagePositionPatient    not found, default it with imagePositionRet,    if any
01703 // if imageOrientationPatient not found, default it with imageOrientationRet, if any
01704 
01705    std::string imagePositionRet        = FileInternal->GetEntryString(0x0020,0x0030);
01706    std::string imageOrientationRet     = FileInternal->GetEntryString(0x0020,0x0035);
01707    std::string imagePositionPatient    = FileInternal->GetEntryString(0x0020,0x0032);
01708    std::string imageOrientationPatient = FileInternal->GetEntryString(0x0020,0x0037);
01709 
01710    if(  imagePositionPatient == GDCM_UNFOUND && imageOrientationPatient == GDCM_UNFOUND
01711      && imagePositionRet     != GDCM_UNFOUND && imageOrientationRet     != GDCM_UNFOUND)
01712    {
01713       CopyMandatoryEntry(0x0020, 0x0032,imagePositionRet,"DS");
01714       Archive->Push(0x0020,0x0030); 
01715       CopyMandatoryEntry(0x0020, 0x0037,imageOrientationRet,"DS");
01716       Archive->Push(0x0020,0x0035);
01717    }
01718 */
01719 
01720    // Samples Per Pixel (type 1) : default to grayscale
01721    CheckMandatoryEntry(0x0028,0x0002,"1","US");
01722 
01723    // --- Check UID-related Entries ---
01724  
01725    // At the end, not to overwrite the original ones,
01726    // needed by 'Referenced SOP Instance UID', 'Referenced SOP Class UID'
01727    // 'SOP Instance UID'  
01728    CopyMandatoryEntry(0x0008,0x0018,sop,"UI");
01729 
01730    if ( ContentType == USER_OWN_IMAGE)
01731    {
01732       gdcmDebugMacro( "USER_OWN_IMAGE (2)");
01733        // Conversion Type.
01734        // Other possible values are :
01735        // See PS 3.3, Page 408
01736 
01737        // DV = Digitized Video
01738        // DI = Digital Interface 
01739        // DF = Digitized Film
01740        // WSD = Workstation
01741        // SD = Scanned Document
01742        // SI = Scanned Image
01743        // DRW = Drawing
01744        // SYN = Synthetic Image
01745 
01746       CheckMandatoryEntry(0x0008,0x0064,"SYN","CS"); // Why not?
01747    } 
01748 /*
01749    if ( ContentType == CREATED_IMAGE)
01750    {
01752    
01753    }
01754 */
01755 
01756    // ---- The user will never have to take any action on the following ----
01757 
01758    // new value for 'SOP Instance UID'
01759    //SetMandatoryEntry(0x0008,0x0018,Util::CreateUniqueUID());
01760 
01761    // Instance Creation Date
01762    const std::string &date = Util::GetCurrentDate();
01763    CopyMandatoryEntry(0x0008,0x0012,date,"DA");
01764 
01765    // Instance Creation Time
01766    const std::string &time = Util::GetCurrentTime();
01767    CopyMandatoryEntry(0x0008,0x0013,time,"TM");
01768 
01769    // Study Date
01770    CheckMandatoryEntry(0x0008,0x0020,date,"DA");
01771    // Study Time
01772    CheckMandatoryEntry(0x0008,0x0030,time,"TM");
01773 
01774    // Accession Number
01775    //CopyMandatoryEntry(0x0008,0x0050,"");
01776    CheckMandatoryEntry(0x0008,0x0050,"","SH");
01777    
01778 
01779    // ----- Add Mandatory Entries if missing ---
01780    // Entries whose type is 1 are mandatory, with a mandatory value
01781    // Entries whose type is 1c are mandatory-inside-a-Sequence,
01782    //                          with a mandatory value
01783    // Entries whose type is 2 are mandatory, with an optional value
01784    // Entries whose type is 2c are mandatory-inside-a-Sequence,
01785    //                          with an optional value
01786    // Entries whose type is 3 are optional
01787 
01788    // 'Study Instance UID'
01789    // Keep the value if exists
01790    // The user is allowed to create his own Study, 
01791    //          keeping the same 'Study Instance UID' for various images
01792    // The user may add images to a 'Manufacturer Study',
01793    //          adding new Series to an already existing Study 
01794    CheckMandatoryEntry(0x0020,0x000d,Util::CreateUniqueUID(),"UI");
01795 
01796    // 'Serie Instance UID'
01797    // Keep the value if exists
01798    // The user is allowed to create his own Series, 
01799    // keeping the same 'Serie Instance UID' for various images
01800    // The user shouldn't add any image to a 'Manufacturer Serie'
01801    // but there is no way no to prevent him for doing that 
01802    CheckMandatoryEntry(0x0020,0x000e,Util::CreateUniqueUID(),"UI");
01803 
01804    // Study ID
01805    CheckMandatoryEntry(0x0020,0x0010,"","SH");
01806 
01807    // Series Number
01808    CheckMandatoryEntry(0x0020,0x0011,"","IS");
01809 
01810    // Instance Number
01811    CheckMandatoryEntry(0x0020,0x0013,"","IS");
01812 
01813    // Patient Orientation
01814    // Can be computed from (0020|0037) :  Image Orientation (Patient)
01815    GDCM_NAME_SPACE::Orientation *o = GDCM_NAME_SPACE::Orientation::New();
01816    std::string ori = o->GetOrientation ( FileInternal );
01817    o->Delete();
01818    if (ori != "\\" && ori != GDCM_UNFOUND)
01819       CheckMandatoryEntry(0x0020,0x0020,ori,"CS");
01820    else
01821       CheckMandatoryEntry(0x0020,0x0020,"","CS");
01822 
01823    // Default Patient Position to HFS
01824    CheckMandatoryEntry(0x0018,0x5100,"HFS","CS");
01825 
01826    // Modality : if missing we set it to 'OTher'
01827    CheckMandatoryEntry(0x0008,0x0060,"OT","CS");
01828 
01829    // Manufacturer : if missing we set it to 'GDCM Factory'
01830    CheckMandatoryEntry(0x0008,0x0070,"GDCM Factory","LO");
01831 
01832    // Institution Name : if missing we set it to 'GDCM Hospital'
01833    CheckMandatoryEntry(0x0008,0x0080,"GDCM Hospital","LO");
01834 
01835    // Patient's Name : if missing, we set it to 'GDCM^Patient'
01836    CheckMandatoryEntry(0x0010,0x0010,"GDCM^Patient","PN");
01837 
01838    // Patient ID : some clinical softwares *demand* it although it's a 'type 2' entry.
01839    CheckMandatoryEntry(0x0010,0x0020,"gdcm ID","LO");
01840 
01841    // Patient's Birth Date : 'type 2' entry -> must exist, value not mandatory
01842    CheckMandatoryEntry(0x0010,0x0030,"","DA");
01843 
01844    // Patient's Sex :'type 2' entry -> must exist, value not mandatory
01845    CheckMandatoryEntry(0x0010,0x0040,"","CS");
01846 
01847    // Referring Physician's Name :'type 2' entry -> must exist, value not mandatory
01848    CheckMandatoryEntry(0x0008,0x0090,"","PN");
01849 
01850  /*
01851    // Deal with element 0x0000 (group length) of each group.
01852    // First stage : get all the different Groups
01853 
01854   GroupHT grHT;
01855   DocEntry *d = FileInternal->GetFirstEntry();
01856   while(d)
01857   {
01858     grHT[d->GetGroup()] = 0;
01859     d=FileInternal->GetNextEntry();
01860   }
01861   // Second stage : add the missing ones (if any)
01862   for (GroupHT::iterator it = grHT.begin(); it != grHT.end(); ++it)  
01863   {
01864       CheckMandatoryEntry(it->first, 0x0000, "0"); 
01865   }    
01866   // Third stage : update all 'zero level' groups length
01867 */
01868 
01869 
01870    if (PhotometricInterpretation == 1)
01871    {
01872    }
01873 } 

void GDCM_NAME_SPACE::FileHelper::CheckMandatoryEntry uint16_t  group,
uint16_t  elem,
std::string  value,
const VRKey vr = GDCM_VRUNKNOWN
[protected]
 

Definition at line 1875 of file gdcmFileHelper.cxx.

References Archive, GDCM_NAME_SPACE::RefCounter::Delete(), FileInternal, GDCM_NAME_SPACE::DocEntrySet::GetDataEntry(), GDCM_NAME_SPACE::DataEntry::New(), GDCM_NAME_SPACE::DocEntryArchive::Push(), and GDCM_NAME_SPACE::DataEntry::SetString().

Referenced by CheckMandatoryElements().

01876 {
01877    DataEntry *entry = FileInternal->GetDataEntry(group,elem);
01878    if ( !entry )
01879    {
01880       //entry = DataEntry::New(Global::GetDicts()->GetDefaultPubDict()->GetEntry(group,elem));
01881       entry = DataEntry::New(group,elem,vr);
01882       entry->SetString(value);
01883       Archive->Push(entry);
01884       entry->Delete();
01885    }    
01886 }

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

Verifies the size of the user given PixelData.

Todo:
move all those 'protected' methods to 'private' since FileHelper is not derived in anything!

Definition at line 851 of file gdcmFileHelper.cxx.

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

Referenced by Write().

00852 {
00853    if ( PixelWriteConverter->GetUserData() )
00854    {
00855       int numberBitsAllocated = FileInternal->GetBitsAllocated();
00856       if ( numberBitsAllocated == 0 || numberBitsAllocated == 12 )
00857       {
00858          gdcmWarningMacro( "numberBitsAllocated changed from " 
00859                           << numberBitsAllocated << " to 16 " 
00860                           << " for consistency purpose" );
00861          numberBitsAllocated = 16;
00862       }
00863 
00864       size_t decSize = FileInternal->GetXSize()
00865                      * FileInternal->GetYSize() 
00866                      * FileInternal->GetZSize()
00867                      * FileInternal->GetTSize()     
00868                      * FileInternal->GetSamplesPerPixel()
00869                      * ( numberBitsAllocated / 8 );
00870       size_t rgbSize = decSize;
00871       if ( FileInternal->HasLUT() )
00872          rgbSize = decSize * 3;
00873 
00874       switch(WriteMode)
00875       {
00876          case WMODE_RAW :
00877             if ( decSize!=PixelWriteConverter->GetUserDataSize() )
00878             {
00879                gdcmWarningMacro( "Data size (Raw) is incorrect. Should be " 
00880                            << decSize << " / Found :" 
00881                            << PixelWriteConverter->GetUserDataSize() );
00882                return false;
00883             }
00884             break;
00885          case WMODE_RGB :
00886             if ( rgbSize!=PixelWriteConverter->GetUserDataSize() )
00887             {
00888                gdcmWarningMacro( "Data size (RGB) is incorrect. Should be " 
00889                           << decSize << " / Found " 
00890                           << PixelWriteConverter->GetUserDataSize() );
00891                return false;
00892             }
00893             break;
00894       }
00895    }
00896    return true;
00897 }

void GDCM_NAME_SPACE::FileHelper::ConvertFixGreyLevels uint8_t *  data,
size_t  size
 

Deal with Grey levels i.e. re-arange them to have low values = dark, high values = bright.

Definition at line 2023 of file gdcmFileHelper.cxx.

References FileInternal, GDCM_NAME_SPACE::File::GetBitsAllocated(), GDCM_NAME_SPACE::File::GetBitsStored(), and GDCM_NAME_SPACE::File::IsSignedPixelData().

02024 {
02025    uint32_t i; // to please M$VC6
02026    int16_t j;
02027 
02028    // Number of Bits Allocated for storing a Pixel is defaulted to 16
02029    // when absent from the file.
02030    int bitsAllocated = FileInternal->GetBitsAllocated();
02031    if ( bitsAllocated == 0 )
02032    {
02033       bitsAllocated = 16;
02034    }
02035 
02036    else if (bitsAllocated > 8 && bitsAllocated < 16 && bitsAllocated != 12)
02037    {
02038       bitsAllocated = 16;
02039    }   
02040    // Number of "Bits Stored", defaulted to number of "Bits Allocated"
02041    // when absent from the file.
02042    int bitsStored = FileInternal->GetBitsStored();
02043    if ( bitsStored == 0 )
02044    {
02045       bitsStored = bitsAllocated;
02046    }
02047 
02048    if (!FileInternal->IsSignedPixelData())
02049    {
02050       if ( bitsAllocated == 8 )
02051       {
02052          uint8_t *deb = (uint8_t *)raw;
02053          for (i=0; i<rawSize; i++)      
02054          {
02055             *deb = 255 - *deb;
02056             deb++;
02057          }
02058          return;
02059       }
02060 
02061       if ( bitsAllocated == 16 )
02062       {
02063          uint16_t mask =1;
02064          for (j=0; j<bitsStored-1; j++)
02065          {
02066             mask = (mask << 1) +1; // will be fff when BitsStored=12
02067          }
02068 
02069          uint16_t *deb = (uint16_t *)raw;
02070          for (i=0; i<rawSize/2; i++)      
02071          {
02072             *deb = mask - *deb;
02073             deb++;
02074          }
02075          return;
02076        }
02077    }
02078    else
02079    {
02080       if ( bitsAllocated == 8 )
02081       {
02082          uint8_t smask8 = 255;
02083          uint8_t *deb = (uint8_t *)raw;
02084          for (i=0; i<rawSize; i++)      
02085          {
02086             *deb = smask8 - *deb;
02087             deb++;
02088          }
02089          return;
02090       }
02091       if ( bitsAllocated == 16 )
02092       {
02093          uint16_t smask16 = 65535;
02094          uint16_t *deb = (uint16_t *)raw;
02095          for (i=0; i<rawSize/2; i++)      
02096          {
02097             *deb = smask16 - *deb;
02098             deb++;
02099          }
02100          return;
02101       }
02102    }
02103 }

DataEntry * GDCM_NAME_SPACE::FileHelper::CopyDataEntry uint16_t  group,
uint16_t  elem,
const VRKey vr = GDCM_VRUNKNOWN
[protected]
 

Duplicates a DataEntry or creates it.

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

Definition at line 1252 of file gdcmFileHelper.cxx.

References GDCM_NAME_SPACE::DataEntry::Copy(), FileInternal, GDCM_NAME_SPACE::GDCM_VRUNKNOWN, GDCM_NAME_SPACE::ElementSet::GetDocEntry(), GetFile(), GDCM_NAME_SPACE::DocEntry::GetVR(), GDCM_NAME_SPACE::DataEntry::New(), and GDCM_NAME_SPACE::DocEntrySet::NewDataEntry().

Referenced by CheckMandatoryElements(), CopyMandatoryEntry(), SetWriteFileTypeToExplicitVR(), SetWriteFileTypeToImplicitVR(), SetWriteFileTypeToJPEG(), SetWriteFileTypeToJPEG2000(), SetWriteToLibido(), SetWriteToNoLibido(), and SetWriteToRGB().

01254 {
01255    DocEntry *oldE = FileInternal->GetDocEntry(group, elem);
01256    DataEntry *newE;
01257 
01258    if ( oldE && vr != GDCM_VRUNKNOWN ) 
01259       if ( oldE->GetVR() != vr )
01260          oldE = NULL;
01261 
01262    if ( oldE )
01263    {
01264       newE = DataEntry::New(group, elem, vr);
01265       newE->Copy(oldE);
01266    }
01267    else
01268    {
01269       newE = GetFile()->NewDataEntry(group, elem, vr);
01270    }
01271 
01272    return newE;
01273 }

void GDCM_NAME_SPACE::FileHelper::CopyMandatoryEntry uint16_t  group,
uint16_t  elem,
std::string  value,
const VRKey vr = GDCM_VRUNKNOWN
[protected]
 

Definition at line 1898 of file gdcmFileHelper.cxx.

References Archive, CopyDataEntry(), GDCM_NAME_SPACE::RefCounter::Delete(), GDCM_NAME_SPACE::DocEntryArchive::Push(), and GDCM_NAME_SPACE::DataEntry::SetString().

Referenced by CheckMandatoryElements().

01899 {
01900    DataEntry *entry = CopyDataEntry(group,elem,vr);
01901    entry->SetString(value);
01902    Archive->Push(entry);
01903    entry->Delete();
01904 }

void GDCM_NAME_SPACE::RefCounter::Delete  )  [inline, inherited]
 

Delete the object.

Remarks:
The object is deleted only if its reference counting is to zero

Definition at line 41 of file gdcmRefCounter.h.

Referenced by GDCM_NAME_SPACE::SerieHelper::AddFileName(), GDCM_NAME_SPACE::Document::Backtrack(), CheckMandatoryElements(), CheckMandatoryEntry(), CopyMandatoryEntry(), GDCM_NAME_SPACE::Dict::DoTheLoadingJob(), GDCM_NAME_SPACE::FillDefaultDataDict(), GDCM_NAME_SPACE::DicomDirObject::FillObject(), vtkGdcmReader::GetFileInformation(), GDCM_NAME_SPACE::DocEntrySet::InsertEntryBinArea(), GDCM_NAME_SPACE::DocEntrySet::InsertEntryString(), GDCM_NAME_SPACE::DocEntrySet::InsertSeqEntry(), vtkGdcmReader::LoadFileInformation(), GDCM_NAME_SPACE::DicomDir::NewMeta(), GDCM_NAME_SPACE::DicomDirStudy::NewVisit(), GDCM_NAME_SPACE::Document::ReadNextDocEntry(), GDCM_NAME_SPACE::DicomDir::SetElement(), SetMandatoryEntry(), SetWriteFileTypeToExplicitVR(), SetWriteFileTypeToImplicitVR(), SetWriteFileTypeToJPEG(), SetWriteFileTypeToJPEG2000(), SetWriteToLibido(), GDCM_NAME_SPACE::DicomDir::~DicomDir(), GDCM_NAME_SPACE::DictSet::~DictSet(), and GDCM_NAME_SPACE::Global::~Global().

00041 { Unregister(); }

GDCM_NAME_SPACE::FileHelper::gdcmTypeMacro FileHelper   )  [private]
 

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

Accessor to File.

Definition at line 63 of file gdcmFileHelper.h.

Referenced by CopyDataEntry(), vtkGdcmReader::LoadImageInMemory(), RestoreWrite(), and SetLoadMode().

00063 { return FileInternal; }

uint8_t * GDCM_NAME_SPACE::FileHelper::GetImageData  ) 
 

brings pixels into memory :

  • 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. (uint8_t is just for prototyping. feel free to cast) NULL if alloc fails

Definition at line 393 of file gdcmFileHelper.cxx.

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

00394 {
00395    if ( PixelWriteConverter->GetUserData() )
00396    {
00397       return PixelWriteConverter->GetUserData();
00398    }
00399 
00400    if ( ! GetRaw() )
00401    {
00402       // If the decompression failed nothing can be done.
00403       return 0;
00404    }
00405 
00406    if ( FileInternal->HasLUT() && PixelReadConverter->BuildRGBImage() )
00407    {
00408       return PixelReadConverter->GetRGB();
00409    }
00410    else
00411    {
00412       // When no LUT or LUT conversion fails, return the Raw
00413       return PixelReadConverter->GetRaw();
00414    }
00415 }

uint8_t * GDCM_NAME_SPACE::FileHelper::GetImageDataRaw  ) 
 

brings pixels into memory :

  • 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. (uint8_t is just for prototyping. feel free to cast) NULL if alloc fails

Definition at line 428 of file gdcmFileHelper.cxx.

References GetRaw().

Referenced by vtkGdcmReader::LoadImageInMemory().

00429 {
00430    return GetRaw();
00431 }

size_t GDCM_NAME_SPACE::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 372 of file gdcmFileHelper.cxx.

References GDCM_NAME_SPACE::PixelWriteConvert::GetUserData(), GDCM_NAME_SPACE::PixelWriteConvert::GetUserDataSize(), and PixelWriteConverter.

00373 {
00374    if ( PixelWriteConverter->GetUserData() )
00375    {
00376       return PixelWriteConverter->GetUserDataSize();
00377    }
00378    return PixelReadConverter->GetRawSize();
00379 }

size_t GDCM_NAME_SPACE::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 356 of file gdcmFileHelper.cxx.

References GDCM_NAME_SPACE::PixelWriteConvert::GetUserData(), GDCM_NAME_SPACE::PixelWriteConvert::GetUserDataSize(), and PixelWriteConverter.

Referenced by vtkGdcmReader::LoadImageInMemory().

00357 {
00358    if ( PixelWriteConverter->GetUserData() )
00359    {
00360       return PixelWriteConverter->GetUserDataSize();
00361    }
00362    return PixelReadConverter->GetRGBSize();
00363 }

int GDCM_NAME_SPACE::FileHelper::GetLutItemNumber  ) 
 

Access to the underlying PixelReadConverter RGBA LUT Item Number.

Definition at line 605 of file gdcmFileHelper.cxx.

References GDCM_NAME_SPACE::PixelReadConvert::GetLutItemNumber(), and PixelReadConverter.

00606 {
00607    return PixelReadConverter->GetLutItemNumber();
00608 }

int GDCM_NAME_SPACE::FileHelper::GetLutItemSize  ) 
 

Access to the underlying PixelReadConverter RGBA LUT Item Size.

Definition at line 613 of file gdcmFileHelper.cxx.

References GDCM_NAME_SPACE::PixelReadConvert::GetLutItemSize(), and PixelReadConverter.

00614 {
00615    return PixelReadConverter->GetLutItemSize();
00616 }

uint8_t * GDCM_NAME_SPACE::FileHelper::GetLutRGBA  ) 
 

Access to the underlying PixelReadConverter RGBA LUT.

Definition at line 595 of file gdcmFileHelper.cxx.

References GDCM_NAME_SPACE::PixelReadConvert::BuildLUTRGBA(), GDCM_NAME_SPACE::PixelReadConvert::GetLutRGBA(), and PixelReadConverter.

Referenced by vtkGdcmReader::LoadImageInMemory().

00596 {
00597    if ( PixelReadConverter->GetLutRGBA() ==0 )
00598       PixelReadConverter->BuildLUTRGBA();
00599    return PixelReadConverter->GetLutRGBA();
00600 }

int GDCM_NAME_SPACE::FileHelper::GetPhotometricInterpretation  )  [inline]
 

1 : white=0, black=high value

Definition at line 153 of file gdcmFileHelper.h.

00153                                       {
00154                                 return PhotometricInterpretation; }

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

Gets the print level for the Dicom Entries.

Definition at line 50 of file gdcmBase.h.

00050 { return PrintLevel; }

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

Reads/[decompresses] the pixels, *without* making RGB from Palette Colors.

Returns:
the pixels area, whatever its type (uint8_t is just for prototyping : feel free to Cast it)

Definition at line 1996 of file gdcmFileHelper.cxx.

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

Referenced by GetImageDataRaw().

01997 {
01998    PixelReadConverter->SetUserFunction( UserFunction );
01999 
02000    uint8_t *raw = PixelReadConverter->GetRaw();
02001    if ( ! raw )
02002    {
02003       // The Raw image migth not be loaded yet:
02004       std::ifstream *fp = FileInternal->OpenFile();
02005       PixelReadConverter->ReadAndDecompressPixelData( fp );
02006       if ( fp ) 
02007          FileInternal->CloseFile();
02008 
02009       raw = PixelReadConverter->GetRaw();
02010       if ( ! raw )
02011       {
02012          gdcmWarningMacro( "Read/decompress of pixel data apparently went wrong.");
02013          return 0;
02014       }
02015    }
02016    return raw;
02017 }

uint8_t * GDCM_NAME_SPACE::FileHelper::GetRawData  ) 
 

Get the image data from the file. Even when a LUT is found, the data are not expanded to RGB!

Definition at line 578 of file gdcmFileHelper.cxx.

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

00579 {
00580    return PixelReadConverter->GetRaw();
00581 }

size_t GDCM_NAME_SPACE::FileHelper::GetRawDataSize  ) 
 

Get the image data size from the file. Even when a LUT is found, the data are not expanded to RGB!

Definition at line 587 of file gdcmFileHelper.cxx.

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

00588 {
00589    return PixelReadConverter->GetRawSize();
00590 }

const unsigned long& GDCM_NAME_SPACE::RefCounter::GetRefCount  )  const [inline, inherited]
 

Get the reference counting.

Returns:
Reference count

Definition at line 59 of file gdcmRefCounter.h.

00060    {
00061       return RefCount;
00062    }

uint8_t * GDCM_NAME_SPACE::FileHelper::GetRGBData  ) 
 

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

Definition at line 560 of file gdcmFileHelper.cxx.

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

00561 {
00562    return PixelReadConverter->GetRGB();
00563 }

size_t GDCM_NAME_SPACE::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 569 of file gdcmFileHelper.cxx.

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

00570 {
00571    return PixelReadConverter->GetRGBSize();
00572 }

uint8_t * GDCM_NAME_SPACE::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 542 of file gdcmFileHelper.cxx.

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

00543 {
00544    return PixelWriteConverter->GetUserData();
00545 }

size_t GDCM_NAME_SPACE::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 551 of file gdcmFileHelper.cxx.

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

00552 {
00553    return PixelWriteConverter->GetUserDataSize();
00554 }

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

Gets the Write Mode ( ).

Definition at line 124 of file gdcmFileHelper.h.

00124 { return WriteMode;         }

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

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

Definition at line 145 of file gdcmFileHelper.h.

00145 { return WriteType;         }

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

Factorization for various forms of constructors.

Definition at line 1975 of file gdcmFileHelper.cxx.

References Archive, ContentType, GDCM_NAME_SPACE::ExplicitVR, FileInternal, PhotometricInterpretation, PixelReadConverter, PixelWriteConverter, GDCM_NAME_SPACE::USER_OWN_IMAGE, UserFunction, WMODE_RAW, WriteMode, and WriteType.

Referenced by FileHelper().

01976 {
01977    UserFunction = 0;
01978    ContentType = USER_OWN_IMAGE;
01979 
01980    WriteMode = WMODE_RAW;
01981    WriteType = ExplicitVR;
01982    
01983    PhotometricInterpretation = 2; // Black = 0
01984 
01985    PixelReadConverter  = new PixelReadConvert;
01986    PixelWriteConverter = new PixelWriteConvert;
01987    Archive = new DocEntryArchive( FileInternal );
01988 }

DataEntry * GDCM_NAME_SPACE::FileHelper::InsertEntryBinArea uint8_t *  binArea,
int  lgth,
uint16_t  group,
uint16_t  elem,
const VRKey vr
 

Modifies the value of a given DataEntry when it exists. Creates 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
vr Value Representation of the DataElement to be inserted
Returns:
pointer to the modified/created DataEntry (NULL when creation failed).

Definition at line 328 of file gdcmFileHelper.cxx.

References FileInternal, and GDCM_NAME_SPACE::DocEntrySet::InsertEntryBinArea().

00331 {
00332    return FileInternal->InsertEntryBinArea(binArea, lgth, group, elem, vr);
00333 }

DataEntry * GDCM_NAME_SPACE::FileHelper::InsertEntryString std::string const &  content,
uint16_t  group,
uint16_t  elem,
const VRKey vr
 

Modifies the value of a given DataEntry when it exists. Creates 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
vr Value Representation of the DataElement to be inserted
Returns:
pointer to the modified/created DataEntry (NULL when creation failed).

Definition at line 309 of file gdcmFileHelper.cxx.

References FileInternal, and GDCM_NAME_SPACE::DocEntrySet::InsertEntryString().

Referenced by SetImageInformation().

00312 {
00313    return FileInternal->InsertEntryString(content, group, elem, vr);
00314 }

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

Adds an empty SeqEntry (remove any existing entry with same group,elem).

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

Definition at line 343 of file gdcmFileHelper.cxx.

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

00344 {
00345    return FileInternal->InsertSeqEntry(group, elem);
00346 }

bool GDCM_NAME_SPACE::FileHelper::Load  ) 
 

Loader.

Returns:
false if file cannot be open or no swap info was found, or no tag was found.

Definition at line 260 of file gdcmFileHelper.cxx.

References FileInternal, GDCM_NAME_SPACE::PixelReadConvert::GrabInformationsFromFile(), GDCM_NAME_SPACE::File::Load(), and PixelReadConverter.

00261 { 
00262    if ( !FileInternal->Load() )
00263       return false;
00264 
00265    PixelReadConverter->GrabInformationsFromFile( FileInternal, this );
00266    return true;
00267 }

static FileHelper* GDCM_NAME_SPACE::FileHelper::New File header  )  [inline, static]
 

Constructs a FileHelper with a RefCounter from a fileHelper.

Definition at line 58 of file gdcmFileHelper.h.

00058 {return new FileHelper(header);}

static FileHelper* GDCM_NAME_SPACE::FileHelper::New  )  [inline, static]
 

Constructs a FileHelper with a RefCounter.

Definition at line 56 of file gdcmFileHelper.h.

Referenced by vtkGdcmReader::LoadImageInMemory(), and vtkGdcmWriter::WriteDcmFile().

00056 {return new FileHelper();}

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

Prints the FileInternal + info on PixelReadConvertor.

Parameters:
os ostream we want to print in
indent (unused)

Reimplemented from GDCM_NAME_SPACE::Base.

Definition at line 2111 of file gdcmFileHelper.cxx.

References FileInternal, GDCM_NAME_SPACE::File::IsReadable(), PixelReadConverter, GDCM_NAME_SPACE::PixelReadConvert::Print(), GDCM_NAME_SPACE::ElementSet::Print(), GDCM_NAME_SPACE::Base::PrintLevel, and GDCM_NAME_SPACE::Base::SetPrintLevel().

02112 {
02113    FileInternal->SetPrintLevel(PrintLevel);
02114    FileInternal->Print(os);
02115 
02116    if ( FileInternal->IsReadable() )
02117    {
02118       PixelReadConverter->SetPrintLevel(PrintLevel);
02119       PixelReadConverter->Print(os);
02120    }
02121 }

void GDCM_NAME_SPACE::RefCounter::Register  )  [inline, inherited]
 

Register the object.

Remarks:
It increments the reference counting

Definition at line 46 of file gdcmRefCounter.h.

Referenced by GDCM_NAME_SPACE::SQItem::AddEntry(), GDCM_NAME_SPACE::SeqEntry::AddSQItem(), GDCM_NAME_SPACE::SeqEntry::Copy(), GDCM_NAME_SPACE::DicomDir::Copy(), FileHelper(), GDCM_NAME_SPACE::DocEntrySet::GetDictEntry(), GDCM_NAME_SPACE::DocEntry::GetName(), GDCM_NAME_SPACE::DocEntry::GetVM(), GDCM_NAME_SPACE::DocEntrySet::InsertEntryString(), GDCM_NAME_SPACE::CommandManager::InSetCommand(), GDCM_NAME_SPACE::DocEntryArchive::Push(), and GDCM_NAME_SPACE::SeqEntry::SetDelimitationItem().

00046 { RefCount++; }

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

Restore the File write mode.

Definition at line 1060 of file gdcmFileHelper.cxx.

References Archive, GetFile(), and GDCM_NAME_SPACE::DocEntryArchive::Restore().

Referenced by Write().

01061 {
01062    Archive->Restore(0x0028,0x0002);
01063    Archive->Restore(0x0028,0x0004);
01064    
01065    Archive->Restore(0x0028,0x0006);
01066    Archive->Restore(GetFile()->GetGrPixel(),GetFile()->GetNumPixel());
01067 
01068    // For old ACR-NEMA (24 bits problem)
01069    Archive->Restore(0x0028,0x0100);
01070    Archive->Restore(0x0028,0x0101);
01071    Archive->Restore(0x0028,0x0102);
01072 
01073    // For the LUT
01074    Archive->Restore(0x0028,0x1101);
01075    Archive->Restore(0x0028,0x1102);
01076    Archive->Restore(0x0028,0x1103);
01077    Archive->Restore(0x0028,0x1201);
01078    Archive->Restore(0x0028,0x1202);
01079    Archive->Restore(0x0028,0x1203);
01080 
01081    // For the Palette Color Lookup Table UID
01082    Archive->Restore(0x0028,0x1203); 
01083 
01084    // group 0002 may be pushed out for ACR-NEMA writting purposes 
01085    Archive->Restore(0x0002,0x0000);
01086    Archive->Restore(0x0002,0x0001);
01087    Archive->Restore(0x0002,0x0002);
01088    Archive->Restore(0x0002,0x0003);
01089    Archive->Restore(0x0002,0x0010);
01090    Archive->Restore(0x0002,0x0012);
01091    Archive->Restore(0x0002,0x0013);
01092    Archive->Restore(0x0002,0x0016);
01093    Archive->Restore(0x0002,0x0100);
01094    Archive->Restore(0x0002,0x0102);
01095 
01096 }

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

void GDCM_NAME_SPACE::FileHelper::RestoreWriteMandatory  )  [protected]
 

Restore in the File the initial group 0002.

Definition at line 1909 of file gdcmFileHelper.cxx.

References Archive, and GDCM_NAME_SPACE::DocEntryArchive::Restore().

01910 {
01911    // group 0002 may be pushed out for ACR-NEMA writting purposes 
01912    Archive->Restore(0x0002,0x0000);
01913    Archive->Restore(0x0002,0x0001);
01914    Archive->Restore(0x0002,0x0002);
01915    Archive->Restore(0x0002,0x0003);
01916    Archive->Restore(0x0002,0x0010);
01917    Archive->Restore(0x0002,0x0012);
01918    Archive->Restore(0x0002,0x0013);
01919    Archive->Restore(0x0002,0x0016);
01920    Archive->Restore(0x0002,0x0100);
01921    Archive->Restore(0x0002,0x0102);
01922 
01923    // FIXME : Check if none is missing !
01924    
01925    Archive->Restore(0x0008,0x0012);
01926    Archive->Restore(0x0008,0x0013);
01927    Archive->Restore(0x0008,0x0016);
01928    Archive->Restore(0x0008,0x0018);
01929    Archive->Restore(0x0008,0x0060);
01930    Archive->Restore(0x0008,0x0070);
01931    Archive->Restore(0x0008,0x0080);
01932    Archive->Restore(0x0008,0x0090);
01933    Archive->Restore(0x0008,0x2112);
01934 
01935    Archive->Restore(0x0010,0x0010);
01936    Archive->Restore(0x0010,0x0030);
01937    Archive->Restore(0x0010,0x0040);
01938 
01939    Archive->Restore(0x0020,0x000d);
01940    Archive->Restore(0x0020,0x000e);
01941 }

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

Restore the Write format.

Definition at line 1232 of file gdcmFileHelper.cxx.

References Archive, and GDCM_NAME_SPACE::DocEntryArchive::Restore().

Referenced by Write().

01233 {
01234    Archive->Restore(0x0028,0x0010);
01235    Archive->Restore(0x0028,0x0011);
01236    Archive->Restore(0x0008,0x0010);
01237 
01238    // Restore 'LibIDO-special' entries, if any
01239    Archive->Restore(0x0028,0x0015);
01240    Archive->Restore(0x0028,0x0016);
01241    Archive->Restore(0x0028,0x0017);
01242    Archive->Restore(0x0028,0x00199);
01243 }

void GDCM_NAME_SPACE::FileHelper::SetContentType ImageContentType  c  )  [inline]
 

We have to deal with 4 *very* different cases : -1) user created ex nihilo his own image and wants to write it as a Dicom image. USER_OWN_IMAGE -2) user modified the pixels of an existing image. FILTERED_IMAGE -3) user created a new image, using existing images (eg MIP, MPR, cartography image) CREATED_IMAGE -4) user modified/added some tags *without processing* the pixels (anonymization... UNMODIFIED_PIXELS_IMAGE.

Definition at line 175 of file gdcmFileHelper.h.

Referenced by vtkGdcmWriter::WriteDcmFile().

00175 { ContentType = c; }

bool GDCM_NAME_SPACE::FileHelper::SetEntryBinArea uint8_t *  content,
int  lgth,
uint16_t  group,
uint16_t  elem
 

Accesses an existing DataEntry through its (group, element) and modifies its 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
Returns:
false if DataEntry not found

Definition at line 293 of file gdcmFileHelper.cxx.

References FileInternal, and GDCM_NAME_SPACE::DocEntrySet::SetEntryBinArea().

00295 {
00296    return FileInternal->SetEntryBinArea(content, lgth, group, elem);
00297 }

bool GDCM_NAME_SPACE::FileHelper::SetEntryString std::string const &  content,
uint16_t  group,
uint16_t  elem
 

Accesses an existing DataEntry through its (group, element) and modifies its 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
Returns:
false if DataEntry not found

Definition at line 277 of file gdcmFileHelper.cxx.

References FileInternal, and GDCM_NAME_SPACE::DocEntrySet::SetEntryString().

00279 { 
00280    return FileInternal->SetEntryString(content, group, elem);
00281 }

void GDCM_NAME_SPACE::FileHelper::SetFileName std::string const &  fileName  ) 
 

Sets the LoadMode of the internal gdcm::File.

Parameters:
fileName name of the file to be open

Definition at line 250 of file gdcmFileHelper.cxx.

References FileInternal, and GDCM_NAME_SPACE::Document::SetFileName().

00251 {
00252    FileInternal->SetFileName( fileName );
00253 }

void GDCM_NAME_SPACE::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 pixels since the size is given in bytes)
expectedSize total image size, *in Bytes*

Definition at line 509 of file gdcmFileHelper.cxx.

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

00510 {
00511    PixelWriteConverter->SetUserData(inData, expectedSize);
00512 }

void GDCM_NAME_SPACE::FileHelper::SetLoadMode int  loadMode  ) 
 

Sets the LoadMode of the internal gdcm::File as a boolean string. NO_SEQ, NO_SHADOW, NO_SHADOWSEQ ... (nothing more, right now) WARNING : before using NO_SHADOW, be sure *all* your files contain accurate values in the 0x0000 element (if any) of *each* Shadow Group. The parser will fail if the size is wrong !

Parameters:
loadMode Load mode to be used

Definition at line 242 of file gdcmFileHelper.cxx.

References GetFile(), and GDCM_NAME_SPACE::Document::SetLoadMode().

00243 { 
00244    GetFile()->SetLoadMode( loadMode ); 
00245 }

void GDCM_NAME_SPACE::FileHelper::SetMandatoryEntry uint16_t  group,
uint16_t  elem,
std::string  value,
const VRKey vr = GDCM_VRUNKNOWN
[protected]
 

Todo:
: what is it used for ? (FileHelper::SetMandatoryEntry)

Definition at line 1889 of file gdcmFileHelper.cxx.

References Archive, GDCM_NAME_SPACE::RefCounter::Delete(), GDCM_NAME_SPACE::DataEntry::New(), GDCM_NAME_SPACE::DocEntryArchive::Push(), and GDCM_NAME_SPACE::DataEntry::SetString().

01890 {
01891    //DataEntry *entry = DataEntry::New(Global::GetDicts()->GetDefaultPubDict()->GetEntry(group,elem));
01892    DataEntry *entry = DataEntry::New(group,elem,vr);
01893    entry->SetString(value);
01894    Archive->Push(entry);
01895    entry->Delete();
01896 }

void GDCM_NAME_SPACE::FileHelper::SetPhotometricInterpretationToMonochrome1  )  [inline]
 

1 : white=0, black=high value

Definition at line 147 of file gdcmFileHelper.h.

00147                                                     {
00148                                     PhotometricInterpretation = 1;}

void GDCM_NAME_SPACE::FileHelper::SetPhotometricInterpretationToMonochrome2  )  [inline]
 

2 : black=0, white=high value (default)

Definition at line 150 of file gdcmFileHelper.h.

00150                                                     {
00151                                     PhotometricInterpretation = 2;}

void GDCM_NAME_SPACE::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 Print

Definition at line 47 of file gdcmBase.h.

Referenced by Print(), and GDCM_NAME_SPACE::DicomDir::Print().

00047 { PrintLevel = level; }

void GDCM_NAME_SPACE::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 pixels since the size is given in bytes)
expectedSize total image size, *in Bytes*

Definition at line 522 of file gdcmFileHelper.cxx.

References FileInternal, GDCM_NAME_SPACE::JPEG, GDCM_NAME_SPACE::JPEG2000, PixelWriteConverter, GDCM_NAME_SPACE::PixelWriteConvert::SetCompressJPEG2000UserData(), GDCM_NAME_SPACE::PixelWriteConvert::SetCompressJPEGUserData(), GDCM_NAME_SPACE::PixelWriteConvert::SetUserData(), and WriteType.

00523 {
00524    if( WriteType == JPEG2000 )
00525    {
00526       PixelWriteConverter->SetCompressJPEG2000UserData(inData, expectedSize, FileInternal);
00527    }
00528    else if( WriteType == JPEG )
00529    {
00530       PixelWriteConverter->SetCompressJPEGUserData(inData, expectedSize, FileInternal);
00531    }
00532    else
00533    {
00534       PixelWriteConverter->SetUserData(inData, expectedSize);
00535    }
00536 }

void GDCM_NAME_SPACE::FileHelper::SetUserFunction VOID_FUNCTION_PUINT8_PFILE_POINTER  userFunc  )  [inline]
 

to allow user to modify pixel order (e.g. Mirror, UpsideDown,...)

Definition at line 70 of file gdcmFileHelper.h.

Referenced by vtkGdcmReader::LoadImageInMemory().

00071                         { UserFunction = userFunc; }   

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

Pushes out the whole group 0002 FIXME : better, set a flag to tell the writer not to write it ... FIXME : method should probably have an other name ! SetWriteFileTypeToACR is NOT opposed to SetWriteFileTypeToExplicitVR and SetWriteFileTypeToImplicitVR.

Definition at line 1105 of file gdcmFileHelper.cxx.

References Archive, and GDCM_NAME_SPACE::DocEntryArchive::Push().

Referenced by Write().

01106 {
01107    Archive->Push(0x0002,0x0000);
01108    Archive->Push(0x0002,0x0001);
01109    Archive->Push(0x0002,0x0002);
01110    Archive->Push(0x0002,0x0003);
01111    Archive->Push(0x0002,0x0010);
01112    Archive->Push(0x0002,0x0012);
01113    Archive->Push(0x0002,0x0013);
01114    Archive->Push(0x0002,0x0016);
01115    Archive->Push(0x0002,0x0100);
01116    Archive->Push(0x0002,0x0102);
01117 }

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

Sets in the File the TransferSyntax to 'Explicit VR Little Endian".

Definition at line 1152 of file gdcmFileHelper.cxx.

References Archive, CopyDataEntry(), GDCM_NAME_SPACE::RefCounter::Delete(), GDCM_NAME_SPACE::Util::DicomString(), GDCM_NAME_SPACE::Global::GetTS(), GDCM_NAME_SPACE::DocEntryArchive::Push(), and GDCM_NAME_SPACE::DataEntry::SetString().

Referenced by Write().

01153 {
01154    std::string ts = Util::DicomString( 
01155       Global::GetTS()->GetSpecialTransferSyntax(TS::ExplicitVRLittleEndian) );
01156 
01157    DataEntry *tss = CopyDataEntry(0x0002,0x0010,"UI");
01158    tss->SetString(ts);
01159    Archive->Push(tss);
01160    tss->Delete();
01161 }

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

Sets in the File the TransferSyntax to 'Implicit VR Little Endian".

Definition at line 1166 of file gdcmFileHelper.cxx.

References Archive, CopyDataEntry(), GDCM_NAME_SPACE::RefCounter::Delete(), GDCM_NAME_SPACE::Util::DicomString(), GDCM_NAME_SPACE::Global::GetTS(), GDCM_NAME_SPACE::DocEntryArchive::Push(), and GDCM_NAME_SPACE::DataEntry::SetString().

Referenced by Write().

01167 {
01168    std::string ts = Util::DicomString(
01169       Global::GetTS()->GetSpecialTransferSyntax(TS::ImplicitVRLittleEndian) );
01170 
01171    DataEntry *tss = CopyDataEntry(0x0002,0x0010,"UI");
01172    tss->SetString(ts);
01173    Archive->Push(tss);
01174    tss->Delete();
01175 }

void GDCM_NAME_SPACE::FileHelper::SetWriteFileTypeToJPEG  )  [protected]
 

Sets in the File the TransferSyntax to 'JPEG'.

Definition at line 1137 of file gdcmFileHelper.cxx.

References Archive, CopyDataEntry(), GDCM_NAME_SPACE::RefCounter::Delete(), GDCM_NAME_SPACE::Util::DicomString(), GDCM_NAME_SPACE::Global::GetTS(), GDCM_NAME_SPACE::DocEntryArchive::Push(), and GDCM_NAME_SPACE::DataEntry::SetString().

Referenced by Write().

01138 {
01139    std::string ts = Util::DicomString(
01140       Global::GetTS()->GetSpecialTransferSyntax(TS::JPEGLosslessProcess14_1) );
01141 
01142    DataEntry *tss = CopyDataEntry(0x0002,0x0010,"UI");
01143    tss->SetString(ts);
01144 
01145    Archive->Push(tss);
01146    tss->Delete();
01147 }

void GDCM_NAME_SPACE::FileHelper::SetWriteFileTypeToJPEG2000  )  [protected]
 

Sets in the File the TransferSyntax to 'JPEG2000'.

Definition at line 1122 of file gdcmFileHelper.cxx.

References Archive, CopyDataEntry(), GDCM_NAME_SPACE::RefCounter::Delete(), GDCM_NAME_SPACE::Util::DicomString(), GDCM_NAME_SPACE::Global::GetTS(), GDCM_NAME_SPACE::DocEntryArchive::Push(), and GDCM_NAME_SPACE::DataEntry::SetString().

Referenced by Write().

01123 {
01124    std::string ts = Util::DicomString(
01125    Global::GetTS()->GetSpecialTransferSyntax(TS::JPEG2000Lossless) );
01126 
01127    DataEntry *tss = CopyDataEntry(0x0002,0x0010,"UI");
01128    tss->SetString(ts);
01129 
01130    Archive->Push(tss);
01131    tss->Delete();   
01132 }

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

Sets the Write Mode ( ).

Definition at line 122 of file gdcmFileHelper.h.

00122 { WriteMode = mode;         }

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

Tells the writer we want to keep 'Grey pixels + Palettes color' when possible (as opposed to convert 'Palettes color' to RGB).

Definition at line 117 of file gdcmFileHelper.h.

00117 { SetWriteMode(WMODE_RAW);  }

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

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

Definition at line 120 of file gdcmFileHelper.h.

00120 { SetWriteMode(WMODE_RGB);  }

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

Set the Write not to Libido format.

Definition at line 1180 of file gdcmFileHelper.cxx.

References Archive, GDCM_NAME_SPACE::DataEntry::Copy(), CopyDataEntry(), GDCM_NAME_SPACE::RefCounter::Delete(), FileInternal, GDCM_NAME_SPACE::DocEntrySet::GetDataEntry(), GDCM_NAME_SPACE::DataEntry::GetString(), GDCM_NAME_SPACE::DataEntry::New(), GDCM_NAME_SPACE::DocEntryArchive::Push(), and GDCM_NAME_SPACE::DataEntry::SetString().

Referenced by Write().

01181 {
01182    DataEntry *oldRow = FileInternal->GetDataEntry(0x0028, 0x0010);
01183    DataEntry *oldCol = FileInternal->GetDataEntry(0x0028, 0x0011);
01184    
01185    if ( oldRow && oldCol )
01186    {
01187       std::string rows, columns; 
01188 
01189       DataEntry *newRow=DataEntry::New(0x0028, 0x0010, "US");
01190       DataEntry *newCol=DataEntry::New(0x0028, 0x0011, "US");
01191 
01192       newRow->Copy(oldCol);
01193       newCol->Copy(oldRow);
01194 
01195       newRow->SetString(oldCol->GetString());
01196       newCol->SetString(oldRow->GetString());
01197 
01198       Archive->Push(newRow);
01199       Archive->Push(newCol);
01200 
01201       newRow->Delete();
01202       newCol->Delete();
01203    }
01204 
01205    DataEntry *libidoCode = CopyDataEntry(0x0008,0x0010,"LO");
01206    libidoCode->SetString("ACRNEMA_LIBIDO_1.1");
01207    Archive->Push(libidoCode);
01208    libidoCode->Delete();
01209 }

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

Set the Write not to No Libido format.

Definition at line 1214 of file gdcmFileHelper.cxx.

References Archive, CopyDataEntry(), FileInternal, GDCM_NAME_SPACE::DocEntrySet::GetDataEntry(), GDCM_NAME_SPACE::DataEntry::GetString(), GDCM_NAME_SPACE::DocEntryArchive::Push(), and GDCM_NAME_SPACE::DataEntry::SetString().

Referenced by Write().

01215 {
01216    DataEntry *recCode = FileInternal->GetDataEntry(0x0008,0x0010);
01217    if ( recCode )
01218    {
01219       if ( recCode->GetString() == "ACRNEMA_LIBIDO_1.1" )
01220       {
01221          DataEntry *libidoCode = CopyDataEntry(0x0008,0x0010,"LO");
01222          libidoCode->SetString("");
01223          Archive->Push(libidoCode);
01224          libidoCode->Delete();
01225       }
01226    }
01227 }

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

Updates the File to write RAW data (as opposed to RGB data) (modifies, when necessary, photochromatic interpretation, bits allocated, Pixels element VR) WARNING : if SetPhotometricInterpretationToMonochrome1() was called before Pixel Elements if modified :-(.

Definition at line 906 of file gdcmFileHelper.cxx.

References FileInternal, GDCM_NAME_SPACE::File::GetNumberOfScalarComponents(), GDCM_NAME_SPACE::File::HasLUT(), and SetWriteToRGB().

Referenced by Write().

00907 {
00908    if ( FileInternal->GetNumberOfScalarComponents() == 3 
00909     && !FileInternal->HasLUT() )
00910    {
00911       SetWriteToRGB();
00912    } 
00913    else
00914    {
00915       // 0x0028,0x0004 : Photometric Interpretation
00916       DataEntry *photInt = CopyDataEntry(0x0028,0x0004,"CS");
00917       if (FileInternal->HasLUT() )
00918       {
00919          photInt->SetString("PALETTE COLOR ");
00920       }
00921       else
00922       {
00923          if (GetPhotometricInterpretation() == 2)
00924             photInt->SetString("MONOCHROME2 ");  // 0 = Black
00925          else
00926             photInt->SetString("MONOCHROME1 ");  // 0 = White !
00927       }
00928 
00929       PixelWriteConverter->SetReadData(PixelReadConverter->GetRaw(),
00930                                        PixelReadConverter->GetRawSize());
00931 
00932       std::string vr = "OB";
00933       if ( FileInternal->GetBitsAllocated()>8 )
00934          vr = "OW";
00935       if ( FileInternal->GetBitsAllocated()==24 ) // For RGB ACR files 
00936          vr = "OB";
00937        // For non RAW data. Mainly JPEG
00938       if( WriteType == JPEG || WriteType == JPEG2000)
00939       {
00940          vr = "OW";
00941       }
00942 
00943       DataEntry *pixel = 
00944          CopyDataEntry(GetFile()->GetGrPixel(),GetFile()->GetNumPixel(),vr);
00945       pixel->SetFlag(DataEntry::FLAG_PIXELDATA);
00946       pixel->SetBinArea(PixelWriteConverter->GetData(),false);
00947       pixel->SetLength(
00948          static_cast< uint32_t >(PixelWriteConverter->GetDataSize()) );
00949 
00950       if (!FileInternal->HasLUT() && GetPhotometricInterpretation() == 1)
00951       {
00952           ConvertFixGreyLevels( pixel->GetBinArea(), pixel->GetLength() );
00953       }
00954 
00955       Archive->Push(photInt);
00956       Archive->Push(pixel);
00957 
00958       photInt->Delete();
00959       pixel->Delete();
00960    }
00961 }

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

Updates the File to write RGB data (as opposed to RAW data) (modifies, when necessary, photochromatic interpretation, samples per pixel, Planar configuration, bits allocated, bits stored, high bit -ACR 24 bits- Pixels element VR, pushes out the LUT, ).

Definition at line 970 of file gdcmFileHelper.cxx.

References GDCM_NAME_SPACE::PixelReadConvert::BuildRGBImage(), CopyDataEntry(), FileInternal, GDCM_NAME_SPACE::File::GetNumberOfScalarComponents(), GDCM_NAME_SPACE::PixelReadConvert::GetRGB(), GDCM_NAME_SPACE::PixelReadConvert::GetRGBSize(), PixelReadConverter, PixelWriteConverter, GDCM_NAME_SPACE::PixelWriteConvert::SetReadData(), and GDCM_NAME_SPACE::DataEntry::SetString().

Referenced by SetWriteToRaw(), and Write().

00971 {
00972    if ( FileInternal->GetNumberOfScalarComponents()==3 )
00973    {
00974       PixelReadConverter->BuildRGBImage();
00975       
00976       DataEntry *spp = CopyDataEntry(0x0028,0x0002,"US");
00977       spp->SetString("3 ");
00978 
00979       DataEntry *planConfig = CopyDataEntry(0x0028,0x0006,"US");
00980       planConfig->SetString("0 ");
00981 
00982       DataEntry *photInt = CopyDataEntry(0x0028,0x0004,"CS");
00983       photInt->SetString("RGB ");
00984 
00985       if ( PixelReadConverter->GetRGB() )
00986       {
00987          PixelWriteConverter->SetReadData(PixelReadConverter->GetRGB(),
00988                                           PixelReadConverter->GetRGBSize());
00989       }
00990       else // Raw data
00991       {
00992          PixelWriteConverter->SetReadData(PixelReadConverter->GetRaw(),
00993                                           PixelReadConverter->GetRawSize());
00994       }
00995 
00996       std::string vr = "OB";
00997       if ( FileInternal->GetBitsAllocated()>8 )
00998          vr = "OW";
00999       if ( FileInternal->GetBitsAllocated()==24 ) // For RGB ACR files 
01000          vr = "OB";
01001       DataEntry *pixel = 
01002          CopyDataEntry(GetFile()->GetGrPixel(),GetFile()->GetNumPixel(),vr);
01003       pixel->SetFlag(DataEntry::FLAG_PIXELDATA);
01004       pixel->SetBinArea(PixelWriteConverter->GetData(),false);
01005       pixel->SetLength(PixelWriteConverter->GetDataSize());
01006 
01007       Archive->Push(spp);
01008       Archive->Push(planConfig);
01009       Archive->Push(photInt);
01010       Archive->Push(pixel);
01011 
01012       spp->Delete();
01013       planConfig->Delete();
01014       photInt->Delete();
01015       pixel->Delete();
01016 
01017       // Remove any LUT
01018       Archive->Push(0x0028,0x1101);
01019       Archive->Push(0x0028,0x1102);
01020       Archive->Push(0x0028,0x1103);
01021       Archive->Push(0x0028,0x1201);
01022       Archive->Push(0x0028,0x1202);
01023       Archive->Push(0x0028,0x1203);
01024 
01025       // push out Palette Color Lookup Table UID, if any
01026       Archive->Push(0x0028,0x1199);
01027 
01028       // For old '24 Bits' ACR-NEMA
01029       // Thus, we have a RGB image and the bits allocated = 24 and 
01030       // samples per pixels = 1 (in the read file)
01031       if ( FileInternal->GetBitsAllocated()==24 ) 
01032       {
01033          DataEntry *bitsAlloc = CopyDataEntry(0x0028,0x0100,"US");
01034          bitsAlloc->SetString("8 ");
01035 
01036          DataEntry *bitsStored = CopyDataEntry(0x0028,0x0101,"US");
01037          bitsStored->SetString("8 ");
01038 
01039          DataEntry *highBit = CopyDataEntry(0x0028,0x0102,"US");
01040          highBit->SetString("7 ");
01041 
01042          Archive->Push(bitsAlloc);
01043          Archive->Push(bitsStored);
01044          Archive->Push(highBit);
01045 
01046          bitsAlloc->Delete();
01047          bitsStored->Delete();
01048          highBit->Delete();
01049       }
01050    }
01051    else
01052    {
01053       SetWriteToRaw();
01054    }
01055 }

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

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

Definition at line 142 of file gdcmFileHelper.h.

00142 { WriteType = format;       }

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

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

Definition at line 133 of file gdcmFileHelper.h.

References GDCM_NAME_SPACE::ACR.

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

00133 { SetWriteType(ACR);        }

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

Tells the writer we want to write as LibIDO.

Definition at line 135 of file gdcmFileHelper.h.

References GDCM_NAME_SPACE::ACR_LIBIDO.

Referenced by vtkGdcmWriter::WriteDcmFile().

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

Tells the writer we want to write as Explicit VR.

Definition at line 131 of file gdcmFileHelper.h.

References GDCM_NAME_SPACE::ExplicitVR.

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

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

Tells the writer we want to write as Implicit VR.

Definition at line 129 of file gdcmFileHelper.h.

References GDCM_NAME_SPACE::ImplicitVR.

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

void GDCM_NAME_SPACE::FileHelper::SetWriteTypeToJPEG  )  [inline]
 

Tells the writer we want to write as JPEG.

Definition at line 137 of file gdcmFileHelper.h.

References GDCM_NAME_SPACE::JPEG.

00137 { SetWriteType(JPEG);       }

void GDCM_NAME_SPACE::FileHelper::SetWriteTypeToJPEG2000  )  [inline]
 

Tells the writer we want to write as JPEG2000.

Definition at line 139 of file gdcmFileHelper.h.

References GDCM_NAME_SPACE::JPEG2000.

00139 { SetWriteType(JPEG2000);   }

void GDCM_NAME_SPACE::RefCounter::Unregister  )  [inline, inherited]
 

Unregister the object.

Remarks:
It decrements the reference counting

Definition at line 50 of file gdcmRefCounter.h.

Referenced by GDCM_NAME_SPACE::Document::ReadNextDocEntry(), GDCM_NAME_SPACE::SQItem::RemoveEntry(), GDCM_NAME_SPACE::ElementSet::RemoveEntry(), and ~FileHelper().

00051    {
00052 //std::cout <<"================Unreg " << typeid(*this).name() << std::endl;
00053       RefCount--;
00054       if(RefCount<=0)
00055         delete this;
00056    }

bool GDCM_NAME_SPACE::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:
FIXME : JPEG may be either ExplicitVR or ImplicitVR
Todo:
the best trick would be *change* the recognition code but pb expected if user deals with, e.g. COMPLEX images

Definition at line 716 of file gdcmFileHelper.cxx.

References GDCM_NAME_SPACE::ACR, GDCM_NAME_SPACE::ACR_LIBIDO, CheckMandatoryElements(), CheckWriteIntegrity(), GDCM_NAME_SPACE::ExplicitVR, FileInternal, GDCM_NAME_SPACE::DocEntrySet::GetDataEntry(), GDCM_NAME_SPACE::ImplicitVR, GDCM_NAME_SPACE::DocEntrySet::InsertEntryString(), GDCM_NAME_SPACE::JPEG, GDCM_NAME_SPACE::JPEG2000, RestoreWrite(), RestoreWriteOfLibido(), SetWriteFileTypeToACR(), SetWriteFileTypeToExplicitVR(), SetWriteFileTypeToImplicitVR(), SetWriteFileTypeToJPEG(), SetWriteFileTypeToJPEG2000(), SetWriteToLibido(), SetWriteToNoLibido(), SetWriteToRaw(), SetWriteToRGB(), GDCM_NAME_SPACE::Unknown, WMODE_RAW, WMODE_RGB, GDCM_NAME_SPACE::File::Write(), WriteMode, and WriteType.

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

00717 { 
00718    CheckMandatoryElements(); //called once, here !
00719    
00720    bool flag = false;
00721    DocEntry *e;   
00722    switch(WriteType)
00723    {
00724       case ImplicitVR:
00725          SetWriteFileTypeToImplicitVR();
00726          break;
00727  
00728       case Unknown:  // should never happen; ExplicitVR is the default value
00729       case ExplicitVR:
00730 
00731    // User should ask gdcm to write an image in Explicit VR mode
00732    // only when he is sure *all* the VR of *all* the DataElements is known.
00733    // i.e : when there are *only* Public Groups
00734    // or *all* the Shadow Groups are fully described in the relevant Shadow
00735    // Dictionnary
00736    // Let's just *dream* about it; *never* trust a user !
00737    // We turn to Implicit VR if at least the VR of one element is unknown.
00738    
00739    // Better we let DocEntry::WriteContent to put vr=UN for undocumented Shadow Groups !
00740 
00741 /*
00742          e = FileInternal->GetFirstEntry();
00743          while (e != 0)
00744          {
00745             if (e->GetVR() == "  ")  
00746             {
00747                SetWriteTypeToDcmImplVR();
00748                SetWriteFileTypeToImplicitVR();
00749                flag = true;
00750                break;         
00751             } 
00752             e = FileInternal->GetNextEntry();
00753          }        
00754 
00755          if (!flag)
00756          {
00757             SetWriteFileTypeToExplicitVR();
00758          }
00759          break;
00760 */
00761 
00762          SetWriteFileTypeToExplicitVR();
00763 
00764   break;
00765       case ACR:
00766       case ACR_LIBIDO:
00767       // NOTHING is done here just for LibIDO.
00768       // Just to avoid further trouble if user creates a file ex-nihilo,
00769       // wants to write it as an ACR-NEMA file,
00770       // and forgets to create any Entry belonging to group 0008
00771       // (shame on him !)
00772       // We add Recognition Code (RET)
00773         if ( ! FileInternal->GetDataEntry(0x0008, 0x0010) )
00774             FileInternal->InsertEntryString("ACR-NEMA V1.0 ", 
00775                                              0x0008, 0x0010, "LO");
00776          SetWriteFileTypeToACR();
00777         // SetWriteFileTypeToImplicitVR(); // ACR IS implicit VR !
00778          break;
00779  
00781       case JPEG:
00782          SetWriteFileTypeToJPEG();
00783          break;
00784 
00785       case JPEG2000:
00786          SetWriteFileTypeToJPEG2000();
00787          break;
00788    }
00789 
00790    // --------------------------------------------------------------
00791    // Special Patch to allow gdcm to re-write ACR-LibIDO formated images
00792    //
00793    // if recognition code tells us we dealt with a LibIDO image
00794    // we reproduce on disk the switch between lineNumber and columnNumber
00795    // just before writting ...
00798    
00799    if ( WriteType == ACR_LIBIDO )
00800    {
00801       SetWriteToLibido();
00802    }
00803    else
00804    {
00805       SetWriteToNoLibido();
00806    }
00807    // ----------------- End of Special Patch ----------------
00808   
00809    switch(WriteMode)
00810    {
00811       case WMODE_RAW :
00812          SetWriteToRaw(); // modifies and pushes to the archive, when necessary
00813          break;
00814       case WMODE_RGB :
00815          SetWriteToRGB(); // modifies and pushes to the archive, when necessary
00816          break;
00817    }
00818 
00819    bool check;
00820    if (WriteType == JPEG || WriteType == JPEG2000)
00821       check = true;
00822    else
00823       check = CheckWriteIntegrity(); // verifies length
00824 
00825    if (check)
00826    {
00827       check = FileInternal->Write(fileName,WriteType);
00828    }
00829 
00830    RestoreWrite();
00831   // RestoreWriteFileType();
00832   // RestoreWriteMandatory();
00833 
00834    // --------------------------------------------------------------
00835    // Special Patch to allow gdcm to re-write ACR-LibIDO formated images
00836    // 
00837    // ...and we restore the header to be Dicom Compliant again 
00838    // just after writting
00839    RestoreWriteOfLibido();
00840    // ----------------- End of Special Patch ----------------
00841 
00842    return check;
00843 }

bool GDCM_NAME_SPACE::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 704 of file gdcmFileHelper.cxx.

References SetWriteTypeToAcr(), and Write().

00705 {
00706    SetWriteTypeToAcr();
00707    return Write(fileName);
00708 }

bool GDCM_NAME_SPACE::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 684 of file gdcmFileHelper.cxx.

References SetWriteTypeToDcmExplVR(), and Write().

00685 {
00686    SetWriteTypeToDcmExplVR();
00687    return Write(fileName);
00688 }

bool GDCM_NAME_SPACE::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 "Endianity".

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

Definition at line 669 of file gdcmFileHelper.cxx.

References SetWriteTypeToDcmImplVR(), and Write().

00670 {
00671    SetWriteTypeToDcmImplVR();
00672    return Write(fileName);
00673 }

bool GDCM_NAME_SPACE::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 626 of file gdcmFileHelper.cxx.

References gdcmWarningMacro, GDCM_NAME_SPACE::PixelWriteConvert::GetUserData(), GDCM_NAME_SPACE::PixelWriteConvert::GetUserDataSize(), and PixelWriteConverter.

00627 {
00628    std::ofstream fp1(fileName.c_str(), std::ios::out | std::ios::binary );
00629    if (!fp1)
00630    {
00631       gdcmWarningMacro( "Fail to open (write) file:" << fileName.c_str());
00632       return false;
00633    }
00634 
00635    if ( PixelWriteConverter->GetUserData() )
00636    {
00637       fp1.write( (char *)PixelWriteConverter->GetUserData(), 
00638                  PixelWriteConverter->GetUserDataSize() );
00639    }
00640    else if ( PixelReadConverter->GetRGB() )
00641    {
00642       fp1.write( (char *)PixelReadConverter->GetRGB(), 
00643                  PixelReadConverter->GetRGBSize());
00644    }
00645    else if ( PixelReadConverter->GetRaw() )
00646    {
00647       fp1.write( (char *)PixelReadConverter->GetRaw(), 
00648                  PixelReadConverter->GetRawSize());
00649    }
00650    else
00651    {
00652       gdcmErrorMacro( "Nothing written." );
00653    }
00654 
00655    fp1.close();
00656 
00657    return true;
00658 }


Member Data Documentation

bool GDCM_NAME_SPACE::FileHelper::Abort [mutable, protected]
 

Definition at line 226 of file gdcmFileHelper.h.

Referenced by CallStartMethod().

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

Pointer to the DocEntryArchive (used while writting process).

Definition at line 246 of file gdcmFileHelper.h.

Referenced by CheckMandatoryElements(), CheckMandatoryEntry(), CopyMandatoryEntry(), Initialize(), RestoreWrite(), RestoreWriteMandatory(), RestoreWriteOfLibido(), SetMandatoryEntry(), SetWriteFileTypeToACR(), SetWriteFileTypeToExplicitVR(), SetWriteFileTypeToImplicitVR(), SetWriteFileTypeToJPEG(), SetWriteFileTypeToJPEG2000(), SetWriteToLibido(), SetWriteToNoLibido(), and ~FileHelper().

ImageContentType GDCM_NAME_SPACE::FileHelper::ContentType [private]
 

only user knows what he did before asking the image to be written

  • he created ex nihilo his own image
  • he just applied a mathematical process on the pixels
  • he created a new image, using existing images (eg MIP, MPR,cartography)
  • he anonymized and image (*no* modif on the pixels)

Definition at line 268 of file gdcmFileHelper.h.

Referenced by CheckMandatoryElements(), and Initialize().

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

gdcm::File to use to load the file

Definition at line 231 of file gdcmFileHelper.h.

Referenced by CheckMandatoryElements(), CheckMandatoryEntry(), CheckWriteIntegrity(), ConvertFixGreyLevels(), CopyDataEntry(), FileHelper(), GetRaw(), Initialize(), InsertEntryBinArea(), InsertEntryString(), InsertSeqEntry(), Load(), Print(), SetEntryBinArea(), SetEntryString(), SetFileName(), SetUserData(), SetWriteToLibido(), SetWriteToNoLibido(), SetWriteToRaw(), SetWriteToRGB(), Write(), and ~FileHelper().

bool GDCM_NAME_SPACE::FileHelper::Parsed [private]
 

Whether already parsed or not.

Definition at line 234 of file gdcmFileHelper.h.

int GDCM_NAME_SPACE::FileHelper::PhotometricInterpretation [private]
 

1 : white=0, black=high value 2 : black=0, white=high value (default)

Definition at line 272 of file gdcmFileHelper.h.

Referenced by Initialize().

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

Pointer to the PixelReadConverter.

Definition at line 239 of file gdcmFileHelper.h.

Referenced by FileHelper(), GetLutItemNumber(), GetLutItemSize(), GetLutRGBA(), GetRaw(), GetRawData(), GetRawDataSize(), GetRGBData(), GetRGBDataSize(), Initialize(), Load(), Print(), SetWriteToRGB(), and ~FileHelper().

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

Pointer to the PixelWriteConverter.

Definition at line 242 of file gdcmFileHelper.h.

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

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

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

Definition at line 55 of file gdcmBase.h.

Referenced by GDCM_NAME_SPACE::SeqEntry::Print(), Print(), GDCM_NAME_SPACE::ElementSet::Print(), GDCM_NAME_SPACE::DocEntry::Print(), GDCM_NAME_SPACE::DictEntry::Print(), GDCM_NAME_SPACE::DicomDirStudy::Print(), GDCM_NAME_SPACE::DicomDirSerie::Print(), GDCM_NAME_SPACE::DicomDirPatient::Print(), GDCM_NAME_SPACE::DicomDirMeta::Print(), GDCM_NAME_SPACE::DicomDir::Print(), and GDCM_NAME_SPACE::DataEntry::Print().

float GDCM_NAME_SPACE::FileHelper::Progress [protected]
 

value of the ??? for any progress bar

Definition at line 225 of file gdcmFileHelper.h.

Referenced by CallEndMethod(), and CallStartMethod().

VOID_FUNCTION_PUINT8_PFILE_POINTER GDCM_NAME_SPACE::FileHelper::UserFunction [private]
 

Pointer to a user supplied function to allow modification of pixel order (e.g. : Mirror, UpsideDown, 90°Rotation, ...) use as : void userSuppliedFunction(uint8_t *im, gdcm::File *f) NB : the "uint8_t *" type of first param is just for prototyping. User will Cast it according what he founds with f->GetPixelType() See vtkgdcmSerieViewer for an example.

Definition at line 261 of file gdcmFileHelper.h.

Referenced by GetRaw(), and Initialize().

FileMode GDCM_NAME_SPACE::FileHelper::WriteMode [private]
 

(WMODE_RAW, WMODE_RGB)

Definition at line 250 of file gdcmFileHelper.h.

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

FileType GDCM_NAME_SPACE::FileHelper::WriteType [private]
 

(ImplicitVR, ExplicitVR, ACR, ACR_LIBIDO)

Definition at line 253 of file gdcmFileHelper.h.

Referenced by CheckMandatoryElements(), Initialize(), SetUserData(), and Write().


The documentation for this class was generated from the following files:
Generated on Fri Aug 24 13:01:49 2007 for gdcm by  doxygen 1.4.6