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

gdcm::DicomDir Class Reference

DicomDir defines an object representing a DICOMDIR in memory as a tree-like structure DicomDirPatient -> DicomDirStudy -> DicomDirSerie -> DicomDirImage. More...

#include <gdcmDicomDir.h>

Inheritance diagram for gdcm::DicomDir:

Inheritance graph
[legend]
Collaboration diagram for gdcm::DicomDir:

Collaboration graph
[legend]
List of all members.

Public Types

enum  DicomDirType {
  GDCM_DICOMDIR_NONE, GDCM_DICOMDIR_META, GDCM_DICOMDIR_PATIENT, GDCM_DICOMDIR_STUDY,
  GDCM_DICOMDIR_SERIE, GDCM_DICOMDIR_VISIT, GDCM_DICOMDIR_IMAGE
}
 Types of the DicomDirObject within the DicomDir. More...
typedef std::list< DicomElementListElements

Public Member Functions

bool Load ()
 Loader. use SetFileName(fn) or SetLoadMode(lm) + SetDirectoryName(dn) before !
void Print (std::ostream &os=std::cout, std::string const &indent="")
 Canonical Printer.
void SetDirectoryName (std::string const &dirName)
 Sets the root Directory name to parse, recursively.
virtual void SetFileName (std::string const &fileName)
 Accessor to Filename.
virtual bool IsReadable ()
 This predicate, based on hopefully reasonable heuristics, decides whether or not the current document was properly parsed and contains the mandatory information for being considered as a well formed and usable DicomDir.
DicomDirMetaNewMeta ()
 adds *the* Meta to a partially created DICOMDIR
DicomDirMetaGetMeta ()
 Returns a pointer to the DicomDirMeta for this DICOMDIR.
DicomDirPatientNewPatient ()
 adds a new Patient (with the basic elements) to a partially created DICOMDIR
void ClearPatient ()
 Remove all Patients.
DicomDirPatientGetFirstPatient ()
 Get the first entry while visiting the DicomDirPatients.
DicomDirPatientGetNextPatient ()
 Get the next entry while visiting the DicomDirPatients.
void ParseDirectory ()
 fills the whole structure, starting from a root Directory
float GetProgress () const
 GetProgress GetProgress.
void AbortProgress ()
 AbortProgress AbortProgress.
bool IsAborted ()
 IsAborted IsAborted.
bool Write (std::string const &fileName)
 writes on disc a DICOMDIR \ warning does NOT add the missing elements in the header : it's up to the user doing it !
bool Anonymize ()
 Anonymize a DICOMDIR.
virtual void Copy (DocEntrySet *set)
 Copies all the attributes from an other DocEntrySet.
DictGetPubDict ()
 Get the public dictionary used.
DictGetShaDict ()
 Get the shadow dictionary used.
bool SetShaDict (Dict *dict)
 Set the shadow dictionary used.
bool SetShaDict (DictKey const &dictName)
 Set the shadow dictionary used.
bool IsParsable ()
 This predicate tells us whether or not the current Document was properly parsed and contains at least *one* Dicom Element (and nothing more, sorry).
bool IsDicomV3 ()
 Predicate for dicom version 3 file.
bool IsPapyrus ()
 Predicate for Papyrus file Dedicated to whomsoever it may concern.
FileType GetFileType ()
 returns the File Type (ACR, ACR_LIBIDO, ExplicitVR, ImplicitVR, Unknown)
std::string GetTransferSyntax ()
 Accessor to the Transfer Syntax (when present) of the current document (it internally handles reading the value from disk when only parsing occured).
std::string GetTransferSyntaxName ()
 Accesses the info from 0002,0010 : Transfer Syntax and TS.
int GetSwapCode ()
 'Swap code' accessor (see SwapCode )
const std::string & GetFileName () const
 Accessor to Filename.
std::ifstream * OpenFile ()
 Tries to open the file Document::Filename and checks the preamble when existing.
bool CloseFile ()
 closes the file
void WriteContent (std::ofstream *fp, FileType type)
 Writes in a file all the Entries (Dicom Elements).
virtual void LoadEntryBinArea (uint16_t group, uint16_t elem)
 Loads (from disk) the element content when a string is not suitable.
virtual void LoadEntryBinArea (DataEntry *entry)
 Loads (from disk) the element content when a string is not suitable.
void LoadDocEntrySafe (DocEntry *entry)
 Loads the element while preserving the current underlying file position indicator as opposed to LoadDocEntry that modifies it.
void AddForceLoadElement (uint16_t group, uint16_t elem)
 Adds a new element we want to load anyway.
bool operator< (Document &document)
 Compares two documents, according to DicomDir rules.
void SetLoadMode (int mode)
 Sets the LoadMode as a boolean string. LD_NOSEQ, LD_NOSHADOW, LD_NOSHADOWSEQ ... (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 !
bool AddEntry (DocEntry *Entry)
 add a new Dicom Element pointer to the H Table
bool RemoveEntry (DocEntry *EntryToRemove)
 Clear the hash table from given entry AND delete the entry.
void ClearEntry ()
 delete all entries in the ElementSet
DocEntryGetFirstEntry ()
 Get the first entry while visiting *the* 'zero level' DocEntrySet (DocEntries out of any Sequence).
DocEntryGetNextEntry ()
 Get the next entry while visiting *the* 'zero level' DocEntrySet (DocEntries out of any Sequence).
DocEntryGetDocEntry (uint16_t group, uint16_t elem)
 retrieves a Dicom Element using (group, element)
bool IsEmpty ()
 Tells us if the ElementSet contains no entry.
virtual std::string GetEntryString (uint16_t group, uint16_t elem)
 Get the "std::string representable" value of the Dicom entry.
virtual void * GetEntryBinArea (uint16_t group, uint16_t elem)
 Gets (from Header) a 'non string' element value.
virtual int GetEntryLength (uint16_t group, uint16_t elem)
 Searches within the DocEntrySet for the value length of a given tag..
DataEntryGetDataEntry (uint16_t group, uint16_t elem)
 Same as Document::GetDocEntry except it returns a result only when the corresponding entry is of type DataEntry.
SeqEntryGetSeqEntry (uint16_t group, uint16_t elem)
 Same as Document::GetDocEntry except it returns a result only when the corresponding entry is of type SeqEntry.
bool SetEntryString (std::string const &content, uint16_t group, uint16_t elem)
 Accesses an existing DocEntry (i.e. a Dicom Element) through it's (group, element) and modifies it's content with the given value.
bool SetEntryString (std::string const &content, DataEntry *entry)
 Accesses an existing DocEntry (i.e. a Dicom Element) and modifies it's content with the given value.
bool SetEntryBinArea (uint8_t *content, int lgth, uint16_t group, uint16_t elem)
 Accesses an existing DocEntry (i.e. a Dicom Element) through it's (group, element) and modifies it's content with the given value.
bool SetEntryBinArea (uint8_t *content, int lgth, DataEntry *entry)
 Accesses an existing DataEntry (i.e. a Dicom Element) and modifies it's content with the given value.
DataEntryInsertEntryString (std::string const &value, uint16_t group, uint16_t elem, VRKey const &vr=GDCM_VRUNKNOWN)
 Modifies the value of a given Doc Entry (Dicom Element) when it exists. Create it with the given value when unexistant.
DataEntryInsertEntryBinArea (uint8_t *binArea, int lgth, uint16_t group, uint16_t elem, VRKey const &vr=GDCM_VRUNKNOWN)
 Modifies the value of a given Header Entry (Dicom Element) when it exists. Create it with the given value when unexistant. A copy of the binArea is made to be kept in the Document.
SeqEntryInsertSeqEntry (uint16_t group, uint16_t elem)
 Creates a new gdcm::SeqEntry and adds it to the current DocEntrySet. (remove any existing entry with same group,elem).
virtual bool CheckIfEntryExist (uint16_t group, uint16_t elem)
 Checks if a given Dicom Element exists within the DocEntrySet.
DataEntryNewDataEntry (uint16_t group, uint16_t elem, VRKey const &vr=GDCM_VRUNKNOWN)
 Build a new DataEntry from all the low level arguments. Check for existence of dictionary entry, and build a default one when absent.
SeqEntryNewSeqEntry (uint16_t group, uint16_t elem)
 Build a new SeqEntry from all the low level arguments. Check for existence of dictionary entry, and build a default one when absent.
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 DicomDirNew ()
 Constructs a DicomDir with a RefCounter.

Protected Member Functions

 DicomDir ()
 Constructor : creates an empty DicomDir.
 ~DicomDir ()
 Canonical destructor.
void CreateDicomDirChainedList (std::string const &path)
 create a Document-like chained list from a root Directory
virtual void CallStartMethod ()
 CallStartMethod.
virtual void CallProgressMethod ()
 CallProgressMethod.
virtual void CallEndMethod ()
 CallEndMethod.
uint16_t ReadInt16 () throw ( FormatError )
 Reads a supposed to be 16 Bits integer (swaps it depending on processor endianness).
uint32_t ReadInt32 () throw ( FormatError )
 Reads a supposed to be 32 Bits integer (swaps it depending on processor endianness).
void SkipBytes (uint32_t)
 skips bytes inside the source file
int ComputeGroup0002Length ()
 Re-computes the length of the Dicom group 0002.
bool MayIWrite (uint16_t)
 Some group are illegal withing some Dicom Documents Only the Document knows it.
DictEntryGetDictEntry (uint16_t group, uint16_t elem)
 Searches [both] the public [and the shadow dictionary (when they exist)] for the presence of the DictEntry with given group and element. The public dictionary has precedence on the shadow one(s), if any.
DictEntryGetDictEntry (uint16_t group, uint16_t elem, VRKey const &vr)
 Searches [both] the public [and the shadow dictionary (when they exist)] for the presence of the DictEntry with given group and element, and create a new virtual DictEntry if necessary.

Protected Attributes

std::string Filename
 Refering underlying filename.
int SwapCode
 Swap code gives an information on the byte order of a supposed to be an int32, as it's read on disc (depending on the image Transfer Syntax *and* on the processor endianess) as opposed as it should in memory to be dealt as an int32. For instance :
  • a 'Little Endian' image, read with a little endian processor will have a SwapCode= 1234 (the order is OK; nothing to do)
  • a 'Little Endian' image, read with a big endian procesor will have a SwapCode= 4321 (the order is wrong; int32 an int16 must be swapped) note : values 2143, 4321, 3412 remain for the ACR-NEMA time, and the well known 'Bad Big Endian' and 'Bad Little Endian' codes.

bool Group0002Parsed
 whether we already parsed group 0002 (Meta Elements)
bool HasDCMPreamble
 whether file has a DCM Preamble
std::ifstream * Fp
 File Pointer, opened during Document parsing.
FileType Filetype
 ACR, ACR_LIBIDO, ExplicitVR, ImplicitVR, Unknown.
ListElements UserAnonymizeList
 User supplied list of elements to Anonymize.
ListElements UserForceLoadList
 User supplied list of elements to force Load.
int LoadMode
 Bit string integer (each one considered as a boolean) Bit 0 : Skip Sequences, if possible Bit 1 : Skip Shadow Groups if possible Probabely, some more to add.
bool IsDocumentAlreadyLoaded
 Whether the gdcm::Document is already parsed/loaded : False from the creation of the gdcm::Document untill gdcm::Document:Load().
bool IsDocumentModified
 Whether the gdcm::Document was modified since the last Load().
float Progress
 value of the ??? for any progress bar
bool Abort
DictRefPubDict
 Public dictionary used to parse this header.
DictRefShaDict
 Optional "shadow dictionary" (private elements) used to parse this header.
uint32_t MaxSizeLoadEntry
 Size threshold above which an element value will NOT be loaded in memory (to avoid loading the image/volume itself). By default, this upper bound is fixed to 1024 bytes (which might look reasonable when one considers the definition of the various VR contents).
uint16_t CurrentGroup
 to allow any inner method to know current tag Group number
uint16_t CurrentElem
 to allow any inner method to know current tag Element number
DocEntryPreviousDocEntry
 To be able to backtrack (Private Sequence, Implicit VR related pb).
int PrintLevel
 Amount of printed details for each Dicom Entries : 0 : stands for the least detail level.

Static Protected Attributes

static const unsigned int HEADER_LENGTH_TO_READ
 After opening the file, we read HEADER_LENGTH_TO_READ bytes.
static const unsigned int MAX_SIZE_LOAD_ELEMENT_VALUE = 0xfff
 Elements whose value is longer than MAX_SIZE_LOAD_ELEMENT_VALUE are NOT loaded.

Private Member Functions

 gdcmTypeMacro (DicomDir)
void Initialize ()
 Sets all fields to NULL.
void CreateDicomDir ()
 create a 'gdcmDicomDir' from a DICOMDIR Header
bool DoTheLoadingJob ()
 Does the Loading Job (internal use only).
bool AddPatientToEnd (DicomDirPatient *dd)
 AddPatientToEnd.
bool AddStudyToEnd (DicomDirStudy *dd)
 AddStudyToEnd.
bool AddSerieToEnd (DicomDirSerie *dd)
 AddSerieToEnd.
bool AddVisitToEnd (DicomDirVisit *dd)
 AddVisitToEnd.
bool AddImageToEnd (DicomDirImage *dd)
 AddImageToEnd.
void SetElements (std::string const &path, VectDocument const &list)
 for each Header of the chained list, add/update the Patient/Study/Serie/Image info
void SetElement (std::string const &path, DicomDirType type, Document *header)
 adds to the HTable the Entries (Dicom Elements) corresponding to the given type
void MoveSQItem (DocEntrySet *dst, DocEntrySet *src)
 Move the content of the source SQItem to the destination SQItem Only DocEntry's are moved.

Static Private Member Functions

static bool HeaderLessThan (Document *header1, Document *header2)
 compares two files

Private Attributes

DicomDirMetaMetaElems
 Pointer on *the* DicomDirObject 'DicomDirMeta Elements'.
ListDicomDirPatient Patients
 Chained list of DicomDirPatient (to be exploited hierarchicaly).
ListDicomDirPatient::iterator ItPatient
bool ParseDir
 value of the ??? for any progress bar

Detailed Description

DicomDir defines an object representing a DICOMDIR in memory as a tree-like structure DicomDirPatient -> DicomDirStudy -> DicomDirSerie -> DicomDirImage.

Definition at line 51 of file gdcmDicomDir.h.


Member Typedef Documentation

typedef std::list<DicomElement> gdcm::Document::ListElements [inherited]
 

Definition at line 47 of file gdcmDocument.h.


Member Enumeration Documentation

enum gdcm::DicomDir::DicomDirType
 

Types of the DicomDirObject within the DicomDir.

Enumerator:
GDCM_DICOMDIR_NONE 
GDCM_DICOMDIR_META 
GDCM_DICOMDIR_PATIENT 
GDCM_DICOMDIR_STUDY 
GDCM_DICOMDIR_SERIE 
GDCM_DICOMDIR_VISIT 
GDCM_DICOMDIR_IMAGE 

Definition at line 104 of file gdcmDicomDir.h.


Constructor & Destructor Documentation

gdcm::DicomDir::DicomDir  )  [protected]
 

Constructor : creates an empty DicomDir.

Definition at line 120 of file gdcmDicomDir.cxx.

References Initialize(), NewMeta(), and ParseDir.

00121 {
00122    Initialize();  // sets all private fields to NULL
00123    ParseDir = false;
00124    NewMeta();
00125 }

gdcm::DicomDir::~DicomDir  )  [protected]
 

Canonical destructor.

Definition at line 130 of file gdcmDicomDir.cxx.

References ClearPatient(), gdcm::RefCounter::Delete(), and MetaElems.

00131 {
00132    ClearPatient();
00133    if ( MetaElems )
00134    {
00135       MetaElems->Delete();
00136    }
00137 }


Member Function Documentation

void gdcm::DicomDir::AbortProgress  )  [inline]
 

AbortProgress AbortProgress.

Definition at line 92 of file gdcmDicomDir.h.

00092 { Abort = true; }

