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

typedef void Method (void *)
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

 GDCM_LEGACY (bool Load(std::string const &filename))
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.
 GDCM_LEGACY (void SetParseDir(bool parseDir))
 DEPRECATED : use SetDirectoryName.
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
void SetStartMethod (DicomDir::Method *method, void *arg=NULL)
void SetProgressMethod (DicomDir::Method *method, void *arg=NULL)
void SetEndMethod (DicomDir::Method *method, void *arg=NULL)
void SetStartMethod (void(*method)(void *), void *arg, void(*argDelete)(void *))
void SetProgressMethod (void(*method)(void *), void *arg, void(*argDelete)(void *))
void SetEndMethod (void(*method)(void *), void *arg, void(*argDelete)(void *))
void SetStartMethodArgDelete (DicomDir::Method *method)
 Set the method to delete the argument The argument is destroyed when the method is changed or when the class is destroyed.
void SetProgressMethodArgDelete (DicomDir::Method *method)
 Set the method to delete the argument The argument is destroyed when the method is changed or when the class is destroyed.
void SetEndMethodArgDelete (DicomDir::Method *method)
 Set the method to delete the argument The argument is destroyed when the method is changed or when the class is destroyed.
float GetProgress ()
 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 bool Load (std::string const &filename)
 Loader. (DEPRECATED : not to break the API).
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 Header Entries (Dicom Elements) parsed with the public and private dictionaries for the value length of a given tag..
virtual std::string GetEntryForcedAsciiValue (uint16_t group, uint16_t elem)
 Return the value of the DataEntry if it's "std::string representable".
DataEntryGetDataEntry (uint16_t group, uint16_t elem)
 Same as Document::GetDocEntry except it only returns a result when the corresponding entry is of type DataEntry.
SeqEntryGetSeqEntry (uint16_t group, uint16_t elem)
 Same as Document::GetDocEntry except it only returns a result 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)
 Modifies the value of a given Doc Entry (Dicom Element) when it exists. Creates it when unexistant.
virtual bool CheckIfEntryExist (uint16_t group, uint16_t elem)
 Checks if a given Dicom Element exists within the H table.
DataEntryNewDataEntry (uint16_t group, uint16_t elem, VRKey const &vr=GDCM_VRUNKNOWN)
 Build a new Val Entry 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 Seq Entry 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 ()

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
void CallStartMethod ()
 CallStartMethod.
void CallProgressMethod ()
 CallProgressMethod.
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().
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
MethodStartMethod
 pointer to the initialisation method for any progress bar
MethodProgressMethod
 pointer to the incrementation method for any progress bar
MethodEndMethod
 pointer to the termination method for any progress bar
MethodStartMethodArgDelete
 pointer to the ??? method for any progress bar
MethodProgressMethodArgDelete
 pointer to the ??? method for any progress bar
MethodEndMethodArgDelete
 pointer to the ??? method for any progress bar
void * StartArg
 pointer to the ??? for any progress bar
void * ProgressArg
 pointer to the ??? for any progress bar
void * EndArg
 pointer to the ??? for any progress bar
float Progress
 value of the ??? for any progress bar
bool Abort
 value of the ??? for any progress bar
bool ParseDir

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 45 of file gdcmDocument.h.

typedef void gdcm::DicomDir::Method(void *)
 

Definition at line 58 of file gdcmDicomDir.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 131 of file gdcmDicomDir.h.


Constructor & Destructor Documentation

gdcm::DicomDir::DicomDir  )  [protected]
 

Constructor : creates an empty DicomDir.

Definition at line 119 of file gdcmDicomDir.cxx.

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

00120          :Document( )
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(), MetaElems, SetEndMethod(), SetProgressMethod(), and SetStartMethod().

00131 {
00132    SetStartMethod(NULL,NULL,NULL);
00133    SetProgressMethod(NULL,NULL,NULL);
00134    SetEndMethod(NULL,NULL,NULL);
00135 
00136    ClearPatient();
00137    if ( MetaElems )
00138    {
00139       MetaElems->Delete();
00140    }
00141 }


Member Function Documentation

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

AbortProgress AbortProgress.

Definition at line 121 of file gdcmDicomDir.h.

00121 { 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 290 of file gdcmDocument.cxx.

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

00291 { 
00292    DicomElement el;
00293    el.Group = group;
00294    el.Elem  = elem;
00295    UserForceLoadList.push_back(el); 
00296 }

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

AddImageToEnd.

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

Definition at line 893 of file gdcmDicomDir.cxx.

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

Referenced by CreateDicomDir(), and SetElement().

00894 {
00895    if ( Patients.size() > 0 )
00896    {
00897       ListDicomDirPatient::iterator itp = Patients.end();
00898       itp--;
00899 
00900       DicomDirStudy *study = (*itp)->GetLastStudy();
00901       if ( study )
00902       {
00903          DicomDirSerie *serie = study->GetLastSerie();
00904          if ( serie )
00905          {
00906             serie->AddImage(dd);
00907             return true;
00908          }
00909       }
00910    }
00911    return false;
00912 }

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

AddPatientToEnd.

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

Definition at line 826 of file gdcmDicomDir.cxx.

References Patients.

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

00827 {
00828    Patients.push_back(dd);
00829    return true;
00830 }

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

AddSerieToEnd.

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

Definition at line 852 of file gdcmDicomDir.cxx.

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

Referenced by CreateDicomDir(), and SetElement().

00853 {
00854    if ( Patients.size() > 0 )
00855    {
00856       ListDicomDirPatient::iterator itp = Patients.end();
00857       itp--;
00858 
00859       DicomDirStudy *study = (*itp)->GetLastStudy();
00860       if ( study )
00861       {
00862          study->AddSerie(dd);
00863          return true;
00864       }
00865    }
00866    return false;
00867 }

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

AddStudyToEnd.

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

Definition at line 836 of file gdcmDicomDir.cxx.

References Patients.

Referenced by CreateDicomDir(), and SetElement().

00837 {
00838    if ( Patients.size() > 0 )
00839    {
00840       ListDicomDirPatient::iterator itp = Patients.end();
00841       itp--;
00842       (*itp)->AddStudy(dd);
00843       return true;
00844    }
00845    return false;
00846 }

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

AddVisitToEnd.

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

Definition at line 873 of file gdcmDicomDir.cxx.

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

Referenced by CreateDicomDir().

00874 {
00875    if ( Patients.size() > 0 )
00876    {
00877       ListDicomDirPatient::iterator itp = Patients.end();
00878       itp--;
00879 
00880       DicomDirStudy *study = (*itp)->GetLastStudy();
00881       if ( study )
00882       {
00883          study->AddVisit(dd);
00884          return true;
00885       }
00886    }
00887    return false;
00888 }

bool gdcm::DicomDir::Anonymize  ) 
 

Anonymize a DICOMDIR.

Returns:
true

Definition at line 545 of file gdcmDicomDir.cxx.

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

00546 {
00547    DataEntry *v;
00548    // Something clever to be found to forge the Patient names
00549    std::ostringstream s;
00550    int i = 1;
00551    for(ListDicomDirPatient::iterator cc = Patients.begin();
00552                                      cc!= Patients.end();
00553                                    ++cc)
00554    {
00555       s << i;
00556       v = (*cc)->GetDataEntry(0x0010, 0x0010) ; // Patient's Name
00557       if (v)
00558       {
00559          v->SetString(s.str());
00560       }
00561 
00562       v = (*cc)->GetDataEntry(0x0010, 0x0020) ; // Patient ID
00563       if (v)
00564       {
00565          v->SetString(" ");
00566       }
00567 
00568       v = (*cc)->GetDataEntry(0x0010, 0x0030) ; // Patient's BirthDate
00569       if (v)
00570       {
00571          v->SetString(" ");
00572       }
00573       s << "";
00574       i++;
00575    }
00576    return true;
00577 }

