#include <gdcmDicomDir.h>
Inheritance diagram for GDCM_NAME_SPACE::DicomDir:
Public Types | |
enum | DicomDirType { GDCM_DICOMDIR_NONE, GDCM_DICOMDIR_META, GDCM_DICOMDIR_PATIENT, GDCM_DICOMDIR_STUDY, GDCM_DICOMDIR_SERIE, GDCM_DICOMDIR_VISIT, GDCM_DICOMDIR_IMAGE, GDCM_DICOMDIR_PRIVATE } |
Types of the DicomDirObject within the DicomDir. More... | |
typedef std::list< DicomElement > | ListElements |
Public Member Functions | |
bool | Load () |
Loader. use SetFileName(fn) or SetLoadMode(lm) + SetDirectoryName(dn) before ! | |
void | Print (std::ostream &os=std::cout, std::string const &indent="") |
Canonical Printer. | |
void | SetDirectoryName (std::string const &dirName) |
Sets the root Directory name to parse, recursively. | |
virtual void | SetFileName (std::string const &fileName) |
Accessor to Filename. | |
virtual bool | IsReadable () |
This predicate, based on hopefully reasonable heuristics, decides whether or not the current document was properly parsed and contains the mandatory information for being considered as a well formed and usable DicomDir. | |
DicomDirMeta * | NewMeta () |
adds *the* Meta to a partially created DICOMDIR | |
DicomDirMeta * | GetMeta () |
Returns a pointer to the DicomDirMeta for this DICOMDIR. | |
DicomDirPatient * | NewPatient () |
adds a new Patient (with the basic elements) to a partially created DICOMDIR | |
void | ClearPatient () |
Remove all Patients. | |
DicomDirPatient * | GetFirstPatient () |
Get the first entry while visiting the DicomDirPatients. | |
DicomDirPatient * | GetNextPatient () |
Get the next entry while visiting the DicomDirPatients. | |
int | GetNumberOfPatients () |
returns the number of Patients currently held in the gdcm::DicomDir | |
void | ParseDirectory () |
fills the whole structure, starting from a root Directory | |
float | GetProgress () const |
GetProgress GetProgress. | |
void | AbortProgress () |
AbortProgress AbortProgress. | |
bool | IsAborted () |
IsAborted IsAborted. | |
bool | Write (std::string const &fileName) |
writes on disc a DICOMDIR \ warning does NOT add the missing elements in the header : it's up to the user doing it ! | |
bool | Anonymize () |
Anonymize a DICOMDIR. | |
virtual void | Copy (DocEntrySet *set) |
Copies all the attributes from an other DocEntrySet. | |
Dict * | GetPubDict () |
Get the public dictionary used. | |
Dict * | GetShaDict () |
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, or if the file starts with an ACR-NEMA look-like element. | |
bool | CloseFile () |
closes the file | |
void | WriteContent (std::ofstream *fp, FileType type) |
Writes in a file all the Entries (Dicom Elements). | |
void | WriteContent (std::ofstream *fp, FileType filetype, bool insideMetaElements) |
Writes the Header Entries (Dicom Elements) from the H Table. | |
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 | SetMaxSizeLoadEntry (long) |
during parsing, Header Elements too long are not loaded in memory | |
void | AddForceLoadElement (uint16_t group, uint16_t elem) |
Adds a new element we want to load anyway. | |
bool | operator< (Document &document) |
Loads the element while preserving the current underlying file position indicator as opposed to LoadDocEntry that modifies it 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 | |
DocEntry * | GetFirstEntry () |
Get the first entry while visiting *the* 'zero level' DocEntrySet (DocEntries out of any Sequence). | |
DocEntry * | GetNextEntry () |
Get the next entry while visiting *the* 'zero level' DocEntrySet (DocEntries out of any Sequence). | |
DocEntry * | GetDocEntry (uint16_t group, uint16_t elem) |
retrieves a Dicom Element using (group, element) | |
bool | IsEmpty () |
Tells us if the ElementSet contains no entry. | |
int | IsVRCoherent (uint16_t group) |
Checks whether *all* the DataEntries of the group have all the same type for VR (ImplicitVR or ExplicitVR). | |
virtual std::string | GetEntryString (uint16_t group, uint16_t elem) |
Get the "std::string representable" value of the Dicom entry. | |
virtual void * | GetEntryBinArea (uint16_t group, uint16_t elem) |
Gets (from Header) a 'non string' element value. | |
virtual int | GetEntryLength (uint16_t group, uint16_t elem) |
Searches within the DocEntrySet for the value length of a given tag.. | |
DataEntry * | GetDataEntry (uint16_t group, uint16_t elem) |
Same as Document::GetDocEntry except it returns a result only when the corresponding entry is of type DataEntry. | |
SeqEntry * | GetSeqEntry (uint16_t group, uint16_t elem) |
Same as Document::GetDocEntry except it returns a result only when the corresponding entry is of type SeqEntry. | |
bool | SetEntryString (std::string const &content, uint16_t group, uint16_t elem) |
Accesses an existing DocEntry (i.e. a Dicom Element) through its (group, element) and modifies its content with the given value. | |
bool | SetEntryString (std::string const &content, DataEntry *entry) |
Accesses an existing DocEntry (i.e. a Dicom Element) and modifies its content with the given value. | |
bool | SetEntryBinArea (uint8_t *content, int lgth, uint16_t group, uint16_t elem) |
Accesses an existing DocEntry (i.e. a Dicom Element) through its (group, element) and modifies its 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 its content with the given value. | |
DataEntry * | InsertEntryString (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. Creates it with the given value when unexistant. | |
DataEntry * | InsertEntryBinArea (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. | |
SeqEntry * | InsertSeqEntry (uint16_t group, uint16_t elem) |
Creates a new gdcm::SeqEntry and adds it to the current DocEntrySet. (remove any existing entry with same group,elem). | |
virtual bool | CheckIfEntryExist (uint16_t group, uint16_t elem) |
Checks if a given Dicom Element exists within the DocEntrySet. | |
DataEntry * | NewDataEntry (uint16_t group, uint16_t elem, VRKey const &vr=GDCM_VRUNKNOWN) |
Build a new DataEntry from all the low level arguments. | |
SeqEntry * | NewSeqEntry (uint16_t group, uint16_t elem) |
Build a new SeqEntry from all the low level arguments. | |
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 DicomDir * | New () |
Constructs a DicomDir with a RefCounter. | |
Protected Member Functions | |
DicomDir () | |
Constructor : creates an empty DicomDir. | |
~DicomDir () | |
Constructor Parses recursively the directory and creates the DicomDir or uses an already built DICOMDIR, depending on 'parseDir' value. Canonical destructor. | |
void | CreateDicomDirChainedList (std::string const &path) |
create a Document-like chained list from a root Directory | |
virtual void | CallStartMethod () |
CallStartMethod. | |
virtual void | CallProgressMethod () |
CallProgressMethod. | |
virtual void | CallEndMethod () |
CallEndMethod. | |
uint16_t | ReadInt16 () throw ( FormatError ) |
Reads a supposed to be 16 Bits integer (swaps it depending on processor endianness). | |
uint32_t | ReadInt32 () throw ( FormatError ) |
Reads a supposed to be 32 Bits integer (swaps it depending on processor endianness). | |
void | SkipBytes (uint32_t nBytes) |
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. | |
DictEntry * | GetDictEntry (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. | |
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 :
| |
bool | Group0002Parsed |
whether we already parsed group 0002 (Meta Elements) | |
bool | HasDCMPreamble |
whether file has a DCM Preamble | |
std::ifstream * | Fp |
File Pointer, opened during Document parsing. | |
FileType | Filetype |
ACR, ACR_LIBIDO, ExplicitVR, ImplicitVR, Unknown. | |
ListElements | UserAnonymizeList |
User supplied list of elements to Anonymize. | |
ListElements | UserForceLoadList |
User supplied list of elements to force Load. | |
int | LoadMode |
Bit string integer (each one considered as a boolean) Bit 0 : Skip Sequences, if possible Bit 1 : Skip Shadow Groups if possible Probabely, some more to add. | |
bool | IsDocumentAlreadyLoaded |
Whether the gdcm::Document is already parsed/loaded : False from the creation of the gdcm::Document untill gdcm::Document:Load(). | |
bool | IsDocumentModified |
Whether the gdcm::Document was modified since the last Load(). | |
float | Progress |
value of the ??? for any progress bar | |
bool | Abort |
Dict * | RefPubDict |
Public dictionary used to parse this header. | |
Dict * | RefShaDict |
Optional "shadow dictionary" (private elements) used to parse this header. | |
uint32_t | MaxSizeLoadEntry |
Size threshold above which an element value will NOT be loaded in memory (to avoid loading the image/volume itself). By default, this upper bound is fixed to 1024 bytes (which might look reasonable when one considers the definition of the various VR contents). | |
uint16_t | CurrentGroup |
to allow any inner method to know current tag Group number | |
uint16_t | CurrentElem |
to allow any inner method to know current tag Element number | |
DocEntry * | PreviousDocEntry |
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 () |
Loader. (DEPRECATED : kept not to break the API) 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. | |
bool | AddPrivateToEnd (DicomDirPrivate *dd) |
AddPrivateToEnd. | |
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 | |
DicomDirMeta * | MetaElems |
Pointer on *the* DicomDirObject 'DicomDirMeta Elements'. | |
ListDicomDirPatient | Patients |
Chained list of DicomDirPatient (to be exploited hierarchicaly). | |
ListDicomDirPatient::iterator | ItPatient |
bool | ParseDir |
value of the ??? for any progress bar |
->DicomDirPatient -> DicomDirStudy -> DicomDirVisit -> DicomDirSerie -> DicomDirImage -> DicomDirPrivate (for Siemens CSA non image)
Definition at line 56 of file gdcmDicomDir.h.
|
Definition at line 47 of file gdcmDocument.h. |
|
Types of the DicomDirObject within the DicomDir.
Definition at line 112 of file gdcmDicomDir.h. 00113 { 00114 GDCM_DICOMDIR_NONE, 00115 GDCM_DICOMDIR_META, 00116 GDCM_DICOMDIR_PATIENT, 00117 GDCM_DICOMDIR_STUDY, 00118 GDCM_DICOMDIR_SERIE, 00119 GDCM_DICOMDIR_VISIT, 00120 GDCM_DICOMDIR_IMAGE, 00121 GDCM_DICOMDIR_PRIVATE 00122 } DicomDirType;
|
|
Constructor : creates an empty DicomDir.
Definition at line 184 of file gdcmDicomDir.cxx. References Initialize(), NewMeta(), and ParseDir. 00185 { 00186 Initialize(); // sets all private fields to NULL 00187 ParseDir = false; 00188 NewMeta(); 00189 }
|
|
Constructor Parses recursively the directory and creates the DicomDir or uses an already built DICOMDIR, depending on 'parseDir' value. Canonical destructor.
Definition at line 226 of file gdcmDicomDir.cxx. References ClearPatient(), GDCM_NAME_SPACE::RefCounter::Delete(), and MetaElems. 00227 { 00228 ClearPatient(); 00229 if ( MetaElems ) 00230 { 00231 MetaElems->Delete(); 00232 } 00233 }
|
|
AbortProgress AbortProgress.
Definition at line 100 of file gdcmDicomDir.h. 00100 { Abort = true; }
|
|
add a new Dicom Element pointer to the H Table
Implements GDCM_NAME_SPACE::DocEntrySet. Definition at line 101 of file gdcmElementSet.cxx. References gdcmWarningMacro, GDCM_NAME_SPACE::DocEntry::GetKey(), and GDCM_NAME_SPACE::ElementSet::TagHT. Referenced by GDCM_NAME_SPACE::DocEntryArchive::Push(), and GDCM_NAME_SPACE::DocEntryArchive::Restore(). 00102 { 00103 const TagKey &key = newEntry->GetKey(); 00104 00105 if ( TagHT.count(key) == 1 ) 00106 { 00107 gdcmWarningMacro( "Key already present: " << key ); 00108 return false; 00109 } 00110 else 00111 { 00112 TagHT.insert(TagDocEntryHT::value_type(newEntry->GetKey(), newEntry)); 00113 newEntry->Register(); 00114 return true; 00115 } 00116 }
|
|
Adds a new element we want to load anyway.
Definition at line 304 of file gdcmDocument.cxx. References GDCM_NAME_SPACE::DicomElement::Elem, GDCM_NAME_SPACE::DicomElement::Group, and GDCM_NAME_SPACE::Document::UserForceLoadList. 00305 { 00306 DicomElement el; 00307 el.Group = group; 00308 el.Elem = elem; 00309 UserForceLoadList.push_back(el); 00310 }
|
|
AddImageToEnd.
Definition at line 874 of file gdcmDicomDir.cxx. References GDCM_NAME_SPACE::DicomDirSerie::AddImage(), GDCM_NAME_SPACE::DicomDirStudy::GetLastSerie(), and Patients. Referenced by CreateDicomDir(), and SetElement(). 00875 { 00876 if ( Patients.size() > 0 ) 00877 { 00878 ListDicomDirPatient::iterator itp = Patients.end(); 00879 itp--; 00880 00881 DicomDirStudy *study = (*itp)->GetLastStudy(); 00882 if ( study ) 00883 { 00884 DicomDirSerie *serie = study->GetLastSerie(); 00885 if ( serie ) 00886 { 00887 serie->AddImage(dd); 00888 return true; 00889 } 00890 } 00891 } 00892 return false; 00893 }
|
|
AddPatientToEnd.
Definition at line 807 of file gdcmDicomDir.cxx. References Patients. Referenced by CreateDicomDir(), NewPatient(), and SetElement(). 00808 { 00809 Patients.push_back(dd); 00810 return true; 00811 }
|
|
AddPrivateToEnd.
Definition at line 900 of file gdcmDicomDir.cxx. References GDCM_NAME_SPACE::DicomDirSerie::AddPrivate(), GDCM_NAME_SPACE::DicomDirStudy::GetLastSerie(), and Patients. Referenced by CreateDicomDir(). 00901 { 00902 if ( Patients.size() > 0 ) 00903 { 00904 ListDicomDirPatient::iterator itp = Patients.end(); 00905 itp--; 00906 00907 DicomDirStudy *study = (*itp)->GetLastStudy(); 00908 if ( study ) 00909 { 00910 DicomDirSerie *serie = study->GetLastSerie(); 00911 if ( serie ) 00912 { 00913 serie->AddPrivate(dd); 00914 return true; 00915 } 00916 } 00917 } 00918 return false; 00919 }
|
|
AddSerieToEnd.
Definition at line 833 of file gdcmDicomDir.cxx. References GDCM_NAME_SPACE::DicomDirStudy::AddSerie(), and Patients. Referenced by CreateDicomDir(), and SetElement(). 00834 { 00835 if ( Patients.size() > 0 ) 00836 { 00837 ListDicomDirPatient::iterator itp = Patients.end(); 00838 itp--; 00839 00840 DicomDirStudy *study = (*itp)->GetLastStudy(); 00841 if ( study ) 00842 { 00843 study->AddSerie(dd); 00844 return true; 00845 } 00846 } 00847 return false; 00848 }
|
|
AddStudyToEnd.
Definition at line 817 of file gdcmDicomDir.cxx. References Patients. Referenced by CreateDicomDir(), and SetElement(). 00818 { 00819 if ( Patients.size() > 0 ) 00820 { 00821 ListDicomDirPatient::iterator itp = Patients.end(); 00822 itp--; 00823 (*itp)->AddStudy(dd); 00824 return true; 00825 } 00826 return false; 00827 }
|
|
AddVisitToEnd.
Definition at line 854 of file gdcmDicomDir.cxx. References GDCM_NAME_SPACE::DicomDirStudy::AddVisit(), and Patients. Referenced by CreateDicomDir(). 00855 { 00856 if ( Patients.size() > 0 ) 00857 { 00858 ListDicomDirPatient::iterator itp = Patients.end(); 00859 itp--; 00860 00861 DicomDirStudy *study = (*itp)->GetLastStudy(); 00862 if ( study ) 00863 { 00864 study->AddVisit(dd); 00865 return true; 00866 } 00867 } 00868 return false; 00869 }
|
|
Anonymize a DICOMDIR.
Definition at line 527 of file gdcmDicomDir.cxx. References Patients, and GDCM_NAME_SPACE::DataEntry::SetString(). 00528 { 00529 DataEntry *v; 00530 // Something clever to be found to forge the Patient names 00531 std::ostringstream s; 00532 int i = 1; 00533 for(ListDicomDirPatient::iterator cc = Patients.begin(); 00534 cc!= Patients.end(); 00535 ++cc) 00536 { 00537 s << i; 00538 v = (*cc)->GetDataEntry(0x0010, 0x0010) ; // Patient's Name 00539 if (v) 00540 { 00541 v->SetString(s.str()); 00542 } 00543 00544 v = (*cc)->GetDataEntry(0x0010, 0x0020) ; // Patient ID 00545 if (v) 00546 { 00547 v->SetString(" "); 00548 } 00549 00550 v = (*cc)->GetDataEntry(0x0010, 0x0030) ; // Patient's BirthDate 00551 if (v) 00552 { 00553 v->SetString(" "); 00554 } 00555 s << ""; 00556 i++; 00557 } 00558 return true; 00559 }
|
|
CallEndMethod.
Definition at line 1074 of file gdcmDocument.cxx. References GDCM_NAME_SPACE::CMD_ENDPROGRESS, GDCM_NAME_SPACE::CommandManager::ExecuteCommand(), and GDCM_NAME_SPACE::Document::Progress. 01075 { 01076 Progress = 1.0f; 01077 CommandManager::ExecuteCommand(this,CMD_ENDPROGRESS); 01078 }
|
|
CallProgressMethod.
Definition at line 1066 of file gdcmDocument.cxx. References GDCM_NAME_SPACE::CMD_PROGRESS, and GDCM_NAME_SPACE::CommandManager::ExecuteCommand(). Referenced by CreateDicomDirChainedList(). 01067 { 01068 CommandManager::ExecuteCommand(this,CMD_PROGRESS); 01069 }
|
|
CallStartMethod.
Definition at line 1056 of file gdcmDocument.cxx. References GDCM_NAME_SPACE::Document::Abort, GDCM_NAME_SPACE::CMD_STARTPROGRESS, GDCM_NAME_SPACE::CommandManager::ExecuteCommand(), and GDCM_NAME_SPACE::Document::Progress. Referenced by CreateDicomDirChainedList(). 01057 { 01058 Progress = 0.0f; 01059 Abort = false; 01060 CommandManager::ExecuteCommand(this,CMD_STARTPROGRESS); 01061 }
|
|
Checks if a given Dicom Element exists within the DocEntrySet.
Definition at line 412 of file gdcmDocEntrySet.cxx. References GDCM_NAME_SPACE::DocEntrySet::GetDocEntry(). 00413 { 00414 return GetDocEntry(group,elem)!=NULL; 00415 }
|
|
delete all entries in the ElementSet
Implements GDCM_NAME_SPACE::DocEntrySet. Definition at line 139 of file gdcmElementSet.cxx. References GDCM_NAME_SPACE::ElementSet::TagHT. Referenced by GDCM_NAME_SPACE::ElementSet::Copy(), CreateDicomDir(), GDCM_NAME_SPACE::Document::DoTheLoadingDocumentJob(), SetElements(), and GDCM_NAME_SPACE::ElementSet::~ElementSet(). 00140 { 00141 for(TagDocEntryHT::iterator cc = TagHT.begin();cc != TagHT.end(); ++cc) 00142 { 00143 if ( cc->second ) 00144 { 00145 cc->second->Unregister(); 00146 } 00147 } 00148 TagHT.clear(); 00149 }
|
|
Remove all Patients.
Definition at line 420 of file gdcmDicomDir.cxx. References Patients. Referenced by Copy(), SetElements(), and ~DicomDir(). 00421 { 00422 for(ListDicomDirPatient::iterator cc = Patients.begin(); 00423 cc!= Patients.end(); 00424 ++cc) 00425 { 00426 (*cc)->Unregister(); 00427 } 00428 Patients.clear(); 00429 }
|
|
closes the file
Definition at line 679 of file gdcmDocument.cxx. Referenced by GDCM_NAME_SPACE::Document::DoTheLoadingDocumentJob(), GDCM_NAME_SPACE::File::DoTheLoadingJob(), GDCM_NAME_SPACE::FileHelper::GetRaw(), and GDCM_NAME_SPACE::Document::~Document(). 00680 { 00681 if ( Fp ) 00682 { 00683 Fp->close(); 00684 delete Fp; 00685 Fp = 0; 00686 } 00687 return true; 00688 }
|
|
Re-computes the length of the Dicom group 0002.
Definition at line 1013 of file gdcmDocument.cxx. References GDCM_NAME_SPACE::DocEntry::GetElement(), GDCM_NAME_SPACE::ElementSet::GetFirstEntry(), GDCM_NAME_SPACE::DocEntry::GetGroup(), GDCM_NAME_SPACE::DocEntry::GetLength(), GDCM_NAME_SPACE::ElementSet::GetNextEntry(), and GDCM_NAME_SPACE::DocEntry::GetVR(). Referenced by GDCM_NAME_SPACE::File::Write(). 01014 { 01015 uint16_t gr; 01016 VRKey vr; 01017 01018 int groupLength = 0; 01019 bool found0002 = false; 01020 01021 // for each zero-level Tag in the DCM Header 01022 DocEntry *entry = GetFirstEntry(); 01023 while( entry ) 01024 { 01025 gr = entry->GetGroup(); 01026 01027 if ( gr == 0x0002 ) 01028 { 01029 found0002 = true; 01030 01031 if ( entry->GetElement() != 0x0000 ) 01032 { 01033 vr = entry->GetVR(); 01034 01035 //if ( (vr == "OB")||(vr == "OW")||(vr == "UT")||(vr == "SQ")) 01036 // (no SQ, OW, UT in group 0x0002;) 01037 if ( vr == "OB" ) 01038 { 01039 // explicit VR AND (OB, OW, SQ, UT) : 4 more bytes 01040 groupLength += 4; 01041 } 01042 groupLength += 2 + 2 + 4 + entry->GetLength(); 01043 } 01044 } 01045 else if (found0002 ) 01046 break; 01047 01048 entry = GetNextEntry(); 01049 } 01050 return groupLength; 01051 }
|
|
Copies all the attributes from an other DocEntrySet.
Reimplemented from GDCM_NAME_SPACE::ElementSet. Definition at line 566 of file gdcmDicomDir.cxx. References ClearPatient(), GDCM_NAME_SPACE::ElementSet::Copy(), ItPatient, MetaElems, Patients, and GDCM_NAME_SPACE::RefCounter::Register(). 00567 { 00568 // Remove all previous childs 00569 ClearPatient(); 00570 00571 Document::Copy(set); 00572 00573 DicomDir *dd = dynamic_cast<DicomDir *>(set); 00574 if( dd ) 00575 { 00576 if(MetaElems) 00577 MetaElems->Unregister(); 00578 MetaElems = dd->MetaElems; 00579 if(MetaElems) 00580 MetaElems->Register(); 00581 00582 Patients = dd->Patients; 00583 for(ItPatient = Patients.begin();ItPatient != Patients.end();++ItPatient) 00584 (*ItPatient)->Register(); 00585 } 00586 }
|
|
create a 'gdcmDicomDir' from a DICOMDIR Header do : deal with PRIVATE (not so easy, since PRIVATE appears at different levels ?!? ) Definition at line 666 of file gdcmDicomDir.cxx. References AddImageToEnd(), AddPatientToEnd(), AddPrivateToEnd(), AddSerieToEnd(), AddStudyToEnd(), AddVisitToEnd(), GDCM_NAME_SPACE::ElementSet::ClearEntry(), GDCM_NAME_SPACE::SQItem::Copy(), gdcmDebugMacro, gdcmErrorMacro, gdcmWarningMacro, GDCM_NAME_SPACE::SQItem::GetDocEntry(), GDCM_NAME_SPACE::ElementSet::GetDocEntry(), GDCM_NAME_SPACE::SeqEntry::GetFirstSQItem(), GDCM_NAME_SPACE::SeqEntry::GetNextSQItem(), GDCM_NAME_SPACE::DicomDirPrivate::New(), GDCM_NAME_SPACE::DicomDirPatient::New(), GDCM_NAME_SPACE::DicomDirStudy::New(), GDCM_NAME_SPACE::DicomDirVisit::New(), GDCM_NAME_SPACE::DicomDirSerie::New(), GDCM_NAME_SPACE::DicomDirImage::New(), and NewMeta(). Referenced by DoTheLoadingJob(), and ParseDirectory(). 00667 { 00668 // The SeqEntries of "Directory Record Sequence" are parsed. 00669 // When a DicomDir tag ("PATIENT", "STUDY", "SERIE", "IMAGE") is found : 00670 // N.B. : VISIT, PRIVATE not fully dealt with 00671 // 1 - we save the beginning iterator 00672 // 2 - we continue to parse 00673 // 3 - we find an other tag 00674 // + we create the object for the precedent tag 00675 // + loop to 1 - 00676 gdcmDebugMacro("Create DicomDir"); 00677 00678 // Directory record sequence 00679 DocEntry *e = GetDocEntry(0x0004, 0x1220); 00680 if ( !e ) 00681 { 00682 gdcmWarningMacro( "No Directory Record Sequence (0004,1220) found"); 00683 return; 00684 } 00685 00686 SeqEntry *s = dynamic_cast<SeqEntry *>(e); 00687 if ( !s ) 00688 { 00689 gdcmWarningMacro( "Element (0004,1220) is not a Sequence ?!?"); 00690 return; 00691 } 00692 00693 NewMeta(); 00694 00695 DocEntry *d; 00696 std::string v; 00697 SQItem *si; 00698 00699 SQItem *tmpSI=s->GetFirstSQItem(); 00700 while(tmpSI) 00701 { 00702 d = tmpSI->GetDocEntry(0x0004, 0x1430); // Directory Record Type 00703 if ( DataEntry *dataEntry = dynamic_cast<DataEntry *>(d) ) 00704 { 00705 v = dataEntry->GetString(); 00706 } 00707 else 00708 { 00709 gdcmWarningMacro( "(0004,1430) not a DataEntry ?!?"); 00710 continue; 00711 } 00712 00713 // A decent DICOMDIR has much more images than series, 00714 // more series than studies, and so on. 00715 // This is the right order to perform the tests 00716 00717 if ( v == "IMAGE " ) 00718 { 00719 si = DicomDirImage::New(true); // true = empty 00720 if ( !AddImageToEnd( static_cast<DicomDirImage *>(si)) ) 00721 { 00722 si->Delete(); 00723 si = NULL; 00724 gdcmErrorMacro( "Add AddImageToEnd failed"); 00725 } 00726 } 00727 else if ( v == "SERIES" ) 00728 { 00729 si = DicomDirSerie::New(true); // true = empty 00730 if ( !AddSerieToEnd( static_cast<DicomDirSerie *>(si)) ) 00731 { 00732 si->Delete(); 00733 si = NULL; 00734 gdcmErrorMacro( "Add AddSerieToEnd failed"); 00735 } 00736 } 00737 else if ( v == "VISIT " ) 00738 { 00739 si = DicomDirVisit::New(true); // true = empty 00740 if ( !AddVisitToEnd( static_cast<DicomDirVisit *>(si)) ) 00741 { 00742 si->Delete(); 00743 si = NULL; 00744 gdcmErrorMacro( "Add AddVisitToEnd failed"); 00745 } 00746 } 00747 else if ( v == "STUDY " ) 00748 { 00749 si = DicomDirStudy::New(true); // true = empty 00750 if ( !AddStudyToEnd( static_cast<DicomDirStudy *>(si)) ) 00751 { 00752 si->Delete(); 00753 si = NULL; 00754 gdcmErrorMacro( "Add AddStudyToEnd failed"); 00755 } 00756 } 00757 else if ( v == "PATIENT " ) 00758 { 00759 si = DicomDirPatient::New(true); // true = empty 00760 if ( !AddPatientToEnd( static_cast<DicomDirPatient *>(si)) ) 00761 { 00762 si->Delete(); 00763 si = NULL; 00764 gdcmErrorMacro( "Add PatientToEnd failed"); 00765 } 00766 } 00769 00770 else if ( v == "PRIVATE " ) // for SIEMENS 'CSA Non Image' 00771 { 00772 00773 gdcmWarningMacro( " -------------------------------------------" 00774 << "a PRIVATE SQItem was found : " << v); 00775 si = DicomDirPrivate::New(true); // true = empty 00776 if ( !AddPrivateToEnd( static_cast<DicomDirPrivate *>(si)) ) 00777 { 00778 si->Delete(); 00779 si = NULL; 00780 gdcmErrorMacro( "Add PrivateToEnd failed"); 00781 } 00782 } 00783 else 00784 { 00785 // It was neither a 'PATIENT', nor a 'STUDY', nor a 'SERIE', 00786 // nor an 'IMAGE' SQItem. Skip to next item. 00787 gdcmWarningMacro( " -------------------------------------------" 00788 << "a non PATIENT/STUDY/SERIE/IMAGE /VISIT/PRIVATE SQItem was found : " 00789 << v); 00790 00791 // FIXME : deal with other item types ! 00792 tmpSI=s->GetNextSQItem(); // To avoid infinite loop 00793 continue; 00794 } 00795 if ( si ) 00796 si->Copy(tmpSI); 00797 00798 tmpSI=s->GetNextSQItem(); 00799 } 00800 ClearEntry(); 00801 }
|
|
create a Document-like chained list from a root Directory
Definition at line 594 of file gdcmDicomDir.cxx. References GDCM_NAME_SPACE::Document::Abort, GDCM_NAME_SPACE::Document::CallProgressMethod(), GDCM_NAME_SPACE::Document::CallStartMethod(), gdcmDebugMacro, GDCM_NAME_SPACE::DirList::GetFilenames(), GDCM_NAME_SPACE::File::IsReadable(), GDCM_NAME_SPACE::File::Load(), GDCM_NAME_SPACE::Document::LoadMode, GDCM_NAME_SPACE::File::New(), GDCM_NAME_SPACE::Document::Progress, GDCM_NAME_SPACE::Document::SetFileName(), and GDCM_NAME_SPACE::Document::SetLoadMode(). Referenced by ParseDirectory(). 00595 { 00596 CallStartMethod(); 00597 DirList dirList(path,1); // gets recursively the file list 00598 unsigned int count = 0; 00599 VectDocument list; 00600 File *f; 00601 00602 DirListType fileList = dirList.GetFilenames(); 00603 unsigned int nbFile = fileList.size(); 00604 for( DirListType::iterator it = fileList.begin(); 00605 it != fileList.end(); 00606 ++it ) 00607 { 00608 Progress = (float)(count+1)/(float)nbFile; 00609 CallProgressMethod(); 00610 if ( Abort ) 00611 { 00612 break; 00613 } 00614 00615 f = File::New( ); 00616 f->SetLoadMode(LoadMode); // we allow user not to load Sequences, 00617 // or Shadow groups, or ...... 00618 f->SetFileName( it->c_str() ); 00619 f->Load( ); 00620 00621 if ( f->IsReadable() ) 00622 { 00623 // Add the file to the chained list: 00624 list.push_back(f); 00625 gdcmDebugMacro( "Readable " << it->c_str() ); 00626 } 00627 else 00628 { 00629 f->Delete(); 00630 } 00631 count++; 00632 } 00633 // sorts Patient/Study/Serie/ 00634 std::sort(list.begin(), list.end(), DicomDir::HeaderLessThan ); 00635 00636 std::string tmp = dirList.GetDirName(); 00637 //for each File of the chained list, add/update the Patient/Study/Serie/Image info 00638 SetElements(tmp, list); 00639 CallEndMethod(); 00640 00641 for(VectDocument::iterator itDoc=list.begin(); 00642 itDoc!=list.end(); 00643 ++itDoc) 00644 { 00645 dynamic_cast<File *>(*itDoc)->Delete(); 00646 } 00647 }
|
|
|
Loader. (DEPRECATED : kept not to break the API) Does the Loading Job (internal use only).
Definition at line 283 of file gdcmDicomDir.cxx. References GDCM_NAME_SPACE::Document::Abort, CreateDicomDir(), GDCM_NAME_SPACE::Document::Fp, gdcmDebugMacro, gdcmErrorMacro, gdcmWarningMacro, GDCM_NAME_SPACE::ElementSet::GetDocEntry(), GDCM_NAME_SPACE::Document::GetFileName(), GDCM_NAME_SPACE::ElementSet::GetFirstEntry(), GDCM_NAME_SPACE::Document::Load(), NewMeta(), ParseDir, ParseDirectory(), GDCM_NAME_SPACE::Document::Progress, and SetFileName(). Referenced by Load(). 00284 { 00285 Progress = 0.0f; 00286 Abort = false; 00287 00288 if (!ParseDir) 00289 { 00290 // Only if user passed a DICOMDIR 00291 // ------------------------------ 00292 Fp = 0; 00293 if (!Document::Load() ) 00294 { 00295 return false; 00296 } 00297 00298 if ( GetFirstEntry() == 0 ) // when user passed a Directory to parse 00299 { 00300 gdcmWarningMacro( "Entry HT empty for file: "<< GetFileName()); 00301 return false; 00302 } 00303 // Directory record sequence 00304 DocEntry *e = GetDocEntry(0x0004, 0x1220); 00305 if ( !e ) 00306 { 00307 gdcmWarningMacro( "NO 'Directory record sequence' (0x0004,0x1220)" 00308 << " in file " << GetFileName()); 00309 return false; 00310 } 00311 else 00312 { 00313 CreateDicomDir(); 00314 } 00315 } 00316 else 00317 { 00318 // Only if user passed a root directory 00319 // ------------------------------------ 00320 if ( GetFileName() == "." ) 00321 { 00322 // user passed '.' as Name 00323 // we get current directory name 00324 char buf[2048]; 00325 const char *cwd = getcwd(buf, 2048); 00326 if( cwd ) 00327 { 00328 SetFileName( buf ); // will be converted into a string 00329 } 00330 else 00331 { 00332 gdcmErrorMacro( "Path was too long to fit on 2048 bytes" ); 00333 } 00334 } 00335 NewMeta(); 00336 gdcmDebugMacro( "Parse directory and create the DicomDir : " 00337 << GetFileName() ); 00338 ParseDirectory(); 00339 } 00340 return true; 00341 }
|
|
|
|
|
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.
Definition at line 473 of file gdcmDocEntrySet.cxx. References gdcmWarningMacro, GDCM_NAME_SPACE::DictSet::GetDefaultPubDict(), GDCM_NAME_SPACE::Global::GetDicts(), GDCM_NAME_SPACE::Dict::GetEntry(), and GDCM_NAME_SPACE::RefCounter::Register(). Referenced by GDCM_NAME_SPACE::Document::ReadNextDocEntry(). 00474 { 00475 DictEntry *found = 0; 00478 Dict *pubDict = Global::GetDicts()->GetDefaultPubDict(); 00479 if (!pubDict) 00480 { 00481 gdcmWarningMacro( "We SHOULD have a default dictionary"); 00482 } 00483 else 00484 { 00485 found = pubDict->GetEntry(group, elem); 00486 if( found ) 00487 found->Register(); 00488 } 00489 return found; 00490 }
|
|
retrieves a Dicom Element using (group, element)
Implements GDCM_NAME_SPACE::DocEntrySet. Definition at line 186 of file gdcmElementSet.cxx. References GDCM_NAME_SPACE::ElementSet::TagHT, and GDCM_NAME_SPACE::DictEntry::TranslateToKey(). Referenced by GDCM_NAME_SPACE::File::AnonymizeFile(), GDCM_NAME_SPACE::File::AnonymizeNoLoad(), GDCM_NAME_SPACE::FileHelper::CopyDataEntry(), CreateDicomDir(), GDCM_NAME_SPACE::File::DoTheLoadingJob(), DoTheLoadingJob(), GDCM_NAME_SPACE::File::GetPixelAreaLength(), GDCM_NAME_SPACE::File::GetPixelOffset(), GDCM_NAME_SPACE::Document::GetTransferSyntax(), GDCM_NAME_SPACE::File::HasLUT(), GDCM_NAME_SPACE::Document::IsDicomV3(), GDCM_NAME_SPACE::Document::IsPapyrus(), GDCM_NAME_SPACE::File::IsReadable(), GDCM_NAME_SPACE::Document::LoadEntryBinArea(), GDCM_NAME_SPACE::DocEntryArchive::Push(), and GDCM_NAME_SPACE::DocEntryArchive::Restore(). 00187 { 00188 TagKey key = DictEntry::TranslateToKey(group, elem); 00189 TagDocEntryHT::iterator it = TagHT.find(key); 00190 00191 if ( it!=TagHT.end() ) 00192 return it->second; 00193 return NULL; 00194 }
|
|
Gets (from Header) a 'non string' element value.
Definition at line 73 of file gdcmDocEntrySet.cxx. References GDCM_NAME_SPACE::DataEntry::GetBinArea(), and GDCM_NAME_SPACE::DocEntrySet::GetDataEntry(). 00074 { 00075 DataEntry *entry = GetDataEntry(group, elem); 00076 if ( entry ) 00077 return entry->GetBinArea(); 00078 return 0; 00079 }
|
|
Searches within the DocEntrySet for the value length of a given tag..
Definition at line 88 of file gdcmDocEntrySet.cxx. References GDCM_NAME_SPACE::DocEntrySet::GetDocEntry(), and GDCM_NAME_SPACE::DocEntry::GetLength(). Referenced by SetElement(), and GDCM_NAME_SPACE::File::Write(). 00089 { 00090 DocEntry *entry = GetDocEntry(group, elem); 00091 if ( entry ) 00092 return entry->GetLength(); 00093 return -1; 00094 }
|
|
Get the "std::string representable" value of the Dicom entry.
Definition at line 51 of file gdcmDocEntrySet.cxx. References GDCM_NAME_SPACE::GDCM_NOTLOADED, GDCM_NAME_SPACE::GDCM_UNFOUND, GDCM_NAME_SPACE::GDCM_UNREAD, GDCM_NAME_SPACE::DocEntrySet::GetDocEntry(), GDCM_NAME_SPACE::DataEntry::GetString(), GDCM_NAME_SPACE::DataEntry::IsNotLoaded(), GDCM_NAME_SPACE::DataEntry::IsUnfound(), and GDCM_NAME_SPACE::DataEntry::IsUnread(). Referenced by GDCM_NAME_SPACE::SerieHelper::AddFile(), GDCM_NAME_SPACE::File::AnonymizeFile(), GDCM_NAME_SPACE::FileHelper::CheckMandatoryElements(), GDCM_NAME_SPACE::SerieHelper::CreateUniqueSeriesIdentifier(), GDCM_NAME_SPACE::SerieHelper::CreateUserDefinedFileIdentifier(), GDCM_NAME_SPACE::Document::DoTheLoadingDocumentJob(), GDCM_NAME_SPACE::File::DoTheLoadingJob(), GDCM_NAME_SPACE::DirList::Explore(), GDCM_NAME_SPACE::File::GetImageNumber(), GDCM_NAME_SPACE::File::GetImageOrientationPatient(), GDCM_NAME_SPACE::File::GetImagePositionPatient(), GDCM_NAME_SPACE::File::GetLUTNbits(), GDCM_NAME_SPACE::File::GetModality(), GDCM_NAME_SPACE::File::GetNumberOfScalarComponents(), GDCM_NAME_SPACE::File::GetNumberOfScalarComponentsRaw(), GDCM_NAME_SPACE::File::GetPixelSize(), GDCM_NAME_SPACE::File::GetPixelType(), GDCM_NAME_SPACE::File::GetRescaleSlope(), GDCM_NAME_SPACE::File::GetRescaleSlopeIntercept(), GDCM_NAME_SPACE::File::GetSpacing(), GDCM_NAME_SPACE::Document::GetTransferSyntaxName(), GDCM_NAME_SPACE::File::GetXSpacing(), GDCM_NAME_SPACE::File::GetYSpacing(), GDCM_NAME_SPACE::File::IsMonochrome(), GDCM_NAME_SPACE::File::IsMonochrome1(), GDCM_NAME_SPACE::File::IsPaletteColor(), GDCM_NAME_SPACE::File::IsReadable(), GDCM_NAME_SPACE::File::IsYBRFull(), GDCM_NAME_SPACE::Document::operator<(), and SetElement(). 00052 { 00053 DataEntry *entry = dynamic_cast<DataEntry *>(GetDocEntry(group,elem)); 00054 if ( entry ) 00055 { 00056 if( entry->IsNotLoaded() ) 00057 return GDCM_NOTLOADED; 00058 if( entry->IsUnfound() ) 00059 return GDCM_UNFOUND; 00060 if( entry->IsUnread() ) 00061 return GDCM_UNREAD; 00062 return entry->GetString(); 00063 } 00064 return GDCM_UNFOUND; 00065 }
|
|
Accessor to Filename.
Definition at line 78 of file gdcmDocument.h. Referenced by DoTheLoadingJob(), GDCM_NAME_SPACE::SerieHelper::FileNameGreaterThan(), GDCM_NAME_SPACE::SerieHelper::FileNameLessThan(), GDCM_NAME_SPACE::Document::IsParsable(), IsReadable(), GDCM_NAME_SPACE::Document::Load(), vtkGdcmReader::LoadImageInMemory(), ParseDirectory(), SetElement(), vtkGdcmReader::TestFileInformation(), and userSuppliedLessThanFunction2(). 00078 { return Filename; }
|
|
returns the File Type (ACR, ACR_LIBIDO, ExplicitVR, ImplicitVR, Unknown)
Definition at line 417 of file gdcmDocument.cxx. References GDCM_NAME_SPACE::Document::Filetype. 00418 { 00419 return Filetype; 00420 }
|
|
Get the first entry while visiting *the* 'zero level' DocEntrySet (DocEntries out of any Sequence).
Implements GDCM_NAME_SPACE::DocEntrySet. Definition at line 156 of file gdcmElementSet.cxx. References GDCM_NAME_SPACE::ElementSet::ItTagHT, and GDCM_NAME_SPACE::ElementSet::TagHT. Referenced by GDCM_NAME_SPACE::Document::ComputeGroup0002Length(), DoTheLoadingJob(), NewMeta(), and GDCM_NAME_SPACE::Validator::SetInput(). 00157 { 00158 ItTagHT = TagHT.begin(); 00159 if (ItTagHT != TagHT.end()) 00160 return ItTagHT->second; 00161 return NULL; 00162 }
|
|
Get the first entry while visiting the DicomDirPatients.
Definition at line 435 of file gdcmDicomDir.cxx. References ItPatient, and Patients. 00436 { 00437 ItPatient = Patients.begin(); 00438 if ( ItPatient != Patients.end() ) 00439 return *ItPatient; 00440 return NULL; 00441 }
|
|
Returns a pointer to the DicomDirMeta for this DICOMDIR.
Definition at line 83 of file gdcmDicomDir.h. Referenced by Write(). 00083 { return MetaElems; }
|
|
Get the next entry while visiting *the* 'zero level' DocEntrySet (DocEntries out of any Sequence).
Implements GDCM_NAME_SPACE::DocEntrySet. Definition at line 170 of file gdcmElementSet.cxx. References gdcmAssertMacro, GDCM_NAME_SPACE::ElementSet::ItTagHT, and GDCM_NAME_SPACE::ElementSet::TagHT. Referenced by GDCM_NAME_SPACE::Document::ComputeGroup0002Length(), and GDCM_NAME_SPACE::Validator::SetInput(). 00171 { 00172 gdcmAssertMacro (ItTagHT != TagHT.end()); 00173 00174 ++ItTagHT; 00175 if (ItTagHT != TagHT.end()) 00176 return ItTagHT->second; 00177 return NULL; 00178 }
|
|
Get the next entry while visiting the DicomDirPatients.
Definition at line 448 of file gdcmDicomDir.cxx. References gdcmAssertMacro, ItPatient, and Patients. 00449 { 00450 gdcmAssertMacro (ItPatient != Patients.end()); 00451 00452 ++ItPatient; 00453 if ( ItPatient != Patients.end() ) 00454 return *ItPatient; 00455 return NULL; 00456 }
|
|
returns the number of Patients currently held in the gdcm::DicomDir
Definition at line 92 of file gdcmDicomDir.h. 00092 { return Patients.size();}
|
|
Gets the print level for the Dicom Entries.
Definition at line 50 of file gdcmBase.h. 00050 { return PrintLevel; }
|
|
GetProgress GetProgress.
Definition at line 98 of file gdcmDicomDir.h. 00098 { return Progress; }
|
|
Get the public dictionary used.
Definition at line 314 of file gdcmDocument.cxx. References GDCM_NAME_SPACE::Document::RefPubDict. 00315 { 00316 return RefPubDict; 00317 }
|
|
Get the reference counting.
Definition at line 59 of file gdcmRefCounter.h. 00060 { 00061 return RefCount; 00062 }
|
|
Same as Document::GetDocEntry except it returns a result only when the corresponding entry is of type SeqEntry.
Definition at line 119 of file gdcmDocEntrySet.cxx. References GDCM_NAME_SPACE::DocEntrySet::GetDocEntry(). Referenced by GDCM_NAME_SPACE::Document::DoTheLoadingDocumentJob(), GDCM_NAME_SPACE::File::GetRescaleSlopeIntercept(), and GDCM_NAME_SPACE::File::GetSpacing(). 00120 { 00121 DocEntry *currentEntry = GetDocEntry(group, elem); 00122 if ( !currentEntry ) 00123 return NULL; 00124 00125 return dynamic_cast<SeqEntry*>(currentEntry); 00126 }
|
|
Get the shadow dictionary used.
Definition at line 322 of file gdcmDocument.cxx. References GDCM_NAME_SPACE::Document::RefShaDict. 00323 { 00324 return RefShaDict; 00325 }
|
|
'Swap code' accessor (see SwapCode )
Definition at line 74 of file gdcmDocument.h. Referenced by GDCM_NAME_SPACE::PixelReadConvert::GrabInformationsFromFile(). 00074 { return SwapCode; }
|
|
Accessor to the Transfer Syntax (when present) of the current document (it internally handles reading the value from disk when only parsing occured).
Definition at line 429 of file gdcmDocument.cxx. References GDCM_NAME_SPACE::GDCM_UNKNOWN, gdcmWarningMacro, and GDCM_NAME_SPACE::ElementSet::GetDocEntry(). Referenced by GDCM_NAME_SPACE::File::ComputeJPEGFragmentInfo(), GDCM_NAME_SPACE::File::ComputeRLEInfo(), GDCM_NAME_SPACE::File::DoTheLoadingJob(), and GDCM_NAME_SPACE::Document::HandleOutOfGroup0002(). 00430 { 00431 DocEntry *entry = GetDocEntry(0x0002, 0x0010); 00432 if ( !entry ) 00433 { 00434 return GDCM_UNKNOWN; 00435 } 00436 00437 // The entry might be present but not loaded (parsing and loading 00438 // happen at different stages): try loading and proceed with check... 00439 00440 // Well ... 00441 // (parsing and loading happen at the very same stage!) 00442 //LoadDocEntrySafe(entry); //JPRx 00443 if (DataEntry *dataEntry = dynamic_cast<DataEntry *>(entry) ) 00444 { 00445 std::string transfer = dataEntry->GetString(); 00446 // The actual transfer (as read from disk) might be padded. We 00447 // first need to remove the potential padding. We can make the 00448 // weak assumption that padding was not executed with digits... 00449 if ( transfer.length() == 0 ) 00450 { 00451 // for brain damaged headers 00452 gdcmWarningMacro( "Transfer Syntax has length = 0."); 00453 return GDCM_UNKNOWN; 00454 } 00455 while ( !isdigit((unsigned char)transfer[transfer.length()-1]) ) 00456 { 00457 transfer.erase(transfer.length()-1, 1); 00458 if ( transfer.length() == 0 ) 00459 { 00460 // for brain damaged headers 00461 gdcmWarningMacro( "Transfer Syntax contains no valid character."); 00462 return GDCM_UNKNOWN; 00463 } 00464 } 00465 return transfer; 00466 } 00467 return GDCM_UNKNOWN; 00468 }
|
|
Accesses the info from 0002,0010 : Transfer Syntax and TS.
Definition at line 474 of file gdcmDocument.cxx. References GDCM_NAME_SPACE::GDCM_NOTLOADED, GDCM_NAME_SPACE::GDCM_UNFOUND, gdcmDebugMacro, gdcmErrorMacro, GDCM_NAME_SPACE::DocEntrySet::GetEntryString(), and GDCM_NAME_SPACE::Global::GetTS(). Referenced by GDCM_NAME_SPACE::Document::HandleOutOfGroup0002(). 00475 { 00476 // use the TS (TS : Transfer Syntax) 00477 std::string transferSyntax = GetEntryString(0x0002,0x0010); 00478 00479 if ( (transferSyntax.find(GDCM_NOTLOADED) < transferSyntax.length()) ) 00480 { 00481 gdcmErrorMacro( "Transfer Syntax not loaded. " << std::endl 00482 << "Better you increase MAX_SIZE_LOAD_ELEMENT_VALUE" ); 00483 return "Uncompressed ACR-NEMA"; 00484 } 00485 if ( transferSyntax == GDCM_UNFOUND ) 00486 { 00487 gdcmDebugMacro( "Unfound Transfer Syntax (0002,0010)"); 00488 return "Uncompressed ACR-NEMA"; 00489 } 00490 00491 // we do it only when we need it 00492 const TSKey &tsName = Global::GetTS()->GetValue( transferSyntax ); 00493 00494 // Global::GetTS() is a global static you shall never try to delete it! 00495 return tsName; 00496 }
|
|
compares two files
Definition at line 1208 of file gdcmDicomDir.cxx.
|
|
Sets all fields to NULL.
Reimplemented from GDCM_NAME_SPACE::Document. Definition at line 655 of file gdcmDicomDir.cxx. References GDCM_NAME_SPACE::Document::Abort, MetaElems, and GDCM_NAME_SPACE::Document::Progress. Referenced by DicomDir().
|
|
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.
Definition at line 290 of file gdcmDocEntrySet.cxx. References GDCM_NAME_SPACE::DocEntrySet::AddEntry(), GDCM_NAME_SPACE::RefCounter::Delete(), gdcmWarningMacro, GDCM_NAME_SPACE::DocEntrySet::GetDocEntry(), GDCM_NAME_SPACE::DocEntry::GetVR(), GDCM_NAME_SPACE::DocEntrySet::NewDataEntry(), GDCM_NAME_SPACE::DocEntrySet::RemoveEntry(), and GDCM_NAME_SPACE::DocEntrySet::SetEntryBinArea(). Referenced by GDCM_NAME_SPACE::FileHelper::InsertEntryBinArea(). 00293 { 00294 DataEntry *dataEntry = 0; 00295 DocEntry *currentEntry = GetDocEntry( group, elem ); 00296 00297 // Verify the currentEntry 00298 if (currentEntry) 00299 { 00300 dataEntry = dynamic_cast<DataEntry *>(currentEntry); 00301 00302 // Verify the VR 00303 if ( dataEntry ) 00304 if ( dataEntry->GetVR()!=vr ) 00305 dataEntry = NULL; 00306 00307 // if currentEntry doesn't correspond to the requested dataEntry 00308 if ( !dataEntry) 00309 { 00310 if ( !RemoveEntry(currentEntry) ) 00311 { 00312 gdcmWarningMacro( "Removal of previous DocEntry failed."); 00313 return NULL; 00314 } 00315 } 00316 } 00317 00318 // Create a new dataEntry if necessary 00319 if ( !dataEntry) 00320 { 00321 dataEntry = NewDataEntry(group, elem, vr); 00322 00323 if ( !AddEntry(dataEntry) ) 00324 { 00325 gdcmWarningMacro( "AddEntry failed although this is a creation."); 00326 dataEntry->Delete(); 00327 return NULL; 00328 } 00329 dataEntry->Delete(); 00330 } 00331 00332 // Set the dataEntry value 00333 uint8_t *tmpArea; 00334 if ( lgth>0 && binArea ) 00335 { 00336 tmpArea = new uint8_t[lgth]; 00337 memcpy(tmpArea,binArea,lgth); 00338 } 00339 else 00340 { 00341 tmpArea = 0; 00342 } 00343 if ( !SetEntryBinArea(tmpArea,lgth,dataEntry) ) 00344 { 00345 if ( tmpArea ) 00346 { 00347 delete[] tmpArea; 00348 } 00349 } 00350 return dataEntry; 00351 }
|
|
Modifies the value of a given Doc Entry (Dicom Element) when it exists. Creates it with the given value when unexistant.
Definition at line 216 of file gdcmDocEntrySet.cxx. References GDCM_NAME_SPACE::DocEntrySet::AddEntry(), GDCM_NAME_SPACE::RefCounter::Delete(), GDCM_NAME_SPACE::GDCM_VRUNKNOWN, gdcmWarningMacro, GDCM_NAME_SPACE::DictSet::GetDefaultPubDict(), GDCM_NAME_SPACE::Global::GetDicts(), GDCM_NAME_SPACE::DocEntrySet::GetDocEntry(), GDCM_NAME_SPACE::Dict::GetEntry(), GDCM_NAME_SPACE::DocEntry::GetKey(), GDCM_NAME_SPACE::DictEntry::GetVR(), GDCM_NAME_SPACE::DocEntry::GetVR(), GDCM_NAME_SPACE::DocEntrySet::NewDataEntry(), GDCM_NAME_SPACE::RefCounter::Register(), GDCM_NAME_SPACE::DocEntrySet::RemoveEntry(), and GDCM_NAME_SPACE::DocEntrySet::SetEntryString(). Referenced by GDCM_NAME_SPACE::FileHelper::InsertEntryString(), GDCM_NAME_SPACE::FileHelper::Write(), and GDCM_NAME_SPACE::File::Write(). 00219 { 00220 DataEntry *dataEntry = 0; 00221 DocEntry *currentEntry = GetDocEntry( group, elem ); 00222 VRKey localVR = vr; 00223 if (currentEntry) 00224 { 00225 dataEntry = dynamic_cast<DataEntry *>(currentEntry); 00226 00227 // Verify the VR 00228 if ( dataEntry ) 00229 if ( dataEntry->GetVR()!=vr ) 00230 dataEntry = NULL; 00231 00232 // if currentEntry doesn't correspond to the requested dataEntry 00233 if ( !dataEntry) 00234 { 00235 if ( !RemoveEntry(currentEntry) ) 00236 { 00237 gdcmWarningMacro( "Removal of previous DocEntry failed."); 00238 return NULL; 00239 } 00240 } 00241 } 00242 00243 else // the 'currentEntry' was not found 00244 { 00245 if ( vr == GDCM_VRUNKNOWN ) // user didn't specify a VR. 00246 // Probabely he trusts the Dicom Dict ! 00247 { 00248 DictEntry *e = 00249 Global::GetDicts()->GetDefaultPubDict()->GetEntry(group, elem); 00250 if ( e ) 00251 { 00252 localVR = e->GetVR(); 00253 e->Register(); // ?? JPRx 00254 } 00255 } 00256 } 00257 00258 // Create a new dataEntry if necessary 00259 if ( !dataEntry ) 00260 { 00261 dataEntry = NewDataEntry( group, elem, localVR ); 00262 00263 if ( !AddEntry(dataEntry) ) 00264 { 00265 gdcmWarningMacro("AddEntry " << dataEntry->GetKey() 00266 << " failed although this is a creation."); 00267 dataEntry->Delete(); 00268 return NULL; 00269 } 00270 dataEntry->Delete(); // ?!? JPRx 00271 } 00272 00273 // Set the dataEntry value 00274 SetEntryString(value, dataEntry); // The std::string value 00275 return dataEntry; 00276 }
|
|
Creates a new gdcm::SeqEntry and adds it to the current DocEntrySet. (remove any existing entry with same group,elem).
Definition at line 361 of file gdcmDocEntrySet.cxx. References GDCM_NAME_SPACE::DocEntrySet::AddEntry(), GDCM_NAME_SPACE::RefCounter::Delete(), gdcmWarningMacro, GDCM_NAME_SPACE::DocEntrySet::GetDocEntry(), GDCM_NAME_SPACE::DocEntrySet::NewSeqEntry(), and GDCM_NAME_SPACE::DocEntrySet::RemoveEntry(). Referenced by GDCM_NAME_SPACE::FileHelper::InsertSeqEntry(). 00362 { 00363 SeqEntry *seqEntry = 0; 00364 DocEntry *currentEntry = GetDocEntry( group, elem ); 00365 00366 // Verify the currentEntry 00367 if ( currentEntry ) 00368 { 00369 seqEntry = dynamic_cast<SeqEntry *>(currentEntry); 00370 00371 // Verify the VR 00372 if ( seqEntry ) 00373 seqEntry = NULL; 00374 00375 // if currentEntry doesn't correspond to the requested seqEntry 00376 if ( !seqEntry ) 00377 { 00378 if (!RemoveEntry(currentEntry)) 00379 { 00380 gdcmWarningMacro( "Removal of previous DocEntry failed for (" 00381 <<std::hex << group << "|" << elem <<")" ); 00382 return NULL; 00383 } 00384 } 00385 } 00386 // Create a new seqEntry if necessary 00387 if ( !seqEntry ) 00388 { 00389 seqEntry = NewSeqEntry(group, elem); 00390 00391 if ( !AddEntry(seqEntry) ) 00392 { 00393 gdcmWarningMacro( "AddEntry failed although this is a creation for (" 00394 <<std::hex << group << "|" << elem <<")" ); 00395 seqEntry->Delete(); 00396 return NULL; 00397 } 00398 seqEntry->Delete(); 00399 } 00400 // Remark : 00401 // SequenceDelimitationItem will be added at the end of the SeqEntry, 00402 // at write time 00403 return seqEntry; 00404 }
|
|
IsAborted IsAborted.
Definition at line 102 of file gdcmDicomDir.h. 00102 { return Abort; }
|
|
Predicate for dicom version 3 file.
Definition at line 386 of file gdcmDocument.cxx. References GDCM_NAME_SPACE::ElementSet::GetDocEntry(). Referenced by GDCM_NAME_SPACE::File::GetYSize(), and GDCM_NAME_SPACE::PixelReadConvert::GrabInformationsFromFile(). 00387 { 00388 // Checking if Transfer Syntax exists is enough 00389 // Anyway, it's too late check if the 'Preamble' was found ... 00390 // And ... would it be a rich idea to check ? 00391 // (some 'no Preamble' DICOM images exist !) 00392 return GetDocEntry(0x0002, 0x0010) != NULL; 00393 }
|
|
Tells us if the ElementSet contains no entry.
Implements GDCM_NAME_SPACE::DocEntrySet. Definition at line 59 of file gdcmElementSet.h. Referenced by GDCM_NAME_SPACE::Document::DoTheLoadingDocumentJob(), and GDCM_NAME_SPACE::Document::IsParsable(). 00059 { return TagHT.empty(); }
|
|
Predicate for Papyrus file Dedicated to whomsoever it may concern.
Definition at line 400 of file gdcmDocument.cxx. References GDCM_NAME_SPACE::ElementSet::GetDocEntry(). 00401 { 00402 // check for Papyrus private Sequence 00403 DocEntry *e = GetDocEntry(0x0041, 0x1050); 00404 if ( !e ) 00405 return false; 00406 // check if it's actually a Sequence 00407 if ( !dynamic_cast<SeqEntry*>(e) ) 00408 return false; 00409 return true; 00410 }
|
|
This predicate tells us whether or not the current Document was properly parsed and contains at least *one* Dicom Element (and nothing more, sorry).
Definition at line 354 of file gdcmDocument.cxx. References GDCM_NAME_SPACE::Document::Filetype, gdcmWarningMacro, GDCM_NAME_SPACE::Document::GetFileName(), GDCM_NAME_SPACE::ElementSet::IsEmpty(), and GDCM_NAME_SPACE::Unknown. Referenced by GDCM_NAME_SPACE::Document::IsReadable(). 00355 { 00356 if ( Filetype == Unknown ) 00357 { 00358 gdcmWarningMacro( "Wrong filetype for " << GetFileName()); 00359 return false; 00360 } 00361 00362 if ( IsEmpty() ) 00363 { 00364 gdcmWarningMacro( "No tag in internal hash table."); 00365 return false; 00366 } 00367 00368 return true; 00369 }
|
|
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.
Reimplemented from GDCM_NAME_SPACE::Document. Definition at line 351 of file gdcmDicomDir.cxx. References GDCM_NAME_SPACE::Document::Filetype, gdcmErrorMacro, gdcmWarningMacro, GDCM_NAME_SPACE::Document::GetFileName(), MetaElems, Patients, and GDCM_NAME_SPACE::Unknown. 00352 { 00353 if ( Filetype == Unknown ) 00354 { 00355 gdcmErrorMacro( "Wrong filetype for " << GetFileName()); 00356 return false; 00357 } 00358 if ( !MetaElems ) 00359 { 00360 gdcmWarningMacro( "Meta Elements missing in DicomDir"); 00361 return false; 00362 } 00363 if ( Patients.size() <= 0 ) 00364 { 00365 gdcmWarningMacro( "NO Patient in DicomDir"); 00366 return false; 00367 } 00368 00369 return true; 00370 }
|
|
Checks whether *all* the DataEntries of the group have all the same type for VR (ImplicitVR or ExplicitVR).
Definition at line 225 of file gdcmElementSet.cxx. References GDCM_NAME_SPACE::ElementSet::TagHT. 00226 { 00227 uint16_t currentGroup; 00228 int codeVR = -1; 00229 int currentCodeVR; 00230 for(TagDocEntryHT::iterator cc = TagHT.begin();cc != TagHT.end(); ++cc) 00231 { 00232 currentGroup = cc->second->GetGroup(); 00233 00234 if ( currentGroup < group ) 00235 continue; 00236 if ( currentGroup > group ) 00237 break; 00238 // currentGroup == group 00239 if (codeVR == -1) 00240 { 00241 if (cc->second->IsImplicitVR() ) 00242 codeVR = 1; 00243 else 00244 codeVR = 2; 00245 continue; 00246 } 00247 else 00248 { 00249 if (cc->second->IsImplicitVR() ) 00250 currentCodeVR = 1; //Implicit 00251 else 00252 currentCodeVR = 2; // Explicit 00253 00254 if ( currentCodeVR == codeVR ) 00255 continue; 00256 else 00257 return -1; // -1 : not coherent 00258 } 00259 } 00260 return codeVR; 00261 }
|
|
Loader. use SetFileName(fn) or SetLoadMode(lm) + SetDirectoryName(dn) before !
Reimplemented from GDCM_NAME_SPACE::Document. Definition at line 244 of file gdcmDicomDir.cxx. References DoTheLoadingJob(), and ParseDir. 00245 { 00246 if (!ParseDir) 00247 { 00248 if ( ! this->Document::Load( ) ) 00249 return false; 00250 } 00251 return DoTheLoadingJob( ); 00252 }
|
|
Loads (from disk) the element content when a string is not suitable.
Definition at line 761 of file gdcmDocument.cxx. References gdcmWarningMacro, GDCM_NAME_SPACE::DataEntry::GetBinArea(), GDCM_NAME_SPACE::DocEntry::GetElement(), GDCM_NAME_SPACE::DocEntry::GetGroup(), GDCM_NAME_SPACE::DocEntry::GetLength(), GDCM_NAME_SPACE::DocEntry::GetOffset(), GDCM_NAME_SPACE::Document::OpenFile(), GDCM_NAME_SPACE::DataEntry::SetState(), and GDCM_NAME_SPACE::DataEntry::STATE_UNREAD. 00762 { 00763 if( entry->GetBinArea() ) 00764 return; 00765 00766 bool openFile = !Fp; 00767 if ( openFile ) 00768 OpenFile(); 00769 00770 //size_t o =(size_t)entry->GetOffset(); 00771 Fp->seekg((size_t)entry->GetOffset(), std::ios::beg); // FIXME : for each DataEntry ! 00772 00773 size_t l = entry->GetLength(); 00774 uint8_t *data = new uint8_t[l]; 00775 if ( !data ) 00776 { 00777 gdcmWarningMacro( "Cannot allocate DataEntry content for : " 00778 << std::hex << entry->GetGroup() 00779 << "|" << entry->GetElement() ); 00780 return; 00781 } 00782 00783 // Read the data 00784 Fp->read((char*)data, l); 00785 if ( Fp->fail() || Fp->eof() ) 00786 { 00787 delete[] data; 00788 entry->SetState(DataEntry::STATE_UNREAD); 00789 return; 00790 } 00791 00792 // Swap the data content if necessary 00793 uint32_t i; 00794 unsigned short vrLgth = 00795 Global::GetVR()->GetAtomicElementLength(entry->GetVR()); 00796 00797 // FIXME : trouble expected if we read an ... OW Entry (LUT, etc ..) 00798 // if( entry->GetVR() == "OW" ) 00799 // vrLgth = 1; 00800 00801 switch(vrLgth) 00802 { 00803 case 1: 00804 { 00805 break; 00806 } 00807 case 2: 00808 { 00809 uint16_t *data16 = (uint16_t *)data; 00810 for(i=0;i<l/vrLgth;i++) 00811 data16[i] = SwapShort(data16[i]); 00812 break; 00813 } 00814 case 4: 00815 { 00816 uint32_t *data32 = (uint32_t *)data; 00817 for(i=0;i<l/vrLgth;i++) 00818 data32[i] = SwapLong(data32[i]); 00819 break; 00820 } 00821 case 8: 00822 { 00823 double *data64 = (double *)data; 00824 for(i=0;i<l/vrLgth;i++) 00825 data64[i] = SwapDouble(data64[i]); 00826 break; 00827 } 00828 } 00829 00830 entry->SetBinArea(data); 00831 00832 if ( openFile ) // The file is left in the state (open/close) it was at entrance 00833 CloseFile(); 00834 }
|
|
Loads (from disk) the element content when a string is not suitable.
Definition at line 736 of file gdcmDocument.cxx. References gdcmDebugMacro, gdcmWarningMacro, and GDCM_NAME_SPACE::ElementSet::GetDocEntry(). Referenced by GDCM_NAME_SPACE::Document::DoTheLoadingDocumentJob(), and GDCM_NAME_SPACE::Document::LoadDocEntry(). 00737 { 00738 // Search the corresponding DocEntry 00739 DocEntry *docEntry = GetDocEntry(group, elem); 00740 if ( !docEntry ) 00741 { 00742 gdcmDebugMacro(std::hex << group << "|" << elem 00743 << " doesn't exist" ); 00744 return; 00745 } 00746 DataEntry *dataEntry = dynamic_cast<DataEntry *>(docEntry); 00747 if ( !dataEntry ) 00748 { 00749 gdcmWarningMacro(std::hex << group << "|" << elem 00750 << " is NOT a DataEntry"); 00751 return; 00752 } 00753 LoadEntryBinArea(dataEntry); 00754 }
|
|
Some group are illegal withing some Dicom Documents Only the Document knows it.
Reimplemented in GDCM_NAME_SPACE::File. Definition at line 70 of file gdcmElementSet.h. Referenced by GDCM_NAME_SPACE::ElementSet::WriteContent().
|
|
Move the content of the source SQItem to the destination SQItem Only DocEntry's are moved.
Definition at line 1190 of file gdcmDicomDir.cxx. References GDCM_NAME_SPACE::DocEntrySet::AddEntry(), GDCM_NAME_SPACE::DocEntrySet::GetFirstEntry(), and GDCM_NAME_SPACE::DocEntrySet::RemoveEntry(). 01191 { 01192 DocEntry *entry; 01193 // todo : rewrite the whole stuff, without using RemoveEntry an AddEntry, 01194 // to save time 01195 entry = src->GetFirstEntry(); 01196 while(entry) 01197 { 01198 dst->AddEntry(entry); // use it, *before* removing it! 01199 src->RemoveEntry(entry); 01200 // we destroyed -> the current iterator is not longer valid 01201 entry = src->GetFirstEntry(); 01202 } 01203 }
|
|
Constructs a DicomDir with a RefCounter.
Definition at line 62 of file gdcmDicomDir.h. 00062 {return new DicomDir();}
|
|
Build a new DataEntry from all the low level arguments.
Definition at line 425 of file gdcmDocEntrySet.cxx. References gdcmWarningMacro, and GDCM_NAME_SPACE::DataEntry::New(). Referenced by GDCM_NAME_SPACE::FileHelper::CopyDataEntry(), GDCM_NAME_SPACE::DocEntrySet::InsertEntryBinArea(), GDCM_NAME_SPACE::DocEntrySet::InsertEntryString(), and GDCM_NAME_SPACE::Document::ReadNextDocEntry(). 00427 { 00428 00429 DataEntry *newEntry = DataEntry::New(group, elem, vr); 00430 if (!newEntry) 00431 { 00432 gdcmWarningMacro( "Failed to allocate DataEntry for (" 00433 <<std::hex << group << "|" << elem <<")" ); 00434 return 0; 00435 } 00436 return newEntry; 00437 }
|
|
adds *the* Meta to a partially created DICOMDIR
Definition at line 375 of file gdcmDicomDir.cxx. References GDCM_NAME_SPACE::SQItem::AddEntry(), GDCM_NAME_SPACE::RefCounter::Delete(), GDCM_NAME_SPACE::ElementSet::GetFirstEntry(), MetaElems, GDCM_NAME_SPACE::DicomDirMeta::New(), GDCM_NAME_SPACE::ElementSet::RemoveEntry(), and GDCM_NAME_SPACE::SQItem::SetSQItemNumber(). Referenced by CreateDicomDir(), DicomDir(), and DoTheLoadingJob(). 00376 { 00377 if ( MetaElems ) 00378 { 00379 MetaElems->Delete(); 00380 } 00381 DocEntry *entry = GetFirstEntry(); 00382 if ( entry ) 00383 { 00384 MetaElems = DicomDirMeta::New(true); // true = empty 00385 00386 entry = GetFirstEntry(); 00387 while( entry ) 00388 { 00389 if ( dynamic_cast<SeqEntry *>(entry) ) 00390 break; 00391 00392 MetaElems->AddEntry(entry); 00393 RemoveEntry(entry); 00394 00395 entry = GetFirstEntry(); 00396 } 00397 } 00398 else // after root directory parsing 00399 { 00400 MetaElems = DicomDirMeta::New(false); // false = not empty 00401 } 00402 MetaElems->SetSQItemNumber(0); // To avoid further missprinting 00403 return MetaElems; 00404 }
|
|
adds a new Patient (with the basic elements) to a partially created DICOMDIR
Definition at line 410 of file gdcmDicomDir.cxx. References AddPatientToEnd(), and GDCM_NAME_SPACE::DicomDirPatient::New(). 00411 { 00412 DicomDirPatient *dd = DicomDirPatient::New(); 00413 AddPatientToEnd( dd ); 00414 return dd; 00415 }
|
|
Build a new SeqEntry from all the low level arguments.
Definition at line 445 of file gdcmDocEntrySet.cxx. References gdcmWarningMacro, and GDCM_NAME_SPACE::SeqEntry::New(). Referenced by GDCM_NAME_SPACE::Document::Backtrack(), GDCM_NAME_SPACE::DocEntrySet::InsertSeqEntry(), and GDCM_NAME_SPACE::Document::ReadNextDocEntry(). 00446 { 00447 //DictEntry *dictEntry = GetDictEntry(group, elem, "SQ"); 00448 00449 //SeqEntry *newEntry = SeqEntry::New( dictEntry ); 00450 SeqEntry *newEntry = SeqEntry::New( group, elem ); 00451 //dictEntry->Unregister(); // GetDictEntry register it 00452 if (!newEntry) 00453 { 00454 gdcmWarningMacro( "Failed to allocate SeqEntry for (" 00455 <<std::hex << group << "|" << elem <<")" ); 00456 return 0; 00457 } 00458 return newEntry; 00459 }
|
|
Tries to open the file Document::Filename and checks the preamble when existing, or if the file starts with an ACR-NEMA look-like element.
Definition at line 590 of file gdcmDocument.cxx. References GDCM_NAME_SPACE::Document::Filename, and GDCM_NAME_SPACE::Document::HasDCMPreamble. Referenced by GDCM_NAME_SPACE::Document::DoTheLoadingDocumentJob(), GDCM_NAME_SPACE::File::DoTheLoadingJob(), GDCM_NAME_SPACE::FileHelper::GetRaw(), and GDCM_NAME_SPACE::Document::LoadEntryBinArea(). 00591 { 00592 HasDCMPreamble = false; 00593 if (Filename.length() == 0) 00594 { 00595 return 0; 00596 } 00597 00598 if ( Fp ) 00599 { 00600 gdcmDebugMacro( "File already open: " << Filename.c_str()); 00601 CloseFile(); 00602 } 00603 00604 Fp = new std::ifstream(Filename.c_str(), std::ios::in | std::ios::binary); 00605 if ( ! *Fp ) 00606 { 00607 // Don't user gdcmErrorMacro : 00608 // a spurious message will appear when you use, for instance 00609 // gdcm::FileHelper *fh = new gdcm::FileHelper( outputFileName ); 00610 // to create outputFileName. 00611 00612 // FIXME : if the upper comment is still usefull 00613 // --> the constructor is not so good ... 00614 00615 gdcmWarningMacro( "Cannot open file: " << Filename.c_str()); 00616 delete Fp; 00617 Fp = 0; 00618 return 0; 00619 //exit(1); // No function is allowed to leave the application instead 00620 // of warning the caller 00621 } 00622 00623 uint16_t zero = 0; 00624 Fp->read((char*)&zero, (size_t)2); 00625 if ( Fp->eof() ) 00626 { 00627 CloseFile(); 00628 return 0; 00629 } 00630 00631 //-- DICOM -- 00632 Fp->seekg(126L, std::ios::cur); // Once per Document 00633 char dicm[4]; // = {' ',' ',' ',' '}; 00634 Fp->read(dicm, (size_t)4); 00635 if ( Fp->eof() ) 00636 { 00637 CloseFile(); 00638 return 0; 00639 } 00640 00641 if ( memcmp(dicm, "DICM", 4) == 0 ) 00642 { 00643 HasDCMPreamble = true; 00644 return Fp; 00645 } 00646 00647 //-- Broken ACR or DICOM (?) with no Preamble; may start with a Shadow Group -- 00648 // FIXME : We cannot be sure the preable is only zeroes.. 00649 // (see ACUSON-24-YBR_FULL-RLE.dcm ) 00650 if ( 00651 zero == 0x0001 || zero == 0x0100 || zero == 0x0002 || zero == 0x0200 || 00652 zero == 0x0003 || zero == 0x0300 || zero == 0x0004 || zero == 0x0400 || 00653 zero == 0x0005 || zero == 0x0500 || zero == 0x0006 || zero == 0x0600 || 00654 zero == 0x0007 || zero == 0x0700 || zero == 0x0008 || zero == 0x0800 || 00655 zero == 0x0028 || 0x2800 // worse : some ACR-NEMA like files 00656 // start 00028 group ?!? 00657 ) 00658 { 00659 std::string msg = Util::Format( 00660 "ACR/DICOM starting by 0x(%04x) at the beginning of the file\n", zero); 00661 // FIXME : is it a Warning message, or a Debug message? 00662 gdcmWarningMacro( msg.c_str() ); 00663 return Fp; 00664 } 00665 00666 // -- Neither ACR/No Preamble Dicom nor DICOMV3 file 00667 CloseFile(); 00668 // Don't user Warning nor Error, not to pollute the output 00669 // while directory recursive parsing ... 00670 gdcmDebugMacro( "Neither ACR/No Preamble Dicom nor DICOMV3 file: " 00671 << Filename.c_str()); 00672 return 0; 00673 }
|
|
Loads the element while preserving the current underlying file position indicator as opposed to LoadDocEntry that modifies it Compares two documents, according to DicomDir rules.
Definition at line 860 of file gdcmDocument.cxx. References GDCM_NAME_SPACE::DocEntrySet::GetEntryString(). 00861 { 00862 // Patient Name 00863 std::string s1 = GetEntryString(0x0010,0x0010); 00864 std::string s2 = document.GetEntryString(0x0010,0x0010); 00865 if (s1 < s2) 00866 { 00867 return true; 00868 } 00869 else if ( s1 > s2 ) 00870 { 00871 return false; 00872 } 00873 else 00874 { 00875 // Patient ID 00876 s1 = GetEntryString(0x0010,0x0020); 00877 s2 = document.GetEntryString(0x0010,0x0020); 00878 if ( s1 < s2 ) 00879 { 00880 return true; 00881 } 00882 else if ( s1 > s2 ) 00883 { 00884 return false; 00885 } 00886 else 00887 { 00888 // Study Instance UID 00889 s1 = GetEntryString(0x0020,0x000d); 00890 s2 = document.GetEntryString(0x0020,0x000d); 00891 if ( s1 < s2 ) 00892 { 00893 return true; 00894 } 00895 else if ( s1 > s2 ) 00896 { 00897 return false; 00898 } 00899 else 00900 { 00901 // Serie Instance UID 00902 s1 = GetEntryString(0x0020,0x000e); 00903 s2 = document.GetEntryString(0x0020,0x000e); 00904 if ( s1 < s2 ) 00905 { 00906 return true; 00907 } 00908 else if ( s1 > s2 ) 00909 { 00910 return false; 00911 } 00912 } 00913 } 00914 } 00915 return false; 00916 }
|
|
fills the whole structure, starting from a root Directory
Definition at line 461 of file gdcmDicomDir.cxx. References CreateDicomDir(), CreateDicomDirChainedList(), and GDCM_NAME_SPACE::Document::GetFileName(). Referenced by DoTheLoadingJob(). 00462 { 00463 CreateDicomDirChainedList( GetFileName() ); 00464 CreateDicomDir(); 00465 }
|
|
Canonical Printer.
Reimplemented from GDCM_NAME_SPACE::ElementSet. Definition at line 1220 of file gdcmDicomDir.cxx. References MetaElems, Patients, GDCM_NAME_SPACE::DicomDirMeta::Print(), GDCM_NAME_SPACE::Base::PrintLevel, and GDCM_NAME_SPACE::Base::SetPrintLevel(). 01221 { 01222 if ( MetaElems ) 01223 { 01224 MetaElems->SetPrintLevel(PrintLevel); 01225 MetaElems->Print(os); 01226 } 01227 for(ListDicomDirPatient::iterator cc = Patients.begin(); 01228 cc != Patients.end(); 01229 ++cc) 01230 { 01231 (*cc)->SetPrintLevel(PrintLevel); 01232 (*cc)->Print(os); 01233 } 01234 }
|
|
Reads a supposed to be 16 Bits integer (swaps it depending on processor endianness).
Definition at line 946 of file gdcmDocument.cxx. Referenced by GDCM_NAME_SPACE::File::ReadTag(). 00948 { 00949 uint16_t g; 00950 Fp->read ((char*)&g, (size_t)2); 00951 if ( Fp->fail() ) 00952 { 00953 throw FormatError( "Document::ReadInt16()", " file error." ); 00954 } 00955 if ( Fp->eof() ) 00956 { 00957 throw FormatError( "Document::ReadInt16()", "EOF." ); 00958 } 00959 g = SwapShort(g); 00960 return g; 00961 }
|
|
Reads a supposed to be 32 Bits integer (swaps it depending on processor endianness).
Definition at line 980 of file gdcmDocument.cxx. Referenced by GDCM_NAME_SPACE::File::ComputeRLEInfo(), GDCM_NAME_SPACE::Document::FindDocEntryLengthOBOrOW(), and GDCM_NAME_SPACE::File::ReadTagLength(). 00982 { 00983 uint32_t g; 00984 Fp->read ((char*)&g, (size_t)4); 00985 if ( Fp->fail() ) 00986 { 00987 throw FormatError( "Document::ReadInt32()", " file error." ); 00988 } 00989 if ( Fp->eof() ) 00990 { 00991 throw FormatError( "Document::ReadInt32()", "EOF." ); 00992 } 00993 g = SwapLong(g); 00994 return g; 00995 }
|
|
Register the object.
Definition at line 46 of file gdcmRefCounter.h. Referenced by GDCM_NAME_SPACE::SQItem::AddEntry(), GDCM_NAME_SPACE::SeqEntry::AddSQItem(), GDCM_NAME_SPACE::SeqEntry::Copy(), Copy(), GDCM_NAME_SPACE::FileHelper::FileHelper(), GDCM_NAME_SPACE::DocEntrySet::GetDictEntry(), GDCM_NAME_SPACE::DocEntry::GetName(), GDCM_NAME_SPACE::DocEntry::GetVM(), GDCM_NAME_SPACE::DocEntrySet::InsertEntryString(), GDCM_NAME_SPACE::CommandManager::InSetCommand(), GDCM_NAME_SPACE::DocEntryArchive::Push(), and GDCM_NAME_SPACE::SeqEntry::SetDelimitationItem(). 00046 { RefCount++; }
|
|
Clear the hash table from given entry AND delete the entry.
Implements GDCM_NAME_SPACE::DocEntrySet. Definition at line 122 of file gdcmElementSet.cxx. References GDCM_NAME_SPACE::DocEntry::GetKey(), GDCM_NAME_SPACE::ElementSet::TagHT, and GDCM_NAME_SPACE::RefCounter::Unregister(). Referenced by GDCM_NAME_SPACE::Document::Backtrack(), NewMeta(), GDCM_NAME_SPACE::DocEntryArchive::Push(), and GDCM_NAME_SPACE::DocEntryArchive::Restore(). 00123 { 00124 const TagKey &key = entryToRemove->GetKey(); 00125 if ( TagHT.count(key) == 1 ) 00126 { 00127 TagHT.erase(key); 00128 entryToRemove->Unregister(); 00129 return true; 00130 } 00131 00132 gdcmWarningMacro( "Key not present : " << key); 00133 return false ; 00134 }
|
|
Sets the root Directory name to parse, recursively.
Definition at line 69 of file gdcmDicomDir.h. 00070 { ParseDir = true; if (Filename != dirName) 00071 Filename = dirName, IsDocumentModified = true;}
|
|
adds to the HTable the Entries (Dicom Elements) corresponding to the given type
Definition at line 995 of file gdcmDicomDir.cxx. References AddImageToEnd(), AddPatientToEnd(), AddSerieToEnd(), AddStudyToEnd(), GDCM_NAME_SPACE::RefCounter::Delete(), GDCM_DICOMDIR_IMAGE, GDCM_DICOMDIR_META, GDCM_DICOMDIR_PATIENT, GDCM_DICOMDIR_SERIE, GDCM_DICOMDIR_STUDY, GDCM_NAME_SPACE::GDCM_FILESEPARATOR, GDCM_NAME_SPACE::GDCM_UNFOUND, gdcmErrorMacro, gdcmWarningMacro, GDCM_NAME_SPACE::Global::GetDicomDirElements(), GDCM_NAME_SPACE::DicomDirElement::GetDicomDirImageElements(), GDCM_NAME_SPACE::DicomDirElement::GetDicomDirMetaElements(), GDCM_NAME_SPACE::DicomDirElement::GetDicomDirPatientElements(), GDCM_NAME_SPACE::DicomDirElement::GetDicomDirSerieElements(), GDCM_NAME_SPACE::DicomDirElement::GetDicomDirStudyElements(), GDCM_NAME_SPACE::DocEntrySet::GetEntryLength(), GDCM_NAME_SPACE::DocEntrySet::GetEntryString(), GDCM_NAME_SPACE::Document::GetFileName(), GDCM_NAME_SPACE::Util::GetName(), MetaElems, GDCM_NAME_SPACE::DataEntry::New(), GDCM_NAME_SPACE::DicomDirMeta::New(), GDCM_NAME_SPACE::DicomDirPatient::New(), GDCM_NAME_SPACE::DicomDirStudy::New(), GDCM_NAME_SPACE::DicomDirSerie::New(), GDCM_NAME_SPACE::DicomDirImage::New(), and GDCM_NAME_SPACE::DocEntry::SetOffset(). Referenced by SetElements(). 00997 { 00998 ListDicomDirElem elemList; 00999 ListDicomDirElem::const_iterator it; 01000 uint16_t tmpGr, tmpEl; 01001 //DictEntry *dictEntry; 01002 DataEntry *entry; 01003 std::string val; 01004 SQItem *si; 01005 switch( type ) 01006 { 01007 case GDCM_DICOMDIR_IMAGE: 01008 elemList = Global::GetDicomDirElements()->GetDicomDirImageElements(); 01009 si = DicomDirImage::New(true); 01010 if ( !AddImageToEnd(static_cast<DicomDirImage *>(si)) ) 01011 { 01012 si->Delete(); 01013 gdcmErrorMacro( "Add ImageToEnd failed"); 01014 } 01015 break; 01016 case GDCM_DICOMDIR_SERIE: 01017 elemList = Global::GetDicomDirElements()->GetDicomDirSerieElements(); 01018 si = DicomDirSerie::New(true); 01019 if ( !AddSerieToEnd(static_cast<DicomDirSerie *>(si)) ) 01020 { 01021 si->Delete(); 01022 gdcmErrorMacro( "Add SerieToEnd failed"); 01023 } 01024 break; 01025 case GDCM_DICOMDIR_STUDY: 01026 elemList = Global::GetDicomDirElements()->GetDicomDirStudyElements(); 01027 si = DicomDirStudy::New(true); 01028 if ( !AddStudyToEnd(static_cast<DicomDirStudy *>(si)) ) 01029 { 01030 si->Delete(); 01031 gdcmErrorMacro( "Add StudyToEnd failed"); 01032 } 01033 break; 01034 case GDCM_DICOMDIR_PATIENT: 01035 elemList = Global::GetDicomDirElements()->GetDicomDirPatientElements(); 01036 si = DicomDirPatient::New(true); 01037 if ( !AddPatientToEnd(static_cast<DicomDirPatient *>(si)) ) 01038 { 01039 si->Delete(); 01040 gdcmErrorMacro( "Add PatientToEnd failed"); 01041 } 01042 break; 01043 case GDCM_DICOMDIR_META: // never used ?!? --> Done within DoTheLoadingJob 01044 if ( MetaElems ) 01045 { 01046 MetaElems->Delete(); 01047 gdcmErrorMacro( "MetaElements already exist, they will be destroyed"); 01048 } 01049 elemList = Global::GetDicomDirElements()->GetDicomDirMetaElements(); 01050 MetaElems = DicomDirMeta::New(true); 01051 si = MetaElems; 01052 break; 01053 default: 01054 return; 01055 } 01056 01057 // FIXME : troubles found when it's a SeqEntry 01058 01059 // removed all the seems-to-be-useless stuff about Referenced Image Sequence 01060 // to avoid further troubles 01061 // imageElem 0008 1140 "" // Referenced Image Sequence 01062 // imageElem fffe e000 "" // 'no length' item : length to be set to 0xffffffff later 01063 // imageElem 0008 1150 "" // Referenced SOP Class UID : to be set/forged later 01064 // imageElem 0008 1155 "" // Referenced SOP Instance UID : to be set/forged later 01065 // imageElem fffe e00d "" // Item delimitation : length to be set to ZERO later 01066 01067 std::string referencedVal; 01068 // for all the relevant elements found in their own spot of the DicomDir.dic 01069 for( it = elemList.begin(); it != elemList.end(); ++it) 01070 { 01071 tmpGr = it->Group; 01072 tmpEl = it->Elem; 01073 01074 entry = DataEntry::New(tmpGr, tmpEl, it->VR); // dicomelements file was modified, to store VR 01075 entry->SetOffset(0); // just to avoid further missprinting 01076 01077 if ( header ) 01078 { 01079 // NULL when we Build Up (ex nihilo) a DICOMDIR 01080 // or when we add the META elems 01081 val = header->GetEntryString(tmpGr, tmpEl); 01082 } 01083 else 01084 { 01085 val = GDCM_UNFOUND; 01086 } 01087 01088 if ( val == GDCM_UNFOUND) 01089 { 01090 if ( tmpGr == 0x0004 ) // never present in File ! 01091 { 01092 switch (tmpEl) 01093 { 01094 case 0x1130: // File-set ID 01095 // force to the *end* File Name 01096 val = Util::GetName( path ); 01097 break; 01098 01099 case 0x1500: // Only used for image 01100 if ( header->GetFileName().substr(0, path.length()) != path ) 01101 { 01102 gdcmWarningMacro( "The base path of file name is incorrect"); 01103 val = header->GetFileName(); 01104 } 01105 else 01106 { 01107 // avoid the first '/' in File name ! 01108 if ( header->GetFileName().c_str()[path.length()] 01109 == GDCM_FILESEPARATOR ) 01110 val = &(header->GetFileName().c_str()[path.length()+1]); 01111 else 01112 val = &(header->GetFileName().c_str()[path.length()]); 01113 } 01114 break; 01115 01116 case 0x1510: // Referenced SOP Class UID in File 01117 referencedVal = header->GetEntryString(0x0008, 0x0016); 01118 // FIXME : probabely something to check 01119 val = referencedVal; 01120 break; 01121 01122 case 0x1511: // Referenced SOP Instance UID in File 01123 referencedVal = header->GetEntryString(0x0008, 0x0018); 01124 // FIXME : probabely something to check 01125 val = referencedVal; 01126 break; 01127 01128 case 0x1512: // Referenced Transfer Syntax UID in File 01129 referencedVal = header->GetEntryString(0x0002, 0x0010); 01130 // FIXME : probabely something to check 01131 val = referencedVal; 01132 break; 01133 01134 default : 01135 val = it->Value; 01136 } 01137 } 01138 else 01139 { 01140 // If the entry is not found in the Header, don't write its 'value' in the DICOMDIR ! 01141 entry->Delete(); 01142 continue; 01143 } 01144 } 01145 else 01146 { 01147 if ( header->GetEntryLength(tmpGr,tmpEl) == 0 ) 01148 { 01149 val = it->Value; 01150 // Don't polute the DICOMDIR with empty fields 01151 if (val == "") 01152 { 01153 entry->Delete(); 01154 continue; 01155 } 01156 } 01157 } 01158 01159 /* FIX later the pb of creating the 'Implementation Version Name'! 01160 01161 if (val == GDCM_UNFOUND) 01162 val = ""; 01163 01164 if ( tmpGr == 0x0002 && tmpEl == 0x0013) 01165 { 01166 // 'Implementation Version Name' 01167 std::string val = "GDCM "; 01168 val += Util::GetVersion(); 01169 } 01170 */ 01171 01172 entry->SetString( val ); // troubles expected when vr=SQ ... 01173 01174 if ( type == GDCM_DICOMDIR_META ) // fusible : should never print ! 01175 { 01176 gdcmDebugMacro("GDCM_DICOMDIR_META ?!? should never print that"); 01177 } 01178 01179 si->AddEntry(entry); 01180 entry->Delete(); 01181 } 01182 }
|
|
for each Header of the chained list, add/update the Patient/Study/Serie/Image info
Definition at line 927 of file gdcmDicomDir.cxx. References GDCM_NAME_SPACE::ElementSet::ClearEntry(), ClearPatient(), GDCM_DICOMDIR_IMAGE, GDCM_DICOMDIR_PATIENT, GDCM_DICOMDIR_SERIE, GDCM_DICOMDIR_STUDY, and SetElement(). 00928 { 00929 ClearEntry(); 00930 ClearPatient(); 00931 00932 std::string patPrevName = "", patPrevID = ""; 00933 std::string studPrevInstanceUID = "", studPrevID = ""; 00934 std::string serPrevInstanceUID = "", serPrevID = ""; 00935 00936 std::string patCurName, patCurID; 00937 std::string studCurInstanceUID, studCurID; 00938 std::string serCurInstanceUID, serCurID; 00939 00940 bool first = true; 00941 for( VectDocument::const_iterator it = list.begin(); 00942 it != list.end(); 00943 ++it ) 00944 { 00945 // get the current file characteristics 00946 patCurName = (*it)->GetEntryString(0x0010,0x0010); 00947 patCurID = (*it)->GetEntryString(0x0010,0x0011); 00948 studCurInstanceUID = (*it)->GetEntryString(0x0020,0x000d); 00949 studCurID = (*it)->GetEntryString(0x0020,0x0010); 00950 serCurInstanceUID = (*it)->GetEntryString(0x0020,0x000e); 00951 serCurID = (*it)->GetEntryString(0x0020,0x0011); 00952 00953 if ( patCurName != patPrevName || patCurID != patPrevID || first ) 00954 { 00955 SetElement(path, GDCM_DICOMDIR_PATIENT, *it); 00956 first = true; 00957 } 00958 00959 // if new Study, deal with 'STUDY' Elements 00960 if ( studCurInstanceUID != studPrevInstanceUID || studCurID != studPrevID 00961 || first ) 00962 { 00963 SetElement(path, GDCM_DICOMDIR_STUDY, *it); 00964 first = true; 00965 } 00966 00967 // if new Serie, deal with 'SERIE' Elements 00968 if ( serCurInstanceUID != serPrevInstanceUID || serCurID != serPrevID 00969 || first ) 00970 { 00971 SetElement(path, GDCM_DICOMDIR_SERIE, *it); 00972 } 00973 00974 // Always Deal with 'IMAGE' Elements 00975 SetElement(path, GDCM_DICOMDIR_IMAGE, *it); 00976 00977 patPrevName = patCurName; 00978 patPrevID = patCurID; 00979 studPrevInstanceUID = studCurInstanceUID; 00980 studPrevID = studCurID; 00981 serPrevInstanceUID = serCurInstanceUID; 00982 serPrevID = serCurID; 00983 first = false; 00984 } 00985 }
|
|
Accesses an existing DataEntry (i.e. a Dicom Element) and modifies its content with the given value.
Definition at line 195 of file gdcmDocEntrySet.cxx. References GDCM_NAME_SPACE::DataEntry::SetBinArea(), and GDCM_NAME_SPACE::DocEntry::SetLength(). 00196 { 00197 if (entry) 00198 { 00199 entry->SetLength(lgth); 00200 entry->SetBinArea(content); 00201 return true; 00202 } 00203 return false; 00204 }
|
|
Accesses an existing DocEntry (i.e. a Dicom Element) through its (group, element) and modifies its content with the given value.
Definition at line 158 of file gdcmDocEntrySet.cxx. References gdcmWarningMacro, and GDCM_NAME_SPACE::DocEntrySet::GetDataEntry(). Referenced by GDCM_NAME_SPACE::DocEntrySet::InsertEntryBinArea(), and GDCM_NAME_SPACE::FileHelper::SetEntryBinArea(). 00160 { 00161 DataEntry *entry = GetDataEntry(group, elem); 00162 if (!entry ) 00163 { 00164 gdcmWarningMacro( "No corresponding DataEntry " << std::hex << group << 00165 "," << elem << " element (try promotion first)."); 00166 return false; 00167 } 00168 00169 return SetEntryBinArea(content,lgth,entry); 00170 }
|
|
Accesses an existing DocEntry (i.e. a Dicom Element) and modifies its content with the given value.
Definition at line 178 of file gdcmDocEntrySet.cxx. References GDCM_NAME_SPACE::DataEntry::SetString(). 00179 { 00180 if (entry) 00181 { 00182 entry->SetString(content); 00183 return true; 00184 } 00185 return false; 00186 }
|
|
Accesses an existing DocEntry (i.e. a Dicom Element) through its (group, element) and modifies its content with the given value.
Definition at line 136 of file gdcmDocEntrySet.cxx. References gdcmWarningMacro, and GDCM_NAME_SPACE::DocEntrySet::GetDataEntry(). Referenced by GDCM_NAME_SPACE::File::AnonymizeFile(), GDCM_NAME_SPACE::DocEntrySet::InsertEntryString(), and GDCM_NAME_SPACE::FileHelper::SetEntryString(). 00138 { 00139 DataEntry *entry = GetDataEntry(group, elem); 00140 if (!entry ) 00141 { 00142 gdcmWarningMacro( "No corresponding DataEntry " << std::hex << group << 00143 "," << elem << " element (try promotion first)."); 00144 return false; 00145 } 00146 return SetEntryString(content,entry); 00147 }
|
|
Accessor to Filename.
Reimplemented from GDCM_NAME_SPACE::Document. Definition at line 73 of file gdcmDicomDir.h. Referenced by DoTheLoadingJob(). 00074 { ParseDir = false; if (Filename != fileName) 00075 Filename = fileName, IsDocumentModified = true;}
|
|
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 !
Definition at line 107 of file gdcmDocument.h. Referenced by GDCM_NAME_SPACE::SerieHelper::AddFileName(), CreateDicomDirChainedList(), vtkGdcmReader::LoadFileInformation(), and GDCM_NAME_SPACE::FileHelper::SetLoadMode(). 00107 { if (LoadMode != mode) 00108 LoadMode=mode, IsDocumentModified = true; }
|
|
during parsing, Header Elements too long are not loaded in memory
Definition at line 2182 of file gdcmDocument.cxx. References GDCM_NAME_SPACE::Document::MaxSizeLoadEntry. Referenced by GDCM_NAME_SPACE::Document::Document(). 02183 { 02184 if ( newSize < 0 ) 02185 { 02186 return; 02187 } 02188 if ((uint32_t)newSize >= (uint32_t)0xffffffff ) 02189 { 02190 MaxSizeLoadEntry = 0xffffffff; 02191 return; 02192 } 02193 MaxSizeLoadEntry = newSize; 02194 }
|
|
Sets the print level for the Dicom Header Elements.
Definition at line 47 of file gdcmBase.h. Referenced by GDCM_NAME_SPACE::FileHelper::Print(), and Print(). 00047 { PrintLevel = level; }
|
|
Set the shadow dictionary used.
Definition at line 341 of file gdcmDocument.cxx. References GDCM_NAME_SPACE::DictSet::GetDict(), GDCM_NAME_SPACE::Global::GetDicts(), and GDCM_NAME_SPACE::Document::RefShaDict. 00342 { 00343 RefShaDict = Global::GetDicts()->GetDict(dictName); 00344 return !RefShaDict; 00345 }
|
|
Set the shadow dictionary used.
Definition at line 331 of file gdcmDocument.cxx. References GDCM_NAME_SPACE::Document::RefShaDict. 00332 { 00333 RefShaDict = dict; 00334 return !RefShaDict; 00335 }
|
|
skips bytes inside the source file
Definition at line 126 of file gdcmDocument.h. Referenced by GDCM_NAME_SPACE::File::ComputeJPEGFragmentInfo(), GDCM_NAME_SPACE::File::ComputeRLEInfo(), GDCM_NAME_SPACE::Document::FindDocEntryLengthOBOrOW(), and GDCM_NAME_SPACE::Document::SkipDocEntry(). 00126 { Fp->seekg((long)nBytes, std::ios::cur);}
|
|
Unregister the object.
Definition at line 50 of file gdcmRefCounter.h. Referenced by GDCM_NAME_SPACE::Document::ReadNextDocEntry(), GDCM_NAME_SPACE::SQItem::RemoveEntry(), GDCM_NAME_SPACE::ElementSet::RemoveEntry(), and GDCM_NAME_SPACE::FileHelper::~FileHelper(). 00051 { 00052 //std::cout <<"================Unreg " << typeid(*this).name() << std::endl; 00053 RefCount--; 00054 if(RefCount<=0) 00055 delete this; 00056 }
|
|
writes on disc a DICOMDIR \ warning does NOT add the missing elements in the header : it's up to the user doing it !
Definition at line 475 of file gdcmDicomDir.cxx. References GDCM_NAME_SPACE::binary_write(), GDCM_NAME_SPACE::ExplicitVR, gdcmWarningMacro, GetMeta(), and GDCM_NAME_SPACE::DicomDirMeta::WriteContent(). 00476 { 00477 int i; 00478 uint16_t sq[6] = { 0x0004, 0x1220, 0x5153, 0x0000, 0xffff, 0xffff }; 00479 uint16_t sqt[4]= { 0xfffe, 0xe0dd, 0x0000, 0x0000 }; 00480 00481 std::ofstream *fp = new std::ofstream(fileName.c_str(), 00482 std::ios::out | std::ios::binary); 00483 if ( !fp ) 00484 { 00485 gdcmWarningMacro("Failed to open(write) File: " << fileName.c_str()); 00486 return false; 00487 } 00488 00489 char filePreamble[128]; 00490 memset(filePreamble, 0, 128); 00491 fp->write(filePreamble, 128); 00492 binary_write( *fp, "DICM"); 00493 00494 DicomDirMeta *ptrMeta = GetMeta(); 00495 ptrMeta->WriteContent(fp, ExplicitVR, true); 00496 00497 // force writing 0004|1220 [SQ ], that CANNOT exist within DicomDirMeta 00498 for(i=0;i<6;++i) 00499 { 00500 binary_write(*fp, sq[i]); 00501 } 00502 00503 for(ListDicomDirPatient::iterator cc = Patients.begin(); 00504 cc != Patients.end(); 00505 ++cc ) 00506 { 00507 (*cc)->WriteContent( fp, ExplicitVR, false ); 00508 } 00509 00510 // force writing Sequence Delimitation Item 00511 for(i=0;i<4;++i) 00512 { 00513 binary_write(*fp, sqt[i]); // fffe e0dd 0000 0000 00514 } 00515 00516 fp->close(); 00517 delete fp; 00518 00519 return true; 00520 }
|
|
Writes the Header Entries (Dicom Elements) from the H Table.
Implements GDCM_NAME_SPACE::DocEntrySet. Definition at line 52 of file gdcmElementSet.cxx. References GDCM_NAME_SPACE::ACR, GDCM_NAME_SPACE::ACR_LIBIDO, GDCM_NAME_SPACE::ElementSet::MayIWrite(), and GDCM_NAME_SPACE::ElementSet::TagHT. Referenced by GDCM_NAME_SPACE::Document::WriteContent(). 00053 { 00054 bool insideMetaElements = false; 00055 bool yetOutsideMetaElements = false; 00056 00057 for (TagDocEntryHT::const_iterator i = TagHT.begin(); 00058 i != TagHT.end(); 00059 ++i) 00060 { 00061 int group = (i->second)->GetGroup(); 00062 00063 if (yetOutsideMetaElements==false && group == 0x0002) 00064 insideMetaElements = true; 00065 00066 if (insideMetaElements == true && group != 0x0002) 00067 { 00068 yetOutsideMetaElements = true; 00069 insideMetaElements = false; 00070 } 00071 00072 // depending on the gdcm::Document type 00073 // (gdcm::File; gdcm::DicomDir, (more to come ?) 00074 // some groups *cannot* be present. 00075 // We hereby protect gdcm for writting stupid things 00076 // if they were found in the original document. 00077 if ( !MayIWrite( group ) ) 00078 continue; 00079 00080 // Skip 'Group Length' element, since it may be wrong. 00081 // except for Group 0x0002 00082 // ( keep it as well for Group 0x0008 of ACR Files, 00083 // since some ACR readers *need* it ) 00084 00085 if ( (i->second)->GetElement() != 0x0000 00086 || 00087 ( (i->second)->GetGroup() == 0x0002 00088 ||( (filetype == ACR || filetype == ACR_LIBIDO ) && (i->second)->GetGroup() == 0x0008 ) ) 00089 ) 00090 { 00091 // There are DocEntries, written recursively 00092 i->second->WriteContent(fp, filetype, insideMetaElements ); 00093 } 00094 } 00095 }
|
|
Writes in a file all the Entries (Dicom Elements).
Definition at line 696 of file gdcmDocument.cxx. References GDCM_NAME_SPACE::ExplicitVR, GDCM_NAME_SPACE::ImplicitVR, GDCM_NAME_SPACE::JPEG, GDCM_NAME_SPACE::JPEG2000, and GDCM_NAME_SPACE::ElementSet::WriteContent(). Referenced by GDCM_NAME_SPACE::File::Write(). 00697 { 00698 // Skip if user wants to write an ACR-NEMA file 00699 00700 if ( filetype == ImplicitVR || filetype == ExplicitVR || 00701 filetype == JPEG || filetype == JPEG2000 ) 00702 { 00703 // writing Dicom File Preamble 00704 char filePreamble[128]; 00705 memset(filePreamble, 0, 128); 00706 fp->write(filePreamble, 128); 00707 fp->write("DICM", 4); 00708 } 00709 /* 00710 * \todo rewrite later, if really usefull 00711 * - 'Group Length' element is optional in DICOM 00712 * - but un-updated odd groups lengthes can causes pb 00713 * (xmedcon breaker) 00714 * 00715 * if ( (filetype == ImplicitVR) || (filetype == ExplicitVR) ) 00716 * UpdateGroupLength(false,filetype); 00717 * if ( filetype == ACR) 00718 * UpdateGroupLength(true,ACR); 00719 * 00720 * --> Computing group length for groups with embeded Sequences 00721 * --> was too much tricky / we were [in a hurry / too lazy] 00722 * --> We don't write the element 0x0000 (group length) 00723 */ 00724 00725 ElementSet::WriteContent(fp, filetype, false); // This one is recursive 00726 }
|
|
Definition at line 235 of file gdcmDocument.h. Referenced by GDCM_NAME_SPACE::Document::CallStartMethod(), CreateDicomDirChainedList(), DoTheLoadingJob(), and Initialize(). |
|
to allow any inner method to know current tag Element number
Definition at line 252 of file gdcmDocument.h. Referenced by GDCM_NAME_SPACE::Document::ReadNextDocEntry(). |
|
to allow any inner method to know current tag Group number
Definition at line 250 of file gdcmDocument.h. Referenced by GDCM_NAME_SPACE::Document::FindDocEntryVR(), and GDCM_NAME_SPACE::Document::ReadNextDocEntry(). |
|
Refering underlying filename.
Definition at line 131 of file gdcmDocument.h. Referenced by GDCM_NAME_SPACE::File::AnonymizeNoLoad(), GDCM_NAME_SPACE::Document::DoTheLoadingDocumentJob(), and GDCM_NAME_SPACE::Document::OpenFile(). |
|
ACR, ACR_LIBIDO, ExplicitVR, ImplicitVR, Unknown.
Definition at line 157 of file gdcmDocument.h. Referenced by GDCM_NAME_SPACE::Document::CheckSwap(), GDCM_NAME_SPACE::Document::Document(), GDCM_NAME_SPACE::Document::DoTheLoadingDocumentJob(), GDCM_NAME_SPACE::Document::FindDocEntryVR(), GDCM_NAME_SPACE::Document::GetFileType(), GDCM_NAME_SPACE::Document::HandleOutOfGroup0002(), GDCM_NAME_SPACE::Document::Initialize(), GDCM_NAME_SPACE::Document::IsParsable(), IsReadable(), and GDCM_NAME_SPACE::Document::ReadNextDocEntry(). |
|
File Pointer, opened during Document parsing.
Definition at line 154 of file gdcmDocument.h. Referenced by GDCM_NAME_SPACE::File::ComputeJPEGFragmentInfo(), GDCM_NAME_SPACE::File::ComputeRLEInfo(), GDCM_NAME_SPACE::Document::Document(), GDCM_NAME_SPACE::Document::DoTheLoadingDocumentJob(), GDCM_NAME_SPACE::File::DoTheLoadingJob(), DoTheLoadingJob(), GDCM_NAME_SPACE::File::ReadEncapsulatedBasicOffsetTable(), and GDCM_NAME_SPACE::File::ReadTag(). |
|
whether we already parsed group 0002 (Meta Elements)
Definition at line 148 of file gdcmDocument.h. Referenced by GDCM_NAME_SPACE::Document::Document(), GDCM_NAME_SPACE::Document::DoTheLoadingDocumentJob(), GDCM_NAME_SPACE::Document::HandleOutOfGroup0002(), and GDCM_NAME_SPACE::Document::ReadNextDocEntry(). |
|
whether file has a DCM Preamble
Definition at line 151 of file gdcmDocument.h. Referenced by GDCM_NAME_SPACE::Document::OpenFile(), and GDCM_NAME_SPACE::Document::ReadNextDocEntry(). |
|
After opening the file, we read HEADER_LENGTH_TO_READ bytes.
Definition at line 160 of file gdcmDocument.h. |
|
Whether the gdcm::Document is already parsed/loaded : False from the creation of the gdcm::Document untill gdcm::Document:Load().
Definition at line 180 of file gdcmDocument.h. Referenced by GDCM_NAME_SPACE::Document::Document(), and GDCM_NAME_SPACE::Document::DoTheLoadingDocumentJob(). |
|
Whether the gdcm::Document was modified since the last Load().
Definition at line 183 of file gdcmDocument.h. Referenced by GDCM_NAME_SPACE::Document::Document(), and GDCM_NAME_SPACE::Document::DoTheLoadingDocumentJob(). |
|
Definition at line 156 of file gdcmDicomDir.h. Referenced by Copy(), GetFirstPatient(), and GetNextPatient(). |
|
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 175 of file gdcmDocument.h. Referenced by CreateDicomDirChainedList(), and GDCM_NAME_SPACE::Document::Document(). |
|
Elements whose value is longer than MAX_SIZE_LOAD_ELEMENT_VALUE are NOT loaded.
Definition at line 163 of file gdcmDocument.h. Referenced by GDCM_NAME_SPACE::Document::Document(). |
|
Size threshold above which an element value will NOT be loaded in memory (to avoid loading the image/volume itself). By default, this upper bound is fixed to 1024 bytes (which might look reasonable when one considers the definition of the various VR contents).
Definition at line 247 of file gdcmDocument.h. Referenced by GDCM_NAME_SPACE::Document::LoadDocEntry(), and GDCM_NAME_SPACE::Document::SetMaxSizeLoadEntry(). |
|
Pointer on *the* DicomDirObject 'DicomDirMeta Elements'.
Definition at line 152 of file gdcmDicomDir.h. Referenced by Copy(), Initialize(), IsReadable(), NewMeta(), Print(), SetElement(), and ~DicomDir(). |
|
value of the ??? for any progress bar
Definition at line 159 of file gdcmDicomDir.h. Referenced by DicomDir(), DoTheLoadingJob(), and Load(). |
|
Chained list of DicomDirPatient (to be exploited hierarchicaly).
Definition at line 155 of file gdcmDicomDir.h. Referenced by AddImageToEnd(), AddPatientToEnd(), AddPrivateToEnd(), AddSerieToEnd(), AddStudyToEnd(), AddVisitToEnd(), Anonymize(), ClearPatient(), Copy(), GetFirstPatient(), GetNextPatient(), IsReadable(), and Print(). |
|
To be able to backtrack (Private Sequence, Implicit VR related pb).
Definition at line 128 of file gdcmDocEntrySet.h. Referenced by GDCM_NAME_SPACE::Document::Backtrack(), and GDCM_NAME_SPACE::DocEntrySet::DocEntrySet(). |
|
Amount of printed details for each Dicom Entries : 0 : stands for the least detail level.
Definition at line 55 of file gdcmBase.h. Referenced by GDCM_NAME_SPACE::SeqEntry::Print(), GDCM_NAME_SPACE::FileHelper::Print(), GDCM_NAME_SPACE::ElementSet::Print(), GDCM_NAME_SPACE::DocEntry::Print(), GDCM_NAME_SPACE::DictEntry::Print(), GDCM_NAME_SPACE::DicomDirStudy::Print(), GDCM_NAME_SPACE::DicomDirSerie::Print(), GDCM_NAME_SPACE::DicomDirPatient::Print(), GDCM_NAME_SPACE::DicomDirMeta::Print(), Print(), and GDCM_NAME_SPACE::DataEntry::Print(). |
|
value of the ??? for any progress bar
Definition at line 234 of file gdcmDocument.h. Referenced by GDCM_NAME_SPACE::Document::CallEndMethod(), GDCM_NAME_SPACE::Document::CallStartMethod(), CreateDicomDirChainedList(), DoTheLoadingJob(), and Initialize(). |
|
Public dictionary used to parse this header.
Definition at line 238 of file gdcmDocument.h. Referenced by GDCM_NAME_SPACE::Document::GetPubDict(), and GDCM_NAME_SPACE::Document::Initialize(). |
|
Optional "shadow dictionary" (private elements) used to parse this header.
Definition at line 241 of file gdcmDocument.h. Referenced by GDCM_NAME_SPACE::Document::GetShaDict(), GDCM_NAME_SPACE::Document::Initialize(), and GDCM_NAME_SPACE::Document::SetShaDict(). |
|
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 :
Definition at line 145 of file gdcmDocument.h. Referenced by GDCM_NAME_SPACE::Document::CheckSwap(), GDCM_NAME_SPACE::Document::Document(), GDCM_NAME_SPACE::Document::SwapDouble(), GDCM_NAME_SPACE::Document::SwapLong(), GDCM_NAME_SPACE::Document::SwapShort(), and GDCM_NAME_SPACE::Document::SwitchByteSwapCode(). |
|
User supplied list of elements to Anonymize.
Definition at line 166 of file gdcmDocument.h. Referenced by GDCM_NAME_SPACE::File::AddAnonymizeElement(), GDCM_NAME_SPACE::File::AnonymizeFile(), and GDCM_NAME_SPACE::File::AnonymizeNoLoad(). |
|
User supplied list of elements to force Load.
Definition at line 169 of file gdcmDocument.h. Referenced by GDCM_NAME_SPACE::Document::AddForceLoadElement(). |