bool gdcm::ElementSet::AddEntry DocEntry newEntry  )  [virtual, inherited]
 

add a new Dicom Element pointer to the H Table

Parameters:
newEntry entry to add

Implements gdcm::DocEntrySet.

Definition at line 78 of file gdcmElementSet.cxx.

References gdcmWarningMacro, gdcm::DocEntry::GetKey(), gdcm::RefCounter::Register(), and gdcm::ElementSet::TagHT.

Referenced by gdcm::File::DoTheLoadingJob(), gdcm::DocEntryArchive::Push(), and gdcm::DocEntryArchive::Restore().

00079 {
00080    const TagKey &key = newEntry->GetKey();
00081 
00082    if ( TagHT.count(key) == 1 )
00083    {
00084       gdcmWarningMacro( "Key already present: " << key );
00085       return false;
00086    }
00087    else
00088    {
00089       TagHT.insert(TagDocEntryHT::value_type(newEntry->GetKey(), newEntry));
00090       newEntry->Register();
00091       return true;
00092    }
00093 }

void gdcm::Document::AddForceLoadElement uint16_t  group,
uint16_t  elem
[inherited]
 

Adds a new element we want to load anyway.

Parameters:
group Group number of the target tag.
elem Element number of the target tag.

Definition at line 279 of file gdcmDocument.cxx.

References gdcm::DicomElement::Elem, gdcm::DicomElement::Group, and gdcm::Document::UserForceLoadList.

00280 { 
00281    DicomElement el;
00282    el.Group = group;
00283    el.Elem  = elem;
00284    UserForceLoadList.push_back(el); 
00285 }

bool gdcm::DicomDir::AddImageToEnd DicomDirImage dd  )  [private]
 

AddImageToEnd.

Parameters:
dd SQ Item to enqueue to the DicomDirImage chained List

Definition at line 734 of file gdcmDicomDir.cxx.

References gdcm::DicomDirSerie::AddImage(), gdcm::DicomDirStudy::GetLastSerie(), and Patients.

Referenced by CreateDicomDir(), and SetElement().

00735 {
00736    if ( Patients.size() > 0 )
00737    {
00738       ListDicomDirPatient::iterator itp = Patients.end();
00739       itp--;
00740 
00741       DicomDirStudy *study = (*itp)->GetLastStudy();
00742       if ( study )
00743       {
00744          DicomDirSerie *serie = study->GetLastSerie();
00745          if ( serie )
00746          {
00747             serie->AddImage(dd);
00748             return true;
00749          }
00750       }
00751    }
00752    return false;
00753 }

bool gdcm::DicomDir::AddPatientToEnd DicomDirPatient dd  )  [private]
 

AddPatientToEnd.

Parameters:
dd SQ Item to enqueue to the DicomPatient chained List

Definition at line 667 of file gdcmDicomDir.cxx.

References Patients.

Referenced by CreateDicomDir(), NewPatient(), and SetElement().

00668 {
00669    Patients.push_back(dd);
00670    return true;
00671 }

bool gdcm::DicomDir::AddSerieToEnd DicomDirSerie dd  )  [private]
 

AddSerieToEnd.

Parameters:
dd SQ Item to enqueue to the DicomDirSerie chained List

Definition at line 693 of file gdcmDicomDir.cxx.

References gdcm::DicomDirStudy::AddSerie(), and Patients.

Referenced by CreateDicomDir(), and SetElement().

00694 {
00695    if ( Patients.size() > 0 )
00696    {
00697       ListDicomDirPatient::iterator itp = Patients.end();
00698       itp--;
00699 
00700       DicomDirStudy *study = (*itp)->GetLastStudy();
00701       if ( study )
00702       {
00703          study->AddSerie(dd);
00704          return true;
00705       }
00706    }
00707    return false;
00708 }

bool gdcm::DicomDir::AddStudyToEnd DicomDirStudy dd  )  [private]
 

AddStudyToEnd.

Parameters:
dd SQ Item to enqueue to the DicomDirStudy chained List

Definition at line 677 of file gdcmDicomDir.cxx.

References Patients.

Referenced by CreateDicomDir(), and SetElement().

00678 {
00679    if ( Patients.size() > 0 )
00680    {
00681       ListDicomDirPatient::iterator itp = Patients.end();
00682       itp--;
00683       (*itp)->AddStudy(dd);
00684       return true;
00685    }
00686    return false;
00687 }

bool gdcm::DicomDir::AddVisitToEnd DicomDirVisit dd  )  [private]
 

AddVisitToEnd.

Parameters:
dd SQ Item to enqueue to the DicomDirVisit chained List

Definition at line 714 of file gdcmDicomDir.cxx.

References gdcm::DicomDirStudy::AddVisit(), and Patients.

Referenced by CreateDicomDir().

00715 {
00716    if ( Patients.size() > 0 )
00717    {
00718       ListDicomDirPatient::iterator itp = Patients.end();
00719       itp--;
00720 
00721       DicomDirStudy *study = (*itp)->GetLastStudy();
00722       if ( study )
00723       {
00724          study->AddVisit(dd);
00725          return true;
00726       }
00727    }
00728    return false;
00729 }

bool gdcm::DicomDir::Anonymize  ) 
 

Anonymize a DICOMDIR.

Returns:
true

Definition at line 404 of file gdcmDicomDir.cxx.

References Patients, and gdcm::DataEntry::SetString().

00405 {
00406    DataEntry *v;
00407    // Something clever to be found to forge the Patient names
00408    std::ostringstream s;
00409    int i = 1;
00410    for(ListDicomDirPatient::iterator cc = Patients.begin();
00411                                      cc!= Patients.end();
00412                                    ++cc)
00413    {
00414       s << i;
00415       v = (*cc)->GetDataEntry(0x0010, 0x0010) ; // Patient's Name
00416       if (v)
00417       {
00418          v->SetString(s.str());
00419       }
00420 
00421       v = (*cc)->GetDataEntry(0x0010, 0x0020) ; // Patient ID
00422       if (v)
00423       {
00424          v->SetString(" ");
00425       }
00426 
00427       v = (*cc)->GetDataEntry(0x0010, 0x0030) ; // Patient's BirthDate
00428       if (v)
00429       {
00430          v->SetString(" ");
00431       }
00432       s << "";
00433       i++;
00434    }
00435    return true;
00436 }

void gdcm::Document::CallEndMethod  )  [protected, virtual, inherited]
 

CallEndMethod.

Definition at line 1007 of file gdcmDocument.cxx.

References gdcm::CMD_ENDPROGRESS, gdcm::CommandManager::ExecuteCommand(), and gdcm::Document::Progress.

Referenced by CreateDicomDirChainedList().

01008 {
01009    Progress = 1.0f;
01010    CommandManager::ExecuteCommand(this,CMD_ENDPROGRESS);
01011 }

void gdcm::Document::CallProgressMethod  )  [protected, virtual, inherited]
 

CallProgressMethod.

Definition at line 999 of file gdcmDocument.cxx.

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

Referenced by CreateDicomDirChainedList().

01000 {
01001    CommandManager::ExecuteCommand(this,CMD_PROGRESS);
01002 }

void gdcm::Document::CallStartMethod  )  [protected, virtual, inherited]
 

CallStartMethod.

Definition at line 989 of file gdcmDocument.cxx.

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

Referenced by CreateDicomDirChainedList().

00990 {
00991    Progress = 0.0f;
00992    Abort    = false;
00993    CommandManager::ExecuteCommand(this,CMD_STARTPROGRESS);
00994 }

bool gdcm::DocEntrySet::CheckIfEntryExist uint16_t  group,
uint16_t  elem
[virtual, inherited]
 

Checks if a given Dicom Element exists within the DocEntrySet.

Parameters:
group Group number of the searched Dicom Element
elem Element number of the searched Dicom Element
Returns:
true is found

Definition at line 392 of file gdcmDocEntrySet.cxx.

References gdcm::DocEntrySet::GetDocEntry().

00393 {
00394    return GetDocEntry(group,elem)!=NULL;
00395 }

void gdcm::ElementSet::ClearEntry  )  [virtual, inherited]
 

delete all entries in the ElementSet

Implements gdcm::DocEntrySet.

Definition at line 116 of file gdcmElementSet.cxx.

References gdcm::ElementSet::TagHT.

Referenced by gdcm::ElementSet::Copy(), CreateDicomDir(), gdcm::Document::DoTheLoadingDocumentJob(), SetElements(), and gdcm::ElementSet::~ElementSet().

00117 {
00118    for(TagDocEntryHT::iterator cc = TagHT.begin();cc != TagHT.end(); ++cc)
00119    {
00120       if ( cc->second )
00121       {
00122          cc->second->Unregister();
00123       }
00124    }
00125    TagHT.clear();
00126 }

void gdcm::DicomDir::ClearPatient  ) 
 

Remove all Patients.

Definition at line 297 of file gdcmDicomDir.cxx.

References Patients.

Referenced by Copy(), SetElements(), and ~DicomDir().

00298 {
00299    for(ListDicomDirPatient::iterator cc = Patients.begin();
00300                                      cc!= Patients.end();
00301                                    ++cc)
00302    {
00303       (*cc)->Unregister();
00304    }
00305    Patients.clear();
00306 }

bool gdcm::Document::CloseFile  )  [inherited]
 

closes the file

Returns:
TRUE if the close was successfull

Definition at line 647 of file gdcmDocument.cxx.

References gdcm::Document::Fp.

Referenced by gdcm::Document::DoTheLoadingDocumentJob(), gdcm::File::DoTheLoadingJob(), gdcm::FileHelper::GetRaw(), gdcm::Document::LoadEntryBinArea(), gdcm::Document::OpenFile(), and gdcm::Document::~Document().

00648 {
00649    if ( Fp )
00650    {
00651       Fp->close();
00652       delete Fp;
00653       Fp = 0;
00654    }
00655    return true;
00656 }

int gdcm::Document::ComputeGroup0002Length  )  [protected, inherited]
 

Re-computes the length of the Dicom group 0002.

Definition at line 945 of file gdcmDocument.cxx.

References gdcm::DocEntry::GetElement(), gdcm::ElementSet::GetFirstEntry(), gdcm::DocEntry::GetGroup(), gdcm::DocEntry::GetLength(), gdcm::ElementSet::GetNextEntry(), and gdcm::DocEntry::GetVR().

Referenced by gdcm::File::Write().

00946 {
00947    uint16_t gr;
00948    VRKey vr;
00949    
00950    int groupLength = 0;
00951    bool found0002 = false;   
00952   
00953    // for each zero-level Tag in the DCM Header
00954    DocEntry *entry = GetFirstEntry();
00955    while( entry )
00956    {
00957       gr = entry->GetGroup();
00958 
00959       if ( gr == 0x0002 )
00960       {
00961          found0002 = true;
00962 
00963          if ( entry->GetElement() != 0x0000 )
00964          {
00965             vr = entry->GetVR();
00966 
00967             //if ( (vr == "OB")||(vr == "OW")||(vr == "UT")||(vr == "SQ"))
00968             // (no SQ, OW, UT in group 0x0002;)
00969                if ( vr == "OB" ) 
00970                {
00971                   // explicit VR AND (OB, OW, SQ, UT) : 4 more bytes
00972                   groupLength +=  4;
00973                }
00974  
00975             groupLength += 2 + 2 + 4 + entry->GetLength();   
00976          }
00977       }
00978       else if (found0002 )
00979          break;
00980 
00981       entry = GetNextEntry();
00982    }
00983    return groupLength; 
00984 }

void gdcm::DicomDir::Copy DocEntrySet set  )  [virtual]
 

Copies all the attributes from an other DocEntrySet.

Parameters:
set entry to copy from
Remarks:
The contained DocEntries are not copied, only referenced

Reimplemented from gdcm::ElementSet.

Definition at line 443 of file gdcmDicomDir.cxx.

References ClearPatient(), gdcm::ElementSet::Copy(), ItPatient, MetaElems, Patients, gdcm::RefCounter::Register(), and gdcm::RefCounter::Unregister().

00444 {
00445    // Remove all previous childs
00446    ClearPatient();
00447 
00448    Document::Copy(set);
00449 
00450    DicomDir *dd = dynamic_cast<DicomDir *>(set);
00451    if( dd )
00452    {
00453       if(MetaElems)
00454          MetaElems->Unregister();
00455       MetaElems = dd->MetaElems;
00456       if(MetaElems)
00457          MetaElems->Register();
00458 
00459       Patients = dd->Patients;
00460       for(ItPatient = Patients.begin();ItPatient != Patients.end();++ItPatient)
00461          (*ItPatient)->Register();
00462    }
00463 }

void gdcm::DicomDir::CreateDicomDir  )  [private]
 

create a 'gdcmDicomDir' from a DICOMDIR Header

Definition at line 543 of file gdcmDicomDir.cxx.

References AddImageToEnd(), AddPatientToEnd(), AddSerieToEnd(), AddStudyToEnd(), AddVisitToEnd(), gdcm::ElementSet::ClearEntry(), gdcm::SQItem::Copy(), gdcmDebugMacro, gdcmErrorMacro, gdcmWarningMacro, gdcm::SQItem::GetDocEntry(), gdcm::ElementSet::GetDocEntry(), gdcm::SeqEntry::GetFirstSQItem(), gdcm::SeqEntry::GetNextSQItem(), gdcm::DicomDirPatient::New(), gdcm::DicomDirStudy::New(), gdcm::DicomDirVisit::New(), gdcm::DicomDirSerie::New(), gdcm::DicomDirImage::New(), and NewMeta().

Referenced by DoTheLoadingJob(), and ParseDirectory().

00544 {
00545    // The SeqEntries of "Directory Record Sequence" are parsed. 
00546    //  When a DicomDir tag ("PATIENT", "STUDY", "SERIE", "IMAGE") is found :
00547    //  1 - we save the beginning iterator
00548    //  2 - we continue to parse
00549    //  3 - we find an other tag
00550    //       + we create the object for the precedent tag
00551    //       + loop to 1 -
00552    gdcmDebugMacro("Create DicomDir");
00553 
00554    // Directory record sequence
00555    DocEntry *e = GetDocEntry(0x0004, 0x1220);
00556    if ( !e )
00557    {
00558       gdcmWarningMacro( "No Directory Record Sequence (0004,1220) found");
00559       return;         
00560    }
00561    
00562    SeqEntry *s = dynamic_cast<SeqEntry *>(e);
00563    if ( !s )
00564    {
00565       gdcmWarningMacro( "Element (0004,1220) is not a Sequence ?!?");
00566       return;
00567    }
00568 
00569    NewMeta();
00570    
00571    DocEntry *d;
00572    std::string v;
00573    SQItem *si;
00574 
00575    SQItem *tmpSI=s->GetFirstSQItem();
00576    while(tmpSI)
00577    {
00578       d = tmpSI->GetDocEntry(0x0004, 0x1430); // Directory Record Type
00579       if ( DataEntry *dataEntry = dynamic_cast<DataEntry *>(d) )
00580       {
00581          v = dataEntry->GetString();
00582       }
00583       else
00584       {
00585          gdcmWarningMacro( "(0004,1430) not a DataEntry ?!?");
00586          continue;
00587       }
00588 
00589       // A decent DICOMDIR has much more images than series,
00590       // more series than studies, and so on.
00591       // This is the right order to perform the tests
00592 
00593       if ( v == "IMAGE " ) 
00594       {
00595          si = DicomDirImage::New(true);
00596          if ( !AddImageToEnd( static_cast<DicomDirImage *>(si)) )
00597          {
00598             si->Delete();
00599             si = NULL;
00600             gdcmErrorMacro( "Add AddImageToEnd failed");
00601          }
00602       }
00603       else if ( v == "SERIES" )
00604       {
00605          si = DicomDirSerie::New(true);
00606          if ( !AddSerieToEnd( static_cast<DicomDirSerie *>(si)) )
00607          {
00608             si->Delete();
00609             si = NULL;
00610             gdcmErrorMacro( "Add AddSerieToEnd failed");
00611          }
00612       }
00613       else if ( v == "VISIT " )
00614       {
00615          si = DicomDirVisit::New(true);
00616          if ( !AddVisitToEnd( static_cast<DicomDirVisit *>(si)) )
00617          {
00618             si->Delete();
00619             si = NULL;
00620             gdcmErrorMacro( "Add AddVisitToEnd failed");
00621          }
00622       }
00623       else if ( v == "STUDY " )
00624       {
00625          si = DicomDirStudy::New(true);
00626          if ( !AddStudyToEnd( static_cast<DicomDirStudy *>(si)) )
00627          {
00628             si->Delete();
00629             si = NULL;
00630             gdcmErrorMacro( "Add AddStudyToEnd failed");
00631          }
00632       }
00633       else if ( v == "PATIENT " )
00634       {
00635          si = DicomDirPatient::New(true);
00636          if ( !AddPatientToEnd( static_cast<DicomDirPatient *>(si)) )
00637          {
00638             si->Delete();
00639             si = NULL;
00640             gdcmErrorMacro( "Add PatientToEnd failed");
00641          }
00642       }
00643       else
00644       {
00645          // It was neither a 'PATIENT', nor a 'STUDY', nor a 'SERIE',
00646          // nor an 'IMAGE' SQItem. Skip to next item.
00647          gdcmDebugMacro( " -------------------------------------------"
00648          << "a non PATIENT/STUDY/SERIE/IMAGE SQItem was found : "
00649          << v);
00650 
00651         // FIXME : deal with other item types !
00652         tmpSI=s->GetNextSQItem(); // To avoid infinite loop
00653         continue;
00654       }
00655       if ( si )
00656          si->Copy(tmpSI);
00657 
00658       tmpSI=s->GetNextSQItem();
00659    }
00660    ClearEntry();
00661 }