void gdcm::DicomDir::CallEndMethod  )  [protected]
 

CallEndMethod.

Definition at line 667 of file gdcmDicomDir.cxx.

References EndArg, EndMethod, and Progress.

Referenced by CreateDicomDirChainedList().

00668 {
00669    Progress = 1.0f;
00670    if ( EndMethod )
00671    {
00672       EndMethod( EndArg );
00673    }
00674 }

void gdcm::DicomDir::CallProgressMethod  )  [protected]
 

CallProgressMethod.

Definition at line 656 of file gdcmDicomDir.cxx.

References ProgressArg, and ProgressMethod.

Referenced by CreateDicomDirChainedList().

00657 {
00658    if ( ProgressMethod )
00659    {
00660       ProgressMethod( ProgressArg );
00661    }
00662 }

void gdcm::DicomDir::CallStartMethod  )  [protected]
 

CallStartMethod.

Definition at line 643 of file gdcmDicomDir.cxx.

References Abort, Progress, StartArg, and StartMethod.

Referenced by CreateDicomDirChainedList().

00644 {
00645    Progress = 0.0f;
00646    Abort    = false;
00647    if ( StartMethod )
00648    {
00649       StartMethod( StartArg );
00650    }
00651 }

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

Checks if a given Dicom Element exists within the H table.

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

Definition at line 430 of file gdcmDocEntrySet.cxx.

References gdcm::DocEntrySet::GetDocEntry().

00431 {
00432    return GetDocEntry(group,elem)!=NULL;
00433 }

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 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 327 of file gdcmDicomDir.cxx.

References Patients.

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

00328 {
00329    for(ListDicomDirPatient::iterator cc = Patients.begin();
00330                                      cc!= Patients.end();
00331                                    ++cc)
00332    {
00333       (*cc)->Unregister();
00334    }
00335    Patients.clear();
00336 }

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

closes the file

Returns:
TRUE if the close was successfull

Definition at line 658 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().

00659 {
00660    if ( Fp )
00661    {
00662       Fp->close();
00663       delete Fp;
00664       Fp = 0;
00665    }
00666    return true;
00667 }

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

Re-computes the length of the Dicom group 0002.

Definition at line 956 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().

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

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

create a 'gdcmDicomDir' from a DICOMDIR Header

Definition at line 702 of file gdcmDicomDir.cxx.

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

Referenced by DoTheLoadingJob(), and ParseDirectory().

00703 {
00704    // The SeqEntries of "Directory Record Sequence" are parsed. 
00705    //  When a DicomDir tag ("PATIENT", "STUDY", "SERIE", "IMAGE") is found :
00706    //  1 - we save the beginning iterator
00707    //  2 - we continue to parse
00708    //  3 - we find an other tag
00709    //       + we create the object for the precedent tag
00710    //       + loop to 1 -
00711    gdcmDebugMacro("Create DicomDir");
00712 
00713    // Directory record sequence
00714    DocEntry *e = GetDocEntry(0x0004, 0x1220);
00715    if ( !e )
00716    {
00717       gdcmWarningMacro( "No Directory Record Sequence (0004,1220) found");
00718       return;         
00719    }
00720    
00721    SeqEntry *s = dynamic_cast<SeqEntry *>(e);
00722    if ( !s )
00723    {
00724       gdcmWarningMacro( "Element (0004,1220) is not a Sequence ?!?");
00725       return;
00726    }
00727 
00728    NewMeta();
00729    
00730    DocEntry *d;
00731    std::string v;
00732    SQItem *si;
00733 
00734    SQItem *tmpSI=s->GetFirstSQItem();
00735    while(tmpSI)
00736    {
00737       d = tmpSI->GetDocEntry(0x0004, 0x1430); // Directory Record Type
00738       if ( DataEntry *dataEntry = dynamic_cast<DataEntry *>(d) )
00739       {
00740          v = dataEntry->GetString();
00741       }
00742       else
00743       {
00744          gdcmWarningMacro( "(0004,1430) not a DataEntry ?!?");
00745          continue;
00746       }
00747 
00748       // A decent DICOMDIR has much more images than series,
00749       // more series than studies, and so on.
00750       // This is the right order to preform the tests
00751 
00752       if ( v == "IMAGE " ) 
00753       {
00754          si = DicomDirImage::New(true);
00755          if ( !AddImageToEnd( static_cast<DicomDirImage *>(si)) )
00756          {
00757             si->Delete();
00758             si = NULL;
00759             gdcmErrorMacro( "Add AddImageToEnd failed");
00760          }
00761       }
00762       else if ( v == "SERIES" )
00763       {
00764          si = DicomDirSerie::New(true);
00765          if ( !AddSerieToEnd( static_cast<DicomDirSerie *>(si)) )
00766          {
00767             si->Delete();
00768             si = NULL;
00769             gdcmErrorMacro( "Add AddSerieToEnd failed");
00770          }
00771       }
00772       else if ( v == "VISIT " )
00773       {
00774          si = DicomDirVisit::New(true);
00775          if ( !AddVisitToEnd( static_cast<DicomDirVisit *>(si)) )
00776          {
00777             si->Delete();
00778             si = NULL;
00779             gdcmErrorMacro( "Add AddVisitToEnd failed");
00780          }
00781       }
00782       else if ( v == "STUDY " )
00783       {
00784          si = DicomDirStudy::New(true);
00785          if ( !AddStudyToEnd( static_cast<DicomDirStudy *>(si)) )
00786          {
00787             si->Delete();
00788             si = NULL;
00789             gdcmErrorMacro( "Add AddStudyToEnd failed");
00790          }
00791       }
00792       else if ( v == "PATIENT " )
00793       {
00794          si = DicomDirPatient::New(true);
00795          if ( !AddPatientToEnd( static_cast<DicomDirPatient *>(si)) )
00796          {
00797             si->Delete();
00798             si = NULL;
00799             gdcmErrorMacro( "Add PatientToEnd failed");
00800          }
00801       }
00802       else
00803       {
00804          // It was neither a 'PATIENT', nor a 'STUDY', nor a 'SERIE',
00805          // nor an 'IMAGE' SQItem. Skip to next item.
00806          gdcmDebugMacro( " -------------------------------------------"
00807          << "a non PATIENT/STUDY/SERIE/IMAGE SQItem was found : "
00808          << v);
00809 
00810         // FIXME : deal with other item types !
00811         tmpSI=s->GetNextSQItem(); // To avoid infinite loop
00812         continue;
00813       }
00814       if ( si )
00815          si->MoveObject(tmpSI);  // New code : Copies the List
00816 
00817       tmpSI=s->GetNextSQItem();
00818    }
00819    ClearEntry();
00820 }

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 585 of file gdcmDicomDir.cxx.

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

Referenced by ParseDirectory().

