#include <gdcmDicomDir.h>
Inheritance diagram for gdcm::DicomDir:
Public Types | |
typedef void( | Method )(void *) |
enum | DicomDirType { GDCM_DICOMDIR_NONE, GDCM_DICOMDIR_META, GDCM_DICOMDIR_PATIENT, GDCM_DICOMDIR_STUDY, GDCM_DICOMDIR_SERIE, GDCM_DICOMDIR_IMAGE } |
Types of the DicomDirObject within the DicomDir. More... | |
typedef std::list< Element > | ListElements |
Public Member Functions | |
DicomDir (std::string const &filename, bool parseDir=false) | |
Constructor Parses recursively the directory and creates the DicomDir or uses an already built DICOMDIR, depending on 'parseDir' value. | |
DicomDir () | |
Constructor : creates an empty DicomDir. | |
~DicomDir () | |
Canonical destructor. | |
void | Print (std::ostream &os=std::cout, std::string const &indent="") |
Canonical Printer. | |
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. | |
void | ParseDirectory () |
fills the whole structure, starting from a root Directory | |
void | SetStartMethod (DicomDir::Method *method, void *arg=NULL, DicomDir::Method *argDelete=NULL) |
Set the start method to call when the parsing of the directory starts. | |
void | SetProgressMethod (DicomDir::Method *method, void *arg=NULL, DicomDir::Method *argDelete=NULL) |
Set the progress method to call when the parsing of the directory progress. | |
void | SetEndMethod (DicomDir::Method *method, void *arg=NULL, DicomDir::Method *argDelete=NULL) |
Set the end method to call when the parsing of the directory ends. | |
void | SetStartMethodArgDelete (DicomDir::Method *m) |
Set the method to delete the argument The argument is destroyed when the method is changed or when the class is destroyed. | |
void | SetProgressMethodArgDelete (DicomDir::Method *m) |
Set the method to delete the argument The argument is destroyed when the method is changed or when the class is destroyed. | |
void | SetEndMethodArgDelete (DicomDir::Method *m) |
Set the method to delete the argument The argument is destroyed when the method is changed or when the class is destroyed. | |
float | GetProgress () |
GetProgress GetProgress. | |
void | AbortProgress () |
AbortProgress AbortProgress. | |
bool | IsAborted () |
IsAborted IsAborted. | |
bool | WriteDicomDir (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 ! | |
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 | 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 ) | |
uint16_t | SwapShort (uint16_t) |
Swaps the bytes so they agree with the processor order. | |
uint32_t | SwapLong (uint32_t) |
Swaps back the bytes of 4-byte long integer accordingly to processor order. | |
uint16_t | UnswapShort (uint16_t a) |
Unswaps back the bytes of 2-bytes long integer so they agree with the processor order. | |
uint32_t | UnswapLong (uint32_t a) |
Unswaps back the bytes of 4-byte long integer so they agree with the processor order. | |
const std::string & | GetFileName () const |
Accessor to Filename. | |
void | SetFileName (std::string const &fileName) |
Accessor to Filename. | |
std::ifstream * | OpenFile () |
Tries to open the file Document::Filename and checks the preamble when existing. | |
bool | CloseFile () |
closes the file | |
void | WriteContent (std::ofstream *fp, FileType type) |
Writes in a file all the Header Entries (Dicom Elements). | |
virtual void | LoadEntryBinArea (uint16_t group, uint16_t elem) |
Loads (from disk) the element content when a string is not suitable. | |
virtual void | LoadEntryBinArea (BinEntry *entry) |
Loads (from disk) the element content when a string is not suitable. | |
void | LoadDocEntrySafe (DocEntry *entry) |
Loads the element while preserving the current underlying file position indicator as opposed to LoadDocEntry that modifies it. | |
bool | operator< (Document &document) |
Compares two documents, according to DicomDir rules. | |
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. | |
bool | RemoveEntryNoDestroy (DocEntry *EntryToRemove) |
Clear the hash table from given entry BUT keep 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. | |
virtual std::string | GetEntryValue (uint16_t group, uint16_t elem) |
Get the "std::string representable" value of the Dicom entry. | |
virtual void * | GetEntryBinArea (uint16_t group, uint16_t elem) |
Gets (from Header) a 'non string' element value. | |
virtual int | GetEntryLength (uint16_t group, uint16_t elem) |
Searches within Header Entries (Dicom Elements) parsed with the public and private dictionaries for the value length of a given tag.. | |
virtual std::string | GetEntryVR (uint16_t group, uint16_t elem) |
Searches within Header Entries (Dicom Elements) parsed with the public [and private dictionaries] for the element value representation of a given tag.. Obtaining the VR (Value Representation) might be needed by caller to convert the string typed content to caller's native type (think of C++ vs Python). The VR is actually of a higher level of semantics than just the native C++ type. | |
ValEntry * | GetValEntry (uint16_t group, uint16_t elem) |
Same as Document::GetDocEntry except it only returns a result when the corresponding entry is of type ValEntry. | |
BinEntry * | GetBinEntry (uint16_t group, uint16_t elem) |
Same as Document::GetDocEntry except it only returns a result when the corresponding entry is of type BinEntry. | |
SeqEntry * | GetSeqEntry (uint16_t group, uint16_t elem) |
Same as Document::GetDocEntry except it only returns a result when the corresponding entry is of type SeqEntry. | |
bool | SetValEntry (std::string const &content, uint16_t group, uint16_t elem) |
Accesses an existing DocEntry (i.e. a Dicom Element) through it's (group, element) and modifies it's content with the given value. | |
bool | SetValEntry (std::string const &content, ValEntry *entry) |
Accesses an existing DocEntry (i.e. a Dicom Element) and modifies it's content with the given value. | |
bool | SetBinEntry (uint8_t *content, int lgth, uint16_t group, uint16_t elem) |
Accesses an existing DocEntry (i.e. a Dicom Element) through it's (group, element) and modifies it's content with the given value. | |
bool | SetBinEntry (uint8_t *content, int lgth, BinEntry *entry) |
Accesses an existing BinEntry (i.e. a Dicom Element) and modifies it's content with the given value. | |
ValEntry * | InsertValEntry (std::string const &value, uint16_t group, uint16_t elem, TagName const &vr=GDCM_UNKNOWN) |
Modifies the value of a given Doc Entry (Dicom Element) when it exists. Create it with the given value when unexistant. | |
BinEntry * | InsertBinEntry (uint8_t *binArea, int lgth, uint16_t group, uint16_t elem, TagName const &vr=GDCM_UNKNOWN) |
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) |
Modifies the value of a given Doc Entry (Dicom Element) when it exists. Creates it when unexistant. | |
virtual bool | CheckIfEntryExist (uint16_t group, uint16_t elem) |
Checks if a given Dicom Element exists within the H table. | |
ValEntry * | NewValEntry (uint16_t group, uint16_t elem, TagName const &vr=GDCM_UNKNOWN) |
Build a new Val Entry from all the low level arguments. Check for existence of dictionary entry, and build a default one when absent. | |
BinEntry * | NewBinEntry (uint16_t group, uint16_t elem, TagName const &vr=GDCM_UNKNOWN) |
Build a new Bin Entry from all the low level arguments. Check for existence of dictionary entry, and build a default one when absent. | |
SeqEntry * | NewSeqEntry (uint16_t group, uint16_t elem) |
Build a new Seq Entry from all the low level arguments. Check for existence of dictionary entry, and build a default one when absent. | |
DictEntry * | NewVirtualDictEntry (uint16_t group, uint16_t elem, TagName const &vr=GDCM_UNKNOWN, TagName const &vm=GDCM_UNKNOWN, TagName const &name=GDCM_UNKNOWN) |
Request a new virtual dict entry to the dict set. | |
void | SetPrintLevel (int level) |
Sets the print level for the Dicom Header Elements. | |
int | GetPrintLevel () |
Gets the print level for the Dicom Entries. | |
Protected Member Functions | |
void | CreateDicomDirChainedList (std::string const &path) |
create a Document-like chained list from a root Directory | |
void | CallStartMethod () |
CallStartMethod. | |
void | CallProgressMethod () |
CallProgressMethod. | |
void | CallEndMethod () |
CallEndMethod. | |
uint16_t | ReadInt16 () throw ( FormatError ) |
Reads a supposed to be 16 Bits integer (swaps it depending on processor endianness). | |
uint32_t | ReadInt32 () throw ( FormatError ) |
Reads a supposed to be 32 Bits integer (swaps it depending on processor endianness). | |
void | SkipBytes (uint32_t) |
skips bytes inside the source file | |
int | ComputeGroup0002Length (FileType filetype) |
Re-computes the length of a ACR-NEMA/Dicom group from a DcmHeader. | |
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. | |
DictEntry * | GetDictEntry (uint16_t group, uint16_t elem, TagName const &vr) |
Searches [both] the public [and the shadow dictionary (when they exist)] for the presence of the DictEntry with given group and element, and create a new virtual DictEntry if necessary. | |
Protected Attributes | |
std::string | Filename |
Refering underlying filename. | |
int | SwapCode |
Swap code gives an information on the byte order of a supposed to be an int32, as it's read on disc (depending on the image Transfer Syntax *and* on the processor endianess) as opposed as it should in memory to be dealt as an int32. For instance :
| |
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 | AnonymizeList |
List of element to Anonymize. | |
int | PrintLevel |
Amount of printed details for each Dicom Entries : 0 : stands for the least detail level. | |
Static Protected Attributes | |
const unsigned int | HEADER_LENGTH_TO_READ |
After opening the file, we read HEADER_LENGTH_TO_READ bytes. | |
const unsigned int | MAX_SIZE_LOAD_ELEMENT_VALUE = 0xfff |
Elements whose value is longer than MAX_SIZE_LOAD_ELEMENT_VALUE are NOT loaded. | |
const unsigned int | MAX_SIZE_PRINT_ELEMENT_VALUE = 0x7fffffff |
Elements whose value is longer than MAX_SIZE_PRINT_ELEMENT_VALUE are NOT printed. | |
Private Member Functions | |
void | Initialize () |
Sets all fields to NULL. | |
void | CreateDicomDir () |
create a 'DicomDir' from a DICOMDIR Header | |
bool | AddPatientToEnd (DicomDirPatient *dd) |
AddPatientToEnd. | |
bool | AddStudyToEnd (DicomDirStudy *dd) |
AddStudyToEnd. | |
bool | AddSerieToEnd (DicomDirSerie *dd) |
AddSerieToEnd. | |
bool | AddImageToEnd (DicomDirImage *dd) |
AddImageToEnd. | |
void | SetElements (std::string const &path, VectDocument const &list) |
for each Header of the chained list, add/update the Patient/Study/Serie/Image info | |
void | SetElement (std::string const &path, DicomDirType type, Document *header) |
adds to the HTable the Entries (Dicom Elements) corresponding to the given type | |
void | MoveSQItem (DocEntrySet *dst, DocEntrySet *src) |
Move the content of the source SQItem to the destination SQItem Only DocEntry's are moved. | |
Static Private Member Functions | |
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 |
Method * | StartMethod |
pointer to the initialisation method for any progress bar | |
Method * | ProgressMethod |
pointer to the incrementation method for any progress bar | |
Method * | EndMethod |
pointer to the termination method for any progress bar | |
Method * | StartMethodArgDelete |
pointer to the ??? method for any progress bar | |
Method * | ProgressMethodArgDelete |
pointer to the ??? method for any progress bar | |
Method * | EndMethodArgDelete |
pointer to the ??? method for any progress bar | |
void * | StartArg |
pointer to the ??? for any progress bar | |
void * | ProgressArg |
pointer to the ??? for any progress bar | |
void * | EndArg |
pointer to the ??? for any progress bar | |
float | Progress |
value of the ??? for any progress bar | |
bool | Abort |
value of the ??? for any progress bar |
Definition at line 49 of file gdcmDicomDir.h.
|
Definition at line 47 of file gdcmDocument.h. |
|
Definition at line 52 of file gdcmDicomDir.h. Referenced by SetEndMethod(), SetEndMethodArgDelete(), SetProgressMethod(), SetProgressMethodArgDelete(), SetStartMethod(), and SetStartMethodArgDelete(). |
|
Types of the DicomDirObject within the DicomDir.
Definition at line 106 of file gdcmDicomDir.h.
00107 { 00108 GDCM_DICOMDIR_NONE, 00109 GDCM_DICOMDIR_META, 00110 GDCM_DICOMDIR_PATIENT, 00111 GDCM_DICOMDIR_STUDY, 00112 GDCM_DICOMDIR_SERIE, 00113 GDCM_DICOMDIR_IMAGE 00114 } DicomDirType; |
|
Constructor Parses recursively the directory and creates the DicomDir or uses an already built DICOMDIR, depending on 'parseDir' value.
Definition at line 131 of file gdcmDicomDir.cxx. References CreateDicomDir(), gdcmWarningMacro, gdcm::ElementSet::GetDocEntry(), gdcm::ElementSet::GetFirstEntry(), Initialize(), NewMeta(), ParseDirectory(), and gdcm::Document::SetFileName().
00131 : 00132 Document( fileName ) 00133 { 00134 // At this step, Document constructor is already executed, 00135 // whatever user passed (a root directory or a DICOMDIR) 00136 // and whatever the value of parseDir was. 00137 // (nothing is cheked in Document constructor, to avoid overhead) 00138 00139 Initialize(); // sets all private fields to NULL 00140 00141 // if user passed a root directory, sure we didn't get anything 00142 00143 if ( GetFirstEntry() == 0 ) // when user passed a Directory to parse 00144 { 00145 if (!parseDir) 00146 gdcmWarningMacro( "Entry HT empty for file: "<<fileName); 00147 00148 // Only if user passed a root directory 00149 // ------------------------------------ 00150 if ( fileName == "." ) 00151 { 00152 // user passed '.' as Name 00153 // we get current directory name 00154 char dummy[1000]; 00155 getcwd(dummy, (size_t)1000); 00156 SetFileName( dummy ); // will be converted into a string 00157 } 00158 00159 if ( parseDir ) // user asked for a recursive parsing of a root directory 00160 { 00161 NewMeta(); 00162 00163 gdcmWarningMacro( "Parse directory and create the DicomDir"); 00164 ParseDirectory(); 00165 } 00166 else 00167 { 00169 // NO ! user may just call ParseDirectory() *after* constructor 00170 } 00171 } 00172 // Only if user passed a DICOMDIR 00173 // ------------------------------ 00174 else 00175 { 00176 // Directory record sequence 00177 DocEntry *e = GetDocEntry(0x0004, 0x1220); 00178 if ( !e ) 00179 { 00180 gdcmWarningMacro( "NO 'Directory record sequence' (0x0004,0x1220)" 00181 << " in file " << fileName); 00184 } 00185 else 00186 CreateDicomDir(); 00187 } 00188 } |
|
Constructor : creates an empty DicomDir.
Definition at line 112 of file gdcmDicomDir.cxx. References Initialize(), and NewMeta().
00113 :Document( ) 00114 { 00115 Initialize(); // sets all private fields to NULL 00116 NewMeta(); 00117 } |
|
Canonical destructor.
Definition at line 193 of file gdcmDicomDir.cxx. References ClearPatient(), MetaElems, SetEndMethod(), SetProgressMethod(), and SetStartMethod().
00194 { 00195 SetStartMethod(NULL); 00196 SetProgressMethod(NULL); 00197 SetEndMethod(NULL); 00198 00199 ClearPatient(); 00200 if ( MetaElems ) 00201 { 00202 delete MetaElems; 00203 } 00204 } |
|
AbortProgress AbortProgress.
Definition at line 98 of file gdcmDicomDir.h.
00098 { Abort = true; }; |
|
add a new Dicom Element pointer to the H Table
Implements gdcm::DocEntrySet. Definition at line 69 of file gdcmElementSet.cxx. References gdcmWarningMacro, gdcm::DocEntry::GetKey(), gdcm::ElementSet::TagHT, and gdcm::TagKey. Referenced by gdcm::File::File(), gdcm::DocEntryArchive::Push(), and gdcm::DocEntryArchive::Restore().
00070 { 00071 const TagKey &key = newEntry->GetKey(); 00072 00073 if( TagHT.count(key) == 1 ) 00074 { 00075 gdcmWarningMacro( "Key already present: " << key.c_str()); 00076 return false; 00077 } 00078 else 00079 { 00080 TagHT.insert(TagDocEntryHT::value_type(newEntry->GetKey(), newEntry)); 00081 return true; 00082 } 00083 } |
|
AddImageToEnd.
Definition at line 759 of file gdcmDicomDir.cxx. References gdcm::DicomDirSerie::AddImage(), gdcm::DicomDirStudy::GetLastSerie(), and Patients. Referenced by CreateDicomDir(), and SetElement().
00760 { 00761 if( Patients.size() > 0 ) 00762 { 00763 ListDicomDirPatient::iterator itp = Patients.end(); 00764 itp--; 00765 00766 DicomDirStudy *study = (*itp)->GetLastStudy(); 00767 if( study ) 00768 { 00769 DicomDirSerie *serie = study->GetLastSerie(); 00770 if( serie ) 00771 { 00772 serie->AddImage(dd); 00773 return true; 00774 } 00775 } 00776 } 00777 return false; 00778 } |
|
AddPatientToEnd.
Definition at line 712 of file gdcmDicomDir.cxx. References Patients. Referenced by CreateDicomDir(), NewPatient(), and SetElement().
00713 { 00714 Patients.push_back(dd); 00715 return true; 00716 } |
|
AddSerieToEnd.
Definition at line 738 of file gdcmDicomDir.cxx. References gdcm::DicomDirStudy::AddSerie(), and Patients. Referenced by CreateDicomDir(), and SetElement().
|
|
AddStudyToEnd.
Definition at line 722 of file gdcmDicomDir.cxx. References Patients. Referenced by CreateDicomDir(), and SetElement().
|
|
CallEndMethod.
Definition at line 573 of file gdcmDicomDir.cxx. References EndArg, EndMethod, and Progress. Referenced by CreateDicomDirChainedList().
|
|
CallProgressMethod.
Definition at line 562 of file gdcmDicomDir.cxx. References ProgressArg, and ProgressMethod. Referenced by CreateDicomDirChainedList().
00563 { 00564 if( ProgressMethod ) 00565 { 00566 ProgressMethod( ProgressArg ); 00567 } 00568 } |
|
CallStartMethod.
Definition at line 549 of file gdcmDicomDir.cxx. References Abort, Progress, StartArg, and StartMethod. Referenced by CreateDicomDirChainedList().
00550 { 00551 Progress = 0.0f; 00552 Abort = false; 00553 if( StartMethod ) 00554 { 00555 StartMethod( StartArg ); 00556 } 00557 } |
|
Checks if a given Dicom Element exists within the H table.
Definition at line 434 of file gdcmDocEntrySet.cxx. References gdcm::DocEntrySet::GetDocEntry().
00435 { 00436 return GetDocEntry(group,elem)!=NULL; 00437 } |
|
delete all entries in the ElementSet
Implements gdcm::DocEntrySet. Definition at line 125 of file gdcmElementSet.cxx. References gdcm::ElementSet::TagHT. Referenced by CreateDicomDir(), SetElements(), and gdcm::ElementSet::~ElementSet().
00126 { 00127 for(TagDocEntryHT::iterator cc = TagHT.begin();cc != TagHT.end(); ++cc) 00128 { 00129 if ( cc->second ) 00130 { 00131 delete cc->second; 00132 } 00133 } 00134 TagHT.clear(); 00135 } |
|
Remove all Patients.
Definition at line 284 of file gdcmDicomDir.cxx. References Patients. Referenced by SetElements(), and ~DicomDir().
|
|
closes the file
Definition at line 464 of file gdcmDocument.cxx. References gdcm::Document::Fp. Referenced by gdcm::Document::Document(), gdcm::File::File(), gdcm::FileHelper::GetRaw(), gdcm::Document::LoadEntryBinArea(), and gdcm::Document::OpenFile().
|
|
Re-computes the length of a ACR-NEMA/Dicom group from a DcmHeader.
Definition at line 717 of file gdcmDocument.cxx. References gdcm::ExplicitVR, gdcm::DocEntry::GetElement(), gdcm::ElementSet::GetFirstEntry(), gdcm::DocEntry::GetGroup(), gdcm::DocEntry::GetLength(), gdcm::ElementSet::GetNextEntry(), and gdcm::DocEntry::GetVR(). Referenced by gdcm::File::Write().
00718 { 00719 uint16_t gr; 00720 std::string vr; 00721 00722 int groupLength = 0; 00723 bool found0002 = false; 00724 00725 // for each zero-level Tag in the DCM Header 00726 DocEntry *entry = GetFirstEntry(); 00727 while( entry ) 00728 { 00729 gr = entry->GetGroup(); 00730 00731 if( gr == 0x0002 ) 00732 { 00733 found0002 = true; 00734 00735 if( entry->GetElement() != 0x0000 ) 00736 { 00737 vr = entry->GetVR(); 00738 00739 if( filetype == ExplicitVR ) 00740 { 00741 if ( (vr == "OB") || (vr == "OW") || (vr == "SQ") ) 00742 { 00743 // explicit VR AND OB, OW, SQ : 4 more bytes 00744 groupLength += 4; 00745 } 00746 } 00747 groupLength += 2 + 2 + 4 + entry->GetLength(); 00748 } 00749 } 00750 else if (found0002 ) 00751 break; 00752 00753 entry = GetNextEntry(); 00754 } 00755 return groupLength; 00756 } |
|
create a 'DicomDir' from a DICOMDIR Header
Definition at line 608 of file gdcmDicomDir.cxx. References AddImageToEnd(), AddPatientToEnd(), AddSerieToEnd(), AddStudyToEnd(), gdcm::ElementSet::ClearEntry(), gdcmErrorMacro, gdcmWarningMacro, gdcm::SQItem::GetDocEntry(), gdcm::ElementSet::GetDocEntry(), gdcm::SeqEntry::GetFirstSQItem(), gdcm::SeqEntry::GetNextSQItem(), gdcm::ContentEntry::GetValue(), MoveSQItem(), and NewMeta(). Referenced by DicomDir(), and ParseDirectory().
00609 { 00610 // The SeqEntries of "Directory Record Sequence" are parsed. 00611 // When a DicomDir tag ("PATIENT", "STUDY", "SERIE", "IMAGE") is found : 00612 // 1 - we save the beginning iterator 00613 // 2 - we continue to parse 00614 // 3 - we find an other tag 00615 // + we create the object for the precedent tag 00616 // + loop to 1 - 00617 00618 // Directory record sequence 00619 DocEntry *e = GetDocEntry(0x0004, 0x1220); 00620 if ( !e ) 00621 { 00622 gdcmWarningMacro( "No Directory Record Sequence (0004,1220) found"); 00624 return; 00625 } 00626 00627 SeqEntry *s = dynamic_cast<SeqEntry *>(e); 00628 if ( !s ) 00629 { 00630 gdcmWarningMacro( "Element (0004,1220) is not a Sequence ?!?"); 00631 return; 00632 } 00633 00634 NewMeta(); 00635 00636 DocEntry *d; 00637 std::string v; 00638 SQItem *si; 00639 00640 SQItem *tmpSI=s->GetFirstSQItem(); 00641 while(tmpSI) 00642 { 00643 d = tmpSI->GetDocEntry(0x0004, 0x1430); // Directory Record Type 00644 if ( ValEntry* valEntry = dynamic_cast<ValEntry *>(d) ) 00645 { 00646 v = valEntry->GetValue(); 00647 } 00648 else 00649 { 00650 gdcmWarningMacro( "Not a ValEntry."); 00651 continue; 00652 } 00653 00654 if( v == "PATIENT " ) 00655 { 00656 si = new DicomDirPatient(true); 00657 if( !AddPatientToEnd( static_cast<DicomDirPatient *>(si)) ) 00658 { 00659 delete si; 00660 si = NULL; 00661 gdcmErrorMacro( "Add PatientToEnd failed"); 00662 } 00663 } 00664 else if( v == "STUDY " ) 00665 { 00666 si = new DicomDirStudy(true); 00667 if( !AddStudyToEnd( static_cast<DicomDirStudy *>(si)) ) 00668 { 00669 delete si; 00670 si = NULL; 00671 gdcmErrorMacro( "Add AddStudyToEnd failed"); 00672 } 00673 } 00674 else if( v == "SERIES" ) 00675 { 00676 si = new DicomDirSerie(true); 00677 if( !AddSerieToEnd( static_cast<DicomDirSerie *>(si)) ) 00678 { 00679 delete si; 00680 si = NULL; 00681 gdcmErrorMacro( "Add AddSerieToEnd failed"); 00682 } 00683 } 00684 else if( v == "IMAGE " ) 00685 { 00686 si = new DicomDirImage(true); 00687 if( !AddImageToEnd( static_cast<DicomDirImage *>(si)) ) 00688 { 00689 delete si; 00690 si = NULL; 00691 gdcmErrorMacro( "Add AddImageToEnd failed"); 00692 } 00693 } 00694 else 00695 { 00696 // It was not a 'PATIENT', nor a 'STUDY', nor a 'SERIE', 00697 // neither an 'IMAGE' SQItem. Skip to next item. 00698 continue; 00699 } 00700 if( si ) 00701 MoveSQItem(si,tmpSI); 00702 00703 tmpSI=s->GetNextSQItem(); 00704 } 00705 ClearEntry(); 00706 } |
|
create a Document-like chained list from a root Directory
Definition at line 490 of file gdcmDicomDir.cxx. References Abort, CallEndMethod(), CallProgressMethod(), CallStartMethod(), gdcm::DirListType, gdcmWarningMacro, gdcm::DirList::GetDirName(), gdcm::DirList::GetFilenames(), gdcm::File::IsReadable(), Progress, SetElements(), and gdcm::VectDocument. Referenced by ParseDirectory().
00491 { 00492 CallStartMethod(); 00493 DirList dirList(path,1); // gets recursively the file list 00494 unsigned int count = 0; 00495 VectDocument list; 00496 File *header; 00497 00498 DirListType fileList = dirList.GetFilenames(); 00499 00500 for( DirListType::iterator it = fileList.begin(); 00501 it != fileList.end(); 00502 ++it ) 00503 { 00504 Progress = (float)(count+1)/(float)fileList.size(); 00505 CallProgressMethod(); 00506 if( Abort ) 00507 { 00508 break; 00509 } 00510 00511 header = new File( it->c_str() ); 00512 if( !header ) 00513 { 00514 gdcmWarningMacro( "Failure in new gdcm::File " << it->c_str() ); 00515 continue; 00516 } 00517 00518 if( header->IsReadable() ) 00519 { 00520 // Add the file to the chained list: 00521 list.push_back(header); 00522 gdcmWarningMacro( "Readable " << it->c_str() ); 00523 } 00524 else 00525 { 00526 delete header; 00527 } 00528 count++; 00529 } 00530 // sorts Patient/Study/Serie/ 00531 std::sort(list.begin(), list.end(), DicomDir::HeaderLessThan ); 00532 00533 std::string tmp = dirList.GetDirName(); 00534 //for each File of the chained list, add/update the Patient/Study/Serie/Image info 00535 SetElements(tmp, list); 00536 CallEndMethod(); 00537 00538 for(VectDocument::iterator itDoc=list.begin(); 00539 itDoc!=list.end(); 00540 ++itDoc) 00541 { 00542 delete dynamic_cast<File *>(*itDoc); 00543 } 00544 } |
|
Same as Document::GetDocEntry except it only returns a result when the corresponding entry is of type BinEntry.
Definition at line 127 of file gdcmDocEntrySet.cxx. References gdcmWarningMacro, and gdcm::DocEntrySet::GetDocEntry(). Referenced by gdcm::DocEntrySet::GetEntryBinArea(), and gdcm::DocEntrySet::SetBinEntry().
00128 { 00129 DocEntry *currentEntry = GetDocEntry(group, elem); 00130 if ( !currentEntry ) 00131 { 00132 gdcmWarningMacro( "No corresponding BinEntry " << std::hex << group << 00133 "," << elem); 00134 return NULL; 00135 } 00136 00137 return dynamic_cast<BinEntry*>(currentEntry); 00138 } |
|
Searches [both] the public [and the shadow dictionary (when they exist)] for the presence of the DictEntry with given group and element, and create a new virtual DictEntry if necessary.
Definition at line 558 of file gdcmDocEntrySet.cxx. References gdcm::GDCM_UNKNOWN, gdcm::DocEntrySet::GetDictEntry(), gdcm::DictEntry::GetName(), gdcm::DictEntry::GetVR(), gdcm::DocEntrySet::NewVirtualDictEntry(), and gdcm::TagName.
00560 { 00561 DictEntry *dictEntry = GetDictEntry(group,elem); 00562 DictEntry *goodEntry = dictEntry; 00563 std::string goodVR = vr; 00564 00565 if (elem == 0x0000) goodVR="UL"; 00566 00567 if ( goodEntry ) 00568 { 00569 if ( goodVR != goodEntry->GetVR() 00570 && goodVR != GDCM_UNKNOWN ) 00571 { 00572 goodEntry = NULL; 00573 } 00574 } 00575 00576 // Create a new virtual DictEntry if necessary 00577 if (!goodEntry) 00578 { 00579 if (dictEntry) 00580 { 00581 goodEntry = NewVirtualDictEntry(group, elem, goodVR, "FIXME", 00582 dictEntry->GetName() ); 00583 } 00584 else 00585 { 00586 goodEntry = NewVirtualDictEntry(group, elem, goodVR); 00587 } 00588 } 00589 return goodEntry; 00590 } |
|
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.
Definition at line 534 of file gdcmDocEntrySet.cxx. References gdcmWarningMacro, and gdcm::Dict::GetEntry(). Referenced by gdcm::DocEntrySet::GetDictEntry(), gdcm::DocEntrySet::NewBinEntry(), gdcm::DocEntrySet::NewSeqEntry(), gdcm::DocEntrySet::NewValEntry(), and gdcm::Document::ReadNextDocEntry().
00535 { 00536 DictEntry *found = 0; 00537 Dict *pubDict = Global::GetDicts()->GetDefaultPubDict(); 00538 if (!pubDict) 00539 { 00540 gdcmWarningMacro( "We SHOULD have a default dictionary"); 00541 } 00542 else 00543 { 00544 found = pubDict->GetEntry(group, elem); 00545 } 00546 return found; 00547 } |
|
|
Gets (from Header) a 'non string' element value.
Definition at line 57 of file gdcmDocEntrySet.cxx. References gdcm::BinEntry::GetBinArea(), and gdcm::DocEntrySet::GetBinEntry(). Referenced by gdcm::PixelReadConvert::GrabInformationsFromFile().
00058 { 00059 BinEntry *entry = GetBinEntry(group, elem); 00060 if( entry ) 00061 return entry->GetBinArea(); 00062 return 0; 00063 } |
|
Searches within Header Entries (Dicom Elements) parsed with the public and private dictionaries for the value length of a given tag..
Definition at line 73 of file gdcmDocEntrySet.cxx. References gdcm::DocEntrySet::GetDocEntry(), and gdcm::DocEntry::GetLength(). Referenced by SetElement(), and gdcm::File::Write().
00074 { 00075 DocEntry *entry = GetDocEntry(group, elem); 00076 if( entry ) 00077 return entry->GetLength(); 00078 return -1; 00079 } |
|
Get the "std::string representable" value of the Dicom entry.
Definition at line 43 of file gdcmDocEntrySet.cxx. References gdcm::GDCM_UNFOUND, gdcm::DocEntrySet::GetDocEntry(), and gdcm::ContentEntry::GetValue(). Referenced by gdcm::SerieHelper::AddFileName(), gdcm::File::AnonymizeFile(), gdcm::Document::Document(), gdcm::File::File(), gdcm::File::GetBitsAllocated(), gdcm::File::GetBitsStored(), gdcm::File::GetHighBitPosition(), gdcm::File::GetImageNumber(), gdcm::File::GetImageOrientationPatient(), gdcm::File::GetLUTNbits(), gdcm::File::GetModality(), gdcm::File::GetNumberOfScalarComponents(), gdcm::File::GetPixelType(), gdcm::File::GetPlanarConfiguration(), gdcm::File::GetRescaleIntercept(), gdcm::File::GetRescaleSlope(), gdcm::File::GetSamplesPerPixel(), gdcm::Document::GetTransferSyntaxName(), gdcm::File::GetXOrigin(), gdcm::File::GetXSize(), gdcm::File::GetXSpacing(), gdcm::File::GetYOrigin(), gdcm::File::GetYSize(), gdcm::File::GetYSpacing(), gdcm::File::GetZOrigin(), gdcm::File::GetZSize(), gdcm::File::GetZSpacing(), gdcm::PixelReadConvert::GrabInformationsFromFile(), gdcm::File::IsMonochrome(), gdcm::File::IsPaletteColor(), gdcm::File::IsReadable(), gdcm::File::IsSignedPixelData(), gdcm::File::IsYBRFull(), gdcm::Document::operator<(), SetElement(), and gdcm::File::Write().
00044 { 00045 ContentEntry *entry = dynamic_cast<ContentEntry *>(GetDocEntry(group,elem)); 00046 if( entry ) 00047 return entry->GetValue(); 00048 return GDCM_UNFOUND; 00049 } |
|
Searches within Header Entries (Dicom Elements) parsed with the public [and private dictionaries] for the element value representation of a given tag.. Obtaining the VR (Value Representation) might be needed by caller to convert the string typed content to caller's native type (think of C++ vs Python). The VR is actually of a higher level of semantics than just the native C++ type.
Definition at line 94 of file gdcmDocEntrySet.cxx. References gdcm::GDCM_UNFOUND, gdcm::DocEntrySet::GetDocEntry(), and gdcm::DocEntry::GetVR().
00095 { 00096 DocEntry *entry = GetDocEntry(group, elem); 00097 if( entry ) 00098 return entry->GetVR(); 00099 return GDCM_UNFOUND; 00100 } |
|
Accessor to Filename.
Definition at line 79 of file gdcmDocument.h. Referenced by gdcm::SerieHelper::FileNameLessThan(), ParseDirectory(), and SetElement().
00079 { return Filename; } |
|
returns the File Type (ACR, ACR_LIBIDO, ExplicitVR, ImplicitVR, Unknown)
Definition at line 276 of file gdcmDocument.cxx. References gdcm::Document::Filetype, and gdcm::FileType.
00277 { 00278 return Filetype; 00279 } |
|
Get the first entry while visiting *the* 'zero level' DocEntrySet (DocEntries out of any Sequence).
Implements gdcm::DocEntrySet. Definition at line 142 of file gdcmElementSet.cxx. References gdcm::ElementSet::ItTagHT, and gdcm::ElementSet::TagHT. Referenced by gdcm::Document::ComputeGroup0002Length(), DicomDir(), and NewMeta().
00143 { 00144 ItTagHT = TagHT.begin(); 00145 if (ItTagHT != TagHT.end()) 00146 return ItTagHT->second; 00147 return NULL; 00148 } |
|
Get the first entry while visiting the DicomDirPatients.
Definition at line 299 of file gdcmDicomDir.cxx. References ItPatient, and Patients.
|
|
Returns a pointer to the DicomDirMeta for this DICOMDIR.
Definition at line 67 of file gdcmDicomDir.h. Referenced by WriteDicomDir().
00067 { return MetaElems; }; |
|
Get the next entry while visiting *the* 'zero level' DocEntrySet (DocEntries out of any Sequence).
Implements gdcm::DocEntrySet. Definition at line 156 of file gdcmElementSet.cxx. References gdcmAssertMacro, gdcm::ElementSet::ItTagHT, and gdcm::ElementSet::TagHT. Referenced by gdcm::Document::ComputeGroup0002Length().
00157 { 00158 gdcmAssertMacro (ItTagHT != TagHT.end()); 00159 00160 ++ItTagHT; 00161 if (ItTagHT != TagHT.end()) 00162 return ItTagHT->second; 00163 return NULL; 00164 } |
|
Get the next entry while visiting the DicomDirPatients.
Definition at line 312 of file gdcmDicomDir.cxx. References gdcmAssertMacro, ItPatient, and Patients.
|
|
Gets the print level for the Dicom Entries.
Definition at line 48 of file gdcmBase.h.
00048 { return PrintLevel; }; |
|
GetProgress GetProgress.
Definition at line 96 of file gdcmDicomDir.h.
00096 { return Progress; }; |
|
Get the public dictionary used.
Definition at line 183 of file gdcmDocument.cxx. References gdcm::Document::RefPubDict. Referenced by SetElement().
00184 {
00185 return RefPubDict;
00186 }
|
|
Same as Document::GetDocEntry except it only returns a result when the corresponding entry is of type SeqEntry.
Definition at line 148 of file gdcmDocEntrySet.cxx. References gdcmWarningMacro, and gdcm::DocEntrySet::GetDocEntry().
00149 { 00150 DocEntry *currentEntry = GetDocEntry(group, elem); 00151 if ( !currentEntry ) 00152 { 00153 gdcmWarningMacro( "No corresponding SeqEntry " << std::hex << group << 00154 "," << elem); 00155 return NULL; 00156 } 00157 00158 return dynamic_cast<SeqEntry*>(currentEntry); 00159 } |
|
Get the shadow dictionary used.
Definition at line 191 of file gdcmDocument.cxx. References gdcm::Document::RefShaDict.
00192 {
00193 return RefShaDict;
00194 }
|
|
'Swap code' accessor (see SwapCode )
Definition at line 66 of file gdcmDocument.h. Referenced by gdcm::PixelReadConvert::GrabInformationsFromFile().
00066 { 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 287 of file gdcmDocument.cxx. References gdcm::GDCM_UNKNOWN, gdcm::ElementSet::GetDocEntry(), gdcm::ContentEntry::GetValue(), and gdcm::Document::LoadDocEntrySafe(). Referenced by gdcm::File::ComputeJPEGFragmentInfo(), gdcm::File::ComputeRLEInfo(), gdcm::File::File(), gdcm::PixelReadConvert::GrabInformationsFromFile(), and gdcm::Document::HandleOutOfGroup0002().
00288 { 00289 DocEntry *entry = GetDocEntry(0x0002, 0x0010); 00290 if ( !entry ) 00291 { 00292 return GDCM_UNKNOWN; 00293 } 00294 00295 // The entry might be present but not loaded (parsing and loading 00296 // happen at different stages): try loading and proceed with check... 00297 LoadDocEntrySafe(entry); 00298 if (ValEntry *valEntry = dynamic_cast< ValEntry* >(entry) ) 00299 { 00300 std::string transfer = valEntry->GetValue(); 00301 // The actual transfer (as read from disk) might be padded. We 00302 // first need to remove the potential padding. We can make the 00303 // weak assumption that padding was not executed with digits... 00304 if ( transfer.length() == 0 ) 00305 { 00306 // for brain damaged headers 00307 return GDCM_UNKNOWN; 00308 } 00309 while ( !isdigit((unsigned char)transfer[transfer.length()-1]) ) 00310 { 00311 transfer.erase(transfer.length()-1, 1); 00312 } 00313 return transfer; 00314 } 00315 return GDCM_UNKNOWN; 00316 } |
|
Accesses the info from 0002,0010 : Transfer Syntax and TS.
Definition at line 322 of file gdcmDocument.cxx. References gdcm::GDCM_NOTLOADED, gdcm::GDCM_UNFOUND, gdcmErrorMacro, gdcmWarningMacro, gdcm::DocEntrySet::GetEntryValue(), and gdcm::TSKey. Referenced by gdcm::Document::HandleOutOfGroup0002().
00323 { 00324 // use the TS (TS : Transfer Syntax) 00325 std::string transferSyntax = GetEntryValue(0x0002,0x0010); 00326 00327 if ( (transferSyntax.find(GDCM_NOTLOADED) < transferSyntax.length()) ) 00328 { 00329 gdcmErrorMacro( "Transfer Syntax not loaded. " << std::endl 00330 << "Better you increase MAX_SIZE_LOAD_ELEMENT_VALUE" ); 00331 return "Uncompressed ACR-NEMA"; 00332 } 00333 if ( transferSyntax == GDCM_UNFOUND ) 00334 { 00335 gdcmWarningMacro( "Unfound Transfer Syntax (0002,0010)"); 00336 return "Uncompressed ACR-NEMA"; 00337 } 00338 00339 // we do it only when we need it 00340 const TSKey &tsName = Global::GetTS()->GetValue( transferSyntax ); 00341 00342 // Global::GetTS() is a global static you shall never try to delete it! 00343 return tsName; 00344 } |
|
Same as Document::GetDocEntry except it only returns a result when the corresponding entry is of type ValEntry.
Definition at line 110 of file gdcmDocEntrySet.cxx. References gdcm::DocEntrySet::GetDocEntry(). Referenced by gdcm::DocEntrySet::SetValEntry(), and gdcm::File::Write().
00111 { 00112 DocEntry *currentEntry = GetDocEntry(group, elem); 00113 if ( !currentEntry ) 00114 return NULL; 00115 00116 return dynamic_cast<ValEntry*>(currentEntry); 00117 } |
|
compares two files
Definition at line 1012 of file gdcmDicomDir.cxx.
01013 {
01014 return *header1 < *header2;
01015 }
|
|
Sets all fields to NULL.
Reimplemented from gdcm::Document. Definition at line 587 of file gdcmDicomDir.cxx. References Abort, EndArg, EndMethod, EndMethodArgDelete, MetaElems, Progress, ProgressArg, ProgressMethod, ProgressMethodArgDelete, StartArg, StartMethod, and StartMethodArgDelete. Referenced by DicomDir().
00588 { 00589 StartMethod = NULL; 00590 ProgressMethod = NULL; 00591 EndMethod = NULL; 00592 StartMethodArgDelete = NULL; 00593 ProgressMethodArgDelete = NULL; 00594 EndMethodArgDelete = NULL; 00595 StartArg = NULL; 00596 ProgressArg = NULL; 00597 EndArg = NULL; 00598 00599 Progress = 0.0; 00600 Abort = false; 00601 00602 MetaElems = NULL; 00603 } |
|
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 309 of file gdcmDocEntrySet.cxx. References gdcm::DocEntrySet::AddEntry(), gdcmWarningMacro, gdcm::DocEntrySet::GetDocEntry(), gdcm::DocEntry::GetVR(), gdcm::DocEntrySet::NewBinEntry(), gdcm::DocEntrySet::RemoveEntry(), gdcm::DocEntrySet::SetBinEntry(), and gdcm::TagName. Referenced by gdcm::File::InitializeDefaultFile(), and gdcm::FileHelper::InsertBinEntry().
00312 { 00313 BinEntry *binEntry = 0; 00314 DocEntry *currentEntry = GetDocEntry( group, elem ); 00315 00316 // Verify the currentEntry 00317 if (currentEntry) 00318 { 00319 binEntry = dynamic_cast<BinEntry *>(currentEntry); 00320 00321 // Verify the VR 00322 if( binEntry ) 00323 if( binEntry->GetVR()!=vr ) 00324 binEntry = NULL; 00325 00326 // if currentEntry doesn't correspond to the requested valEntry 00327 if( !binEntry) 00328 { 00329 if( !RemoveEntry(currentEntry) ) 00330 { 00331 gdcmWarningMacro( "Removal of previous DocEntry failed."); 00332 00333 return NULL; 00334 } 00335 } 00336 } 00337 00338 // Create a new binEntry if necessary 00339 if( !binEntry) 00340 { 00341 binEntry = NewBinEntry(group, elem, vr); 00342 00343 if ( !AddEntry(binEntry) ) 00344 { 00345 gdcmWarningMacro( "AddEntry failed allthough this is a creation."); 00346 00347 delete binEntry; 00348 return NULL; 00349 } 00350 } 00351 00352 // Set the binEntry value 00353 uint8_t *tmpArea; 00354 if( lgth>0 && binArea ) 00355 { 00356 tmpArea = new uint8_t[lgth]; 00357 memcpy(tmpArea,binArea,lgth); 00358 } 00359 else 00360 { 00361 tmpArea = 0; 00362 } 00363 if( !SetBinEntry(tmpArea,lgth,binEntry) ) 00364 { 00365 if( tmpArea ) 00366 { 00367 delete[] tmpArea; 00368 } 00369 } 00370 00371 return binEntry; 00372 } |
|
Modifies the value of a given Doc Entry (Dicom Element) when it exists. Creates it when unexistant.
Definition at line 382 of file gdcmDocEntrySet.cxx. References gdcm::DocEntrySet::AddEntry(), gdcmWarningMacro, gdcm::DocEntrySet::GetDocEntry(), gdcm::DocEntrySet::NewSeqEntry(), and gdcm::DocEntrySet::RemoveEntry(). Referenced by gdcm::FileHelper::InsertSeqEntry().
00383 { 00384 SeqEntry *seqEntry = 0; 00385 DocEntry *currentEntry = GetDocEntry( group, elem ); 00386 00387 // Verify the currentEntry 00388 if( currentEntry ) 00389 { 00390 seqEntry = dynamic_cast<SeqEntry *>(currentEntry); 00391 00392 // Verify the VR 00393 if( seqEntry ) 00394 seqEntry = NULL; 00395 00396 // if currentEntry doesn't correspond to the requested seqEntry 00397 if( !seqEntry ) 00398 { 00399 if (!RemoveEntry(currentEntry)) 00400 { 00401 gdcmWarningMacro( "Removal of previous DocEntry failed."); 00402 00403 return NULL; 00404 } 00405 } 00406 } 00407 // Create a new seqEntry if necessary 00408 if( !seqEntry ) 00409 { 00410 seqEntry = NewSeqEntry(group, elem); 00411 00412 if( !AddEntry(seqEntry) ) 00413 { 00414 gdcmWarningMacro( "AddEntry failed allthough this is a creation."); 00415 00416 delete seqEntry; 00417 return NULL; 00418 } 00419 } 00420 00421 // TODO : Find a trick to insert a SequenceDelimitationItem 00422 // in the SeqEntry, at the end. 00423 return seqEntry; 00424 } |
|
Modifies the value of a given Doc Entry (Dicom Element) when it exists. Create it with the given value when unexistant.
Definition at line 250 of file gdcmDocEntrySet.cxx. References gdcm::DocEntrySet::AddEntry(), gdcmWarningMacro, gdcm::DocEntrySet::GetDocEntry(), gdcm::DocEntry::GetVR(), gdcm::DocEntrySet::NewValEntry(), gdcm::DocEntrySet::RemoveEntry(), gdcm::DocEntrySet::SetValEntry(), and gdcm::TagName. Referenced by gdcm::File::InitializeDefaultFile(), gdcm::FileHelper::InsertValEntry(), and gdcm::File::Write().
00253 { 00254 ValEntry *valEntry = 0; 00255 DocEntry *currentEntry = GetDocEntry( group, elem ); 00256 00257 if (currentEntry) 00258 { 00259 valEntry = dynamic_cast<ValEntry *>(currentEntry); 00260 00261 // Verify the VR 00262 if( valEntry ) 00263 if( valEntry->GetVR()!=vr ) 00264 valEntry = NULL; 00265 00266 // if currentEntry doesn't correspond to the requested valEntry 00267 if( !valEntry) 00268 { 00269 if( !RemoveEntry(currentEntry) ) 00270 { 00271 gdcmWarningMacro( "Removal of previous DocEntry failed."); 00272 00273 return NULL; 00274 } 00275 } 00276 } 00277 00278 // Create a new valEntry if necessary 00279 if( !valEntry ) 00280 { 00281 valEntry = NewValEntry( group, elem, vr ); 00282 00283 if ( !AddEntry(valEntry) ) 00284 { 00285 gdcmWarningMacro("AddEntry failed although this is a creation."); 00286 00287 delete valEntry; 00288 return NULL; 00289 } 00290 } 00291 00292 // Set the binEntry value 00293 SetValEntry(value, valEntry); // The std::string value 00294 return valEntry; 00295 } |
|
IsAborted IsAborted.
Definition at line 100 of file gdcmDicomDir.h.
00100 { return Abort; }; |
|
Predicate for dicom version 3 file.
Definition at line 245 of file gdcmDocument.cxx. References gdcm::ElementSet::GetDocEntry(). Referenced by gdcm::File::GetYSize(), and gdcm::PixelReadConvert::GrabInformationsFromFile().
00246 { 00247 // Checking if Transfer Syntax exists is enough 00248 // Anyway, it's to late check if the 'Preamble' was found ... 00249 // And ... would it be a rich idea to check ? 00250 // (some 'no Preamble' DICOM images exist !) 00251 return GetDocEntry(0x0002, 0x0010) != NULL; 00252 } |
|
Tells us if the ElementSet contains no entry.
Implements gdcm::DocEntrySet. Definition at line 63 of file gdcmElementSet.h. Referenced by gdcm::Document::IsReadable().
00063 { return TagHT.empty(); };
|
|
Predicate for Papyrus file Dedicated to whomsoever it may concern.
Definition at line 259 of file gdcmDocument.cxx. References gdcm::ElementSet::GetDocEntry().
00260 { 00261 // check for Papyrus private Sequence 00262 DocEntry *e = GetDocEntry(0x0041, 0x1050); 00263 if ( !e ) 00264 return false; 00265 // check if it's actually a Sequence 00266 if ( !dynamic_cast<SeqEntry*>(e) ) 00267 return false; 00268 return true; 00269 } |
|
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::Document. Definition at line 216 of file gdcmDicomDir.cxx. References gdcmWarningMacro, MetaElems, Patients, and gdcm::Unknown.
00217 { 00218 if( Filetype == Unknown) 00219 { 00220 gdcmWarningMacro( "Wrong filetype"); 00221 return false; 00222 } 00223 if( !MetaElems ) 00224 { 00225 gdcmWarningMacro( "Meta Elements missing in DicomDir"); 00226 return false; 00227 } 00228 if( Patients.size() <= 0 ) 00229 { 00230 gdcmWarningMacro( "NO Patient in DicomDir"); 00231 return false; 00232 } 00233 00234 return true; 00235 } |
|
Loads the element while preserving the current underlying file position indicator as opposed to LoadDocEntry that modifies it.
Definition at line 581 of file gdcmDocument.cxx. References gdcm::Document::Fp, and gdcm::Document::LoadDocEntry(). Referenced by gdcm::Document::GetTransferSyntax().
00582 { 00583 if(Fp) 00584 { 00585 long PositionOnEntry = Fp->tellg(); 00586 LoadDocEntry(entry); 00587 Fp->seekg(PositionOnEntry, std::ios::beg); 00588 } 00589 } |
|
Loads (from disk) the element content when a string is not suitable.
Definition at line 541 of file gdcmDocument.cxx. References gdcm::Document::CloseFile(), gdcm::Document::Fp, gdcmWarningMacro, gdcm::BinEntry::GetBinArea(), gdcm::DocEntry::GetLength(), gdcm::DocEntry::GetOffset(), gdcm::Document::OpenFile(), and gdcm::BinEntry::SetBinArea().
00542 { 00543 if(elem->GetBinArea()) 00544 return; 00545 00546 bool openFile = !Fp; 00547 if(openFile) 00548 OpenFile(); 00549 00550 size_t o =(size_t)elem->GetOffset(); 00551 Fp->seekg(o, std::ios::beg); 00552 00553 size_t l = elem->GetLength(); 00554 uint8_t *a = new uint8_t[l]; 00555 if( !a ) 00556 { 00557 gdcmWarningMacro( "Cannot allocate BinEntry content"); 00558 return; 00559 } 00560 00562 Fp->read((char*)a, l); 00563 if( Fp->fail() || Fp->eof()) 00564 { 00565 delete[] a; 00566 return; 00567 } 00568 00569 elem->SetBinArea(a); 00570 00571 if(openFile) 00572 CloseFile(); 00573 } |
|
Loads (from disk) the element content when a string is not suitable.
Definition at line 522 of file gdcmDocument.cxx. References gdcm::ElementSet::GetDocEntry(). Referenced by gdcm::Document::Document(), gdcm::PixelReadConvert::GrabInformationsFromFile(), and gdcm::Document::LoadDocEntry().
00523 { 00524 // Search the corresponding DocEntry 00525 DocEntry *docElement = GetDocEntry(group, elem); 00526 if ( !docElement ) 00527 return; 00528 00529 BinEntry *binElement = dynamic_cast<BinEntry *>(docElement); 00530 if( !binElement ) 00531 return; 00532 00533 LoadEntryBinArea(binElement); 00534 } |
|
Move the content of the source SQItem to the destination SQItem Only DocEntry's are moved.
Definition at line 995 of file gdcmDicomDir.cxx. References gdcm::DocEntrySet::AddEntry(), gdcm::DocEntrySet::GetFirstEntry(), and gdcm::DocEntrySet::RemoveEntryNoDestroy(). Referenced by CreateDicomDir().
00996 { 00997 DocEntry *entry; 00998 00999 entry = src->GetFirstEntry(); 01000 while(entry) 01001 { 01002 src->RemoveEntryNoDestroy(entry); 01003 dst->AddEntry(entry); 01004 // we destroyed -> the current iterator is not longer valid 01005 entry = src->GetFirstEntry(); 01006 } 01007 } |
|
Build a new Bin Entry from all the low level arguments. Check for existence of dictionary entry, and build a default one when absent.
Definition at line 471 of file gdcmDocEntrySet.cxx. References gdcmAssertMacro, gdcmWarningMacro, gdcm::DocEntrySet::GetDictEntry(), and gdcm::TagName. Referenced by gdcm::FileHelper::CopyBinEntry(), gdcm::DocEntrySet::InsertBinEntry(), and gdcm::Document::ReadNextDocEntry().
00473 { 00474 DictEntry *dictEntry = GetDictEntry(group, elem, vr); 00475 gdcmAssertMacro(dictEntry); 00476 00477 BinEntry *newEntry = new BinEntry(dictEntry); 00478 if (!newEntry) 00479 { 00480 gdcmWarningMacro( "Failed to allocate BinEntry"); 00481 return 0; 00482 } 00483 return newEntry; 00484 } |
|
adds *the* Meta to a partially created DICOMDIR
Definition at line 240 of file gdcmDicomDir.cxx. References gdcm::SQItem::AddEntry(), gdcm::ElementSet::GetFirstEntry(), MetaElems, gdcm::ElementSet::RemoveEntryNoDestroy(), and gdcm::SQItem::SetSQItemNumber(). Referenced by CreateDicomDir(), and DicomDir().
00241 { 00242 if( MetaElems ) 00243 delete MetaElems; 00244 00245 DocEntry *entry = GetFirstEntry(); 00246 if( entry ) 00247 { 00248 MetaElems = new DicomDirMeta(true); 00249 00250 entry = GetFirstEntry(); 00251 while( entry ) 00252 { 00253 if( dynamic_cast<SeqEntry *>(entry) ) 00254 break; 00255 00256 RemoveEntryNoDestroy(entry); 00257 MetaElems->AddEntry(entry); 00258 00259 entry = GetFirstEntry(); 00260 } 00261 } 00262 else // after root directory parsing 00263 { 00264 MetaElems = new DicomDirMeta(false); 00265 } 00266 MetaElems->SetSQItemNumber(0); // To avoid further missprinting 00267 return MetaElems; 00268 } |
|
adds a new Patient (with the basic elements) to a partially created DICOMDIR
Definition at line 274 of file gdcmDicomDir.cxx. References AddPatientToEnd().
00275 { 00276 DicomDirPatient *p = new DicomDirPatient(); 00277 AddPatientToEnd( p ); 00278 return p; 00279 } |
|
Build a new Seq Entry from all the low level arguments. Check for existence of dictionary entry, and build a default one when absent.
Definition at line 493 of file gdcmDocEntrySet.cxx. References gdcmAssertMacro, gdcmWarningMacro, and gdcm::DocEntrySet::GetDictEntry(). Referenced by gdcm::DocEntrySet::InsertSeqEntry(), and gdcm::Document::ReadNextDocEntry().
00494 { 00495 DictEntry *dictEntry = GetDictEntry(group, elem, "SQ"); 00496 gdcmAssertMacro(dictEntry); 00497 00498 SeqEntry *newEntry = new SeqEntry( dictEntry ); 00499 if (!newEntry) 00500 { 00501 gdcmWarningMacro( "Failed to allocate SeqEntry"); 00502 return 0; 00503 } 00504 return newEntry; 00505 } |
|
Build a new Val Entry from all the low level arguments. Check for existence of dictionary entry, and build a default one when absent.
Definition at line 447 of file gdcmDocEntrySet.cxx. References gdcmAssertMacro, gdcmWarningMacro, gdcm::DocEntrySet::GetDictEntry(), and gdcm::TagName. Referenced by gdcm::FileHelper::CopyValEntry(), gdcm::DocEntrySet::InsertValEntry(), and gdcm::Document::ReadNextDocEntry().
00449 { 00450 DictEntry *dictEntry = GetDictEntry(group, elem, vr); 00451 gdcmAssertMacro(dictEntry); 00452 00453 ValEntry *newEntry = new ValEntry(dictEntry); 00454 if (!newEntry) 00455 { 00456 gdcmWarningMacro( "Failed to allocate ValEntry"); 00457 return 0; 00458 } 00459 return newEntry; 00460 } |
|
Request a new virtual dict entry to the dict set.
Definition at line 515 of file gdcmDocEntrySet.cxx. References gdcm::TagName. Referenced by gdcm::File::File(), and gdcm::DocEntrySet::GetDictEntry().
00519 {
00520 return Global::GetDicts()->NewVirtualDictEntry(group,elem,vr,vm,name);
00521 }
|
|
Tries to open the file Document::Filename and checks the preamble when existing.
Definition at line 395 of file gdcmDocument.cxx. References gdcm::Document::CloseFile(), gdcm::Document::Fp, gdcmDebugMacro, gdcmWarningMacro, and gdcm::Document::HasDCMPreamble. Referenced by gdcm::Document::Document(), gdcm::File::File(), gdcm::FileHelper::GetRaw(), and gdcm::Document::LoadEntryBinArea().
00396 { 00397 HasDCMPreamble = false; 00398 if (Filename.length() == 0) 00399 { 00400 return 0; 00401 } 00402 00403 if(Fp) 00404 { 00405 gdcmWarningMacro( "File already open: " << Filename.c_str()); 00406 CloseFile(); 00407 } 00408 00409 Fp = new std::ifstream(Filename.c_str(), std::ios::in | std::ios::binary); 00410 if( ! *Fp ) 00411 { 00412 gdcmDebugMacro( "Cannot open file: " << Filename.c_str()); 00413 delete Fp; 00414 Fp = 0; 00415 return 0; 00416 } 00417 00418 uint16_t zero = 0; 00419 Fp->read((char*)&zero, (size_t)2); 00420 if( Fp->eof() ) 00421 { 00422 CloseFile(); 00423 return 0; 00424 } 00425 00426 //ACR -- or DICOM with no Preamble; may start with a Shadow Group -- 00427 if( 00428 zero == 0x0001 || zero == 0x0100 || zero == 0x0002 || zero == 0x0200 || 00429 zero == 0x0003 || zero == 0x0300 || zero == 0x0004 || zero == 0x0400 || 00430 zero == 0x0005 || zero == 0x0500 || zero == 0x0006 || zero == 0x0600 || 00431 zero == 0x0007 || zero == 0x0700 || zero == 0x0008 || zero == 0x0800 ) 00432 { 00433 std::string msg 00434 = Util::Format("ACR/DICOM with no preamble: (%04x)\n", zero); 00435 gdcmWarningMacro( msg.c_str() ); 00436 return Fp; 00437 } 00438 00439 //DICOM 00440 Fp->seekg(126L, std::ios::cur); 00441 char dicm[4] = {' ',' ',' ',' '}; 00442 Fp->read(dicm, (size_t)4); 00443 if( Fp->eof() ) 00444 { 00445 CloseFile(); 00446 return 0; 00447 } 00448 if( memcmp(dicm, "DICM", 4) == 0 ) 00449 { 00450 HasDCMPreamble = true; 00451 return Fp; 00452 } 00453 00454 CloseFile(); 00455 gdcmWarningMacro( "Not DICOM/ACR (missing preamble)" << Filename.c_str()); 00456 00457 return 0; 00458 } |
|
Compares two documents, according to DicomDir rules.
Definition at line 598 of file gdcmDocument.cxx. References gdcm::DocEntrySet::GetEntryValue().
00599 { 00600 // Patient Name 00601 std::string s1 = GetEntryValue(0x0010,0x0010); 00602 std::string s2 = document.GetEntryValue(0x0010,0x0010); 00603 if(s1 < s2) 00604 { 00605 return true; 00606 } 00607 else if( s1 > s2 ) 00608 { 00609 return false; 00610 } 00611 else 00612 { 00613 // Patient ID 00614 s1 = GetEntryValue(0x0010,0x0020); 00615 s2 = document.GetEntryValue(0x0010,0x0020); 00616 if ( s1 < s2 ) 00617 { 00618 return true; 00619 } 00620 else if ( s1 > s2 ) 00621 { 00622 return false; 00623 } 00624 else 00625 { 00626 // Study Instance UID 00627 s1 = GetEntryValue(0x0020,0x000d); 00628 s2 = document.GetEntryValue(0x0020,0x000d); 00629 if ( s1 < s2 ) 00630 { 00631 return true; 00632 } 00633 else if( s1 > s2 ) 00634 { 00635 return false; 00636 } 00637 else 00638 { 00639 // Serie Instance UID 00640 s1 = GetEntryValue(0x0020,0x000e); 00641 s2 = document.GetEntryValue(0x0020,0x000e); 00642 if ( s1 < s2 ) 00643 { 00644 return true; 00645 } 00646 else if( s1 > s2 ) 00647 { 00648 return false; 00649 } 00650 } 00651 } 00652 } 00653 return false; 00654 } |
|
fills the whole structure, starting from a root Directory
Definition at line 325 of file gdcmDicomDir.cxx. References CreateDicomDir(), CreateDicomDirChainedList(), and gdcm::Document::GetFileName(). Referenced by DicomDir().
00326 { 00327 CreateDicomDirChainedList( GetFileName() ); 00328 CreateDicomDir(); 00329 } |
|
Canonical Printer.
Reimplemented from gdcm::ElementSet. Definition at line 1024 of file gdcmDicomDir.cxx. References MetaElems, Patients, gdcm::DicomDirMeta::Print(), and gdcm::Base::SetPrintLevel().
01025 { 01026 if( MetaElems ) 01027 { 01028 MetaElems->SetPrintLevel(PrintLevel); 01029 MetaElems->Print(os); 01030 } 01031 for(ListDicomDirPatient::iterator cc = Patients.begin(); 01032 cc != Patients.end(); 01033 ++cc) 01034 { 01035 (*cc)->SetPrintLevel(PrintLevel); 01036 (*cc)->Print(os); 01037 } 01038 } |
|
Reads a supposed to be 16 Bits integer (swaps it depending on processor endianness).
Definition at line 663 of file gdcmDocument.cxx. Referenced by gdcm::Document::LoadDocEntry(), gdcm::Document::ReadNextDocEntry(), and gdcm::File::ReadTag().
00665 { 00666 uint16_t g; 00667 Fp->read ((char*)&g, (size_t)2); 00668 if ( Fp->fail() ) 00669 { 00670 throw FormatError( "Document::ReadInt16()", " file error." ); 00671 } 00672 if( Fp->eof() ) 00673 { 00674 throw FormatError( "Document::ReadInt16()", "EOF." ); 00675 } 00676 g = SwapShort(g); 00677 return g; 00678 } |
|
Reads a supposed to be 32 Bits integer (swaps it depending on processor endianness).
Definition at line 685 of file gdcmDocument.cxx. Referenced by gdcm::File::ComputeRLEInfo(), gdcm::Document::LoadDocEntry(), and gdcm::File::ReadTagLength().
00687 { 00688 uint32_t g; 00689 Fp->read ((char*)&g, (size_t)4); 00690 if ( Fp->fail() ) 00691 { 00692 throw FormatError( "Document::ReadInt32()", " file error." ); 00693 } 00694 if( Fp->eof() ) 00695 { 00696 throw FormatError( "Document::ReadInt32()", "EOF." ); 00697 } 00698 g = SwapLong(g); 00699 return g; 00700 } |
|
Clear the hash table from given entry AND delete the entry.
Implements gdcm::DocEntrySet. Definition at line 89 of file gdcmElementSet.cxx. References gdcmWarningMacro, gdcm::DocEntry::GetKey(), gdcm::ElementSet::TagHT, and gdcm::TagKey. Referenced by gdcm::File::File(), and gdcm::DocEntryArchive::Restore().
00090 { 00091 const TagKey &key = entryToRemove->GetKey(); 00092 if( TagHT.count(key) == 1 ) 00093 { 00094 TagHT.erase(key); 00095 //gdcmWarningMacro( "One element erased."); 00096 delete entryToRemove; 00097 return true; 00098 } 00099 00100 gdcmWarningMacro( "Key not present"); 00101 return false ; 00102 } |
|
Clear the hash table from given entry BUT keep the entry.
Implements gdcm::DocEntrySet. Definition at line 108 of file gdcmElementSet.cxx. References gdcmWarningMacro, gdcm::DocEntry::GetKey(), gdcm::ElementSet::TagHT, and gdcm::TagKey. Referenced by NewMeta(), gdcm::DocEntryArchive::Push(), and gdcm::File::Write().
00109 { 00110 const TagKey &key = entryToRemove->GetKey(); 00111 if( TagHT.count(key) == 1 ) 00112 { 00113 TagHT.erase(key); 00114 //gdcmWarningMacro( "One element erased."); 00115 return true; 00116 } 00117 00118 gdcmWarningMacro( "Key not present"); 00119 return false ; 00120 } |
|
Accesses an existing BinEntry (i.e. a Dicom Element) and modifies it's content with the given value.
Definition at line 228 of file gdcmDocEntrySet.cxx. References gdcm::GDCM_BINLOADED, gdcm::BinEntry::SetBinArea(), gdcm::DocEntry::SetLength(), and gdcm::ContentEntry::SetValue().
00229 { 00230 if(entry) 00231 { 00232 entry->SetBinArea(content); 00233 entry->SetLength(lgth); 00234 entry->SetValue(GDCM_BINLOADED); 00235 return true; 00236 } 00237 return false; 00238 } |
|
Accesses an existing DocEntry (i.e. a Dicom Element) through it's (group, element) and modifies it's content with the given value.
Definition at line 191 of file gdcmDocEntrySet.cxx. References gdcmWarningMacro, and gdcm::DocEntrySet::GetBinEntry(). Referenced by gdcm::DocEntrySet::InsertBinEntry(), and gdcm::FileHelper::SetBinEntry().
00193 { 00194 BinEntry *entry = GetBinEntry(group, elem); 00195 if (!entry ) 00196 { 00197 gdcmWarningMacro( "No corresponding ValEntry " << std::hex << group << 00198 "," << elem << " element (try promotion first)."); 00199 return false; 00200 } 00201 00202 return SetBinEntry(content,lgth,entry); 00203 } |
|
adds to the HTable the Entries (Dicom Elements) corresponding to the given type
Definition at line 855 of file gdcmDicomDir.cxx. References gdcm::SQItem::AddEntry(), AddImageToEnd(), AddPatientToEnd(), AddSerieToEnd(), AddStudyToEnd(), GDCM_DICOMDIR_IMAGE, GDCM_DICOMDIR_META, GDCM_DICOMDIR_PATIENT, GDCM_DICOMDIR_SERIE, GDCM_DICOMDIR_STUDY, gdcm::GDCM_UNFOUND, gdcmErrorMacro, gdcmWarningMacro, gdcm::Dict::GetEntry(), gdcm::DocEntrySet::GetEntryLength(), gdcm::DocEntrySet::GetEntryValue(), gdcm::Document::GetFileName(), gdcm::Document::GetPubDict(), gdcm::ListDicomDirElem, MetaElems, gdcm::DocEntry::SetOffset(), and gdcm::ValEntry::SetValue(). Referenced by SetElements().
00857 { 00858 ListDicomDirElem elemList; //FIXME this is going to be a by copy operation 00859 ListDicomDirElem::const_iterator it; 00860 uint16_t tmpGr, tmpEl; 00861 DictEntry *dictEntry; 00862 ValEntry *entry; 00863 std::string val; 00864 SQItem *si; 00865 00866 switch( type ) 00867 { 00868 case GDCM_DICOMDIR_IMAGE: 00869 elemList = Global::GetDicomDirElements()->GetDicomDirImageElements(); 00870 si = new DicomDirImage(true); 00871 if( !AddImageToEnd(static_cast<DicomDirImage *>(si)) ) 00872 { 00873 delete si; 00874 gdcmErrorMacro( "Add ImageToEnd failed"); 00875 } 00876 break; 00877 case GDCM_DICOMDIR_SERIE: 00878 elemList = Global::GetDicomDirElements()->GetDicomDirSerieElements(); 00879 si = new DicomDirSerie(true); 00880 if( !AddSerieToEnd(static_cast<DicomDirSerie *>(si)) ) 00881 { 00882 delete si; 00883 gdcmErrorMacro( "Add SerieToEnd failed"); 00884 } 00885 break; 00886 case GDCM_DICOMDIR_STUDY: 00887 elemList = Global::GetDicomDirElements()->GetDicomDirStudyElements(); 00888 si = new DicomDirStudy(true); 00889 if( !AddStudyToEnd(static_cast<DicomDirStudy *>(si)) ) 00890 { 00891 delete si; 00892 gdcmErrorMacro( "Add StudyToEnd failed"); 00893 } 00894 break; 00895 case GDCM_DICOMDIR_PATIENT: 00896 elemList = Global::GetDicomDirElements()->GetDicomDirPatientElements(); 00897 si = new DicomDirPatient(true); 00898 if( !AddPatientToEnd(static_cast<DicomDirPatient *>(si)) ) 00899 { 00900 delete si; 00901 gdcmErrorMacro( "Add PatientToEnd failed"); 00902 } 00903 break; 00904 case GDCM_DICOMDIR_META: 00905 elemList = Global::GetDicomDirElements()->GetDicomDirMetaElements(); 00906 si = new DicomDirMeta(true); 00907 if( MetaElems ) 00908 { 00909 delete MetaElems; 00910 gdcmErrorMacro( "MetaElements already exist, they will be destroyed"); 00911 } 00912 MetaElems = static_cast<DicomDirMeta *>(si); 00913 break; 00914 default: 00915 return; 00916 } 00917 // removed all the seems-to-be-useless stuff about Referenced Image Sequence 00918 // to avoid further troubles 00919 // imageElem 0008 1140 "" // Referenced Image Sequence 00920 // imageElem fffe e000 "" // 'no length' item : length to be set to 0xffffffff later 00921 // imageElem 0008 1150 "" // Referenced SOP Class UID : to be set/forged later 00922 // imageElem 0008 1155 "" // Referenced SOP Instance UID : to be set/forged later 00923 // imageElem fffe e00d "" // Item delimitation : length to be set to ZERO later 00924 00925 // FIXME : troubles found when it's a SeqEntry 00926 00927 // for all the relevant elements found in their own spot of the DicomDir.dic 00928 for( it = elemList.begin(); it != elemList.end(); ++it) 00929 { 00930 tmpGr = it->Group; 00931 tmpEl = it->Elem; 00932 dictEntry = GetPubDict()->GetEntry(tmpGr, tmpEl); 00933 00934 entry = new ValEntry( dictEntry ); // Be sure it's never a BinEntry ! 00935 00936 entry->SetOffset(0); // just to avoid further missprinting 00937 00938 if( header ) 00939 { 00940 // NULL when we Build Up (ex nihilo) a DICOMDIR 00941 // or when we add the META elems 00942 val = header->GetEntryValue(tmpGr, tmpEl); 00943 } 00944 else 00945 { 00946 val = GDCM_UNFOUND; 00947 } 00948 00949 if( val == GDCM_UNFOUND) 00950 { 00951 if( tmpGr == 0x0004 && tmpEl == 0x1130 ) // File-set ID 00952 { 00953 // force to the *end* File Name 00954 val = Util::GetName( path ); 00955 } 00956 else if( tmpGr == 0x0004 && tmpEl == 0x1500 ) // Only used for image 00957 { 00958 if( header->GetFileName().substr(0, path.length()) != path ) 00959 { 00960 gdcmWarningMacro( "The base path of file name is incorrect"); 00961 val = header->GetFileName(); 00962 } 00963 else 00964 { 00965 val = &(header->GetFileName().c_str()[path.length()]); 00966 } 00967 } 00968 else 00969 { 00970 val = it->Value; 00971 } 00972 } 00973 else 00974 { 00975 if ( header->GetEntryLength(tmpGr,tmpEl) == 0 ) 00976 val = it->Value; 00977 } 00978 00979 entry->SetValue( val ); // troubles expected when vr=SQ ... 00980 00981 if ( type == GDCM_DICOMDIR_META ) // fusible : should never print ! 00982 { 00983 gdcmWarningMacro("GDCM_DICOMDIR_META ?!? should never print that"); 00984 } 00985 si->AddEntry(entry); 00986 } 00987 } |
|
for each Header of the chained list, add/update the Patient/Study/Serie/Image info
Definition at line 786 of file gdcmDicomDir.cxx. References gdcm::ElementSet::ClearEntry(), ClearPatient(), GDCM_DICOMDIR_IMAGE, GDCM_DICOMDIR_PATIENT, GDCM_DICOMDIR_SERIE, GDCM_DICOMDIR_STUDY, SetElement(), and gdcm::VectDocument. Referenced by CreateDicomDirChainedList().
00787 { 00788 ClearEntry(); 00789 ClearPatient(); 00790 00791 std::string patPrevName = "", patPrevID = ""; 00792 std::string studPrevInstanceUID = "", studPrevID = ""; 00793 std::string serPrevInstanceUID = "", serPrevID = ""; 00794 00795 std::string patCurName, patCurID; 00796 std::string studCurInstanceUID, studCurID; 00797 std::string serCurInstanceUID, serCurID; 00798 00799 bool first = true; 00800 for( VectDocument::const_iterator it = list.begin(); 00801 it != list.end(); 00802 ++it ) 00803 { 00804 // get the current file characteristics 00805 patCurName = (*it)->GetEntryValue(0x0010,0x0010); 00806 patCurID = (*it)->GetEntryValue(0x0010,0x0011); 00807 studCurInstanceUID = (*it)->GetEntryValue(0x0020,0x000d); 00808 studCurID = (*it)->GetEntryValue(0x0020,0x0010); 00809 serCurInstanceUID = (*it)->GetEntryValue(0x0020,0x000e); 00810 serCurID = (*it)->GetEntryValue(0x0020,0x0011); 00811 00812 if( patCurName != patPrevName || patCurID != patPrevID || first ) 00813 { 00814 SetElement(path, GDCM_DICOMDIR_PATIENT, *it); 00815 first = true; 00816 } 00817 00818 // if new Study Deal with 'STUDY' Elements 00819 if( studCurInstanceUID != studPrevInstanceUID || studCurID != studPrevID 00820 || first ) 00821 { 00822 SetElement(path, GDCM_DICOMDIR_STUDY, *it); 00823 first = true; 00824 } 00825 00826 // if new Serie Deal with 'SERIE' Elements 00827 if( serCurInstanceUID != serPrevInstanceUID || serCurID != serPrevID 00828 || first ) 00829 { 00830 SetElement(path, GDCM_DICOMDIR_SERIE, *it); 00831 first = true; 00832 } 00833 00834 // Always Deal with 'IMAGE' Elements 00835 SetElement(path, GDCM_DICOMDIR_IMAGE, *it); 00836 00837 patPrevName = patCurName; 00838 patPrevID = patCurID; 00839 studPrevInstanceUID = studCurInstanceUID; 00840 studPrevID = studCurID; 00841 serPrevInstanceUID = serCurInstanceUID; 00842 serPrevID = serCurID; 00843 first = false; 00844 } 00845 } |
|
Set the end method to call when the parsing of the directory ends.
Definition at line 380 of file gdcmDicomDir.cxx. References EndArg, EndMethod, EndMethodArgDelete, and Method. Referenced by ~DicomDir().
00382 { 00383 if( EndArg && EndMethodArgDelete ) 00384 { 00385 EndMethodArgDelete( EndArg ); 00386 } 00387 00388 EndMethod = method; 00389 EndArg = arg; 00390 EndMethodArgDelete = argDelete; 00391 } |
|
Set the method to delete the argument The argument is destroyed when the method is changed or when the class is destroyed.
Definition at line 421 of file gdcmDicomDir.cxx. References EndMethodArgDelete, and Method.
00422 { 00423 EndMethodArgDelete = method; 00424 } |
|
Accessor to Filename.
Definition at line 81 of file gdcmDocument.h. Referenced by DicomDir().
00081 { Filename = fileName; } |
|
Sets the print level for the Dicom Header Elements.
Definition at line 45 of file gdcmBase.h. Referenced by gdcm::SQItem::Print(), gdcm::SeqEntry::Print(), gdcm::FileHelper::Print(), gdcm::ElementSet::Print(), and Print().
00045 { PrintLevel = level; }; |
|
Set the progress method to call when the parsing of the directory progress.
Definition at line 360 of file gdcmDicomDir.cxx. References Method, ProgressArg, ProgressMethod, and ProgressMethodArgDelete. Referenced by ~DicomDir().
00362 { 00363 if( ProgressArg && ProgressMethodArgDelete ) 00364 { 00365 ProgressMethodArgDelete( ProgressArg ); 00366 } 00367 00368 ProgressMethod = method; 00369 ProgressArg = arg; 00370 ProgressMethodArgDelete = argDelete; 00371 } |
|
Set the method to delete the argument The argument is destroyed when the method is changed or when the class is destroyed.
Definition at line 410 of file gdcmDicomDir.cxx. References Method, and ProgressMethodArgDelete.
00411 { 00412 ProgressMethodArgDelete = method; 00413 } |
|
Set the shadow dictionary used.
Definition at line 210 of file gdcmDocument.cxx. References gdcm::DictKey, and gdcm::Document::RefShaDict.
00211 {
00212 RefShaDict = Global::GetDicts()->GetDict(dictName);
00213 return !RefShaDict;
00214 }
|
|
Set the shadow dictionary used.
Definition at line 200 of file gdcmDocument.cxx. References gdcm::Document::RefShaDict.
00201 {
00202 RefShaDict = dict;
00203 return !RefShaDict;
00204 }
|
|
Set the start method to call when the parsing of the directory starts.
Definition at line 339 of file gdcmDicomDir.cxx. References Method, StartArg, StartMethod, and StartMethodArgDelete. Referenced by ~DicomDir().
00341 { 00342 if( StartArg && StartMethodArgDelete ) 00343 { 00344 StartMethodArgDelete( StartArg ); 00345 } 00346 00347 StartMethod = method; 00348 StartArg = arg; 00349 StartMethodArgDelete = argDelete; 00350 } |
|
Set the method to delete the argument The argument is destroyed when the method is changed or when the class is destroyed.
Definition at line 399 of file gdcmDicomDir.cxx. References Method, and StartMethodArgDelete.
00400 { 00401 StartMethodArgDelete = method; 00402 } |
|
Accesses an existing DocEntry (i.e. a Dicom Element) and modifies it's content with the given value.
Definition at line 211 of file gdcmDocEntrySet.cxx. References gdcm::ValEntry::SetValue().
00212 { 00213 if(entry) 00214 { 00215 entry->SetValue(content); 00216 return true; 00217 } 00218 return false; 00219 } |
|
Accesses an existing DocEntry (i.e. a Dicom Element) through it's (group, element) and modifies it's content with the given value.
Definition at line 169 of file gdcmDocEntrySet.cxx. References gdcmWarningMacro, and gdcm::DocEntrySet::GetValEntry(). Referenced by gdcm::File::AnonymizeFile(), gdcm::Document::Document(), gdcm::DocEntrySet::InsertValEntry(), gdcm::FileHelper::SetValEntry(), and gdcm::File::Write().
00171 { 00172 ValEntry *entry = GetValEntry(group, elem); 00173 if (!entry ) 00174 { 00175 gdcmWarningMacro( "No corresponding ValEntry " << std::hex << group << 00176 "," << elem << " element (try promotion first)."); 00177 return false; 00178 } 00179 return SetValEntry(content,entry); 00180 } |
|
skips bytes inside the source file
Definition at line 707 of file gdcmDocument.cxx. References gdcm::Document::Fp. Referenced by gdcm::File::ComputeJPEGFragmentInfo(), gdcm::File::ComputeRLEInfo(), and gdcm::Document::SkipDocEntry().
00708 { 00709 //FIXME don't dump the returned value 00710 Fp->seekg((long)nBytes, std::ios::cur); 00711 } |
|
Swaps back the bytes of 4-byte long integer accordingly to processor order.
Definition at line 365 of file gdcmDocument.cxx. References gdcmErrorMacro, and gdcm::Document::SwapCode. Referenced by gdcm::Document::GetDocEntryValue().
00366 { 00367 switch (SwapCode) 00368 { 00369 case 1234 : 00370 break; 00371 case 4321 : 00372 a=( ((a<<24) & 0xff000000) | ((a<<8) & 0x00ff0000) | 00373 ((a>>8) & 0x0000ff00) | ((a>>24) & 0x000000ff) ); 00374 break; 00375 case 3412 : 00376 a=( ((a<<16) & 0xffff0000) | ((a>>16) & 0x0000ffff) ); 00377 break; 00378 case 2143 : 00379 a=( ((a<< 8) & 0xff00ff00) | ((a>>8) & 0x00ff00ff) ); 00380 break; 00381 default : 00382 gdcmErrorMacro( "Unset swap code:" << SwapCode ); 00383 a = 0; 00384 } 00385 return a; 00386 } |
|
Swaps the bytes so they agree with the processor order.
Definition at line 351 of file gdcmDocument.cxx. References gdcm::Document::SwapCode. Referenced by gdcm::Document::GetDocEntryValue(), and gdcm::Document::HandleOutOfGroup0002().
|
|
Unswaps back the bytes of 4-byte long integer so they agree with the processor order.
Definition at line 75 of file gdcmDocument.h.
00075 { return SwapLong(a);} |
|
Unswaps back the bytes of 2-bytes long integer so they agree with the processor order.
Definition at line 72 of file gdcmDocument.h.
00072 { return SwapShort(a);} |
|
Writes in a file all the Header Entries (Dicom Elements).
Reimplemented from gdcm::ElementSet. Definition at line 482 of file gdcmDocument.cxx. References gdcm::ExplicitVR, and gdcm::ImplicitVR.
00483 { 00484 // \TODO move the following lines (and a lot of others, to be written) 00485 // to a future function CheckAndCorrectHeader 00486 00487 // (necessary if user wants to write a DICOM V3 file 00488 // starting from an ACR-NEMA (V2) Header 00489 00490 if ( filetype == ImplicitVR || filetype == ExplicitVR ) 00491 { 00492 // writing Dicom File Preamble 00493 char filePreamble[128]; 00494 memset(filePreamble, 0, 128); 00495 fp->write(filePreamble, 128); 00496 fp->write("DICM", 4); 00497 } 00498 00499 /* 00500 * \todo rewrite later, if really usefull 00501 * - 'Group Length' element is optional in DICOM 00502 * - but un-updated odd groups lengthes can causes pb 00503 * (xmedcon breaker) 00504 * 00505 * if ( (filetype == ImplicitVR) || (filetype == ExplicitVR) ) 00506 * UpdateGroupLength(false,filetype); 00507 * if ( filetype == ACR) 00508 * UpdateGroupLength(true,ACR); 00509 */ 00510 00511 ElementSet::WriteContent(fp, filetype); // This one is recursive 00512 } |
|
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 437 of file gdcmDicomDir.cxx. References gdcm::binary_write(), gdcm::ExplicitVR, gdcmWarningMacro, GetMeta(), Patients, and gdcm::DicomDirMeta::WriteContent().
00438 { 00439 int i; 00440 uint16_t sq[4] = { 0x0004, 0x1220, 0xffff, 0xffff }; 00441 uint16_t sqt[4]= { 0xfffe, 0xe0dd, 0xffff, 0xffff }; 00442 00443 std::ofstream *fp = new std::ofstream(fileName.c_str(), 00444 std::ios::out | std::ios::binary); 00445 if( !fp ) 00446 { 00447 gdcmWarningMacro("Failed to open(write) File: " << fileName.c_str()); 00448 return false; 00449 } 00450 00451 char filePreamble[128]; 00452 memset(filePreamble, 0, 128); 00453 fp->write(filePreamble, 128); //FIXME 00454 binary_write( *fp, "DICM"); 00455 00456 DicomDirMeta *ptrMeta = GetMeta(); 00457 ptrMeta->WriteContent(fp, ExplicitVR); 00458 00459 // force writing 0004|1220 [SQ ], that CANNOT exist within DicomDirMeta 00460 for(i=0;i<4;++i) 00461 { 00462 binary_write(*fp, sq[i]); 00463 } 00464 00465 for(ListDicomDirPatient::iterator cc = Patients.begin(); 00466 cc != Patients.end(); 00467 ++cc ) 00468 { 00469 (*cc)->WriteContent( fp, ExplicitVR ); 00470 } 00471 00472 // force writing Sequence Delimitation Item 00473 for(i=0;i<4;++i) 00474 { 00475 binary_write(*fp, sqt[i]); // fffe e0dd ffff ffff 00476 } 00477 00478 fp->close(); 00479 delete fp; 00480 00481 return true; 00482 } |
|
value of the ??? for any progress bar
Definition at line 168 of file gdcmDicomDir.h. Referenced by CallStartMethod(), CreateDicomDirChainedList(), and Initialize(). |
|
List of element to Anonymize.
Definition at line 150 of file gdcmDocument.h. |
|
pointer to the ??? for any progress bar
Definition at line 164 of file gdcmDicomDir.h. Referenced by CallEndMethod(), Initialize(), and SetEndMethod(). |
|
pointer to the termination method for any progress bar
Definition at line 152 of file gdcmDicomDir.h. Referenced by CallEndMethod(), Initialize(), and SetEndMethod(). |
|
pointer to the ??? method for any progress bar
Definition at line 158 of file gdcmDicomDir.h. Referenced by Initialize(), SetEndMethod(), and SetEndMethodArgDelete(). |
|
Refering underlying filename.
Definition at line 112 of file gdcmDocument.h. |
|
ACR, ACR_LIBIDO, ExplicitVR, ImplicitVR, Unknown.
Definition at line 138 of file gdcmDocument.h. Referenced by gdcm::Document::CheckSwap(), gdcm::Document::Document(), gdcm::Document::FindDocEntryVR(), gdcm::Document::GetFileType(), gdcm::Document::HandleOutOfGroup0002(), gdcm::Document::Initialize(), gdcm::Document::IsReadable(), gdcm::Document::ParseDES(), and gdcm::Document::ReadNextDocEntry(). |
|
File Pointer, opened during Document parsing.
Definition at line 135 of file gdcmDocument.h. Referenced by gdcm::Document::CheckSwap(), gdcm::Document::CloseFile(), gdcm::Document::Document(), gdcm::Document::FindDocEntryVR(), gdcm::Document::IsDocEntryAnInteger(), gdcm::Document::LoadDocEntry(), gdcm::Document::LoadDocEntrySafe(), gdcm::Document::LoadEntryBinArea(), gdcm::Document::OpenFile(), gdcm::Document::ParseDES(), gdcm::Document::ParseSQ(), gdcm::Document::ReadNextDocEntry(), gdcm::Document::SkipBytes(), and gdcm::Document::SkipToNextDocEntry(). |
|
whether we already parsed group 0002 (Meta Elements)
Definition at line 129 of file gdcmDocument.h. Referenced by gdcm::Document::Document(), and gdcm::Document::HandleOutOfGroup0002(). |
|
whether file has a DCM Preamble
Definition at line 132 of file gdcmDocument.h. Referenced by gdcm::Document::OpenFile(), and gdcm::Document::ReadNextDocEntry(). |
|
After opening the file, we read HEADER_LENGTH_TO_READ bytes.
Definition at line 141 of file gdcmDocument.h. |
|
Definition at line 145 of file gdcmDicomDir.h. Referenced by GetFirstPatient(), and GetNextPatient(). |
|
Elements whose value is longer than MAX_SIZE_LOAD_ELEMENT_VALUE are NOT loaded.
Definition at line 51 of file gdcmDocument.cxx. Referenced by gdcm::Document::Document(). |
|
Elements whose value is longer than MAX_SIZE_PRINT_ELEMENT_VALUE are NOT printed.
Definition at line 52 of file gdcmDocument.cxx. |
|
Pointer on *the* DicomDirObject 'DicomDirMeta Elements'.
Definition at line 141 of file gdcmDicomDir.h. Referenced by Initialize(), IsReadable(), NewMeta(), Print(), SetElement(), and ~DicomDir(). |
|
Chained list of DicomDirPatient (to be exploited hierarchicaly).
Definition at line 144 of file gdcmDicomDir.h. Referenced by AddImageToEnd(), AddPatientToEnd(), AddSerieToEnd(), AddStudyToEnd(), ClearPatient(), GetFirstPatient(), GetNextPatient(), IsReadable(), Print(), and WriteDicomDir(). |
|
Amount of printed details for each Dicom Entries : 0 : stands for the least detail level.
Definition at line 53 of file gdcmBase.h. Referenced by gdcm::Base::Base(). |
|
value of the ??? for any progress bar
Definition at line 166 of file gdcmDicomDir.h. Referenced by CallEndMethod(), CallStartMethod(), CreateDicomDirChainedList(), and Initialize(). |
|
pointer to the ??? for any progress bar
Definition at line 162 of file gdcmDicomDir.h. Referenced by CallProgressMethod(), Initialize(), and SetProgressMethod(). |
|
pointer to the incrementation method for any progress bar
Definition at line 150 of file gdcmDicomDir.h. Referenced by CallProgressMethod(), Initialize(), and SetProgressMethod(). |
|
pointer to the ??? method for any progress bar
Definition at line 156 of file gdcmDicomDir.h. Referenced by Initialize(), SetProgressMethod(), and SetProgressMethodArgDelete(). |
|
pointer to the ??? for any progress bar
Definition at line 160 of file gdcmDicomDir.h. Referenced by CallStartMethod(), Initialize(), and SetStartMethod(). |
|
pointer to the initialisation method for any progress bar
Definition at line 148 of file gdcmDicomDir.h. Referenced by CallStartMethod(), Initialize(), and SetStartMethod(). |
|
pointer to the ??? method for any progress bar
Definition at line 154 of file gdcmDicomDir.h. Referenced by Initialize(), SetStartMethod(), and SetStartMethodArgDelete(). |
|
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 126 of file gdcmDocument.h. Referenced by gdcm::Document::CheckSwap(), gdcm::Document::Document(), gdcm::Document::SwapLong(), gdcm::Document::SwapShort(), and gdcm::Document::SwitchByteSwapCode(). |