void gdcm::DicomDir::CreateDicomDirChainedList std::string const &  path  )  [protected]
 

create a Document-like chained list from a root Directory

Parameters:
path entry point of the tree-like structure

Definition at line 471 of file gdcmDicomDir.cxx.

References gdcm::Document::Abort, gdcm::Document::CallEndMethod(), gdcm::Document::CallProgressMethod(), gdcm::Document::CallStartMethod(), gdcm::RefCounter::Delete(), gdcmDebugMacro, gdcm::DirList::GetDirName(), gdcm::DirList::GetFilenames(), HeaderLessThan(), gdcm::File::IsReadable(), gdcm::File::Load(), gdcm::Document::LoadMode, gdcm::File::New(), gdcm::Document::Progress, SetElements(), gdcm::Document::SetFileName(), and gdcm::Document::SetLoadMode().

Referenced by ParseDirectory().

00472 {
00473    CallStartMethod();
00474    DirList dirList(path,1); // gets recursively the file list
00475    unsigned int count = 0;
00476    VectDocument list;
00477    File *f;
00478 
00479    DirListType fileList = dirList.GetFilenames();
00480    unsigned int nbFile = fileList.size();
00481    for( DirListType::iterator it  = fileList.begin();
00482                               it != fileList.end();
00483                               ++it )
00484    {
00485       Progress = (float)(count+1)/(float)nbFile;
00486       CallProgressMethod();
00487       if ( Abort )
00488       {
00489          break;
00490       }
00491 
00492       f = File::New( );
00493       f->SetLoadMode(LoadMode); // we allow user not to load Sequences, 
00494                                 //        or Shadow groups, or ......
00495       f->SetFileName( it->c_str() );
00496       f->Load( );
00497 
00498       if ( f->IsReadable() )
00499       {
00500          // Add the file to the chained list:
00501          list.push_back(f);
00502          gdcmDebugMacro( "Readable " << it->c_str() );
00503        }
00504        else
00505        {
00506           f->Delete();
00507        }
00508        count++;
00509    }
00510    // sorts Patient/Study/Serie/
00511    std::sort(list.begin(), list.end(), DicomDir::HeaderLessThan );
00512    
00513    std::string tmp = dirList.GetDirName();      
00514    //for each File of the chained list, add/update the Patient/Study/Serie/Image info
00515    SetElements(tmp, list);
00516    CallEndMethod();
00517 
00518    for(VectDocument::iterator itDoc=list.begin();
00519        itDoc!=list.end();
00520        ++itDoc)
00521    {
00522       dynamic_cast<File *>(*itDoc)->Delete();
00523    }
00524 }

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

Delete the object.

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

Definition at line 39 of file gdcmRefCounter.h.

Referenced by gdcm::SerieHelper::AddFileName(), gdcm::Document::Backtrack(), gdcm::FileHelper::CheckMandatoryElements(), gdcm::FileHelper::CheckMandatoryEntry(), gdcm::FileHelper::CopyMandatoryEntry(), CreateDicomDirChainedList(), gdcm::File::DoTheLoadingJob(), gdcm::Dict::DoTheLoadingJob(), gdcm::DicomDirObject::FillObject(), gdcm::DocEntrySet::InsertEntryBinArea(), gdcm::DocEntrySet::InsertEntryString(), gdcm::DocEntrySet::InsertSeqEntry(), vtkGdcmReader::LoadFileInformation(), vtkGdcmReader::LoadImageInMemory(), main(), NewMeta(), gdcm::DicomDirStudy::NewVisit(), gdcm::Document::ParseDES(), gdcm::Document::ParseSQ(), gdcm::Document::ReadNextDocEntry(), SetElement(), gdcm::FileHelper::SetMandatoryEntry(), gdcm::FileHelper::SetWriteFileTypeToExplicitVR(), gdcm::FileHelper::SetWriteFileTypeToImplicitVR(), gdcm::FileHelper::SetWriteFileTypeToJPEG(), gdcm::FileHelper::SetWriteToLibido(), gdcm::FileHelper::SetWriteToNoLibido(), gdcm::FileHelper::SetWriteToRaw(), gdcm::FileHelper::SetWriteToRGB(), vtkGdcmWriter::WriteDcmFile(), ~DicomDir(), and gdcm::Global::~Global().

00039 { Unregister(); }

bool gdcm::DicomDir::DoTheLoadingJob  )  [private]
 

Does the Loading Job (internal use only).

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

Definition at line 163 of file gdcmDicomDir.cxx.

References gdcm::Document::Abort, CreateDicomDir(), gdcm::Document::Fp, gdcmDebugMacro, gdcmErrorMacro, gdcmWarningMacro, gdcm::ElementSet::GetDocEntry(), gdcm::Document::GetFileName(), gdcm::ElementSet::GetFirstEntry(), gdcm::Document::Load(), NewMeta(), ParseDir, ParseDirectory(), gdcm::Document::Progress, and SetFileName().

Referenced by Load().

00164 {
00165    Progress = 0.0f;
00166    Abort = false;
00167 
00168    if (!ParseDir)
00169    {
00170    // Only if user passed a DICOMDIR
00171    // ------------------------------
00172       Fp = 0;
00173       if (!Document::Load() )
00174       {
00175          return false;
00176       }
00177 
00178       if ( GetFirstEntry() == 0 ) // when user passed a Directory to parse
00179       {
00180          gdcmWarningMacro( "Entry HT empty for file: "<< GetFileName());
00181          return false;
00182       }
00183       // Directory record sequence
00184       DocEntry *e = GetDocEntry(0x0004, 0x1220);
00185       if ( !e )
00186       {
00187          gdcmWarningMacro( "NO 'Directory record sequence' (0x0004,0x1220)"
00188                           << " in file " << GetFileName());
00189          return false;
00190       }
00191       else
00192          CreateDicomDir();
00193    }
00194    else
00195    {
00196    // Only if user passed a root directory
00197    // ------------------------------------
00198       if ( GetFileName() == "." )
00199       {
00200          // user passed '.' as Name
00201          // we get current directory name
00202          char buf[2048];
00203          const char *cwd = getcwd(buf, 2048);
00204          if( cwd )
00205          {
00206            SetFileName( buf ); // will be converted into a string
00207          }
00208          else
00209          {
00210            gdcmErrorMacro( "Path was too long to fit on 2048 bytes" );
00211          }
00212       }
00213       NewMeta();
00214       gdcmDebugMacro( "Parse directory and create the DicomDir : " 
00215                          << GetFileName() );
00216       ParseDirectory();
00217    }
00218    return true;
00219 }

gdcm::DicomDir::gdcmTypeMacro DicomDir   )  [private]
 

DataEntry * gdcm::DocEntrySet::GetDataEntry uint16_t  group,
uint16_t  elem
[inherited]
 

Same as Document::GetDocEntry except it returns a result only when the corresponding entry is of type DataEntry.

Parameters:
group Group number of the searched Dicom Element
elem Element number of the searched Dicom Element
Returns:
When present, the corresponding DataEntry.

Definition at line 99 of file gdcmDocEntrySet.cxx.

References gdcm::DocEntrySet::GetDocEntry().

Referenced by gdcm::FileHelper::CheckMandatoryElements(), gdcm::FileHelper::CheckMandatoryEntry(), gdcm::Document::DoTheLoadingDocumentJob(), gdcm::File::GetBitsAllocated(), gdcm::File::GetBitsStored(), gdcm::DocEntrySet::GetEntryBinArea(), gdcm::File::GetHighBitPosition(), gdcm::File::GetPlanarConfiguration(), gdcm::File::GetRescaleIntercept(), gdcm::File::GetRescaleSlope(), gdcm::File::GetSamplesPerPixel(), gdcm::File::GetXOrigin(), gdcm::File::GetXSize(), gdcm::File::GetXSpacing(), gdcm::File::GetYOrigin(), gdcm::File::GetYSize(), gdcm::File::GetYSpacing(), gdcm::File::GetZOrigin(), gdcm::File::GetZSize(), gdcm::File::GetZSpacing(), gdcm::File::IsSignedPixelData(), gdcm::ElementSet::Print(), gdcm::DocEntrySet::SetEntryBinArea(), gdcm::DocEntrySet::SetEntryString(), gdcm::FileHelper::SetWriteToLibido(), gdcm::FileHelper::SetWriteToNoLibido(), userSuppliedLessThanFunction(), gdcm::FileHelper::Write(), gdcm::File::Write(), and gdcm::DicomDirMeta::WriteContent().

00100 {
00101    DocEntry *currentEntry = GetDocEntry(group, elem);
00102    if ( !currentEntry )
00103       return NULL;
00104 
00105    return dynamic_cast<DataEntry*>(currentEntry);
00106 }

DictEntry * gdcm::DocEntrySet::GetDictEntry uint16_t  group,
uint16_t  elem,
VRKey const &  vr
[protected, inherited]
 

Searches [both] the public [and the shadow dictionary (when they exist)] for the presence of the DictEntry with given group and element, and create a new virtual DictEntry if necessary.

Parameters:
group group number of the searched DictEntry
elem element number of the searched DictEntry
vr V(alue) R(epresentation) to use, if necessary
Returns:
Corresponding DictEntry when it exists, NULL otherwise.
Remarks:
The returned DictEntry is registered

Definition at line 484 of file gdcmDocEntrySet.cxx.

References gdcm::GDCM_VRUNKNOWN, gdcmWarningMacro, gdcm::DocEntrySet::GetDictEntry(), gdcm::DictEntry::GetVM(), gdcm::DictEntry::GetVR(), gdcm::DictEntry::New(), gdcm::RefCounter::Register(), and gdcm::RefCounter::Unregister().

00486 {
00487    DictEntry *dictEntry = GetDictEntry(group,elem);
00488    DictEntry *goodEntry = dictEntry;
00489    VRKey goodVR = vr;
00490    TagName vm;
00491    if (elem == 0x0000) 
00492       goodVR="UL";
00493 
00494    if ( goodEntry )
00495    {
00496       if ( goodVR != goodEntry->GetVR()
00497         && goodVR != GDCM_VRUNKNOWN )
00498       { 
00499          gdcmWarningMacro("For (" << std::hex << group << "|"
00500             << elem << "), found VR : [" << vr << "]"
00501             << " expected: [" << goodEntry->GetVR() << "]" ) ;
00502         // avoid confusing further validator with "FIXME" VM
00503         // when possible      
00504          vm = dictEntry->GetVM();
00505          goodEntry = NULL;
00506       }
00507       dictEntry->Unregister();
00508    }
00509    else
00510    {
00511       vm = "FIXME";
00512    }
00513    // Create a new virtual DictEntry if necessary
00514    if (!goodEntry)
00515    {
00516       if (dictEntry)
00517       {
00518 
00519          goodEntry = DictEntry::New(group, elem, goodVR, vm,//"FIXME", 
00520                                     dictEntry->GetName() );
00521       }
00522       else
00523       {
00524          goodEntry = DictEntry::New(group, elem, goodVR);
00525       }
00526    }
00527    else
00528    {
00529       goodEntry->Register();
00530    }
00531    return goodEntry;
00532 }

DictEntry * gdcm::DocEntrySet::GetDictEntry uint16_t  group,
uint16_t  elem
[protected, inherited]
 

Searches [both] the public [and the shadow dictionary (when they exist)] for the presence of the DictEntry with given group and element. The public dictionary has precedence on the shadow one(s), if any.

Parameters:
group Group number of the searched DictEntry
elem Element number of the searched DictEntry
Returns:
Corresponding DictEntry when it exists, NULL otherwise.
Remarks:
The returned DictEntry is registered when existing

Definition at line 457 of file gdcmDocEntrySet.cxx.

References gdcmWarningMacro, gdcm::DictSet::GetDefaultPubDict(), gdcm::Global::GetDicts(), gdcm::Dict::GetEntry(), and gdcm::RefCounter::Register().

Referenced by gdcm::DocEntrySet::GetDictEntry(), gdcm::DocEntrySet::NewDataEntry(), gdcm::DocEntrySet::NewSeqEntry(), and gdcm::Document::ReadNextDocEntry().

00458 {
00459    DictEntry *found = 0;
00460    Dict *pubDict = Global::GetDicts()->GetDefaultPubDict();
00461    if (!pubDict) 
00462    {
00463       gdcmWarningMacro( "We SHOULD have a default dictionary");
00464    }
00465    else
00466    {
00467       found = pubDict->GetEntry(group, elem);
00468       if( found )
00469          found->Register();
00470    }
00471    return found;
00472 }

DocEntry * gdcm::ElementSet::GetDocEntry uint16_t  group,
uint16_t  elem
[virtual, inherited]
 

retrieves a Dicom Element using (group, element)

Parameters:
group Group number of the searched Dicom Element
elem Element number of the searched Dicom Element
Returns:

Implements gdcm::DocEntrySet.

Definition at line 163 of file gdcmElementSet.cxx.

References gdcm::ElementSet::TagHT, and gdcm::DictEntry::TranslateToKey().

Referenced by gdcm::File::AnonymizeFile(), gdcm::File::AnonymizeNoLoad(), gdcm::FileHelper::CopyDataEntry(), CreateDicomDir(), gdcm::Document::DoTheLoadingDocumentJob(), gdcm::File::DoTheLoadingJob(), DoTheLoadingJob(), gdcm::File::GetPixelAreaLength(), gdcm::File::GetPixelOffset(), gdcm::Document::GetTransferSyntax(), gdcm::File::HasLUT(), gdcm::Document::IsDicomV3(), gdcm::Document::IsPapyrus(), gdcm::File::IsReadable(), gdcm::Document::LoadEntryBinArea(), gdcm::DocEntryArchive::Push(), and gdcm::DocEntryArchive::Restore().

00164 {
00165    TagKey key = DictEntry::TranslateToKey(group, elem);
00166    TagDocEntryHT::iterator it = TagHT.find(key);
00167 
00168    if ( it!=TagHT.end() )
00169       return it->second;
00170    return NULL;
00171 }

void * gdcm::DocEntrySet::GetEntryBinArea uint16_t  group,
uint16_t  elem
[virtual, inherited]
 

Gets (from Header) a 'non string' element value.

Parameters:
group group number of the Entry
elem element number of the Entry
Returns:
Pointer to the 'non string' area