00586 {
00587    CallStartMethod();
00588    DirList dirList(path,1); // gets recursively the file list
00589    unsigned int count = 0;
00590    VectDocument list;
00591    File *f;
00592 
00593    DirListType fileList = dirList.GetFilenames();
00594 
00595    for( DirListType::iterator it  = fileList.begin();
00596                               it != fileList.end();
00597                               ++it )
00598    {
00599       Progress = (float)(count+1)/(float)fileList.size();
00600       CallProgressMethod();
00601       if ( Abort )
00602       {
00603          break;
00604       }
00605 
00606       f = File::New( );
00607       f->SetLoadMode(LoadMode); // we allow user not to load Sequences, 
00608                                 //        or Shadow groups, or ......
00609       f->SetFileName( it->c_str() );
00610       f->Load( );
00611 
00612       if ( f->IsReadable() )
00613       {
00614          // Add the file to the chained list:
00615          list.push_back(f);
00616          gdcmDebugMacro( "Readable " << it->c_str() );
00617        }
00618        else
00619        {
00620           f->Delete();
00621        }
00622        count++;
00623    }
00624    // sorts Patient/Study/Serie/
00625    std::sort(list.begin(), list.end(), DicomDir::HeaderLessThan );
00626    
00627    std::string tmp = dirList.GetDirName();      
00628    //for each File of the chained list, add/update the Patient/Study/Serie/Image info
00629    SetElements(tmp, list);
00630    CallEndMethod();
00631 
00632    for(VectDocument::iterator itDoc=list.begin();
00633        itDoc!=list.end();
00634        ++itDoc)
00635    {
00636       dynamic_cast<File *>(*itDoc)->Delete();
00637    }
00638 }

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 40 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(), 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(), ~DicomDir(), and gdcm::Global::~Global().

00040 { 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 193 of file gdcmDicomDir.cxx.

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

Referenced by Load().

00194 {
00195    Progress = 0.0f;
00196    Abort = false;
00197 
00198    if (!ParseDir)
00199    {
00200    // Only if user passed a DICOMDIR
00201    // ------------------------------
00202       Fp = 0;
00203       if (!Document::Load() )
00204       {
00205          return false;
00206       }
00207 
00208       if ( GetFirstEntry() == 0 ) // when user passed a Directory to parse
00209       {
00210          gdcmWarningMacro( "Entry HT empty for file: "<< GetFileName());
00211          return false;
00212       }
00213       // Directory record sequence
00214       DocEntry *e = GetDocEntry(0x0004, 0x1220);
00215       if ( !e )
00216       {
00217          gdcmWarningMacro( "NO 'Directory record sequence' (0x0004,0x1220)"
00218                           << " in file " << GetFileName());
00219          return false;
00220       }
00221       else
00222          CreateDicomDir();
00223    }
00224    else
00225    {
00226    // Only if user passed a root directory
00227    // ------------------------------------
00228       if ( GetFileName() == "." )
00229       {
00230          // user passed '.' as Name
00231          // we get current directory name
00232          char buf[2048];
00233          const char *cwd = getcwd(buf, 2048);
00234          if( cwd )
00235            {
00236            SetFileName( buf ); // will be converted into a string
00237            }
00238          else
00239            {
00240            gdcmErrorMacro( "Path was too long to fit on 2048 bytes" );
00241            }
00242       }
00243       NewMeta();
00244       gdcmDebugMacro( "Parse directory and create the DicomDir : " 
00245                          << GetFileName() );
00246       ParseDirectory();
00247    }
00248    return true;
00249 }

gdcm::DicomDir::GDCM_LEGACY void   SetParseDir(bool parseDir)  ) 
 

DEPRECATED : use SetDirectoryName.

gdcm::DicomDir::GDCM_LEGACY bool   Load(std::string const &filename)  ) 
 

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

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

Same as Document::GetDocEntry except it only returns a result 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 136 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(), gdcm::FileHelper::Write(), gdcm::File::Write(), and gdcm::DicomDirMeta::WriteContent().

00137 {
00138    DocEntry *currentEntry = GetDocEntry(group, elem);
00139    if ( !currentEntry )
00140       return NULL;
00141 
00142    return dynamic_cast<DataEntry*>(currentEntry);
00143 }

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 520 of file gdcmDocEntrySet.cxx.

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

00522 {
00523    DictEntry *dictEntry = GetDictEntry(group,elem);
00524    DictEntry *goodEntry = dictEntry;
00525    VRKey goodVR = vr;
00526 
00527    if (elem == 0x0000) 
00528       goodVR="UL";
00529 
00530    if ( goodEntry )
00531    {
00532       if ( goodVR != goodEntry->GetVR()
00533         && goodVR != GDCM_VRUNKNOWN )
00534       {
00535          goodEntry = NULL;
00536       }
00537       dictEntry->Unregister();
00538    }
00539 
00540    // Create a new virtual DictEntry if necessary
00541    if (!goodEntry)
00542    {
00543       if (dictEntry)
00544       {
00545          goodEntry = DictEntry::New(group, elem, goodVR, "FIXME", 
00546                                     dictEntry->GetName() );
00547       }
00548       else
00549       {
00550          goodEntry = DictEntry::New(group, elem, goodVR);
00551       }
00552    }
00553    else
00554    {
00555       goodEntry->Register();
00556    }
00557    return goodEntry;
00558 }

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 493 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().

00494 {
00495    DictEntry *found = 0;
00496    Dict *pubDict = Global::GetDicts()->GetDefaultPubDict();
00497    if (!pubDict) 
00498    {
00499       gdcmWarningMacro( "We SHOULD have a default dictionary");
00500    }
00501    else
00502    {
00503       found = pubDict->GetEntry(group, elem);
00504       if( found )
00505          found->Register();
00506    }
00507    return found;
00508 }

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::DicomEntry::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 }

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

Return the value of the DataEntry if it's "std::string representable".

Parameters:
group Group number of the searched tag.
elem Element number of the searched tag.
Returns:
Corresponding element value when it's "std::string representable" and the string GDCM_NOTASCII otherwise.

Definition at line 84 of file gdcmDocEntrySet.cxx.

References gdcm::Util::CreateCleanString(), gdcm::GDCM_NOTASCII, gdcm::GDCM_NOTLOADED, gdcm::GDCM_UNFOUND, gdcm::GDCM_UNREAD, gdcm::DataEntry::GetBinArea(), gdcm::DocEntrySet::GetDocEntry(), gdcm::DocEntry::GetLength(), gdcm::DataEntry::GetString(), gdcm::DocEntry::GetVR(), gdcm::Global::GetVR(), gdcm::Util::IsCleanArea(), gdcm::DataEntry::IsNotLoaded(), gdcm::DataEntry::IsUnfound(), gdcm::DataEntry::IsUnread(), and gdcm::VR::IsVROfStringRepresentable().

00085 {
00086    DocEntry *d = GetDocEntry(group,elem);
00087    if ( !d )
00088       return GDCM_UNFOUND;
00089 
00090    DataEntry *de = dynamic_cast<DataEntry *>(d);
00091    if ( de )
00092    {
00093       if( de->IsNotLoaded() )
00094          return GDCM_NOTLOADED;
00095       if( de->IsUnfound() )
00096          return GDCM_UNFOUND;
00097       if( de->IsUnread() )
00098          return GDCM_UNREAD;
00099    }
00100 
00101    if( Global::GetVR()->IsVROfStringRepresentable( de->GetVR() ) )
00102       return de->GetString();
00103    else
00104    {
00105       uint8_t *a = de->GetBinArea();
00106       if( Util::IsCleanArea(a, de->GetLength()) )
00107          return  Util::CreateCleanString(a, de->GetLength());
00108    }
00109    return GDCM_NOTASCII;
00110 }

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

Searches within Header Entries (Dicom Elements) parsed with the public and private dictionaries 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; -2 if not found

Definition at line 120 of file gdcmDocEntrySet.cxx.

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

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

00121 {
00122    DocEntry *entry = GetDocEntry(group, elem);
00123    if ( entry )
00124       return entry->GetLength();
00125    return -1;
00126 }

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::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 74 of file gdcmDocument.h.

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

00074 { return Filename; }

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

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

Returns:
the FileType code

Definition at line 403 of file gdcmDocument.cxx.

References gdcm::Document::Filetype.

00404 {
00405    return Filetype;
00406 }

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 342 of file gdcmDicomDir.cxx.

References ItPatient, and Patients.

00343 {
00344    ItPatient = Patients.begin();
00345    if ( ItPatient != Patients.end() )
00346       return *ItPatient;
00347    return NULL;
00348 }

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

Returns a pointer to the DicomDirMeta for this DICOMDIR.

Definition at line 82 of file gdcmDicomDir.h.

Referenced by Write().

00082 { 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 355 of file gdcmDicomDir.cxx.

References gdcmAssertMacro, ItPatient, and Patients.

00356 {
00357    gdcmAssertMacro (ItPatient != Patients.end());
00358 
00359    ++ItPatient;
00360    if ( ItPatient != Patients.end() )
00361       return *ItPatient;
00362    return NULL;
00363 }

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  )  [inline]
 

GetProgress GetProgress.

Definition at line 119 of file gdcmDicomDir.h.

00119 { return Progress; }

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

Get the public dictionary used.

Definition at line 300 of file gdcmDocument.cxx.

References gdcm::Document::RefPubDict.

Referenced by SetElement().

00301 {
00302    return RefPubDict;
00303 }

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

Get the reference counting.

Returns:
Reference count

Definition at line 57 of file gdcmRefCounter.h.

00058    {
00059       return RefCount;
00060    }

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

Same as Document::GetDocEntry except it only returns a result 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 153 of file gdcmDocEntrySet.cxx.

References gdcm::DocEntrySet::GetDocEntry().

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

00154 {
00155    DocEntry *currentEntry = GetDocEntry(group, elem);
00156    if ( !currentEntry )
00157       return NULL;
00158       
00159    return dynamic_cast<SeqEntry*>(currentEntry);
00160 }

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

Get the shadow dictionary used.

Definition at line 308 of file gdcmDocument.cxx.

References gdcm::Document::RefShaDict.

00309 {
00310    return RefShaDict;
00311 }

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

'Swap code' accessor (see SwapCode )

Definition at line 70 of file gdcmDocument.h.

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