Definition at line 69 of file gdcmDocEntrySet.cxx.

References gdcm::DataEntry::GetBinArea(), and gdcm::DocEntrySet::GetDataEntry().

Referenced by gdcm::PixelReadConvert::GrabInformationsFromFile().

00070 {
00071    DataEntry *entry = GetDataEntry(group, elem);
00072    if ( entry )
00073       return entry->GetBinArea();
00074    return 0;
00075 }

int gdcm::DocEntrySet::GetEntryLength uint16_t  group,
uint16_t  elem
[virtual, inherited]
 

Searches within the DocEntrySet for the value length of a given tag..

Parameters:
group Group number of the searched tag.
elem Element number of the searched tag.
Returns:
Corresponding element length; -1 if not found

Definition at line 84 of file gdcmDocEntrySet.cxx.

References gdcm::DocEntrySet::GetDocEntry(), and gdcm::DocEntry::GetLength().

Referenced by SetElement(), and gdcm::File::Write().

00085 {
00086    DocEntry *entry = GetDocEntry(group, elem);
00087    if ( entry )
00088       return entry->GetLength();
00089    return -1;
00090 }

std::string gdcm::DocEntrySet::GetEntryString uint16_t  group,
uint16_t  elem
[virtual, inherited]
 

Get the "std::string representable" value of the Dicom entry.

Parameters:
group Group number of the searched tag.
elem Element number of the searched tag.
Returns:
Corresponding element value when it exists, and the string GDCM_UNFOUND otherwise.

Definition at line 47 of file gdcmDocEntrySet.cxx.

References gdcm::GDCM_NOTLOADED, gdcm::GDCM_UNFOUND, gdcm::GDCM_UNREAD, gdcm::DocEntrySet::GetDocEntry(), gdcm::DataEntry::GetString(), gdcm::DataEntry::IsNotLoaded(), gdcm::DataEntry::IsUnfound(), and gdcm::DataEntry::IsUnread().

Referenced by gdcm::SerieHelper::AddFileName(), gdcm::File::AnonymizeFile(), gdcm::FileHelper::CheckMandatoryElements(), gdcm::SerieHelper::CreateUniqueSeriesIdentifier(), gdcm::SerieHelper::CreateUserDefinedFileIdentifier(), gdcm::Document::DoTheLoadingDocumentJob(), gdcm::File::DoTheLoadingJob(), gdcm::File::GetImageNumber(), gdcm::File::GetImageOrientationPatient(), gdcm::File::GetLUTNbits(), gdcm::File::GetModality(), gdcm::File::GetNumberOfScalarComponents(), gdcm::File::GetNumberOfScalarComponentsRaw(), gdcm::File::GetPixelSize(), gdcm::File::GetPixelType(), gdcm::Document::GetTransferSyntaxName(), gdcm::PixelReadConvert::GrabInformationsFromFile(), gdcm::File::IsMonochrome(), gdcm::File::IsMonochrome1(), gdcm::File::IsPaletteColor(), gdcm::File::IsReadable(), gdcm::File::IsYBRFull(), gdcm::Document::operator<(), and SetElement().

00048 {
00049    DataEntry *entry = dynamic_cast<DataEntry *>(GetDocEntry(group,elem));
00050    if ( entry )
00051    {
00052       if( entry->IsNotLoaded() )
00053          return GDCM_NOTLOADED;
00054       if( entry->IsUnfound() )
00055          return GDCM_UNFOUND;
00056       if( entry->IsUnread() )
00057          return GDCM_UNREAD;
00058       return entry->GetString();
00059    }
00060    return GDCM_UNFOUND;
00061 }

const std::string& gdcm::Document::GetFileName  )  const [inline, inherited]
 

Accessor to Filename.

Definition at line 77 of file gdcmDocument.h.

Referenced by DoTheLoadingJob(), gdcm::SerieHelper::FileNameGreaterThan(), gdcm::SerieHelper::FileNameLessThan(), gdcm::Document::IsParsable(), IsReadable(), gdcm::Document::Load(), vtkGdcmReader::LoadImageInMemory(), ParseDirectory(), SetElement(), vtkGdcmReader::TestFileInformation(), and userSuppliedLessThanFunction2().

00077 { return Filename; }

FileType gdcm::Document::GetFileType  )  [inherited]
 

returns the File Type (ACR, ACR_LIBIDO, ExplicitVR, ImplicitVR, Unknown)

Returns:
the FileType code

Definition at line 392 of file gdcmDocument.cxx.

References gdcm::Document::Filetype.

00393 {
00394    return Filetype;
00395 }

DocEntry * gdcm::ElementSet::GetFirstEntry  )  [virtual, inherited]
 

Get the first entry while visiting *the* 'zero level' DocEntrySet (DocEntries out of any Sequence).

Returns:
The first DocEntry if found, otherwhise NULL

Implements gdcm::DocEntrySet.

Definition at line 133 of file gdcmElementSet.cxx.

References gdcm::ElementSet::ItTagHT, and gdcm::ElementSet::TagHT.

Referenced by gdcm::Document::ComputeGroup0002Length(), DoTheLoadingJob(), NewMeta(), and gdcm::Validator::SetInput().

00134 {
00135    ItTagHT = TagHT.begin();
00136    if (ItTagHT != TagHT.end())
00137       return  ItTagHT->second;
00138    return NULL;
00139 }

DicomDirPatient * gdcm::DicomDir::GetFirstPatient  ) 
 

Get the first entry while visiting the DicomDirPatients.

Returns:
The first DicomDirPatient if found, otherwhise NULL

Definition at line 312 of file gdcmDicomDir.cxx.

References ItPatient, and Patients.

00313 {
00314    ItPatient = Patients.begin();
00315    if ( ItPatient != Patients.end() )
00316       return *ItPatient;
00317    return NULL;
00318 }

DicomDirMeta* gdcm::DicomDir::GetMeta  )  [inline]
 

Returns a pointer to the DicomDirMeta for this DICOMDIR.

Definition at line 77 of file gdcmDicomDir.h.

Referenced by Write().

00077 { return MetaElems; }

DocEntry * gdcm::ElementSet::GetNextEntry  )  [virtual, inherited]
 

Get the next entry while visiting *the* 'zero level' DocEntrySet (DocEntries out of any Sequence).

Note:
: meaningfull only if GetFirstEntry already called
Returns:
The next DocEntry if found, otherwhise NULL

Implements gdcm::DocEntrySet.

Definition at line 147 of file gdcmElementSet.cxx.

References gdcmAssertMacro, gdcm::ElementSet::ItTagHT, and gdcm::ElementSet::TagHT.

Referenced by gdcm::Document::ComputeGroup0002Length(), and gdcm::Validator::SetInput().

00148 {
00149    gdcmAssertMacro (ItTagHT != TagHT.end());
00150 
00151    ++ItTagHT;
00152    if (ItTagHT != TagHT.end())
00153       return  ItTagHT->second;
00154    return NULL;
00155 }

DicomDirPatient * gdcm::DicomDir::GetNextPatient  ) 
 

Get the next entry while visiting the DicomDirPatients.

Note:
: meaningfull only if GetFirstEntry already called
Returns:
The next DicomDirPatient if found, otherwhise NULL

Definition at line 325 of file gdcmDicomDir.cxx.

References gdcmAssertMacro, ItPatient, and Patients.

00326 {
00327    gdcmAssertMacro (ItPatient != Patients.end());
00328 
00329    ++ItPatient;
00330    if ( ItPatient != Patients.end() )
00331       return *ItPatient;
00332    return NULL;
00333 }

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

Gets the print level for the Dicom Entries.

Definition at line 50 of file gdcmBase.h.

00050 { return PrintLevel; }

float gdcm::DicomDir::GetProgress  )  const [inline]
 

GetProgress GetProgress.

Definition at line 90 of file gdcmDicomDir.h.

00090 { return Progress; }

Dict * gdcm::Document::GetPubDict  )  [inherited]
 

Get the public dictionary used.

Definition at line 289 of file gdcmDocument.cxx.

References gdcm::Document::RefPubDict.

Referenced by SetElement().

00290 {
00291    return RefPubDict;
00292 }

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

Get the reference counting.

Returns:
Reference count

Definition at line 56 of file gdcmRefCounter.h.

00057    {
00058       return RefCount;
00059    }

SeqEntry * gdcm::DocEntrySet::GetSeqEntry uint16_t  group,
uint16_t  elem
[inherited]
 

Same as Document::GetDocEntry except it returns a result only when the corresponding entry is of type SeqEntry.

Parameters:
group Group number of the searched Dicom Element
elem Element number of the searched Dicom Element
Returns:
When present, the corresponding SeqEntry.

Definition at line 115 of file gdcmDocEntrySet.cxx.

References gdcm::DocEntrySet::GetDocEntry().

Referenced by gdcm::Document::DoTheLoadingDocumentJob().

00116 {
00117    DocEntry *currentEntry = GetDocEntry(group, elem);
00118    if ( !currentEntry )
00119       return NULL;
00120       
00121    return dynamic_cast<SeqEntry*>(currentEntry);
00122 }

Dict * gdcm::Document::GetShaDict  )  [inherited]
 

Get the shadow dictionary used.

Definition at line 297 of file gdcmDocument.cxx.

References gdcm::Document::RefShaDict.

00298 {
00299    return RefShaDict;
00300 }

int gdcm::Document::GetSwapCode  )  [inline, inherited]
 

'Swap code' accessor (see SwapCode )

Definition at line 73 of file gdcmDocument.h.

Referenced by gdcm::PixelReadConvert::GrabInformationsFromFile().

00073 { return SwapCode; }

std::string gdcm::Document::GetTransferSyntax  )  [inherited]
 

Accessor to the Transfer Syntax (when present) of the current document (it internally handles reading the value from disk when only parsing occured).

Returns:
The encountered Transfer Syntax of the current document, if DICOM. GDCM_UNKNOWN for ACR-NEMA files (or broken headers ...)

Definition at line 404 of file gdcmDocument.cxx.

References gdcm::GDCM_UNKNOWN, gdcmWarningMacro, gdcm::ElementSet::GetDocEntry(), and gdcm::Document::LoadDocEntrySafe().

Referenced by gdcm::File::ComputeJPEGFragmentInfo(), gdcm::File::ComputeRLEInfo(), gdcm::File::DoTheLoadingJob(), gdcm::PixelReadConvert::GrabInformationsFromFile(), and gdcm::Document::HandleOutOfGroup0002().

00405 {
00406    DocEntry *entry = GetDocEntry(0x0002, 0x0010);
00407    if ( !entry )
00408    {
00409       return GDCM_UNKNOWN;
00410    }
00411 
00412    // The entry might be present but not loaded (parsing and loading
00413    // happen at different stages): try loading and proceed with check...
00414    LoadDocEntrySafe(entry);
00415    if (DataEntry *dataEntry = dynamic_cast<DataEntry *>(entry) )
00416    {
00417       std::string transfer = dataEntry->GetString();
00418       // The actual transfer (as read from disk) might be padded. We
00419       // first need to remove the potential padding. We can make the
00420       // weak assumption that padding was not executed with digits...
00421       if  ( transfer.length() == 0 )
00422       {
00423          // for brain damaged headers
00424          gdcmWarningMacro( "Transfer Syntax has length = 0.");
00425          return GDCM_UNKNOWN;
00426       }
00427       while ( !isdigit((unsigned char)transfer[transfer.length()-1]) )
00428       {
00429          transfer.erase(transfer.length()-1, 1);
00430          if  ( transfer.length() == 0 )
00431          {
00432             // for brain damaged headers
00433             gdcmWarningMacro( "Transfer Syntax contains no valid character.");
00434             return GDCM_UNKNOWN;
00435          }
00436       }
00437       return transfer;
00438    }
00439    return GDCM_UNKNOWN;
00440 }

std::string gdcm::Document::GetTransferSyntaxName  )  [inherited]
 

Accesses the info from 0002,0010 : Transfer Syntax and TS.

Returns:
The full Transfer Syntax Name (as opposed to Transfer Syntax UID)

Definition at line 446 of file gdcmDocument.cxx.

References gdcm::GDCM_NOTLOADED, gdcm::GDCM_UNFOUND, gdcmDebugMacro, gdcmErrorMacro, gdcm::DocEntrySet::GetEntryString(), gdcm::Global::GetTS(), and gdcm::TS::GetValue().

Referenced by gdcm::Document::HandleOutOfGroup0002().

00447 {
00448    // use the TS (TS : Transfer Syntax)
00449    std::string transferSyntax = GetEntryString(0x0002,0x0010);
00450 
00451    if ( (transferSyntax.find(GDCM_NOTLOADED) < transferSyntax.length()) )
00452    {
00453       gdcmErrorMacro( "Transfer Syntax not loaded. " << std::endl
00454                << "Better you increase MAX_SIZE_LOAD_ELEMENT_VALUE" );
00455       return "Uncompressed ACR-NEMA";
00456    }
00457    if ( transferSyntax == GDCM_UNFOUND )
00458    {
00459       gdcmDebugMacro( "Unfound Transfer Syntax (0002,0010)");
00460       return "Uncompressed ACR-NEMA";
00461    }
00462 
00463    // we do it only when we need it
00464    const TSKey &tsName = Global::GetTS()->GetValue( transferSyntax );
00465 
00466    // Global::GetTS() is a global static you shall never try to delete it!
00467    return tsName;
00468 }

bool gdcm::DicomDir::HeaderLessThan Document header1,
Document header2
[static, private]
 

compares two files

Definition at line 1045 of file gdcmDicomDir.cxx.

Referenced by CreateDicomDirChainedList().

01046 {
01047    return *header1 < *header2;
01048 }

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

Sets all fields to NULL.

Reimplemented from gdcm::Document.

Definition at line 532 of file gdcmDicomDir.cxx.

References gdcm::Document::Abort, MetaElems, and gdcm::Document::Progress.

Referenced by DicomDir().

00533 {
00534    Progress = 0.0;
00535    Abort = false;
00536 
00537    MetaElems = NULL;   
00538 }

DataEntry * gdcm::DocEntrySet::InsertEntryBinArea uint8_t *  binArea,
int  lgth,
uint16_t  group,
uint16_t  elem,
VRKey const &  vr = GDCM_VRUNKNOWN
[inherited]
 

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

Parameters:
binArea (binary) value to be set
lgth length of the Bin Area we want to set
group Group number of the Entry
elem Element number of the Entry
vr V(alue) R(epresentation) of the Entry -if private Entry-
Returns:
pointer to the modified/created Header Entry (NULL when creation failed).

Definition at line 270 of file gdcmDocEntrySet.cxx.

References gdcm::DocEntrySet::AddEntry(), gdcm::RefCounter::Delete(), gdcmWarningMacro, gdcm::DocEntrySet::GetDocEntry(), gdcm::DocEntry::GetVR(), gdcm::DocEntrySet::NewDataEntry(), gdcm::DocEntrySet::RemoveEntry(), and gdcm::DocEntrySet::SetEntryBinArea().

Referenced by gdcm::FileHelper::InsertEntryBinArea().

00273 {
00274    DataEntry *dataEntry = 0;
00275    DocEntry *currentEntry = GetDocEntry( group, elem );
00276 
00277    // Verify the currentEntry
00278    if (currentEntry)
00279    {
00280       dataEntry = dynamic_cast<DataEntry *>(currentEntry);
00281 
00282       // Verify the VR
00283       if ( dataEntry )
00284          if ( dataEntry->GetVR()!=vr )
00285             dataEntry = NULL;
00286 
00287       // if currentEntry doesn't correspond to the requested dataEntry
00288       if ( !dataEntry)
00289       {
00290          if ( !RemoveEntry(currentEntry) )
00291          {
00292             gdcmWarningMacro( "Removal of previous DocEntry failed.");
00293             return NULL;
00294          }
00295       }
00296    }
00297 
00298    // Create a new dataEntry if necessary
00299    if ( !dataEntry)
00300    {
00301       dataEntry = NewDataEntry(group, elem, vr);
00302 
00303       if ( !AddEntry(dataEntry) )
00304       {
00305          gdcmWarningMacro( "AddEntry failed although this is a creation.");
00306          dataEntry->Delete();
00307          return NULL;
00308       }
00309       dataEntry->Delete();
00310    }
00311 
00312    // Set the dataEntry value
00313    uint8_t *tmpArea;
00314    if ( lgth>0 && binArea )
00315    {
00316       tmpArea = new uint8_t[lgth];
00317       memcpy(tmpArea,binArea,lgth);
00318    }
00319    else
00320    {
00321       tmpArea = 0;
00322    }
00323    if ( !SetEntryBinArea(tmpArea,lgth,dataEntry) )
00324    {
00325       if ( tmpArea )
00326       {
00327          delete[] tmpArea;
00328       }
00329    }
00330    return dataEntry;
00331 }  