00070 { 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 415 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().

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

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 457 of file gdcmDocument.cxx.

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

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

00458 {
00459    // use the TS (TS : Transfer Syntax)
00460    std::string transferSyntax = GetEntryString(0x0002,0x0010);
00461 
00462    if ( (transferSyntax.find(GDCM_NOTLOADED) < transferSyntax.length()) )
00463    {
00464       gdcmErrorMacro( "Transfer Syntax not loaded. " << std::endl
00465                << "Better you increase MAX_SIZE_LOAD_ELEMENT_VALUE" );
00466       return "Uncompressed ACR-NEMA";
00467    }
00468    if ( transferSyntax == GDCM_UNFOUND )
00469    {
00470       gdcmDebugMacro( "Unfound Transfer Syntax (0002,0010)");
00471       return "Uncompressed ACR-NEMA";
00472    }
00473 
00474    // we do it only when we need it
00475    const TSKey &tsName = Global::GetTS()->GetValue( transferSyntax );
00476 
00477    // Global::GetTS() is a global static you shall never try to delete it!
00478    return tsName;
00479 }

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

compares two files

Definition at line 1182 of file gdcmDicomDir.cxx.

Referenced by CreateDicomDirChainedList().

01183 {
01184    return *header1 < *header2;
01185 }

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

Sets all fields to NULL.

Reimplemented from gdcm::Document.

Definition at line 681 of file gdcmDicomDir.cxx.

References Abort, EndArg, EndMethod, EndMethodArgDelete, MetaElems, Progress, ProgressArg, ProgressMethod, ProgressMethodArgDelete, StartArg, StartMethod, and StartMethodArgDelete.

Referenced by DicomDir().

00682 {
00683    StartMethod             = NULL;
00684    ProgressMethod          = NULL;
00685    EndMethod               = NULL;
00686    StartMethodArgDelete    = NULL;
00687    ProgressMethodArgDelete = NULL;
00688    EndMethodArgDelete      = NULL;
00689    StartArg                = NULL;
00690    ProgressArg             = NULL;
00691    EndArg                  = NULL;
00692 
00693    Progress = 0.0;
00694    Abort = false;
00695 
00696    MetaElems = NULL;   
00697 }

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 308 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().

00311 {
00312    DataEntry *dataEntry = 0;
00313    DocEntry *currentEntry = GetDocEntry( group, elem );
00314 
00315    // Verify the currentEntry
00316    if (currentEntry)
00317    {
00318       dataEntry = dynamic_cast<DataEntry *>(currentEntry);
00319 
00320       // Verify the VR
00321       if ( dataEntry )
00322          if ( dataEntry->GetVR()!=vr )
00323             dataEntry = NULL;
00324 
00325       // if currentEntry doesn't correspond to the requested dataEntry
00326       if ( !dataEntry)
00327       {
00328          if ( !RemoveEntry(currentEntry) )
00329          {
00330             gdcmWarningMacro( "Removal of previous DocEntry failed.");
00331             return NULL;
00332          }
00333       }
00334    }
00335 
00336    // Create a new dataEntry if necessary
00337    if ( !dataEntry)
00338    {
00339       dataEntry = NewDataEntry(group, elem, vr);
00340 
00341       if ( !AddEntry(dataEntry) )
00342       {
00343          gdcmWarningMacro( "AddEntry failed although this is a creation.");
00344          dataEntry->Delete();
00345          return NULL;
00346       }
00347       dataEntry->Delete();
00348    }
00349 
00350    // Set the dataEntry value
00351    uint8_t *tmpArea;
00352    if ( lgth>0 && binArea )
00353    {
00354       tmpArea = new uint8_t[lgth];
00355       memcpy(tmpArea,binArea,lgth);
00356    }
00357    else
00358    {
00359       tmpArea = 0;
00360    }
00361    if ( !SetEntryBinArea(tmpArea,lgth,dataEntry) )
00362    {
00363       if ( tmpArea )
00364       {
00365          delete[] tmpArea;
00366       }
00367    }
00368 
00369    return dataEntry;
00370 }  

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 250 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().

00253 {
00254    DataEntry *dataEntry = 0;
00255    DocEntry *currentEntry = GetDocEntry( group, elem );
00256    
00257    if (currentEntry)
00258    {
00259       dataEntry = dynamic_cast<DataEntry *>(currentEntry);
00260 
00261       // Verify the VR
00262       if ( dataEntry )
00263          if ( dataEntry->GetVR()!=vr )
00264             dataEntry = NULL;
00265 
00266       // if currentEntry doesn't correspond to the requested dataEntry
00267       if ( !dataEntry)
00268       {
00269          if ( !RemoveEntry(currentEntry) )
00270          {
00271             gdcmWarningMacro( "Removal of previous DocEntry failed.");
00272             return NULL;
00273          }
00274       }
00275    }
00276 
00277    // Create a new dataEntry if necessary
00278    if ( !dataEntry )
00279    {
00280       dataEntry = NewDataEntry( group, elem, vr );
00281 
00282       if ( !AddEntry(dataEntry) )
00283       {
00284          gdcmWarningMacro("AddEntry failed although this is a creation.");
00285          dataEntry->Delete();
00286          return NULL;
00287       }
00288       dataEntry->Delete();
00289    }
00290 
00291    // Set the dataEntry value
00292    SetEntryString(value, dataEntry); // The std::string value
00293    return dataEntry;
00294 }

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

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

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

Definition at line 380 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().

00381 {
00382    SeqEntry *seqEntry = 0;
00383    DocEntry *currentEntry = GetDocEntry( group, elem );
00384 
00385    // Verify the currentEntry
00386    if ( currentEntry )
00387    {
00388       seqEntry = dynamic_cast<SeqEntry *>(currentEntry);
00389 
00390       // Verify the VR
00391       if ( seqEntry )
00392          seqEntry = NULL;
00393 
00394       // if currentEntry doesn't correspond to the requested seqEntry
00395       if ( !seqEntry )
00396       {
00397          if (!RemoveEntry(currentEntry))
00398          {
00399             gdcmWarningMacro( "Removal of previous DocEntry failed.");
00400 
00401             return NULL;
00402          }
00403       }
00404    }
00405    // Create a new seqEntry if necessary
00406    if ( !seqEntry )
00407    {
00408       seqEntry = NewSeqEntry(group, elem);
00409 
00410       if ( !AddEntry(seqEntry) )
00411       {
00412          gdcmWarningMacro( "AddEntry failed although this is a creation.");
00413          seqEntry->Delete();
00414          return NULL;
00415       }
00416       seqEntry->Delete();
00417    }
00418 
00419    // TODO : Find a trick to insert a SequenceDelimitationItem 
00420    //       in the SeqEntry, at the end.
00421    return seqEntry;
00422 } 

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

IsAborted IsAborted.

Definition at line 123 of file gdcmDicomDir.h.

00123 { 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 372 of file gdcmDocument.cxx.

References gdcm::ElementSet::GetDocEntry().

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

00373 {
00374    // Checking if Transfer Syntax exists is enough
00375    // Anyway, it's too late check if the 'Preamble' was found ...
00376    // And ... would it be a rich idea to check ?
00377    // (some 'no Preamble' DICOM images exist !)
00378    return GetDocEntry(0x0002, 0x0010) != NULL;
00379 }

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

Tells us if the ElementSet contains no entry.

Implements gdcm::DocEntrySet.

Definition at line 60 of file gdcmElementSet.h.

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

00060 { 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 386 of file gdcmDocument.cxx.

References gdcm::ElementSet::GetDocEntry().

00387 {
00388    // check for Papyrus private Sequence
00389    DocEntry *e = GetDocEntry(0x0041, 0x1050);
00390    if ( !e )
00391       return false;
00392    // check if it's actually a Sequence
00393    if ( !dynamic_cast<SeqEntry*>(e) )
00394       return  false;
00395    return true;
00396 }

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 340 of file gdcmDocument.cxx.

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

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

00341 {
00342    if ( Filetype == Unknown )
00343    {
00344       gdcmWarningMacro( "Wrong filetype for " << GetFileName());
00345       return false;
00346    }
00347 
00348    if ( IsEmpty() )
00349    { 
00350       gdcmWarningMacro( "No tag in internal hash table.");
00351       return false;
00352    }
00353 
00354    return true;
00355 }

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 259 of file gdcmDicomDir.cxx.

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

00260 {
00261    if ( Filetype == Unknown )
00262    {
00263       gdcmErrorMacro( "Wrong filetype for " << GetFileName());
00264       return false;
00265    }
00266    if ( !MetaElems )
00267    {
00268       gdcmWarningMacro( "Meta Elements missing in DicomDir");
00269       return false;
00270    }
00271    if ( Patients.size() <= 0 )
00272    {
00273       gdcmWarningMacro( "NO Patient in DicomDir");
00274       return false;
00275    }
00276 
00277    return true;
00278 }

bool gdcm::Document::Load std::string const &  fileName  )  [virtual, inherited]
 

Loader. (DEPRECATED : not to break the API).

Parameters:
fileName 'Document' (File or DicomDir) to be open for parsing
Returns:
false if file cannot be open or no swap info was found, or no tag was found.

Definition at line 99 of file gdcmDocument.cxx.

References gdcm::Document::DoTheLoadingDocumentJob(), and gdcm::Document::Filename.

00100 {
00101    Filename = fileName;
00102    return DoTheLoadingDocumentJob( );
00103 }

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 152 of file gdcmDicomDir.cxx.

References DoTheLoadingJob(), and ParseDir.

00153 {
00154    if (!ParseDir)
00155    {
00156       if ( ! this->Document::Load( ) )
00157          return false;
00158    }
00159    return DoTheLoadingJob( );   
00160 }

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 822 of file gdcmDocument.cxx.

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

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

00823 {
00824    if ( Fp )
00825    {
00826       long PositionOnEntry = Fp->tellg();
00827       LoadDocEntry(entry);
00828       Fp->seekg(PositionOnEntry, std::ios::beg);
00829    }
00830 }

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 741 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().

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

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 716 of file gdcmDocument.cxx.

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

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

00717 {
00718    // Search the corresponding DocEntry
00719    DocEntry *docEntry = GetDocEntry(group, elem);
00720    if ( !docEntry )
00721    {
00722       gdcmDebugMacro(std::hex << group << "|" << elem 
00723                        <<  " doesn't exist" );
00724       return;
00725    }
00726    DataEntry *dataEntry = dynamic_cast<DataEntry *>(docEntry);
00727    if ( !dataEntry )
00728    {
00729       gdcmWarningMacro(std::hex << group << "|" << elem 
00730                        <<  " is NOT a DataEntry");
00731       return;
00732    }
00733    LoadEntryBinArea(dataEntry);
00734 }

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 1165 of file gdcmDicomDir.cxx.

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

01166 { 
01167    DocEntry *entry;
01168 
01169    entry = src->GetFirstEntry();
01170    while(entry)
01171    {
01172       src->RemoveEntry(entry);
01173       dst->AddEntry(entry);
01174       // we destroyed -> the current iterator is not longer valid
01175       entry = src->GetFirstEntry();
01176    }
01177 }

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

Definition at line 56 of file gdcmDicomDir.h.

00056 {return new DicomDir();}

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

Build a new Val Entry 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 444 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().

00446 {
00447    DictEntry *dictEntry = GetDictEntry(group, elem, vr);
00448 
00449    DataEntry *newEntry = DataEntry::New(dictEntry);
00450    dictEntry->Unregister(); // GetDictEntry register it
00451    if (!newEntry) 
00452    {
00453       gdcmWarningMacro( "Failed to allocate DataEntry");
00454       return 0;
00455    }
00456    return newEntry;
00457 }

DicomDirMeta * gdcm::DicomDir::NewMeta  ) 
 

adds *the* Meta to a partially created DICOMDIR

Definition at line 283 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().

00284 {
00285    if ( MetaElems )
00286       MetaElems->Delete();
00287 
00288    DocEntry *entry = GetFirstEntry();
00289    if ( entry )
00290    { 
00291       MetaElems = DicomDirMeta::New(true); // true = empty
00292 
00293       entry = GetFirstEntry();
00294       while( entry )
00295       {
00296          if ( dynamic_cast<SeqEntry *>(entry) )
00297             break;
00298 
00299          MetaElems->AddEntry(entry);
00300          RemoveEntry(entry);
00301 
00302          entry = GetFirstEntry();
00303       }
00304    }
00305    else  // after root directory parsing
00306    {
00307       MetaElems = DicomDirMeta::New(false); // false = not empty
00308    }
00309    MetaElems->SetSQItemNumber(0); // To avoid further missprinting
00310    return MetaElems;  
00311 }

DicomDirPatient * gdcm::DicomDir::NewPatient  ) 
 

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

Definition at line 317 of file gdcmDicomDir.cxx.

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

00318 {
00319    DicomDirPatient *dd = DicomDirPatient::New();
00320    AddPatientToEnd( dd );
00321    return dd;
00322 }

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

Build a new Seq Entry 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 467 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().