DataEntry * gdcm::DocEntrySet::InsertEntryString std::string const &  value,
uint16_t  group,
uint16_t  elem,
VRKey const &  vr = GDCM_VRUNKNOWN
[inherited]
 

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

Parameters:
value (string) Value to be set
group Group number of the Entry
elem Element number of the Entry
vr V(alue) R(epresentation) of the Entry -if private Entry-
Returns:
pointer to the modified/created Header Entry (NULL when creation failed).

Definition at line 212 of file gdcmDocEntrySet.cxx.

References gdcm::DocEntrySet::AddEntry(), gdcm::RefCounter::Delete(), gdcmWarningMacro, gdcm::DocEntrySet::GetDocEntry(), gdcm::DocEntry::GetVR(), gdcm::DocEntrySet::NewDataEntry(), gdcm::DocEntrySet::RemoveEntry(), and gdcm::DocEntrySet::SetEntryString().

Referenced by gdcm::FileHelper::InsertEntryString(), gdcm::FileHelper::Write(), and gdcm::File::Write().

00215 {
00216    DataEntry *dataEntry = 0;
00217    DocEntry *currentEntry = GetDocEntry( group, elem );
00218    
00219    if (currentEntry)
00220    {
00221       dataEntry = dynamic_cast<DataEntry *>(currentEntry);
00222 
00223       // Verify the VR
00224       if ( dataEntry )
00225          if ( dataEntry->GetVR()!=vr )
00226             dataEntry = NULL;
00227 
00228       // if currentEntry doesn't correspond to the requested dataEntry
00229       if ( !dataEntry)
00230       {
00231          if ( !RemoveEntry(currentEntry) )
00232          {
00233             gdcmWarningMacro( "Removal of previous DocEntry failed.");
00234             return NULL;
00235          }
00236       }
00237    }
00238 
00239    // Create a new dataEntry if necessary
00240    if ( !dataEntry )
00241    {
00242       dataEntry = NewDataEntry( group, elem, vr );
00243 
00244       if ( !AddEntry(dataEntry) )
00245       {
00246          gdcmWarningMacro("AddEntry failed although this is a creation.");
00247          dataEntry->Delete();
00248          return NULL;
00249       }
00250       dataEntry->Delete();
00251    }
00252 
00253    // Set the dataEntry value
00254    SetEntryString(value, dataEntry); // The std::string value
00255    return dataEntry;
00256 }

SeqEntry * gdcm::DocEntrySet::InsertSeqEntry uint16_t  group,
uint16_t  elem
[inherited]
 

Creates a new gdcm::SeqEntry and adds it to the current DocEntrySet. (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 341 of file gdcmDocEntrySet.cxx.

References gdcm::DocEntrySet::AddEntry(), gdcm::RefCounter::Delete(), gdcmWarningMacro, gdcm::DocEntrySet::GetDocEntry(), gdcm::DocEntrySet::NewSeqEntry(), and gdcm::DocEntrySet::RemoveEntry().

Referenced by gdcm::FileHelper::InsertSeqEntry().

00342 {
00343    SeqEntry *seqEntry = 0;
00344    DocEntry *currentEntry = GetDocEntry( group, elem );
00345 
00346    // Verify the currentEntry
00347    if ( currentEntry )
00348    {
00349       seqEntry = dynamic_cast<SeqEntry *>(currentEntry);
00350 
00351       // Verify the VR
00352       if ( seqEntry )
00353          seqEntry = NULL;
00354 
00355       // if currentEntry doesn't correspond to the requested seqEntry
00356       if ( !seqEntry )
00357       {
00358          if (!RemoveEntry(currentEntry))
00359          {
00360             gdcmWarningMacro( "Removal of previous DocEntry failed for ("
00361                <<std::hex << group << "|" << elem <<")" );
00362             return NULL;
00363          }
00364       }
00365    }
00366    // Create a new seqEntry if necessary
00367    if ( !seqEntry )
00368    {
00369       seqEntry = NewSeqEntry(group, elem);
00370 
00371       if ( !AddEntry(seqEntry) )
00372       {
00373          gdcmWarningMacro( "AddEntry failed although this is a creation for ("
00374             <<std::hex << group << "|" << elem <<")" );
00375          seqEntry->Delete();
00376          return NULL;
00377       }
00378       seqEntry->Delete();
00379    }
00380    // Remark :
00381    // SequenceDelimitationItem will be added at the end of the SeqEntry,
00382    // at write time
00383    return seqEntry;
00384 } 

bool gdcm::DicomDir::IsAborted  )  [inline]
 

IsAborted IsAborted.

Definition at line 94 of file gdcmDicomDir.h.

00094 { return Abort; }

bool gdcm::Document::IsDicomV3  )  [inherited]
 

Predicate for dicom version 3 file.

Returns:
True when the file is a dicom version 3.

Definition at line 361 of file gdcmDocument.cxx.

References gdcm::ElementSet::GetDocEntry().

Referenced by gdcm::File::GetYSize(), and gdcm::PixelReadConvert::GrabInformationsFromFile().

00362 {
00363    // Checking if Transfer Syntax exists is enough
00364    // Anyway, it's too late check if the 'Preamble' was found ...
00365    // And ... would it be a rich idea to check ?
00366    // (some 'no Preamble' DICOM images exist !)
00367    return GetDocEntry(0x0002, 0x0010) != NULL;
00368 }

bool gdcm::ElementSet::IsEmpty  )  [inline, virtual, inherited]
 

Tells us if the ElementSet contains no entry.

Implements gdcm::DocEntrySet.

Definition at line 58 of file gdcmElementSet.h.

Referenced by gdcm::Document::DoTheLoadingDocumentJob(), and gdcm::Document::IsParsable().

00058 { return TagHT.empty(); }

bool gdcm::Document::IsPapyrus  )  [inherited]
 

Predicate for Papyrus file Dedicated to whomsoever it may concern.

Returns:
True when the file is a Papyrus file.

Definition at line 375 of file gdcmDocument.cxx.

References gdcm::ElementSet::GetDocEntry().

00376 {
00377    // check for Papyrus private Sequence
00378    DocEntry *e = GetDocEntry(0x0041, 0x1050);
00379    if ( !e )
00380       return false;
00381    // check if it's actually a Sequence
00382    if ( !dynamic_cast<SeqEntry*>(e) )
00383       return  false;
00384    return true;
00385 }

bool gdcm::Document::IsParsable  )  [inherited]
 

This predicate tells us whether or not the current Document was properly parsed and contains at least *one* Dicom Element (and nothing more, sorry).

Returns:
false when we're 150 % sure it's NOT a Dicom/Acr file, true otherwise.

Definition at line 329 of file gdcmDocument.cxx.

References gdcm::Document::Filetype, gdcmWarningMacro, gdcm::Document::GetFileName(), gdcm::ElementSet::IsEmpty(), and gdcm::Unknown.

Referenced by gdcm::Document::IsReadable().

00330 {
00331    if ( Filetype == Unknown )
00332    {
00333       gdcmWarningMacro( "Wrong filetype for " << GetFileName());
00334       return false;
00335    }
00336 
00337    if ( IsEmpty() )
00338    { 
00339       gdcmWarningMacro( "No tag in internal hash table.");
00340       return false;
00341    }
00342 
00343    return true;
00344 }

bool gdcm::DicomDir::IsReadable  )  [virtual]
 

This predicate, based on hopefully reasonable heuristics, decides whether or not the current document was properly parsed and contains the mandatory information for being considered as a well formed and usable DicomDir.

Returns:
true when Document is the one of a reasonable DicomDir, false otherwise.

Reimplemented from gdcm::Document.

Definition at line 229 of file gdcmDicomDir.cxx.

References gdcm::Document::Filetype, gdcmErrorMacro, gdcmWarningMacro, gdcm::Document::GetFileName(), MetaElems, Patients, and gdcm::Unknown.

00230 {
00231    if ( Filetype == Unknown )
00232    {
00233       gdcmErrorMacro( "Wrong filetype for " << GetFileName());
00234       return false;
00235    }
00236    if ( !MetaElems )
00237    {
00238       gdcmWarningMacro( "Meta Elements missing in DicomDir");
00239       return false;
00240    }
00241    if ( Patients.size() <= 0 )
00242    {
00243       gdcmWarningMacro( "NO Patient in DicomDir");
00244       return false;
00245    }
00246 
00247    return true;
00248 }

bool gdcm::DicomDir::Load  )  [virtual]
 

Loader. use SetFileName(fn) or SetLoadMode(lm) + SetDirectoryName(dn) before !

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

Reimplemented from gdcm::Document.

Definition at line 148 of file gdcmDicomDir.cxx.

References DoTheLoadingJob(), and ParseDir.

00149 {
00150    if (!ParseDir)
00151    {
00152       if ( ! this->Document::Load( ) )
00153          return false;
00154    }
00155    return DoTheLoadingJob( );   
00156 }

void gdcm::Document::LoadDocEntrySafe DocEntry entry  )  [inherited]
 

Loads the element while preserving the current underlying file position indicator as opposed to LoadDocEntry that modifies it.

Parameters:
entry DocEntry whose value will be loaded.

Definition at line 811 of file gdcmDocument.cxx.

References gdcm::Document::Fp, and gdcm::Document::LoadDocEntry().

Referenced by gdcm::Document::GetTransferSyntax().

00812 {
00813    if ( Fp )
00814    {
00815       long PositionOnEntry = Fp->tellg();
00816       LoadDocEntry(entry);
00817       Fp->seekg(PositionOnEntry, std::ios::beg);
00818    }
00819 }

void gdcm::Document::LoadEntryBinArea DataEntry entry  )  [virtual, inherited]
 

Loads (from disk) the element content when a string is not suitable.

Parameters:
entry Entry whose binArea is going to be loaded

Definition at line 730 of file gdcmDocument.cxx.

References gdcm::Document::CloseFile(), gdcm::Document::Fp, gdcmWarningMacro, gdcm::VR::GetAtomicElementLength(), gdcm::DataEntry::GetBinArea(), gdcm::DocEntry::GetElement(), gdcm::DocEntry::GetGroup(), gdcm::DocEntry::GetLength(), gdcm::DocEntry::GetOffset(), gdcm::DocEntry::GetVR(), gdcm::Global::GetVR(), gdcm::Document::OpenFile(), gdcm::DataEntry::SetBinArea(), gdcm::DataEntry::SetState(), gdcm::DataEntry::STATE_UNREAD, gdcm::Document::SwapDouble(), gdcm::Document::SwapLong(), and gdcm::Document::SwapShort().

00731 {
00732    if( entry->GetBinArea() )
00733       return;
00734 
00735    bool openFile = !Fp;
00736    if ( openFile )
00737       OpenFile();
00738 
00739    size_t o =(size_t)entry->GetOffset();
00740    Fp->seekg(o, std::ios::beg);
00741 
00742    size_t l = entry->GetLength();
00743    uint8_t *data = new uint8_t[l];
00744    if ( !data )
00745    {
00746       gdcmWarningMacro(  "Cannot allocate DataEntry content for : "
00747                        << std::hex << entry->GetGroup() 
00748                        << "|" << entry->GetElement() );
00749       return;
00750    }
00751 
00752    // Read the data
00753    Fp->read((char*)data, l);
00754    if ( Fp->fail() || Fp->eof() )
00755    {
00756       delete[] data;
00757       entry->SetState(DataEntry::STATE_UNREAD);
00758       return;
00759    }
00760 
00761    // Swap the data content if necessary
00762    uint32_t i;
00763    unsigned short vrLgth = 
00764                         Global::GetVR()->GetAtomicElementLength(entry->GetVR());
00765 
00766 // FIXME : trouble expected if we read an ... OW Entry (LUT, etc ..)
00767 //   if( entry->GetVR() == "OW" )
00768 //      vrLgth = 1;
00769 
00770    switch(vrLgth)
00771    {
00772       case 1:
00773       {
00774          break;
00775       }     
00776       case 2:
00777       {
00778          uint16_t *data16 = (uint16_t *)data;
00779          for(i=0;i<l/vrLgth;i++)
00780             data16[i] = SwapShort(data16[i]);
00781          break;
00782       }
00783       case 4:
00784       {
00785          uint32_t *data32 = (uint32_t *)data;
00786          for(i=0;i<l/vrLgth;i++)
00787             data32[i] = SwapLong(data32[i]);
00788          break;
00789       }
00790       case 8:
00791       {
00792          double *data64 = (double *)data;
00793          for(i=0;i<l/vrLgth;i++)
00794             data64[i] = SwapDouble(data64[i]);
00795          break;
00796       }
00797    }
00798    
00799    entry->SetBinArea(data);
00800 
00801    if ( openFile )
00802       CloseFile();
00803 }

void gdcm::Document::LoadEntryBinArea uint16_t  group,
uint16_t  elem
[virtual, inherited]
 

Loads (from disk) the element content when a string is not suitable.

Parameters:
group group number of the Entry
elem element number of the Entry

Definition at line 705 of file gdcmDocument.cxx.

References gdcmDebugMacro, gdcmWarningMacro, and gdcm::ElementSet::GetDocEntry().

Referenced by gdcm::Document::DoTheLoadingDocumentJob(), gdcm::PixelReadConvert::GrabInformationsFromFile(), and gdcm::Document::LoadDocEntry().

00706 {
00707    // Search the corresponding DocEntry
00708    DocEntry *docEntry = GetDocEntry(group, elem);
00709    if ( !docEntry )
00710    {
00711       gdcmDebugMacro(std::hex << group << "|" << elem 
00712                        <<  " doesn't exist" );
00713       return;
00714    }
00715    DataEntry *dataEntry = dynamic_cast<DataEntry *>(docEntry);
00716    if ( !dataEntry )
00717    {
00718       gdcmWarningMacro(std::hex << group << "|" << elem 
00719                        <<  " is NOT a DataEntry");
00720       return;
00721    }
00722    LoadEntryBinArea(dataEntry);
00723 }

bool gdcm::ElementSet::MayIWrite uint16_t   )  [inline, protected, inherited]
 

Some group are illegal withing some Dicom Documents Only the Document knows it.

Reimplemented in gdcm::File.

Definition at line 67 of file gdcmElementSet.h.

Referenced by gdcm::ElementSet::WriteContent().

00068                  { return true; }

void gdcm::DicomDir::MoveSQItem DocEntrySet dst,
DocEntrySet src
[private]
 

Move the content of the source SQItem to the destination SQItem Only DocEntry's are moved.

Parameters:
dst destination SQItem
src source SQItem

Definition at line 1027 of file gdcmDicomDir.cxx.

References gdcm::DocEntrySet::AddEntry(), gdcm::DocEntrySet::GetFirstEntry(), and gdcm::DocEntrySet::RemoveEntry().

01028 { 
01029    DocEntry *entry;
01030 // todo : rewrite the whole stuff, without using RemoveEntry an AddEntry,
01031 //        to save time
01032    entry = src->GetFirstEntry();
01033    while(entry)
01034    {
01035       dst->AddEntry(entry);  // use it, *before* removing it!
01036       src->RemoveEntry(entry);
01037       // we destroyed -> the current iterator is not longer valid
01038       entry = src->GetFirstEntry();
01039    }
01040 }