00468 {
00469    DictEntry *dictEntry = GetDictEntry(group, elem, "SQ");
00470 
00471    SeqEntry *newEntry = SeqEntry::New( dictEntry );
00472    dictEntry->Unregister(); // GetDictEntry register it
00473    if (!newEntry)
00474    {
00475       gdcmWarningMacro( "Failed to allocate SeqEntry");
00476       return 0;
00477    }
00478    return newEntry;
00479 }

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 572 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().

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

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 839 of file gdcmDocument.cxx.

References gdcm::DocEntrySet::GetEntryString().

00840 {
00841    // Patient Name
00842    std::string s1 = GetEntryString(0x0010,0x0010);
00843    std::string s2 = document.GetEntryString(0x0010,0x0010);
00844    if (s1 < s2)
00845    {
00846       return true;
00847    }
00848    else if ( s1 > s2 )
00849    {
00850       return false;
00851    }
00852    else
00853    {
00854       // Patient ID
00855       s1 = GetEntryString(0x0010,0x0020);
00856       s2 = document.GetEntryString(0x0010,0x0020);
00857       if ( s1 < s2 )
00858       {
00859          return true;
00860       }
00861       else if ( s1 > s2 )
00862       {
00863          return false;
00864       }
00865       else
00866       {
00867          // Study Instance UID
00868          s1 = GetEntryString(0x0020,0x000d);
00869          s2 = document.GetEntryString(0x0020,0x000d);
00870          if ( s1 < s2 )
00871          {
00872             return true;
00873          }
00874          else if ( s1 > s2 )
00875          {
00876             return false;
00877          }
00878          else
00879          {
00880             // Serie Instance UID
00881             s1 = GetEntryString(0x0020,0x000e);
00882             s2 = document.GetEntryString(0x0020,0x000e);    
00883             if ( s1 < s2 )
00884             {
00885                return true;
00886             }
00887             else if ( s1 > s2 )
00888             {
00889                return false;
00890             }
00891          }
00892       }
00893    }
00894    return false;
00895 }

void gdcm::DicomDir::ParseDirectory  ) 
 

fills the whole structure, starting from a root Directory

Definition at line 368 of file gdcmDicomDir.cxx.

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

Referenced by DoTheLoadingJob().

00369 {
00370    CreateDicomDirChainedList( GetFileName() );
00371    CreateDicomDir();
00372 }

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 1194 of file gdcmDicomDir.cxx.

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

01195 {
01196    if ( MetaElems )
01197    {
01198       MetaElems->SetPrintLevel(PrintLevel);
01199       MetaElems->Print(os);   
01200    }   
01201    for(ListDicomDirPatient::iterator cc  = Patients.begin();
01202                                      cc != Patients.end();
01203                                    ++cc)
01204    {
01205      (*cc)->SetPrintLevel(PrintLevel);
01206      (*cc)->Print(os);
01207    }
01208 }

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 904 of file gdcmDocument.cxx.

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

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

00906 {
00907    uint16_t g;
00908    Fp->read ((char*)&g, (size_t)2);
00909    if ( Fp->fail() )
00910    {
00911       throw FormatError( "Document::ReadInt16()", " file error." );
00912    }
00913    if ( Fp->eof() )
00914    {
00915       throw FormatError( "Document::ReadInt16()", "EOF." );
00916    }
00917    g = SwapShort(g); 
00918    return g;
00919 }

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 926 of file gdcmDocument.cxx.

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

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

00928 {
00929    uint32_t g;
00930    Fp->read ((char*)&g, (size_t)4);
00931    if ( Fp->fail() )
00932    {
00933       throw FormatError( "Document::ReadInt32()", " file error." );
00934    }
00935    if ( Fp->eof() )
00936    {
00937       throw FormatError( "Document::ReadInt32()", "EOF." );
00938    }
00939    g = SwapLong(g);
00940    return g;
00941 }

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

Register the object.

Remarks:
It increments the reference counting

Definition at line 45 of file gdcmRefCounter.h.

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