static DicomDir* gdcm::DicomDir::New  )  [inline, static]
 

Constructs a DicomDir with a RefCounter.

Definition at line 57 of file gdcmDicomDir.h.

00057 {return new DicomDir();}

DataEntry * gdcm::DocEntrySet::NewDataEntry uint16_t  group,
uint16_t  elem,
VRKey const &  vr = GDCM_VRUNKNOWN
[inherited]
 

Build a new DataEntry from all the low level arguments. Check for existence of dictionary entry, and build a default one when absent.

Parameters:
group Group number of the new Entry
elem Element number of the new Entry
vr V(alue) R(epresentation) of the new Entry
Remarks:
The user of this method must destroy the DataEntry when unused

Definition at line 406 of file gdcmDocEntrySet.cxx.

References gdcmWarningMacro, gdcm::DocEntrySet::GetDictEntry(), gdcm::DataEntry::New(), and gdcm::RefCounter::Unregister().

Referenced by gdcm::FileHelper::CopyDataEntry(), gdcm::DocEntrySet::InsertEntryBinArea(), gdcm::DocEntrySet::InsertEntryString(), and gdcm::Document::ReadNextDocEntry().

00408 {
00409    DictEntry *dictEntry = GetDictEntry(group, elem, vr);
00410 
00411    DataEntry *newEntry = DataEntry::New(dictEntry);
00412    dictEntry->Unregister(); // GetDictEntry register it
00413    if (!newEntry) 
00414    {
00415       gdcmWarningMacro( "Failed to allocate DataEntry for ("
00416           <<std::hex << group << "|" << elem <<")" );
00417       return 0;
00418    }
00419    return newEntry;
00420 }

DicomDirMeta * gdcm::DicomDir::NewMeta  ) 
 

adds *the* Meta to a partially created DICOMDIR

Definition at line 253 of file gdcmDicomDir.cxx.

References gdcm::SQItem::AddEntry(), gdcm::RefCounter::Delete(), gdcm::ElementSet::GetFirstEntry(), MetaElems, gdcm::DicomDirMeta::New(), gdcm::ElementSet::RemoveEntry(), and gdcm::SQItem::SetSQItemNumber().

Referenced by CreateDicomDir(), DicomDir(), and DoTheLoadingJob().

00254 {
00255    if ( MetaElems )
00256       MetaElems->Delete();
00257 
00258    DocEntry *entry = GetFirstEntry();
00259    if ( entry )
00260    { 
00261       MetaElems = DicomDirMeta::New(true); // true = empty
00262 
00263       entry = GetFirstEntry();
00264       while( entry )
00265       {
00266          if ( dynamic_cast<SeqEntry *>(entry) )
00267             break;
00268 
00269          MetaElems->AddEntry(entry);
00270          RemoveEntry(entry);
00271 
00272          entry = GetFirstEntry();
00273       }
00274    }
00275    else  // after root directory parsing
00276    {
00277       MetaElems = DicomDirMeta::New(false); // false = not empty
00278    }
00279    MetaElems->SetSQItemNumber(0); // To avoid further missprinting
00280    return MetaElems;  
00281 }

DicomDirPatient * gdcm::DicomDir::NewPatient  ) 
 

adds a new Patient (with the basic elements) to a partially created DICOMDIR

Definition at line 287 of file gdcmDicomDir.cxx.

References AddPatientToEnd(), and gdcm::DicomDirPatient::New().

00288 {
00289    DicomDirPatient *dd = DicomDirPatient::New();
00290    AddPatientToEnd( dd );
00291    return dd;
00292 }

SeqEntry * gdcm::DocEntrySet::NewSeqEntry uint16_t  group,
uint16_t  elem
[inherited]
 

Build a new SeqEntry from all the low level arguments. Check for existence of dictionary entry, and build a default one when absent.

Parameters:
group Group number of the new Entry
elem Element number of the new Entry
Remarks:
The user of this method must destroy the SeqEntry when unused

Definition at line 430 of file gdcmDocEntrySet.cxx.

References gdcmWarningMacro, gdcm::DocEntrySet::GetDictEntry(), gdcm::SeqEntry::New(), and gdcm::RefCounter::Unregister().

Referenced by gdcm::Document::Backtrack(), gdcm::DocEntrySet::InsertSeqEntry(), and gdcm::Document::ReadNextDocEntry().

00431 {
00432    DictEntry *dictEntry = GetDictEntry(group, elem, "SQ");
00433 
00434    SeqEntry *newEntry = SeqEntry::New( dictEntry );
00435    dictEntry->Unregister(); // GetDictEntry register it
00436    if (!newEntry)
00437    {
00438       gdcmWarningMacro( "Failed to allocate SeqEntry for ("
00439          <<std::hex << group << "|" << elem <<")" );
00440       return 0;
00441    }
00442    return newEntry;
00443 }

std::ifstream * gdcm::Document::OpenFile  )  [inherited]
 

Tries to open the file Document::Filename and checks the preamble when existing.

Returns:
The FILE pointer on success.

Definition at line 561 of file gdcmDocument.cxx.

References gdcm::Document::CloseFile(), gdcm::Document::Filename, gdcm::Util::Format(), gdcm::Document::Fp, gdcmDebugMacro, gdcmWarningMacro, and gdcm::Document::HasDCMPreamble.

Referenced by gdcm::Document::DoTheLoadingDocumentJob(), gdcm::File::DoTheLoadingJob(), gdcm::FileHelper::GetRaw(), and gdcm::Document::LoadEntryBinArea().

00562 {
00563    HasDCMPreamble = false;
00564    if (Filename.length() == 0) 
00565    {
00566       return 0;
00567    }
00568 
00569    if ( Fp )
00570    {
00571       gdcmDebugMacro( "File already open: " << Filename.c_str());
00572       CloseFile();
00573    }
00574 
00575    Fp = new std::ifstream(Filename.c_str(), std::ios::in | std::ios::binary);
00576    if ( ! *Fp )
00577    {
00578    // Don't user gdcmErrorMacro :
00579    // a spurious message will appear when you use, for instance 
00580    // gdcm::FileHelper *fh = new gdcm::FileHelper( outputFileName );
00581    // to create outputFileName.
00582    
00583    // FIXME : if the upper comment is still usefull 
00584    //         --> the constructor is not so good ...
00585    
00586       gdcmWarningMacro( "Cannot open file: " << Filename.c_str());
00587       delete Fp;
00588       Fp = 0;
00589       return 0;
00590       //exit(1); // No function is allowed to leave the application instead
00591                  // of warning the caller
00592    }
00593  
00594    uint16_t zero = 0;
00595    Fp->read((char*)&zero, (size_t)2);
00596    if ( Fp->eof() )
00597    {
00598       CloseFile();
00599       return 0;
00600    }
00601  
00602    //-- Broken ACR or DICOM with no Preamble; may start with a Shadow Group --
00603    
00604    // FIXME : We cannot be sure the preable is only zeroes..
00605    //         (see ACUSON-24-YBR_FULL-RLE.dcm )
00606    if ( 
00607        zero == 0x0001 || zero == 0x0100 || zero == 0x0002 || zero == 0x0200 ||
00608        zero == 0x0003 || zero == 0x0300 || zero == 0x0004 || zero == 0x0400 ||
00609        zero == 0x0005 || zero == 0x0500 || zero == 0x0006 || zero == 0x0600 ||
00610        zero == 0x0007 || zero == 0x0700 || zero == 0x0008 || zero == 0x0800 )
00611    {
00612       std::string msg = Util::Format(
00613         "ACR/DICOM starting by 0x(%04x) at the beginning of the file\n", zero);
00614       // FIXME : is it a Warning message, or a Debug message?
00615       gdcmWarningMacro( msg.c_str() );
00616       return Fp;
00617    }
00618  
00619    //-- DICOM --
00620    Fp->seekg(126L, std::ios::cur);
00621    char dicm[4]; // = {' ',' ',' ',' '};
00622    Fp->read(dicm,  (size_t)4);
00623    if ( Fp->eof() )
00624    {
00625       CloseFile();
00626       return 0;
00627    }
00628    if ( memcmp(dicm, "DICM", 4) == 0 )
00629    {
00630       HasDCMPreamble = true;
00631       return Fp;
00632    }
00633 
00634    // -- Neither ACR/No Preamble Dicom nor DICOMV3 file
00635    CloseFile();
00636    // Don't user Warning nor Error, not to polute the output
00637    // while directory recursive parsing ...
00638    gdcmDebugMacro( "Neither ACR/No Preamble Dicom nor DICOMV3 file: "
00639                       << Filename.c_str()); 
00640    return 0;
00641 }

bool gdcm::Document::operator< Document document  )  [inherited]
 

Compares two documents, according to DicomDir rules.

Warning:
Does NOT work with ACR-NEMA files
Todo:
Find a trick to solve the pb (use RET fields ?)
Parameters:
document to compare with current one
Returns:
true if 'smaller'

Definition at line 828 of file gdcmDocument.cxx.

References gdcm::DocEntrySet::GetEntryString().

00829 {
00830    // Patient Name
00831    std::string s1 = GetEntryString(0x0010,0x0010);
00832    std::string s2 = document.GetEntryString(0x0010,0x0010);
00833    if (s1 < s2)
00834    {
00835       return true;
00836    }
00837    else if ( s1 > s2 )
00838    {
00839       return false;
00840    }
00841    else
00842    {
00843       // Patient ID
00844       s1 = GetEntryString(0x0010,0x0020);
00845       s2 = document.GetEntryString(0x0010,0x0020);
00846       if ( s1 < s2 )
00847       {
00848          return true;
00849       }
00850       else if ( s1 > s2 )
00851       {
00852          return false;
00853       }
00854       else
00855       {
00856          // Study Instance UID
00857          s1 = GetEntryString(0x0020,0x000d);
00858          s2 = document.GetEntryString(0x0020,0x000d);
00859          if ( s1 < s2 )
00860          {
00861             return true;
00862          }
00863          else if ( s1 > s2 )
00864          {
00865             return false;
00866          }
00867          else
00868          {
00869             // Serie Instance UID
00870             s1 = GetEntryString(0x0020,0x000e);
00871             s2 = document.GetEntryString(0x0020,0x000e);    
00872             if ( s1 < s2 )
00873             {
00874                return true;
00875             }
00876             else if ( s1 > s2 )
00877             {
00878                return false;
00879             }
00880          }
00881       }
00882    }
00883    return false;
00884 }

void gdcm::DicomDir::ParseDirectory  ) 
 

fills the whole structure, starting from a root Directory

Definition at line 338 of file gdcmDicomDir.cxx.

References CreateDicomDir(), CreateDicomDirChainedList(), and gdcm::Document::GetFileName().

Referenced by DoTheLoadingJob().

00339 {
00340    CreateDicomDirChainedList( GetFileName() );
00341    CreateDicomDir();
00342 }

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

Canonical Printer.

Parameters:
os ostream we want to print in
indent Indentation string to be prepended during printing

Reimplemented from gdcm::ElementSet.

Definition at line 1057 of file gdcmDicomDir.cxx.

References MetaElems, Patients, gdcm::DicomDirMeta::Print(), gdcm::Base::PrintLevel, and gdcm::Base::SetPrintLevel().

01058 {
01059    if ( MetaElems )
01060    {
01061       MetaElems->SetPrintLevel(PrintLevel);
01062       MetaElems->Print(os);   
01063    }   
01064    for(ListDicomDirPatient::iterator cc  = Patients.begin();
01065                                      cc != Patients.end();
01066                                    ++cc)
01067    {
01068      (*cc)->SetPrintLevel(PrintLevel);
01069      (*cc)->Print(os);
01070    }
01071 }

uint16_t gdcm::Document::ReadInt16  )  throw ( FormatError ) [protected, inherited]
 

Reads a supposed to be 16 Bits integer (swaps it depending on processor endianness).

Returns:
read value

Definition at line 893 of file gdcmDocument.cxx.

References gdcm::Document::Fp, and gdcm::Document::SwapShort().

Referenced by gdcm::Document::FindDocEntryLengthOBOrOW(), gdcm::Document::ReadNextDocEntry(), and gdcm::File::ReadTag().

00895 {
00896    uint16_t g;
00897    Fp->read ((char*)&g, (size_t)2);
00898    if ( Fp->fail() )
00899    {
00900       throw FormatError( "Document::ReadInt16()", " file error." );
00901    }
00902    if ( Fp->eof() )
00903    {
00904       throw FormatError( "Document::ReadInt16()", "EOF." );
00905    }
00906    g = SwapShort(g); 
00907    return g;
00908 }

uint32_t gdcm::Document::ReadInt32  )  throw ( FormatError ) [protected, inherited]
 

Reads a supposed to be 32 Bits integer (swaps it depending on processor endianness).

Returns:
read value

Definition at line 915 of file gdcmDocument.cxx.

References gdcm::Document::Fp, and gdcm::Document::SwapLong().

Referenced by gdcm::File::ComputeRLEInfo(), gdcm::Document::FindDocEntryLengthOBOrOW(), and gdcm::File::ReadTagLength().

00917 {
00918    uint32_t g;
00919    Fp->read ((char*)&g, (size_t)4);
00920    if ( Fp->fail() )
00921    {
00922       throw FormatError( "Document::ReadInt32()", " file error." );
00923    }
00924    if ( Fp->eof() )
00925    {
00926       throw FormatError( "Document::ReadInt32()", "EOF." );
00927    }
00928    g = SwapLong(g);
00929    return g;
00930 }

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

Register the object.

Remarks:
It increments the reference counting

Definition at line 44 of file gdcmRefCounter.h.

Referenced by gdcm::SQItem::AddEntry(), gdcm::ElementSet::AddEntry(), gdcm::Dict::AddEntry(), gdcm::SeqEntry::AddSQItem(), gdcm::SeqEntry::Copy(), Copy(), gdcm::DocEntry::DocEntry(), gdcm::FileHelper::FileHelper(), gdcm::DocEntrySet::GetDictEntry(), gdcm::CommandManager::InSetCommand(), gdcm::DocEntryArchive::Push(), gdcm::Dict::ReplaceEntry(), and gdcm::SeqEntry::SetDelimitationItem().

00044 { RefCount++; }

bool gdcm::ElementSet::RemoveEntry DocEntry entryToRemove  )  [virtual, inherited]
 

Clear the hash table from given entry AND delete the entry.

Parameters:
entryToRemove Entry to remove AND delete.

Implements gdcm::DocEntrySet.

Definition at line 99 of file gdcmElementSet.cxx.

References gdcmWarningMacro, gdcm::DocEntry::GetKey(), gdcm::ElementSet::TagHT, and gdcm::RefCounter::Unregister().

Referenced by gdcm::Document::Backtrack(), gdcm::File::DoTheLoadingJob(), NewMeta(), gdcm::Document::ParseDES(), gdcm::DocEntryArchive::Push(), and gdcm::DocEntryArchive::Restore().

00100 {
00101    const TagKey &key = entryToRemove->GetKey();
00102    if ( TagHT.count(key) == 1 )
00103    {
00104       TagHT.erase(key);
00105       entryToRemove->Unregister();
00106       return true;
00107    }
00108 
00109    gdcmWarningMacro( "Key not present : " << key);
00110    return false ;
00111 }

void gdcm::DicomDir::SetDirectoryName std::string const &  dirName  )  [inline]
 

Sets the root Directory name to parse, recursively.

Definition at line 63 of file gdcmDicomDir.h.

00064         { ParseDir = true; if (Filename != dirName)
00065                                Filename = dirName, IsDocumentModified = true; }

void gdcm::DicomDir::SetElement std::string const &  path,
DicomDirType  type,
Document header
[private]
 

adds to the HTable the Entries (Dicom Elements) corresponding to the given type