00045 { 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 65 of file gdcmDicomDir.h.

00066         { ParseDir = true; if (Filename != dirName)
00067                                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 988 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_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().

00990 {
00991    ListDicomDirElem elemList;
00992    ListDicomDirElem::const_iterator it;
00993    uint16_t tmpGr, tmpEl;
00994    DictEntry *dictEntry;
00995    DataEntry *entry;
00996    std::string val;
00997    SQItem *si;
00998 
00999    switch( type )
01000    {
01001       case GDCM_DICOMDIR_IMAGE:
01002          elemList = Global::GetDicomDirElements()->GetDicomDirImageElements();
01003          si = DicomDirImage::New(true);
01004          if ( !AddImageToEnd(static_cast<DicomDirImage *>(si)) )
01005          {
01006             si->Delete();
01007             gdcmErrorMacro( "Add ImageToEnd failed");
01008          }
01009          break;
01010       case GDCM_DICOMDIR_SERIE:
01011          elemList = Global::GetDicomDirElements()->GetDicomDirSerieElements();
01012          si = DicomDirSerie::New(true);
01013          if ( !AddSerieToEnd(static_cast<DicomDirSerie *>(si)) )
01014          {
01015             si->Delete();
01016             gdcmErrorMacro( "Add SerieToEnd failed");
01017          }
01018          break;
01019       case GDCM_DICOMDIR_STUDY:
01020          elemList = Global::GetDicomDirElements()->GetDicomDirStudyElements();
01021          si = DicomDirStudy::New(true);
01022          if ( !AddStudyToEnd(static_cast<DicomDirStudy *>(si)) )
01023          {
01024             si->Delete();
01025             gdcmErrorMacro( "Add StudyToEnd failed");
01026          }
01027          break;
01028       case GDCM_DICOMDIR_PATIENT:
01029          elemList = Global::GetDicomDirElements()->GetDicomDirPatientElements();
01030          si = DicomDirPatient::New(true);
01031          if ( !AddPatientToEnd(static_cast<DicomDirPatient *>(si)) )
01032          {
01033             si->Delete();
01034             gdcmErrorMacro( "Add PatientToEnd failed");
01035          }
01036          break;
01037       case GDCM_DICOMDIR_META:
01038          if ( MetaElems )
01039          {
01040             MetaElems->Delete();
01041             gdcmErrorMacro( "MetaElements already exist, they will be destroyed");
01042          }
01043          elemList = Global::GetDicomDirElements()->GetDicomDirMetaElements();
01044          MetaElems = DicomDirMeta::New(true);
01045          si = MetaElems;
01046          break;
01047       default:
01048          return;
01049    }
01050    
01051    // FIXME : troubles found when it's a SeqEntry
01052       
01053    // removed all the seems-to-be-useless stuff about Referenced Image Sequence
01054    // to avoid further troubles
01055    // imageElem 0008 1140 "" // Referenced Image Sequence
01056    // imageElem fffe e000 "" // 'no length' item : length to be set to 0xffffffff later
01057    // imageElem 0008 1150 "" // Referenced SOP Class UID    : to be set/forged later
01058    // imageElem 0008 1155 "" // Referenced SOP Instance UID : to be set/forged later
01059    // imageElem fffe e00d "" // Item delimitation : length to be set to ZERO later
01060  
01061    std::string referencedVal;
01062    // for all the relevant elements found in their own spot of the DicomDir.dic
01063    for( it = elemList.begin(); it != elemList.end(); ++it)
01064    {
01065       tmpGr     = it->Group;
01066       tmpEl     = it->Elem;
01067       dictEntry = GetPubDict()->GetEntry(tmpGr, tmpEl);
01068 
01069       entry     = DataEntry::New( dictEntry ); 
01070       entry->SetOffset(0); // just to avoid further missprinting
01071 
01072       if ( header )
01073       {
01074          // NULL when we Build Up (ex nihilo) a DICOMDIR
01075          //   or when we add the META elems
01076  
01077             val = header->GetEntryString(tmpGr, tmpEl); 
01078       }
01079       else
01080       {
01081          val = GDCM_UNFOUND;
01082       }
01083 
01084       if ( val == GDCM_UNFOUND) 
01085       {       
01086          if ( tmpGr == 0x0004 ) // never present in File !     
01087          {
01088             switch (tmpEl)
01089            {
01090            case 0x1130: // File-set ID
01091               // force to the *end* File Name
01092               val = Util::GetName( path );
01093               break;
01094       
01095            case 0x1500: // Only used for image    
01096                if ( header->GetFileName().substr(0, path.length()) != path )
01097                {
01098                   gdcmWarningMacro( "The base path of file name is incorrect");
01099                   val = header->GetFileName();
01100                }
01101                else
01102                {
01103                   val = &(header->GetFileName().c_str()[path.length()+1]);
01104                }
01105        break;
01106     
01107        case 0x1510:  // Referenced SOP Class UID in File
01108           referencedVal = header->GetEntryString(0x0008, 0x0016);
01109           // FIXME : probabely something to check
01110           val = referencedVal;
01111           break;
01112        
01113        case 0x1511: // Referenced SOP Instance UID in File
01114           referencedVal = header->GetEntryString(0x0008, 0x0018);
01115           // FIXME : probabely something to check
01116           val = referencedVal;
01117           break;
01118     
01119        case 0x1512: // Referenced Transfer Syntax UID in File
01120           referencedVal = header->GetEntryString(0x0002, 0x0010);
01121           // FIXME : probabely something to check
01122           val = referencedVal;
01123           break;
01124     
01125        default :
01126          val = it->Value;   
01127     } 
01128          }
01129       }
01130       else
01131       {
01132          if ( header->GetEntryLength(tmpGr,tmpEl) == 0 )
01133             val = it->Value;
01134       }
01135 
01136 /* FIX later the pb of creating the 'Implementation Version Name'!
01137 
01138       if (val == GDCM_UNFOUND)
01139          val = "";
01140 
01141       if ( tmpGr == 0x0002 && tmpEl == 0x0013)
01142       { 
01143          // 'Implementation Version Name'
01144          std::string val = "GDCM ";
01145          val += Util::GetVersion();
01146       }
01147 */ 
01148       entry->SetString( val ); // troubles expected when vr=SQ ...
01149 
01150       if ( type == GDCM_DICOMDIR_META ) // fusible : should never print !
01151       {
01152          gdcmDebugMacro("GDCM_DICOMDIR_META ?!? should never print that");
01153       }
01154       si->AddEntry(entry);
01155       entry->Delete();
01156    }
01157 }

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 920 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().

00921 {
00922    ClearEntry();
00923    ClearPatient();
00924 
00925    std::string patPrevName         = "", patPrevID  = "";
00926    std::string studPrevInstanceUID = "", studPrevID = "";
00927    std::string serPrevInstanceUID  = "", serPrevID  = "";
00928 
00929    std::string patCurName,         patCurID;
00930    std::string studCurInstanceUID, studCurID;
00931    std::string serCurInstanceUID,  serCurID;
00932 
00933    bool first = true;
00934    for( VectDocument::const_iterator it = list.begin();
00935                                      it != list.end(); 
00936                                    ++it )
00937    {
00938       // get the current file characteristics
00939       patCurName         = (*it)->GetEntryString(0x0010,0x0010);
00940       patCurID           = (*it)->GetEntryString(0x0010,0x0011);
00941       studCurInstanceUID = (*it)->GetEntryString(0x0020,0x000d);
00942       studCurID          = (*it)->GetEntryString(0x0020,0x0010);
00943       serCurInstanceUID  = (*it)->GetEntryString(0x0020,0x000e);
00944       serCurID           = (*it)->GetEntryString(0x0020,0x0011);
00945 
00946       if ( patCurName != patPrevName || patCurID != patPrevID || first )
00947       {
00948          SetElement(path, GDCM_DICOMDIR_PATIENT, *it);
00949          first = true;
00950       }
00951 
00952       // if new Study, deal with 'STUDY' Elements   
00953       if ( studCurInstanceUID != studPrevInstanceUID || studCurID != studPrevID 
00954          || first )
00955       {
00956          SetElement(path, GDCM_DICOMDIR_STUDY, *it);
00957          first = true;
00958       }
00959 
00960       // if new Serie, deal with 'SERIE' Elements   
00961       if ( serCurInstanceUID != serPrevInstanceUID || serCurID != serPrevID
00962          || first )
00963       {
00964          SetElement(path, GDCM_DICOMDIR_SERIE, *it);
00965       }
00966       
00967       // Always Deal with 'IMAGE' Elements  
00968       SetElement(path, GDCM_DICOMDIR_IMAGE, *it);
00969 
00970       patPrevName         = patCurName;
00971       patPrevID           = patCurID;
00972       studPrevInstanceUID = studCurInstanceUID;
00973       studPrevID          = studCurID;
00974       serPrevInstanceUID  = serCurInstanceUID;
00975       serPrevID           = serCurID;
00976       first = false;
00977    }
00978 }

void gdcm::DicomDir::SetEndMethod void(*)(void *)  method,
void *  arg,
void(*)(void *)  argDelete
 

void gdcm::DicomDir::SetEndMethod DicomDir::Method method,
void *  arg = NULL
 

Definition at line 384 of file gdcmDicomDir.cxx.

Referenced by ~DicomDir().

00385 {
00386    SetEndMethod(method,arg,NULL);
00387 }

void gdcm::DicomDir::SetEndMethodArgDelete DicomDir::Method method  ) 
 

Set the method to delete the argument The argument is destroyed when the method is changed or when the class is destroyed.

Parameters:
method Method to call to delete the argument

Definition at line 480 of file gdcmDicomDir.cxx.

References EndMethodArgDelete.

00481 {
00482    EndMethodArgDelete = method;
00483 }

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 229 of file gdcmDocEntrySet.cxx.

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

00230 {
00231    if (entry)
00232    {
00233       entry->SetLength(lgth);
00234       entry->SetBinArea(content);  
00235       return true;
00236    }
00237    return false;
00238 }

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 192 of file gdcmDocEntrySet.cxx.

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

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

00194 {
00195    DataEntry *entry = GetDataEntry(group, elem);
00196    if (!entry )
00197    {
00198       gdcmWarningMacro( "No corresponding DataEntry " << std::hex << group <<
00199                         "," << elem << " element (try promotion first).");
00200       return false;
00201    }
00202 
00203    return SetEntryBinArea(content,lgth,entry);
00204 } 

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 212 of file gdcmDocEntrySet.cxx.

References gdcm::DataEntry::SetString().

00213 {
00214    if (entry)
00215    {
00216       entry->SetString(content);
00217       return true;
00218    }
00219    return false;
00220 }

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 170 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().

00172 {
00173    DataEntry *entry = GetDataEntry(group, elem);
00174    if (!entry )
00175    {
00176       gdcmWarningMacro( "No corresponding DataEntry " << std::hex << group <<
00177                          "," << elem << " element (try promotion first).");
00178       return false;
00179    }
00180    return SetEntryString(content,entry);
00181 }

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

Accessor to Filename.

Reimplemented from gdcm::Document.

Definition at line 69 of file gdcmDicomDir.h.

Referenced by DoTheLoadingJob().

00070                    { ParseDir = false; if (Filename != fileName)
00071                               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 103 of file gdcmDocument.h.

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

00103                                { if (LoadMode != mode) 
00104                                      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; }

void gdcm::DicomDir::SetProgressMethod void(*)(void *)  method,
void *  arg,
void(*)(void *)  argDelete
 

void gdcm::DicomDir::SetProgressMethod DicomDir::Method method,
void *  arg = NULL
 

Definition at line 379 of file gdcmDicomDir.cxx.

Referenced by ~DicomDir().

00380 {
00381    SetProgressMethod(method,arg,NULL);
00382 }

void gdcm::DicomDir::SetProgressMethodArgDelete DicomDir::Method method  ) 
 

Set the method to delete the argument The argument is destroyed when the method is changed or when the class is destroyed.

Parameters:
method Method to call to delete the argument

Definition at line 469 of file gdcmDicomDir.cxx.

References ProgressMethodArgDelete.

00470 {
00471    ProgressMethodArgDelete = method;
00472 }

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 327 of file gdcmDocument.cxx.

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

00328 {
00329    RefShaDict = Global::GetDicts()->GetDict(dictName);
00330    return !RefShaDict;
00331 }

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

Set the shadow dictionary used.

Parameters:
dict dictionary to use in shadow

Definition at line 317 of file gdcmDocument.cxx.

References gdcm::Document::RefShaDict.

00318 {
00319    RefShaDict = dict;
00320    return !RefShaDict;
00321 }

void gdcm::DicomDir::SetStartMethod void(*)(void *)  method,
void *  arg,
void(*)(void *)  argDelete
 

void gdcm::DicomDir::SetStartMethod DicomDir::Method method,
void *  arg = NULL
 

Definition at line 374 of file gdcmDicomDir.cxx.

Referenced by ~DicomDir().

00375 {
00376    SetStartMethod(method,arg,NULL);
00377 }

void gdcm::DicomDir::SetStartMethodArgDelete DicomDir::Method method  ) 
 