Parameters:
path full path file name (only used when type = GDCM_DICOMDIR_IMAGE
type DicomDirObject type to create (GDCM_DICOMDIR_PATIENT, GDCM_DICOMDIR_STUDY, GDCM_DICOMDIR_SERIE ...)
header Header of the current file

Definition at line 829 of file gdcmDicomDir.cxx.

References gdcm::SQItem::AddEntry(), AddImageToEnd(), AddPatientToEnd(), AddSerieToEnd(), AddStudyToEnd(), gdcm::RefCounter::Delete(), GDCM_DICOMDIR_IMAGE, GDCM_DICOMDIR_META, GDCM_DICOMDIR_PATIENT, GDCM_DICOMDIR_SERIE, GDCM_DICOMDIR_STUDY, gdcm::GDCM_FILESEPARATOR, gdcm::GDCM_UNFOUND, gdcmDebugMacro, gdcmErrorMacro, gdcmWarningMacro, gdcm::Global::GetDicomDirElements(), gdcm::DicomDirElement::GetDicomDirImageElements(), gdcm::DicomDirElement::GetDicomDirMetaElements(), gdcm::DicomDirElement::GetDicomDirPatientElements(), gdcm::DicomDirElement::GetDicomDirSerieElements(), gdcm::DicomDirElement::GetDicomDirStudyElements(), gdcm::Dict::GetEntry(), gdcm::DocEntrySet::GetEntryLength(), gdcm::DocEntrySet::GetEntryString(), gdcm::Document::GetFileName(), gdcm::Util::GetName(), gdcm::Document::GetPubDict(), MetaElems, gdcm::DataEntry::New(), gdcm::DicomDirMeta::New(), gdcm::DicomDirPatient::New(), gdcm::DicomDirStudy::New(), gdcm::DicomDirSerie::New(), gdcm::DicomDirImage::New(), gdcm::DocEntry::SetOffset(), and gdcm::DataEntry::SetString().

Referenced by SetElements().

00831 {
00832    ListDicomDirElem elemList;
00833    ListDicomDirElem::const_iterator it;
00834    uint16_t tmpGr, tmpEl;
00835    DictEntry *dictEntry;
00836    DataEntry *entry;
00837    std::string val;
00838    SQItem *si;
00839 
00840    switch( type )
00841    {
00842       case GDCM_DICOMDIR_IMAGE:
00843          elemList = Global::GetDicomDirElements()->GetDicomDirImageElements();
00844          si = DicomDirImage::New(true);
00845          if ( !AddImageToEnd(static_cast<DicomDirImage *>(si)) )
00846          {
00847             si->Delete();
00848             gdcmErrorMacro( "Add ImageToEnd failed");
00849          }
00850          break;
00851       case GDCM_DICOMDIR_SERIE:
00852          elemList = Global::GetDicomDirElements()->GetDicomDirSerieElements();
00853          si = DicomDirSerie::New(true);
00854          if ( !AddSerieToEnd(static_cast<DicomDirSerie *>(si)) )
00855          {
00856             si->Delete();
00857             gdcmErrorMacro( "Add SerieToEnd failed");
00858          }
00859          break;
00860       case GDCM_DICOMDIR_STUDY:
00861          elemList = Global::GetDicomDirElements()->GetDicomDirStudyElements();
00862          si = DicomDirStudy::New(true);
00863          if ( !AddStudyToEnd(static_cast<DicomDirStudy *>(si)) )
00864          {
00865             si->Delete();
00866             gdcmErrorMacro( "Add StudyToEnd failed");
00867          }
00868          break;
00869       case GDCM_DICOMDIR_PATIENT:
00870          elemList = Global::GetDicomDirElements()->GetDicomDirPatientElements();
00871          si = DicomDirPatient::New(true);
00872          if ( !AddPatientToEnd(static_cast<DicomDirPatient *>(si)) )
00873          {
00874             si->Delete();
00875             gdcmErrorMacro( "Add PatientToEnd failed");
00876          }
00877          break;
00878       case GDCM_DICOMDIR_META:
00879          if ( MetaElems )
00880          {
00881             MetaElems->Delete();
00882             gdcmErrorMacro( "MetaElements already exist, they will be destroyed");
00883          }
00884          elemList = Global::GetDicomDirElements()->GetDicomDirMetaElements();
00885          MetaElems = DicomDirMeta::New(true);
00886          si = MetaElems;
00887          break;
00888       default:
00889          return;
00890    }
00891    
00892    // FIXME : troubles found when it's a SeqEntry
00893       
00894    // removed all the seems-to-be-useless stuff about Referenced Image Sequence
00895    // to avoid further troubles
00896    // imageElem 0008 1140 "" // Referenced Image Sequence
00897    // imageElem fffe e000 "" // 'no length' item : length to be set to 0xffffffff later
00898    // imageElem 0008 1150 "" // Referenced SOP Class UID    : to be set/forged later
00899    // imageElem 0008 1155 "" // Referenced SOP Instance UID : to be set/forged later
00900    // imageElem fffe e00d "" // Item delimitation : length to be set to ZERO later
00901  
00902    std::string referencedVal;
00903    // for all the relevant elements found in their own spot of the DicomDir.dic
00904    for( it = elemList.begin(); it != elemList.end(); ++it)
00905    {
00906       tmpGr     = it->Group;
00907       tmpEl     = it->Elem;
00908       dictEntry = GetPubDict()->GetEntry(tmpGr, tmpEl);
00909 
00910       entry     = DataEntry::New( dictEntry ); 
00911       entry->SetOffset(0); // just to avoid further missprinting
00912 
00913       if ( header )
00914       {
00915          // NULL when we Build Up (ex nihilo) a DICOMDIR
00916          //   or when we add the META elems
00917  
00918             val = header->GetEntryString(tmpGr, tmpEl); 
00919       }
00920       else
00921       {
00922          val = GDCM_UNFOUND;
00923       }
00924 
00925       if ( val == GDCM_UNFOUND) 
00926       {       
00927          if ( tmpGr == 0x0004 ) // never present in File !     
00928          {
00929             switch (tmpEl)
00930             {
00931             case 0x1130: // File-set ID
00932                // force to the *end* File Name
00933                val = Util::GetName( path );
00934                break;
00935       
00936             case 0x1500: // Only used for image    
00937                if ( header->GetFileName().substr(0, path.length()) != path )
00938                { 
00939                  gdcmWarningMacro( "The base path of file name is incorrect");
00940                  val = header->GetFileName();
00941                }
00942                else
00943                { 
00944                  // avoid the first '/' in File name !
00945                  if ( header->GetFileName().c_str()[path.length()] 
00946                                                       == GDCM_FILESEPARATOR )
00947                     val = &(header->GetFileName().c_str()[path.length()+1]);
00948                  else  
00949                     val = &(header->GetFileName().c_str()[path.length()]);   
00950                }
00951                break;
00952     
00953              case 0x1510:  // Referenced SOP Class UID in File
00954                referencedVal = header->GetEntryString(0x0008, 0x0016);
00955                // FIXME : probabely something to check
00956                val = referencedVal;
00957                break;
00958        
00959              case 0x1511: // Referenced SOP Instance UID in File
00960                referencedVal = header->GetEntryString(0x0008, 0x0018);
00961                // FIXME : probabely something to check
00962                val = referencedVal;
00963                break;
00964     
00965             case 0x1512: // Referenced Transfer Syntax UID in File
00966                referencedVal = header->GetEntryString(0x0002, 0x0010);
00967                // FIXME : probabely something to check
00968                val = referencedVal;
00969                break;
00970     
00971             default :
00972                val = it->Value;   
00973             } 
00974          }
00975          else
00976          {
00977             // If the entry is not found in the Header, don't write its 'value' in the DICOMDIR !
00978             entry->Delete();
00979             continue;
00980           }
00981       }
00982       else
00983       {
00984          if ( header->GetEntryLength(tmpGr,tmpEl) == 0 )
00985          {
00986             val = it->Value;
00987             // Don't polute the DICOMDIR with empty fields
00988             if (val == "")
00989             {
00990                entry->Delete();
00991                continue;
00992             }  
00993          }    
00994       }
00995 
00996 /* FIX later the pb of creating the 'Implementation Version Name'!
00997 
00998       if (val == GDCM_UNFOUND)
00999          val = "";
01000 
01001       if ( tmpGr == 0x0002 && tmpEl == 0x0013)
01002       { 
01003          // 'Implementation Version Name'
01004          std::string val = "GDCM ";
01005          val += Util::GetVersion();
01006       }
01007 */ 
01008 
01009       entry->SetString( val ); // troubles expected when vr=SQ ...
01010 
01011       if ( type == GDCM_DICOMDIR_META ) // fusible : should never print !
01012       {
01013          gdcmDebugMacro("GDCM_DICOMDIR_META ?!? should never print that");
01014       }
01015       
01016       si->AddEntry(entry);
01017       entry->Delete();
01018    }
01019 }

void gdcm::DicomDir::SetElements std::string const &  path,
VectDocument const &  list
[private]
 

for each Header of the chained list, add/update the Patient/Study/Serie/Image info

Parameters:
path path of the root directory
list chained list of Headers

Definition at line 761 of file gdcmDicomDir.cxx.

References gdcm::ElementSet::ClearEntry(), ClearPatient(), GDCM_DICOMDIR_IMAGE, GDCM_DICOMDIR_PATIENT, GDCM_DICOMDIR_SERIE, GDCM_DICOMDIR_STUDY, and SetElement().

Referenced by CreateDicomDirChainedList().

00762 {
00763    ClearEntry();
00764    ClearPatient();
00765 
00766    std::string patPrevName         = "", patPrevID  = "";
00767    std::string studPrevInstanceUID = "", studPrevID = "";
00768    std::string serPrevInstanceUID  = "", serPrevID  = "";
00769 
00770    std::string patCurName,         patCurID;
00771    std::string studCurInstanceUID, studCurID;
00772    std::string serCurInstanceUID,  serCurID;
00773 
00774    bool first = true;
00775    for( VectDocument::const_iterator it = list.begin();
00776                                      it != list.end(); 
00777                                    ++it )
00778    {
00779       // get the current file characteristics
00780       patCurName         = (*it)->GetEntryString(0x0010,0x0010);
00781       patCurID           = (*it)->GetEntryString(0x0010,0x0011);
00782       studCurInstanceUID = (*it)->GetEntryString(0x0020,0x000d);
00783       studCurID          = (*it)->GetEntryString(0x0020,0x0010);
00784       serCurInstanceUID  = (*it)->GetEntryString(0x0020,0x000e);
00785       serCurID           = (*it)->GetEntryString(0x0020,0x0011);
00786 
00787       if ( patCurName != patPrevName || patCurID != patPrevID || first )
00788       {
00789          SetElement(path, GDCM_DICOMDIR_PATIENT, *it);
00790          first = true;
00791       }
00792 
00793       // if new Study, deal with 'STUDY' Elements   
00794       if ( studCurInstanceUID != studPrevInstanceUID || studCurID != studPrevID 
00795          || first )
00796       {
00797          SetElement(path, GDCM_DICOMDIR_STUDY, *it);
00798          first = true;
00799       }
00800 
00801       // if new Serie, deal with 'SERIE' Elements   
00802       if ( serCurInstanceUID != serPrevInstanceUID || serCurID != serPrevID
00803          || first )
00804       {
00805          SetElement(path, GDCM_DICOMDIR_SERIE, *it);
00806       }
00807       
00808       // Always Deal with 'IMAGE' Elements  
00809       SetElement(path, GDCM_DICOMDIR_IMAGE, *it);
00810 
00811       patPrevName         = patCurName;
00812       patPrevID           = patCurID;
00813       studPrevInstanceUID = studCurInstanceUID;
00814       studPrevID          = studCurID;
00815       serPrevInstanceUID  = serCurInstanceUID;
00816       serPrevID           = serCurID;
00817       first = false;
00818    }
00819 }

bool gdcm::DocEntrySet::SetEntryBinArea uint8_t *  content,
int  lgth,
DataEntry entry
[inherited]
 

Accesses an existing DataEntry (i.e. a Dicom Element) and modifies it's content with the given value.

Parameters:
content new value (void* -> uint8_t*) to substitute with
entry Entry to be modified
lgth new value length

Definition at line 191 of file gdcmDocEntrySet.cxx.

References gdcm::DataEntry::SetBinArea(), and gdcm::DocEntry::SetLength().

00192 {
00193    if (entry)
00194    {
00195       entry->SetLength(lgth);
00196       entry->SetBinArea(content);  
00197       return true;
00198    }
00199    return false;
00200 }

bool gdcm::DocEntrySet::SetEntryBinArea uint8_t *  content,
int  lgth,
uint16_t  group,
uint16_t  elem
[inherited]
 

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

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

Definition at line 154 of file gdcmDocEntrySet.cxx.

References gdcmWarningMacro, and gdcm::DocEntrySet::GetDataEntry().

Referenced by gdcm::DocEntrySet::InsertEntryBinArea(), and gdcm::FileHelper::SetEntryBinArea().

00156 {
00157    DataEntry *entry = GetDataEntry(group, elem);
00158    if (!entry )
00159    {
00160       gdcmWarningMacro( "No corresponding DataEntry " << std::hex << group <<
00161                         "," << elem << " element (try promotion first).");
00162       return false;
00163    }
00164 
00165    return SetEntryBinArea(content,lgth,entry);
00166 } 

bool gdcm::DocEntrySet::SetEntryString std::string const &  content,
DataEntry entry
[inherited]
 

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

Parameters:
content new value (string) to substitute with
entry Entry to be modified

Definition at line 174 of file gdcmDocEntrySet.cxx.

References gdcm::DataEntry::SetString().

00175 {
00176    if (entry)
00177    {
00178       entry->SetString(content);
00179       return true;
00180    }
00181    return false;
00182 }

bool gdcm::DocEntrySet::SetEntryString std::string const &  content,
uint16_t  group,
uint16_t  elem
[inherited]
 

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

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

Definition at line 132 of file gdcmDocEntrySet.cxx.

References gdcmWarningMacro, and gdcm::DocEntrySet::GetDataEntry().

Referenced by gdcm::File::AnonymizeFile(), gdcm::Document::DoTheLoadingDocumentJob(), gdcm::DocEntrySet::InsertEntryString(), and gdcm::FileHelper::SetEntryString().

00134 {
00135    DataEntry *entry = GetDataEntry(group, elem);
00136    if (!entry )
00137    {
00138       gdcmWarningMacro( "No corresponding DataEntry " << std::hex << group <<
00139                          "," << elem << " element (try promotion first).");
00140       return false;
00141    }
00142    return SetEntryString(content,entry);
00143 }

virtual void gdcm::DicomDir::SetFileName std::string const &  fileName  )  [inline, virtual]
 

Accessor to Filename.

Reimplemented from gdcm::Document.

Definition at line 67 of file gdcmDicomDir.h.

Referenced by DoTheLoadingJob().

00068                    { ParseDir = false; if (Filename != fileName)
00069                               Filename = fileName, IsDocumentModified = true;}

void gdcm::Document::SetLoadMode int  mode  )  [inline, inherited]
 

Sets the LoadMode as a boolean string. LD_NOSEQ, LD_NOSHADOW, LD_NOSHADOWSEQ ... (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:
mode Load mode to be used

Definition at line 106 of file gdcmDocument.h.

Referenced by gdcm::SerieHelper::AddFileName(), CreateDicomDirChainedList(), vtkGdcmReader::LoadFileInformation(), and gdcm::FileHelper::SetLoadMode().

00106                                { if (LoadMode != mode) 
00107                                      LoadMode=mode, IsDocumentModified = true; }

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

Sets the print level for the Dicom Header Elements.

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

Definition at line 47 of file gdcmBase.h.

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

00047 { PrintLevel = level; }

bool gdcm::Document::SetShaDict DictKey const &  dictName  )  [inherited]
 

Set the shadow dictionary used.

Parameters:
dictName name of the dictionary to use in shadow

Definition at line 316 of file gdcmDocument.cxx.

References gdcm::DictSet::GetDict(), gdcm::Global::GetDicts(), and gdcm::Document::RefShaDict.

00317 {
00318    RefShaDict = Global::GetDicts()->GetDict(dictName);
00319    return !RefShaDict;
00320 }