Set the method to delete the argument The argument is destroyed when the method is changed or when the class is destroyed.

Parameters:
method Method to call to delete the argument

Definition at line 458 of file gdcmDicomDir.cxx.

References StartMethodArgDelete.

00459 {
00460    StartMethodArgDelete = method;
00461 }

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

skips bytes inside the source file

Returns:

Definition at line 947 of file gdcmDocument.cxx.

References gdcm::Document::Fp.

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

00948 {
00949    //FIXME don't dump the returned value
00950    Fp->seekg((long)nBytes, std::ios::cur);
00951 }

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

Unregister the object.

Remarks:
It decrements the reference counting

Definition at line 49 of file gdcmRefCounter.h.

Referenced by gdcm::SeqEntry::ClearSQItem(), gdcm::DocEntrySet::GetDictEntry(), 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().

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

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 493 of file gdcmDicomDir.cxx.

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

00494 {  
00495    int i;
00496    uint16_t sq[6] = { 0x0004, 0x1220, 0x5153, 0x0000, 0xffff, 0xffff };
00497    uint16_t sqt[4]= { 0xfffe, 0xe0dd, 0xffff, 0xffff };
00498 
00499    std::ofstream *fp = new std::ofstream(fileName.c_str(),  
00500                                          std::ios::out | std::ios::binary);
00501    if ( !fp ) 
00502    {
00503       gdcmWarningMacro("Failed to open(write) File: " << fileName.c_str());
00504       return false;
00505    }
00506 
00507    char filePreamble[128];
00508    memset(filePreamble, 0, 128);
00509    fp->write(filePreamble, 128);
00510    binary_write( *fp, "DICM");
00511  
00512    DicomDirMeta *ptrMeta = GetMeta();
00513    ptrMeta->WriteContent(fp, ExplicitVR);
00514    
00515    // force writing 0004|1220 [SQ ], that CANNOT exist within DicomDirMeta
00516    for(i=0;i<6;++i)
00517    {
00518       binary_write(*fp, sq[i]);
00519    }
00520         
00521    for(ListDicomDirPatient::iterator cc  = Patients.begin();
00522                                      cc != Patients.end();
00523                                    ++cc )
00524    {
00525       (*cc)->WriteContent( fp, ExplicitVR );
00526    }
00527    
00528    // force writing Sequence Delimitation Item
00529    for(i=0;i<4;++i)
00530    {
00531       binary_write(*fp, sqt[i]);  // fffe e0dd ffff ffff 
00532    }
00533 
00534    fp->close();
00535    delete fp;
00536 
00537    return true;
00538 }

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 675 of file gdcmDocument.cxx.

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

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

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


Member Data Documentation

bool gdcm::DicomDir::Abort [private]
 

value of the ??? for any progress bar

Definition at line 198 of file gdcmDicomDir.h.

Referenced by CallStartMethod(), CreateDicomDirChainedList(), DoTheLoadingJob(), and Initialize().

void* gdcm::DicomDir::EndArg [private]
 

pointer to the ??? for any progress bar

Definition at line 194 of file gdcmDicomDir.h.

Referenced by CallEndMethod(), and Initialize().

Method* gdcm::DicomDir::EndMethod [private]
 

pointer to the termination method for any progress bar

Definition at line 182 of file gdcmDicomDir.h.

Referenced by CallEndMethod(), and Initialize().

Method* gdcm::DicomDir::EndMethodArgDelete [private]
 

pointer to the ??? method for any progress bar

Definition at line 188 of file gdcmDicomDir.h.

Referenced by Initialize(), and SetEndMethodArgDelete().

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

Refering underlying filename.

Definition at line 121 of file gdcmDocument.h.

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

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

ACR, ACR_LIBIDO, ExplicitVR, ImplicitVR, Unknown.

Definition at line 147 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 144 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 138 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 141 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 150 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 170 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 173 of file gdcmDocument.h.

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

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

Definition at line 175 of file gdcmDicomDir.h.

Referenced by 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 165 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 153 of file gdcmDocument.h.

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

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

Pointer on *the* DicomDirObject 'DicomDirMeta Elements'.

Definition at line 171 of file gdcmDicomDir.h.

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

bool gdcm::DicomDir::ParseDir [private]
 

Definition at line 199 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 174 of file gdcmDicomDir.h.

Referenced by AddImageToEnd(), AddPatientToEnd(), AddSerieToEnd(), AddStudyToEnd(), AddVisitToEnd(), Anonymize(), ClearPatient(), 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 124 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::DicomDir::Progress [private]
 

value of the ??? for any progress bar

Definition at line 196 of file gdcmDicomDir.h.

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

void* gdcm::DicomDir::ProgressArg [private]
 

pointer to the ??? for any progress bar

Definition at line 192 of file gdcmDicomDir.h.

Referenced by CallProgressMethod(), and Initialize().

Method* gdcm::DicomDir::ProgressMethod [private]
 

pointer to the incrementation method for any progress bar

Definition at line 180 of file gdcmDicomDir.h.

Referenced by CallProgressMethod(), and Initialize().

Method* gdcm::DicomDir::ProgressMethodArgDelete [private]
 

pointer to the ??? method for any progress bar

Definition at line 186 of file gdcmDicomDir.h.

Referenced by Initialize(), and SetProgressMethodArgDelete().

void* gdcm::DicomDir::StartArg [private]
 

pointer to the ??? for any progress bar

Definition at line 190 of file gdcmDicomDir.h.

Referenced by CallStartMethod(), and Initialize().

Method* gdcm::DicomDir::StartMethod [private]
 

pointer to the initialisation method for any progress bar

Definition at line 178 of file gdcmDicomDir.h.

Referenced by CallStartMethod(), and Initialize().

Method* gdcm::DicomDir::StartMethodArgDelete [private]
 

pointer to the ??? method for any progress bar

Definition at line 184 of file gdcmDicomDir.h.

Referenced by Initialize(), and SetStartMethodArgDelete().

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 135 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 156 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 159 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 Nov 18 15:58:07 2005 for gdcm by  doxygen 1.4.4