bool gdcm::Document::SetShaDict Dict dict  )  [inherited]
 

Set the shadow dictionary used.

Parameters:
dict dictionary to use in shadow

Definition at line 306 of file gdcmDocument.cxx.

References gdcm::Document::RefShaDict.

00307 {
00308    RefShaDict = dict;
00309    return !RefShaDict;
00310 }

void gdcm::Document::SkipBytes uint32_t  nBytes  )  [protected, inherited]
 

skips bytes inside the source file

Returns:

Definition at line 936 of file gdcmDocument.cxx.

References gdcm::Document::Fp.

Referenced by gdcm::File::ComputeJPEGFragmentInfo(), gdcm::File::ComputeRLEInfo(), gdcm::Document::FindDocEntryLengthOBOrOW(), and gdcm::Document::SkipDocEntry().

00937 {
00938    //FIXME don't dump the returned value
00939    Fp->seekg((long)nBytes, std::ios::cur);
00940 }

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

Unregister the object.

Remarks:
It decrements the reference counting

Definition at line 48 of file gdcmRefCounter.h.

Referenced by gdcm::SeqEntry::ClearSQItem(), Copy(), gdcm::DocEntrySet::GetDictEntry(), gdcm::CommandManager::InSetCommand(), gdcm::DocEntrySet::NewDataEntry(), gdcm::DocEntrySet::NewSeqEntry(), gdcm::Document::ReadNextDocEntry(), gdcm::SQItem::RemoveEntry(), gdcm::ElementSet::RemoveEntry(), gdcm::SeqEntry::SetDelimitationItem(), gdcm::DocEntry::~DocEntry(), and gdcm::FileHelper::~FileHelper().

00049    {
00050       RefCount--;
00051       if(RefCount<=0)
00052          delete this;
00053    }

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

writes on disc a DICOMDIR \ warning does NOT add the missing elements in the header : it's up to the user doing it !

Parameters:
fileName file to be written to
Returns:
false only when fail to open

Definition at line 352 of file gdcmDicomDir.cxx.

References gdcm::binary_write(), gdcm::ExplicitVR, gdcmWarningMacro, GetMeta(), Patients, and gdcm::DicomDirMeta::WriteContent().

00353 {  
00354    int i;
00355    uint16_t sq[6] = { 0x0004, 0x1220, 0x5153, 0x0000, 0xffff, 0xffff };
00356    uint16_t sqt[4]= { 0xfffe, 0xe0dd, 0x0000, 0x0000 };
00357 
00358    std::ofstream *fp = new std::ofstream(fileName.c_str(),  
00359                                          std::ios::out | std::ios::binary);
00360    if ( !fp ) 
00361    {
00362       gdcmWarningMacro("Failed to open(write) File: " << fileName.c_str());
00363       return false;
00364    }
00365 
00366    char filePreamble[128];
00367    memset(filePreamble, 0, 128);
00368    fp->write(filePreamble, 128);
00369    binary_write( *fp, "DICM");
00370  
00371    DicomDirMeta *ptrMeta = GetMeta();
00372    ptrMeta->WriteContent(fp, ExplicitVR);
00373    
00374    // force writing 0004|1220 [SQ ], that CANNOT exist within DicomDirMeta
00375    for(i=0;i<6;++i)
00376    {
00377       binary_write(*fp, sq[i]);
00378    }
00379         
00380    for(ListDicomDirPatient::iterator cc  = Patients.begin();
00381                                      cc != Patients.end();
00382                                    ++cc )
00383    {
00384       (*cc)->WriteContent( fp, ExplicitVR );
00385    }
00386    
00387    // force writing Sequence Delimitation Item
00388    for(i=0;i<4;++i)
00389    {
00390       binary_write(*fp, sqt[i]);  // fffe e0dd 0000 0000 
00391    }
00392 
00393    fp->close();
00394    delete fp;
00395 
00396    return true;
00397 }

void gdcm::Document::WriteContent std::ofstream *  fp,
FileType  filetype
[virtual, inherited]
 

Writes in a file all the Entries (Dicom Elements).

Parameters:
fp file pointer on an already open file (actually: Output File Stream)
filetype Type of the File to be written (ACR-NEMA, ExplicitVR, ImplicitVR)

Reimplemented from gdcm::ElementSet.

Definition at line 664 of file gdcmDocument.cxx.

References gdcm::ExplicitVR, gdcm::ImplicitVR, gdcm::JPEG, and gdcm::ElementSet::WriteContent().

Referenced by gdcm::File::Write().

00665 {
00666    // Skip if user wants to write an ACR-NEMA file
00667 
00668    if ( filetype == ImplicitVR || filetype == ExplicitVR ||
00669         filetype == JPEG )
00670    {
00671       // writing Dicom File Preamble
00672       char filePreamble[128];
00673       memset(filePreamble, 0, 128);
00674       fp->write(filePreamble, 128);
00675       fp->write("DICM", 4);
00676    }
00677 
00678    /*
00679     * \todo rewrite later, if really usefull
00680     *       - 'Group Length' element is optional in DICOM
00681     *       - but un-updated odd groups lengthes can causes pb
00682     *         (xmedcon breaker)
00683     *
00684     * if ( (filetype == ImplicitVR) || (filetype == ExplicitVR) )
00685     *    UpdateGroupLength(false,filetype);
00686     * if ( filetype == ACR)
00687     *    UpdateGroupLength(true,ACR);
00688     *
00689     * --> Computing group length for groups with embeded Sequences
00690     * --> was too much tricky / we were [in a hurry / too lazy]
00691     * --> We don't write the element 0x0000 (group length)
00692     */
00693 
00694    ElementSet::WriteContent(fp, filetype); // This one is recursive
00695 }


Member Data Documentation

bool gdcm::Document::Abort [mutable, protected, inherited]
 

Definition at line 229 of file gdcmDocument.h.

Referenced by gdcm::Document::CallStartMethod(), CreateDicomDirChainedList(), DoTheLoadingJob(), and Initialize().

uint16_t gdcm::Document::CurrentElem [protected, inherited]
 

to allow any inner method to know current tag Element number

Definition at line 246 of file gdcmDocument.h.

Referenced by gdcm::Document::ReadNextDocEntry().

uint16_t gdcm::Document::CurrentGroup [protected, inherited]
 

to allow any inner method to know current tag Group number

Definition at line 244 of file gdcmDocument.h.

Referenced by gdcm::Document::FindDocEntryVR(), and gdcm::Document::ReadNextDocEntry().

std::string gdcm::Document::Filename [protected, inherited]
 

Refering underlying filename.

Definition at line 128 of file gdcmDocument.h.

Referenced by gdcm::File::AnonymizeNoLoad(), gdcm::Document::DoTheLoadingDocumentJob(), and gdcm::Document::OpenFile().

FileType gdcm::Document::Filetype [protected, inherited]
 

ACR, ACR_LIBIDO, ExplicitVR, ImplicitVR, Unknown.

Definition at line 154 of file gdcmDocument.h.

Referenced by gdcm::Document::CheckSwap(), gdcm::Document::Document(), gdcm::Document::DoTheLoadingDocumentJob(), gdcm::Document::FindDocEntryVR(), gdcm::Document::GetFileType(), gdcm::Document::HandleOutOfGroup0002(), gdcm::Document::Initialize(), gdcm::Document::IsParsable(), IsReadable(), and gdcm::Document::ReadNextDocEntry().

std::ifstream* gdcm::Document::Fp [protected, inherited]
 

File Pointer, opened during Document parsing.

Definition at line 151 of file gdcmDocument.h.

Referenced by gdcm::Document::Backtrack(), gdcm::Document::CheckSwap(), gdcm::Document::CloseFile(), gdcm::File::ComputeJPEGFragmentInfo(), gdcm::File::ComputeRLEInfo(), gdcm::Document::Document(), gdcm::Document::DoTheLoadingDocumentJob(), gdcm::File::DoTheLoadingJob(), DoTheLoadingJob(), gdcm::Document::FindDocEntryLengthOBOrOW(), gdcm::Document::FindDocEntryVR(), gdcm::Document::IsDocEntryAnInteger(), gdcm::Document::LoadDocEntry(), gdcm::Document::LoadDocEntrySafe(), gdcm::Document::LoadEntryBinArea(), gdcm::Document::OpenFile(), gdcm::Document::ParseDES(), gdcm::Document::ParseSQ(), gdcm::File::ReadEncapsulatedBasicOffsetTable(), gdcm::Document::ReadInt16(), gdcm::Document::ReadInt32(), gdcm::Document::ReadNextDocEntry(), gdcm::File::ReadTag(), gdcm::File::ReadTagLength(), gdcm::Document::SkipBytes(), gdcm::Document::SkipToNextDocEntry(), and gdcm::Document::SwitchByteSwapCode().

bool gdcm::Document::Group0002Parsed [protected, inherited]
 

whether we already parsed group 0002 (Meta Elements)

Definition at line 145 of file gdcmDocument.h.

Referenced by gdcm::Document::Document(), gdcm::Document::DoTheLoadingDocumentJob(), and gdcm::Document::HandleOutOfGroup0002().

bool gdcm::Document::HasDCMPreamble [protected, inherited]
 

whether file has a DCM Preamble

Definition at line 148 of file gdcmDocument.h.

Referenced by gdcm::Document::OpenFile(), and gdcm::Document::ReadNextDocEntry().

const unsigned int gdcm::Document::HEADER_LENGTH_TO_READ [static, protected, inherited]
 

After opening the file, we read HEADER_LENGTH_TO_READ bytes.

Definition at line 157 of file gdcmDocument.h.

bool gdcm::Document::IsDocumentAlreadyLoaded [protected, inherited]
 

Whether the gdcm::Document is already parsed/loaded : False from the creation of the gdcm::Document untill gdcm::Document:Load().

Definition at line 177 of file gdcmDocument.h.

Referenced by gdcm::Document::Document(), and gdcm::Document::DoTheLoadingDocumentJob().

bool gdcm::Document::IsDocumentModified [protected, inherited]
 

Whether the gdcm::Document was modified since the last Load().

Definition at line 180 of file gdcmDocument.h.

Referenced by gdcm::Document::Document(), and gdcm::Document::DoTheLoadingDocumentJob().

ListDicomDirPatient::iterator gdcm::DicomDir::ItPatient [private]
 

Definition at line 145 of file gdcmDicomDir.h.

Referenced by Copy(), GetFirstPatient(), and GetNextPatient().

int gdcm::Document::LoadMode [protected, inherited]
 

Bit string integer (each one considered as a boolean) Bit 0 : Skip Sequences, if possible Bit 1 : Skip Shadow Groups if possible Probabely, some more to add.

Definition at line 172 of file gdcmDocument.h.

Referenced by CreateDicomDirChainedList(), gdcm::Document::Document(), and gdcm::Document::ParseDES().

const unsigned int gdcm::Document::MAX_SIZE_LOAD_ELEMENT_VALUE = 0xfff [static, protected, inherited]
 

Elements whose value is longer than MAX_SIZE_LOAD_ELEMENT_VALUE are NOT loaded.

Definition at line 160 of file gdcmDocument.h.

Referenced by gdcm::Document::Document().

uint32_t gdcm::Document::MaxSizeLoadEntry [protected, inherited]
 

Size threshold above which an element value will NOT be loaded in memory (to avoid loading the image/volume itself). By default, this upper bound is fixed to 1024 bytes (which might look reasonable when one considers the definition of the various VR contents).

Definition at line 241 of file gdcmDocument.h.

Referenced by gdcm::Document::LoadDocEntry(), and gdcm::Document::SetMaxSizeLoadEntry().

DicomDirMeta* gdcm::DicomDir::MetaElems [private]
 

Pointer on *the* DicomDirObject 'DicomDirMeta Elements'.

Definition at line 141 of file gdcmDicomDir.h.

Referenced by Copy(), Initialize(), IsReadable(), NewMeta(), Print(), SetElement(), and ~DicomDir().

bool gdcm::DicomDir::ParseDir [private]
 

value of the ??? for any progress bar

Definition at line 148 of file gdcmDicomDir.h.

Referenced by DicomDir(), DoTheLoadingJob(), and Load().

ListDicomDirPatient gdcm::DicomDir::Patients [private]
 

Chained list of DicomDirPatient (to be exploited hierarchicaly).

Definition at line 144 of file gdcmDicomDir.h.

Referenced by AddImageToEnd(), AddPatientToEnd(), AddSerieToEnd(), AddStudyToEnd(), AddVisitToEnd(), Anonymize(), ClearPatient(), Copy(), GetFirstPatient(), GetNextPatient(), IsReadable(), Print(), and Write().

DocEntry* gdcm::DocEntrySet::PreviousDocEntry [protected, inherited]
 

To be able to backtrack (Private Sequence, Implicit VR related pb).

Definition at line 127 of file gdcmDocEntrySet.h.

Referenced by gdcm::Document::Backtrack(), gdcm::DocEntrySet::DocEntrySet(), and gdcm::Document::ParseDES().

int gdcm::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::SQItem::Print(), gdcm::SeqEntry::Print(), gdcm::FileHelper::Print(), gdcm::ElementSet::Print(), gdcm::DocEntry::Print(), gdcm::DictEntry::Print(), gdcm::DicomDirStudy::Print(), gdcm::DicomDirSerie::Print(), gdcm::DicomDirPatient::Print(), gdcm::DicomDirMeta::Print(), Print(), and gdcm::DataEntry::Print().

float gdcm::Document::Progress [protected, inherited]
 

value of the ??? for any progress bar

Definition at line 228 of file gdcmDocument.h.

Referenced by gdcm::Document::CallEndMethod(), gdcm::Document::CallStartMethod(), CreateDicomDirChainedList(), DoTheLoadingJob(), and Initialize().

Dict* gdcm::Document::RefPubDict [protected, inherited]
 

Public dictionary used to parse this header.

Definition at line 232 of file gdcmDocument.h.

Referenced by gdcm::Document::GetPubDict(), and gdcm::Document::Initialize().

Dict* gdcm::Document::RefShaDict [protected, inherited]
 

Optional "shadow dictionary" (private elements) used to parse this header.

Definition at line 235 of file gdcmDocument.h.

Referenced by gdcm::Document::GetShaDict(), gdcm::Document::Initialize(), and gdcm::Document::SetShaDict().

int gdcm::Document::SwapCode [protected, inherited]
 

Swap code gives an information on the byte order of a supposed to be an int32, as it's read on disc (depending on the image Transfer Syntax *and* on the processor endianess) as opposed as it should in memory to be dealt as an int32. For instance :

  • a 'Little Endian' image, read with a little endian processor will have a SwapCode= 1234 (the order is OK; nothing to do)
  • a 'Little Endian' image, read with a big endian procesor will have a SwapCode= 4321 (the order is wrong; int32 an int16 must be swapped) note : values 2143, 4321, 3412 remain for the ACR-NEMA time, and the well known 'Bad Big Endian' and 'Bad Little Endian' codes.

Definition at line 142 of file gdcmDocument.h.

Referenced by gdcm::Document::CheckSwap(), gdcm::Document::Document(), gdcm::Document::SwapDouble(), gdcm::Document::SwapLong(), gdcm::Document::SwapShort(), and gdcm::Document::SwitchByteSwapCode().

ListElements gdcm::Document::UserAnonymizeList [protected, inherited]
 

User supplied list of elements to Anonymize.

Definition at line 163 of file gdcmDocument.h.

Referenced by gdcm::File::AddAnonymizeElement(), gdcm::File::AnonymizeFile(), and gdcm::File::AnonymizeNoLoad().

ListElements gdcm::Document::UserForceLoadList [protected, inherited]
 

User supplied list of elements to force Load.

Definition at line 166 of file gdcmDocument.h.

Referenced by gdcm::Document::AddForceLoadElement(), and gdcm::Document::DoTheLoadingDocumentJob().


The documentation for this class was generated from the following files:
Generated on Fri Jan 20 10:14:32 2006 for gdcm by  doxygen 1.4.4