#include <gdcmDocument.h>
Inheritance diagram for gdcm::Document:
Public Types | |
typedef std::list< DicomElement > | ListElements |
Public Member Functions | |
virtual bool | Load (std::string const &filename) |
Loader. (DEPRECATED : not to break the API). | |
virtual bool | Load () |
Loader. use SetLoadMode(), SetFileName() before ! | |
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). | |
virtual bool | IsReadable () |
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. | |
virtual 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 Entries (Dicom Elements). | |
virtual void | LoadEntryBinArea (uint16_t group, uint16_t elem) |
Loads (from disk) the element content when a string is not suitable. | |
virtual void | LoadEntryBinArea (DataEntry *entry) |
Loads (from disk) the element content when a string is not suitable. | |
void | LoadDocEntrySafe (DocEntry *entry) |
Loads the element while preserving the current underlying file position indicator as opposed to LoadDocEntry that modifies it. | |
void | AddForceLoadElement (uint16_t group, uint16_t elem) |
Adds a new element we want to load anyway. | |
bool | operator< (Document &document) |
Compares two documents, according to DicomDir rules. | |
void | SetLoadMode (int mode) |
Sets the LoadMode as a boolean string. LD_NOSEQ, LD_NOSHADOW, LD_NOSHADOWSEQ ... (nothing more, right now) WARNING : before using NO_SHADOW, be sure *all* your files contain accurate values in the 0x0000 element (if any) of *each* Shadow Group. The parser will fail if the size is wrong ! | |
virtual void | Print (std::ostream &os=std::cout, std::string const &indent="") |
Prints the Header Entries (Dicom Elements) from the H Table. | |
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. | |
virtual std::string | GetEntryString (uint16_t group, uint16_t elem) |
Get the "std::string representable" value of the Dicom entry. | |
virtual void * | GetEntryBinArea (uint16_t group, uint16_t elem) |
Gets (from Header) a 'non string' element value. | |
virtual int | GetEntryLength (uint16_t group, uint16_t elem) |
Searches within Header Entries (Dicom Elements) parsed with the public and private dictionaries for the value length of a given tag.. | |
virtual std::string | GetEntryForcedAsciiValue (uint16_t group, uint16_t elem) |
Return the value of the DataEntry if it's "std::string representable". | |
DataEntry * | GetDataEntry (uint16_t group, uint16_t elem) |
Same as Document::GetDocEntry except it only returns a result when the corresponding entry is of type DataEntry. | |
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 | SetEntryString (std::string const &content, uint16_t group, uint16_t elem) |
Accesses an existing DocEntry (i.e. a Dicom Element) through it's (group, element) and modifies it's content with the given value. | |
bool | SetEntryString (std::string const &content, DataEntry *entry) |
Accesses an existing DocEntry (i.e. a Dicom Element) and modifies it's content with the given value. | |
bool | SetEntryBinArea (uint8_t *content, int lgth, uint16_t group, uint16_t elem) |
Accesses an existing DocEntry (i.e. a Dicom Element) through it's (group, element) and modifies it's content with the given value. | |
bool | SetEntryBinArea (uint8_t *content, int lgth, DataEntry *entry) |
Accesses an existing DataEntry (i.e. a Dicom Element) and modifies it's content with the given value. | |
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. Create 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) |
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. | |
DataEntry * | NewDataEntry (uint16_t group, uint16_t elem, VRKey const &vr=GDCM_VRUNKNOWN) |
Build a new Val Entry from all the low level arguments. Check for existence of dictionary entry, and build a default one when absent. | |
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. | |
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. | |
Protected Member Functions | |
Document () | |
This default constructor neither loads nor parses the file. You should then invoke Document::Load. | |
virtual | ~Document () |
Canonical destructor. | |
uint16_t | ReadInt16 () throw ( FormatError ) |
Reads a supposed to be 16 Bits integer (swaps it depending on processor endianness). | |
uint32_t | ReadInt32 () throw ( FormatError ) |
Reads a supposed to be 32 Bits integer (swaps it depending on processor endianness). | |
void | SkipBytes (uint32_t) |
skips bytes inside the source file | |
int | ComputeGroup0002Length () |
Re-computes the length of the Dicom group 0002. | |
bool | MayIWrite (uint16_t) |
Some group are illegal withing some Dicom Documents Only the Document knows it. | |
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. | |
DictEntry * | GetDictEntry (uint16_t group, uint16_t elem, VRKey const &vr) |
Searches [both] the public [and the shadow dictionary (when they exist)] for the presence of the DictEntry with given group and element, and create a new virtual DictEntry if necessary. | |
Protected Attributes | |
std::string | Filename |
Refering underlying filename. | |
int | SwapCode |
Swap code gives an information on the byte order of a supposed to be an int32, as it's read on disc (depending on the image Transfer Syntax *and* on the processor endianess) as opposed as it should in memory to be dealt as an int32. For instance :
| |
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(). | |
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 (Document) | |
void | Initialize () |
Loads all the needed Dictionaries. | |
bool | DoTheLoadingDocumentJob () |
Performs the Loading Job (internal use only). | |
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. | |
double | SwapDouble (double) |
Swaps back the bytes of 8-byte long 'double' 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. | |
void | ParseDES (DocEntrySet *set, long offset, long l_max, bool delim_mode) |
Parses a DocEntrySet (Zero-level DocEntries or SQ Item DocEntries). | |
void | ParseSQ (SeqEntry *seq, long offset, long l_max, bool delim_mode) |
Parses a Sequence ( SeqEntry after SeqEntry). | |
void | LoadDocEntry (DocEntry *e, bool forceLoad=false) |
Loads (or not) the element content depending if its length exceeds or not the value specified with Document::SetMaxSizeLoadEntry(). | |
void | FindDocEntryLength (DocEntry *e) throw ( FormatError ) |
Find the value Length of the passed Doc Entry. | |
uint32_t | FindDocEntryLengthOBOrOW () throw ( FormatUnexpected ) |
Find the Length till the next sequence delimiter. | |
VRKey | FindDocEntryVR () |
Find the Value Representation of the current Dicom Element. | |
bool | CheckDocEntryVR (const VRKey &k) |
Check the correspondance between the VR of the header entry and the taken VR. If they are different, the header entry is updated with the new VR. | |
void | SkipDocEntry (DocEntry *entry) |
Skip a given Header Entry. | |
void | SkipToNextDocEntry (DocEntry *entry) |
Skips to the beginning of the next Header Entry. | |
void | FixDocEntryFoundLength (DocEntry *entry, uint32_t l) |
When the length of an element value is obviously wrong (because the parser went Jabberwocky) one can hope improving things by applying some heuristics. | |
bool | IsDocEntryAnInteger (DocEntry *entry) |
Apply some heuristics to predict whether the considered element value contains/represents an integer or not. | |
bool | CheckSwap () |
Discover what the swap code is (among little endian, big endian, bad little endian, bad big endian). sw is set. | |
void | SwitchByteSwapCode () |
Change the Byte Swap code. | |
void | SetMaxSizeLoadEntry (long) |
during parsing, Header Elements too long are not loaded in memory | |
DocEntry * | ReadNextDocEntry () |
Read the next tag WITHOUT loading it's value (read the 'Group Number', the 'Element Number', gets the Dict Entry gets the VR, gets the length, gets the offset value). | |
void | HandleBrokenEndian (uint16_t &group, uint16_t &elem) |
Handle broken private tag from Philips NTSCAN where the endianess is being switched to BigEndian for no apparent reason. | |
void | HandleOutOfGroup0002 (uint16_t &group, uint16_t &elem) |
Group 0002 is always coded Little Endian whatever Transfer Syntax is. | |
DocEntry * | Backtrack (DocEntry *docEntry) |
When a private Sequence + Implicit VR is encountered we cannot guess it's a Sequence till we find the first Item Starter. We then backtrack to do the job. | |
Private Attributes | |
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 |
Definition at line 40 of file gdcmDocument.h.
|
Definition at line 45 of file gdcmDocument.h. |
|
This default constructor neither loads nor parses the file. You should then invoke Document::Load.
Definition at line 52 of file gdcmDocument.cxx. References gdcm::ExplicitVR, Filetype, Fp, Group0002Parsed, Initialize(), IsDocumentAlreadyLoaded, IsDocumentModified, gdcm::LD_ALL, LoadMode, MAX_SIZE_LOAD_ELEMENT_VALUE, SetFileName(), SetMaxSizeLoadEntry(), and SwapCode. 00053 :ElementSet() 00054 { 00055 Fp = 0; 00056 00057 SetMaxSizeLoadEntry(MAX_SIZE_LOAD_ELEMENT_VALUE); 00058 Initialize(); 00059 SwapCode = 1234; 00060 Filetype = ExplicitVR; 00061 // Load will set it to true if sucessfull 00062 Group0002Parsed = false; 00063 IsDocumentAlreadyLoaded = false; 00064 IsDocumentModified = true; 00065 LoadMode = LD_ALL; // default : load everything, later 00066 SetFileName(""); 00067 }
|
|
Canonical destructor.
Definition at line 72 of file gdcmDocument.cxx. References CloseFile(). 00073 { 00074 CloseFile(); 00075 }
|
|
add a new Dicom Element pointer to the H Table
Implements gdcm::DocEntrySet. Definition at line 78 of file gdcmElementSet.cxx. References gdcmWarningMacro, gdcm::DocEntry::GetKey(), gdcm::RefCounter::Register(), and gdcm::ElementSet::TagHT. Referenced by gdcm::File::DoTheLoadingJob(), gdcm::DocEntryArchive::Push(), and gdcm::DocEntryArchive::Restore(). 00079 { 00080 const TagKey &key = newEntry->GetKey(); 00081 00082 if ( TagHT.count(key) == 1 ) 00083 { 00084 gdcmWarningMacro( "Key already present: " << key ); 00085 return false; 00086 } 00087 else 00088 { 00089 TagHT.insert(TagDocEntryHT::value_type(newEntry->GetKey(), newEntry)); 00090 newEntry->Register(); 00091 return true; 00092 } 00093 }
|
|
Adds a new element we want to load anyway.
Definition at line 290 of file gdcmDocument.cxx. References gdcm::DicomElement::Elem, gdcm::DicomElement::Group, and UserForceLoadList. 00291 { 00292 DicomElement el; 00293 el.Group = group; 00294 el.Elem = elem; 00295 UserForceLoadList.push_back(el); 00296 }
|
|
When a private Sequence + Implicit VR is encountered we cannot guess it's a Sequence till we find the first Item Starter. We then backtrack to do the job.
Definition at line 1296 of file gdcmDocument.cxx. References gdcm::RefCounter::Delete(), Fp, gdcmDebugMacro, gdcm::DocEntry::GetElement(), gdcm::DocEntry::GetGroup(), gdcm::DocEntry::GetLength(), gdcm::DocEntry::GetOffset(), gdcm::DocEntrySet::NewSeqEntry(), gdcm::DocEntrySet::PreviousDocEntry, gdcm::ElementSet::RemoveEntry(), gdcm::DocEntry::SetLength(), and gdcm::DocEntry::SetOffset(). Referenced by ParseDES(). 01297 { 01298 // delete the Item Starter, built erroneously out of any Sequence 01299 // it's not yet in the HTable/chained list 01300 docEntry->Delete(); 01301 01302 // Get all info we can from PreviousDocEntry 01303 uint16_t group = PreviousDocEntry->GetGroup(); 01304 uint16_t elem = PreviousDocEntry->GetElement(); 01305 uint32_t lgt = PreviousDocEntry->GetLength(); 01306 long offset = PreviousDocEntry->GetOffset(); 01307 01308 gdcmDebugMacro( "Backtrack :" << std::hex << group 01309 << "|" << elem 01310 << " at offset " << offset ); 01311 RemoveEntry( PreviousDocEntry ); 01312 01313 // forge the Seq Entry 01314 DocEntry *newEntry = NewSeqEntry(group, elem); 01315 newEntry->SetLength(lgt); 01316 newEntry->SetOffset(offset); 01317 01318 // Move back to the beginning of the Sequence 01319 Fp->seekg( 0, std::ios::beg); 01320 Fp->seekg(offset, std::ios::cur); 01321 01322 return newEntry; 01323 }
|
|
Check the correspondance between the VR of the header entry and the taken VR. If they are different, the header entry is updated with the new VR.
Definition at line 1576 of file gdcmDocument.cxx. References gdcm::Global::GetVR(), and gdcm::VR::IsValidVR(). Referenced by FindDocEntryVR(). 01577 { 01578 return Global::GetVR()->IsValidVR(vr); 01579 }
|
|
Checks if a given Dicom Element exists within the H table.
Definition at line 430 of file gdcmDocEntrySet.cxx. References gdcm::DocEntrySet::GetDocEntry(). 00431 { 00432 return GetDocEntry(group,elem)!=NULL; 00433 }
|
|
Discover what the swap code is (among little endian, big endian, bad little endian, bad big endian). sw is set.
Definition at line 1737 of file gdcmDocument.cxx. References gdcm::ACR, gdcm::ExplicitVR, Filetype, Fp, gdcmDebugMacro, gdcmWarningMacro, gdcm::ImplicitVR, gdcm::Util::IsCurrentProcessorBigEndian(), SwapCode, and gdcm::Unknown. Referenced by DoTheLoadingDocumentJob(). 01738 { 01739 uint32_t s32; 01740 uint16_t s16; 01741 01742 char deb[256]; 01743 01744 // First, compare HostByteOrder and NetworkByteOrder in order to 01745 // determine if we shall need to swap bytes (i.e. the Endian type). 01746 bool net2host = Util::IsCurrentProcessorBigEndian(); 01747 01748 // The easiest case is the one of a 'true' DICOM header, we just have 01749 // to look for the string "DICM" inside the file preamble. 01750 Fp->read(deb, 256); 01751 01752 char *entCur = deb + 128; 01753 if ( memcmp(entCur, "DICM", (size_t)4) == 0 ) 01754 { 01755 gdcmDebugMacro( "Looks like DICOM Version3 (preamble + DCM)" ); 01756 01757 // Group 0002 should always be VR, and the first element 0000 01758 // Let's be carefull (so many wrong headers ...) 01759 // and determine the value representation (VR) : 01760 // Let's skip to the first element (0002,0000) and check there if we find 01761 // "UL" - or "OB" if the 1st one is (0002,0001) -, 01762 // in which case we (almost) know it is explicit VR. 01763 // WARNING: if it happens to be implicit VR then what we will read 01764 // is the length of the group. If this ascii representation of this 01765 // length happens to be "UL" then we shall believe it is explicit VR. 01766 // We need to skip : 01767 // * the 128 bytes of File Preamble (often padded with zeroes), 01768 // * the 4 bytes of "DICM" string, 01769 // * the 4 bytes of the first tag (0002, 0000),or (0002, 0001) 01770 // i.e. a total of 136 bytes. 01771 entCur = deb + 136; 01772 01773 // group 0x0002 *is always* Explicit VR Sometimes , 01774 // even if elem 0002,0010 (Transfer Syntax) tells us the file is 01775 // *Implicit* VR (see former 'gdcmData/icone.dcm') 01776 01777 if ( memcmp(entCur, "UL", (size_t)2) == 0 || 01778 memcmp(entCur, "OB", (size_t)2) == 0 || 01779 memcmp(entCur, "UI", (size_t)2) == 0 || 01780 memcmp(entCur, "CS", (size_t)2) == 0 ) // CS, to remove later 01781 // when Write DCM *adds* 01782 // FIXME 01783 // Use Document::dicom_vr to test all the possibilities 01784 // instead of just checking for UL, OB and UI !? group 0000 01785 { 01786 Filetype = ExplicitVR; 01787 gdcmDebugMacro( "Group 0002 : Explicit Value Representation"); 01788 } 01789 else 01790 { 01791 Filetype = ImplicitVR; 01792 gdcmWarningMacro( "Group 0002 :Not an explicit Value Representation;" 01793 << "Looks like a bugged Header!"); 01794 } 01795 01796 if ( net2host ) 01797 { 01798 SwapCode = 4321; 01799 gdcmDebugMacro( "HostByteOrder != NetworkByteOrder, SwapCode = 4321"); 01800 } 01801 else 01802 { 01803 SwapCode = 1234; 01804 gdcmDebugMacro( "HostByteOrder = NetworkByteOrder, SwapCode = 1234"); 01805 } 01806 01807 // Position the file position indicator at first tag 01808 // (i.e. after the file preamble and the "DICM" string). 01809 01810 Fp->seekg(0, std::ios::beg); // FIXME : Is it usefull? 01811 01812 Fp->seekg ( 132L, std::ios::beg); 01813 return true; 01814 } // ------------------------------- End of DicomV3 ---------------- 01815 01816 // Alas, this is not a DicomV3 file and whatever happens there is no file 01817 // preamble. We can reset the file position indicator to where the data 01818 // is (i.e. the beginning of the file). 01819 01820 gdcmWarningMacro( "Not a Kosher DICOM Version3 file (no preamble)"); 01821 01822 Fp->seekg(0, std::ios::beg); 01823 01824 // Let's check 'No Preamble Dicom File' : 01825 // Should start with group 0x0002 01826 // and be Explicit Value Representation 01827 01828 s16 = *((uint16_t *)(deb)); 01829 SwapCode = 0; 01830 switch ( s16 ) 01831 { 01832 case 0x0002 : 01833 SwapCode = 1234; 01834 entCur = deb + 4; 01835 break; 01836 case 0x0200 : 01837 SwapCode = 4321; 01838 entCur = deb + 6; 01839 } 01840 01841 if ( SwapCode != 0 ) 01842 { 01843 if ( memcmp(entCur, "UL", (size_t)2) == 0 || 01844 memcmp(entCur, "OB", (size_t)2) == 0 || 01845 memcmp(entCur, "UI", (size_t)2) == 0 || 01846 memcmp(entCur, "SH", (size_t)2) == 0 || 01847 memcmp(entCur, "AE", (size_t)2) == 0 || 01848 memcmp(entCur, "OB", (size_t)2) == 0 ) 01849 { 01850 Filetype = ExplicitVR; 01851 gdcmDebugMacro( "Group 0002 : Explicit Value Representation"); 01852 return true; 01853 } 01854 } 01855 // ------------------------------- End of 'No Preamble' DicomV3 ------------- 01856 01857 // Our next best chance would be to be considering a 'clean' ACR/NEMA file. 01858 // By clean we mean that the length of the first group is written down. 01859 // If this is the case and since the length of the first group HAS to be 01860 // four (bytes), then determining the proper swap code is straightforward. 01861 01862 entCur = deb + 4; 01863 // We assume the array of char we are considering contains the binary 01864 // representation of a 32 bits integer. Hence the following dirty 01865 // trick : 01866 s32 = *((uint32_t *)(entCur)); 01867 switch( s32 ) 01868 { 01869 case 0x00040000 : 01870 SwapCode = 3412; 01871 Filetype = ACR; 01872 return true; 01873 case 0x04000000 : 01874 SwapCode = 4321; 01875 Filetype = ACR; 01876 return true; 01877 case 0x00000400 : 01878 SwapCode = 2143; 01879 Filetype = ACR; 01880 return true; 01881 case 0x00000004 : 01882 SwapCode = 1234; 01883 Filetype = ACR; 01884 return true; 01885 default : 01886 // We are out of luck. It is not a DicomV3 nor a 'clean' ACR/NEMA file. 01887 // It is time for despaired wild guesses. 01888 // So, let's check if this file wouldn't happen to be 'dirty' ACR/NEMA, 01889 // i.e. the 'group length' element is not present : 01890 01891 // check the supposed-to-be 'group number' 01892 // in ( 0x0001 .. 0x0008 ) 01893 // to determine ' SwapCode' value . 01894 // Only 0 or 4321 will be possible 01895 // (no oportunity to check for the formerly well known 01896 // ACR-NEMA 'Bad Big Endian' or 'Bad Little Endian' 01897 // if unsuccessfull (i.e. neither 0x0002 nor 0x0200 etc-3, 4, ..., 8-) 01898 // the file IS NOT ACR-NEMA nor DICOM V3 01899 // Find a trick to tell it the caller... 01900 01901 s16 = *((uint16_t *)(deb)); 01902 01903 switch ( s16 ) 01904 { 01905 case 0x0001 : 01906 case 0x0002 : 01907 case 0x0003 : 01908 case 0x0004 : 01909 case 0x0005 : 01910 case 0x0006 : 01911 case 0x0007 : 01912 case 0x0008 : 01913 SwapCode = 1234; 01914 Filetype = ACR; 01915 return true; 01916 case 0x0100 : 01917 case 0x0200 : 01918 case 0x0300 : 01919 case 0x0400 : 01920 case 0x0500 : 01921 case 0x0600 : 01922 case 0x0700 : 01923 case 0x0800 : 01924 SwapCode = 4321; 01925 Filetype = ACR; 01926 return true; 01927 default : 01928 gdcmWarningMacro("ACR/NEMA unfound swap info (Hopeless !)"); 01929 Filetype = Unknown; 01930 return false; 01931 } 01932 } 01933 }
|
|
delete all entries in the ElementSet
Implements gdcm::DocEntrySet. Definition at line 116 of file gdcmElementSet.cxx. References gdcm::ElementSet::TagHT. Referenced by gdcm::DicomDir::CreateDicomDir(), DoTheLoadingDocumentJob(), gdcm::DicomDir::SetElements(), and gdcm::ElementSet::~ElementSet(). 00117 { 00118 for(TagDocEntryHT::iterator cc = TagHT.begin();cc != TagHT.end(); ++cc) 00119 { 00120 if ( cc->second ) 00121 { 00122 cc->second->Unregister(); 00123 } 00124 } 00125 TagHT.clear(); 00126 }
|
|
closes the file
Definition at line 658 of file gdcmDocument.cxx. References Fp. Referenced by DoTheLoadingDocumentJob(), gdcm::File::DoTheLoadingJob(), gdcm::FileHelper::GetRaw(), LoadEntryBinArea(), OpenFile(), and ~Document(). 00659 { 00660 if ( Fp ) 00661 { 00662 Fp->close(); 00663 delete Fp; 00664 Fp = 0; 00665 } 00666 return true; 00667 }
|
|
Re-computes the length of the Dicom group 0002.
Definition at line 956 of file gdcmDocument.cxx. References gdcm::DocEntry::GetElement(), gdcm::ElementSet::GetFirstEntry(), gdcm::DocEntry::GetGroup(), gdcm::DocEntry::GetLength(), gdcm::ElementSet::GetNextEntry(), and gdcm::DocEntry::GetVR(). Referenced by gdcm::File::Write(). 00957 { 00958 uint16_t gr; 00959 VRKey vr; 00960 00961 int groupLength = 0; 00962 bool found0002 = false; 00963 00964 // for each zero-level Tag in the DCM Header 00965 DocEntry *entry = GetFirstEntry(); 00966 while( entry ) 00967 { 00968 gr = entry->GetGroup(); 00969 00970 if ( gr == 0x0002 ) 00971 { 00972 found0002 = true; 00973 00974 if ( entry->GetElement() != 0x0000 ) 00975 { 00976 vr = entry->GetVR(); 00977 00978 //if ( (vr == "OB")||(vr == "OW")||(vr == "UT")||(vr == "SQ")) 00979 // (no SQ, OW, UT in group 0x0002;) 00980 if ( vr == "OB" ) 00981 { 00982 // explicit VR AND (OB, OW, SQ, UT) : 4 more bytes 00983 groupLength += 4; 00984 } 00985 00986 groupLength += 2 + 2 + 4 + entry->GetLength(); 00987 } 00988 } 00989 else if (found0002 ) 00990 break; 00991 00992 entry = GetNextEntry(); 00993 } 00994 return groupLength; 00995 }
|
|
|
Performs the Loading Job (internal use only).
Definition at line 110 of file gdcmDocument.cxx. References gdcm::ACR_LIBIDO, CheckSwap(), gdcm::ElementSet::ClearEntry(), CloseFile(), Filename, Filetype, Fp, gdcmDebugMacro, gdcmErrorMacro, gdcmWarningMacro, gdcm::DocEntrySet::GetDataEntry(), gdcm::ElementSet::GetDocEntry(), gdcm::DocEntrySet::GetEntryString(), gdcm::SeqEntry::GetFirstSQItem(), gdcm::DocEntry::GetLength(), gdcm::DocEntrySet::GetSeqEntry(), Group0002Parsed, IsDocumentAlreadyLoaded, IsDocumentModified, gdcm::ElementSet::IsEmpty(), LoadDocEntry(), LoadEntryBinArea(), OpenFile(), ParseDES(), gdcm::DocEntrySet::SetEntryString(), gdcm::Unknown, and UserForceLoadList. Referenced by Load(). 00111 { 00112 if ( ! IsDocumentModified ) // Nothing to do ! 00113 return true; 00114 00115 ClearEntry(); 00116 00117 Fp = 0; 00118 if ( !OpenFile() ) 00119 { 00120 // warning already performed in OpenFile() 00121 Filetype = Unknown; 00122 return false; 00123 } 00124 00125 Group0002Parsed = false; 00126 00127 gdcmDebugMacro( "Starting parsing of file: " << Filename.c_str()); 00128 00129 Fp->seekg(0, std::ios::end); 00130 long lgt = Fp->tellg(); // total length of the file 00131 00132 Fp->seekg(0, std::ios::beg); 00133 00134 // CheckSwap returns a boolean 00135 // (false if no swap info of any kind was found) 00136 if (! CheckSwap() ) 00137 { 00138 gdcmWarningMacro( "Neither a DICOM V3 nor an ACR-NEMA file: " 00139 << Filename.c_str()); 00140 CloseFile(); 00141 return false; 00142 } 00143 00144 long beg = Fp->tellg(); // just after DICOM preamble (if any) 00145 00146 lgt -= beg; // remaining length to parse 00147 00148 // Recursive call. 00149 // Loading is done during parsing 00150 ParseDES( this, beg, lgt, false); // delim_mode is first defaulted to false 00151 00152 if ( IsEmpty() ) 00153 { 00154 gdcmErrorMacro( "No tag in internal hash table for: " 00155 << Filename.c_str()); 00156 CloseFile(); 00157 return false; 00158 } 00159 IsDocumentAlreadyLoaded = true; 00160 00161 Fp->seekg( 0, std::ios::beg); 00162 00163 // Load 'non string' values 00164 00165 std::string PhotometricInterpretation = GetEntryString(0x0028,0x0004); 00166 if ( PhotometricInterpretation == "PALETTE COLOR " ) 00167 { 00168 // FIXME 00169 // Probabely this line should be outside the 'if' 00170 // Try to find an image sample holding a 'gray LUT' 00171 LoadEntryBinArea(0x0028,0x1200); // gray LUT 00172 00195 00196 // --> OB (byte aray) or OW (short int aray) 00197 // The actual VR has to be deduced from other entries. 00198 // Our way of loading them may fail in some cases : 00199 // We must or not SwapByte depending on other field values. 00200 00201 LoadEntryBinArea(0x0028,0x1201); // R LUT 00202 LoadEntryBinArea(0x0028,0x1202); // G LUT 00203 LoadEntryBinArea(0x0028,0x1203); // B LUT 00204 00205 // Segmented Red Palette Color LUT Data 00206 LoadEntryBinArea(0x0028,0x1221); 00207 // Segmented Green Palette Color LUT Data 00208 LoadEntryBinArea(0x0028,0x1222); 00209 // Segmented Blue Palette Color LUT Data 00210 LoadEntryBinArea(0x0028,0x1223); 00211 } 00212 00213 //FIXME later : how to use it? 00214 SeqEntry *modLutSeq = GetSeqEntry(0x0028,0x3000); 00215 if ( modLutSeq !=0 ) 00216 { 00217 SQItem *sqi= modLutSeq->GetFirstSQItem(); 00218 if ( sqi != 0 ) 00219 { 00220 DataEntry *dataEntry = sqi->GetDataEntry(0x0028,0x3006); 00221 if ( dataEntry != 0 ) 00222 { 00223 if ( dataEntry->GetLength() != 0 ) 00224 { 00225 // FIXME : CTX dependent means : contexted dependant. 00226 // see upper comment. 00227 LoadEntryBinArea(dataEntry); //LUT Data (CTX dependent) 00228 } 00229 } 00230 } 00231 } 00232 00233 // Force Loading some more elements if user asked to. 00234 00235 gdcm::DocEntry *d; 00236 for (ListElements::iterator it = UserForceLoadList.begin(); 00237 it != UserForceLoadList.end(); 00238 ++it) 00239 { 00240 gdcmDebugMacro( "Force Load " << std::hex 00241 << (*it).Group << "|" <<(*it).Elem ); 00242 00243 d = GetDocEntry( (*it).Group, (*it).Elem); 00244 00245 if ( d == NULL) 00246 { 00247 gdcmWarningMacro( "You asked toForce Load " << std::hex 00248 << (*it).Group <<"|"<< (*it).Elem 00249 << " that doesn't exist" ); 00250 continue; 00251 } 00252 00253 LoadDocEntry(d, true); 00254 } 00255 00256 CloseFile(); 00257 00258 // ---------------------------- 00259 // Specific code to allow gdcm to read ACR-LibIDO formated images 00260 // Note: ACR-LibIDO is an extension of the ACR standard that was 00261 // used at CREATIS. For the time being (say a couple of years) 00262 // we keep this kludge to allow CREATIS users 00263 // reading their old images. 00264 // 00265 // if recognition code tells us we deal with a LibIDO image 00266 // we switch lineNumber and columnNumber 00267 // 00268 std::string RecCode; 00269 RecCode = GetEntryString(0x0008, 0x0010); // recognition code (RET) 00270 if (RecCode == "ACRNEMA_LIBIDO_1.1" || 00271 RecCode == "CANRME_AILIBOD1_1." ) // for brain-damaged softwares 00272 // with "little-endian strings" 00273 { 00274 Filetype = ACR_LIBIDO; 00275 std::string rows = GetEntryString(0x0028, 0x0010); 00276 std::string columns = GetEntryString(0x0028, 0x0011); 00277 SetEntryString(columns, 0x0028, 0x0010); 00278 SetEntryString(rows , 0x0028, 0x0011); 00279 } 00280 // --- End of ACR-LibIDO kludge --- 00281 return true; 00282 }
|
|
Find the value Length of the passed Doc Entry.
Definition at line 1393 of file gdcmDocument.cxx. References gdcm::ExplicitVR, and gdcmWarningMacro. Referenced by ReadNextDocEntry(). 01395 { 01396 const VRKey &vr = entry->GetVR(); 01397 uint16_t length16; 01398 01399 if ( Filetype == ExplicitVR && !entry->IsImplicitVR() ) 01400 { 01401 if ( vr == "OB" || vr == "OW" || vr == "SQ" || vr == "UT" 01402 || vr == "UN" ) 01403 { 01404 // The following reserved two bytes (see PS 3.5-2003, section 01405 // "7.1.2 Data element structure with explicit vr", p 27) must be 01406 // skipped before proceeding on reading the length on 4 bytes. 01407 Fp->seekg( 2L, std::ios::cur); 01408 uint32_t length32 = ReadInt32(); 01409 01410 if ( (vr == "OB" || vr == "OW") && length32 == 0xffffffff ) 01411 { 01412 uint32_t lengthOB; 01413 try 01414 { 01415 lengthOB = FindDocEntryLengthOBOrOW(); 01416 } 01417 catch ( FormatUnexpected ) 01418 { 01419 // Computing the length failed (this happens with broken 01420 // files like gdcm-JPEG-LossLess3a.dcm). We still have a 01421 // chance to get the pixels by deciding the element goes 01422 // until the end of the file. Hence we artificially fix the 01423 // the length and proceed. 01424 gdcmWarningMacro( " Computing the length failed for " << 01425 entry->GetKey() <<" in " <<GetFileName()); 01426 01427 long currentPosition = Fp->tellg(); 01428 Fp->seekg(0L,std::ios::end); 01429 01430 long lengthUntilEOF = (long)(Fp->tellg())-currentPosition; 01431 Fp->seekg(currentPosition, std::ios::beg); 01432 01433 entry->SetReadLength(lengthUntilEOF); 01434 entry->SetLength(lengthUntilEOF); 01435 return; 01436 } 01437 entry->SetReadLength(lengthOB); 01438 entry->SetLength(lengthOB); 01439 return; 01440 } 01441 FixDocEntryFoundLength(entry, length32); 01442 return; 01443 } 01444 01445 // Length is encoded on 2 bytes. 01446 length16 = ReadInt16(); 01447 01448 // 0xffff means that we deal with 'No Length' Sequence 01449 // or 'No Length' SQItem 01450 if ( length16 == 0xffff) 01451 { 01452 length16 = 0; 01453 } 01454 FixDocEntryFoundLength( entry, (uint32_t)length16 ); 01455 return; 01456 } 01457 else 01458 { 01459 // Either implicit VR or a non DICOM conformal (see note below) explicit 01460 // VR that ommited the VR of (at least) this element. Farts happen. 01461 // [Note: according to the part 5, PS 3.5-2001, section 7.1 p25 01462 // on Data elements "Implicit and Explicit VR Data Elements shall 01463 // not coexist in a Data Set and Data Sets nested within it".] 01464 // Length is on 4 bytes. 01465 01466 // Well ... group 0002 is always coded in 'Explicit VR Litle Endian' 01467 // even if Transfer Syntax is 'Implicit VR ...' 01468 // --> Except for 'Implicit VR Big Endian Transfer Syntax GE Private' 01469 01470 FixDocEntryFoundLength( entry, ReadInt32() ); 01471 return; 01472 } 01473 }
|
|
Find the Length till the next sequence delimiter.
Definition at line 1479 of file gdcmDocument.cxx. References Fp, gdcmWarningMacro, ReadInt16(), ReadInt32(), and SkipBytes(). 01481 { 01482 // See PS 3.5-2001, section A.4 p. 49 on encapsulation of encoded pixel data. 01483 long positionOnEntry = Fp->tellg(); 01484 bool foundSequenceDelimiter = false; 01485 uint32_t totalLength = 0; 01486 01487 while ( !foundSequenceDelimiter ) 01488 { 01489 uint16_t group; 01490 uint16_t elem; 01491 try 01492 { 01493 group = ReadInt16(); 01494 elem = ReadInt16(); 01495 } 01496 catch ( FormatError ) 01497 { 01498 throw FormatError("Unexpected end of file encountered during ", 01499 "Document::FindDocEntryLengthOBOrOW()"); 01500 } 01501 // We have to decount the group and element we just read 01502 totalLength += 4; 01503 if ( group != 0xfffe || ( ( elem != 0xe0dd ) && ( elem != 0xe000 ) ) ) 01504 { 01505 long filePosition = Fp->tellg(); 01506 gdcmWarningMacro( 01507 "Neither an Item tag nor a Sequence delimiter tag on :" 01508 << std::hex << group << " , " << elem 01509 << ") -before- position x(" << filePosition << ")" ); 01510 01511 Fp->seekg(positionOnEntry, std::ios::beg); 01512 throw FormatUnexpected( 01513 "Neither an Item tag nor a Sequence delimiter tag."); 01514 } 01515 if ( elem == 0xe0dd ) 01516 { 01517 foundSequenceDelimiter = true; 01518 } 01519 uint32_t itemLength = ReadInt32(); 01520 // We add 4 bytes since we just read the ItemLength with ReadInt32 01521 totalLength += itemLength + 4; 01522 SkipBytes(itemLength); 01523 01524 if ( foundSequenceDelimiter ) 01525 { 01526 break; 01527 } 01528 } 01529 Fp->seekg( positionOnEntry, std::ios::beg); 01530 return totalLength; 01531 }
|
|
Find the Value Representation of the current Dicom Element.
Definition at line 1537 of file gdcmDocument.cxx. References CheckDocEntryVR(), CurrentGroup, gdcm::ExplicitVR, Filetype, Fp, gdcm::GDCM_VRUNKNOWN, and gdcmWarningMacro. Referenced by ReadNextDocEntry(). 01538 { 01539 if ( Filetype != ExplicitVR ) 01540 return GDCM_VRUNKNOWN; 01541 01542 long positionOnEntry = Fp->tellg(); 01543 // Warning: we believe this is explicit VR (Value Representation) because 01544 // we used a heuristic that found "UL" in the first tag and/or 01545 // 'Transfer Syntax' told us it is. 01546 // Alas this doesn't guarantee that all the tags will be in explicit VR. 01547 // In some cases one finds implicit VR tags mixed within an explicit VR file. 01548 // Hence we make sure the present tag is in explicit VR and try to fix things 01549 // if it happens not to be the case. 01550 01551 VRKey vr; 01552 Fp->read(&(vr[0]),(size_t)2); 01553 01554 if ( !CheckDocEntryVR(vr) ) 01555 { 01556 // Don't warn user with useless messages 01557 // Often, delimiters (0xfffe), are not explicit VR ... 01558 if ( CurrentGroup != 0xfffe ) 01559 gdcmWarningMacro( "Unknown VR " << std::hex << "0x(" 01560 << (unsigned int)vr[0] << "|" << (unsigned int)vr[1] 01561 << ") at offset :" << positionOnEntry ); 01562 Fp->seekg(positionOnEntry, std::ios::beg); 01563 return GDCM_VRUNKNOWN; 01564 } 01565 return vr; 01566 }
|
|
When the length of an element value is obviously wrong (because the parser went Jabberwocky) one can hope improving things by applying some heuristics.
Definition at line 1614 of file gdcmDocument.cxx. References gdcmWarningMacro, gdcm::DocEntry::GetElement(), gdcm::DocEntry::GetGroup(), gdcm::DocEntry::GetVR(), gdcm::DocEntry::SetLength(), and gdcm::DocEntry::SetReadLength(). 01616 { 01617 entry->SetReadLength( foundLength );// will be updated only if a bug is found 01618 if ( foundLength == 0xffffffff) 01619 { 01620 foundLength = 0; 01621 } 01622 01623 uint16_t gr = entry->GetGroup(); 01624 uint16_t elem = entry->GetElement(); 01625 01626 if ( foundLength % 2) 01627 { 01628 gdcmWarningMacro( "Warning : Tag with uneven length " << foundLength 01629 << " in x(" << std::hex << gr << "," << elem <<")"); 01630 } 01631 01633 // Allthough not recent many such GE corrupted images are still present 01634 // on Creatis hard disks. Hence this fix shall remain when such images 01635 // are no longer in use (we are talking a few years, here)... 01636 // Note: XMedCon probably uses such a trick since it is able to read 01637 // those pesky GE images ... 01638 if ( foundLength == 13) 01639 { 01640 // Only happens for this length ! 01641 if ( gr != 0x0008 || ( elem != 0x0070 && elem != 0x0080 ) ) 01642 { 01643 foundLength = 10; 01644 entry->SetReadLength(10); // a bug is to be fixed !? 01645 } 01646 } 01647 01649 // Occurence of such images is quite low (unless one leaves close to a 01650 // 'Leonardo' source. Hence, one might consider commenting out the 01651 // following fix on efficiency reasons. 01652 else if ( gr == 0x0009 && ( elem == 0x1113 || elem == 0x1114 ) ) 01653 { 01654 foundLength = 4; 01655 entry->SetReadLength(4); // a bug is to be fixed ! 01656 } 01657 01658 else if ( entry->GetVR() == "SQ" ) 01659 { 01660 foundLength = 0; // ReadLength is unchanged 01661 } 01662 01664 // "fffe|xxxx" which is just a marker. Delimiters length should not be 01665 // taken into account. 01666 else if ( gr == 0xfffe ) 01667 { 01668 // According to the norm, fffe|0000 shouldn't exist. BUT the Philips 01669 // image gdcmData/gdcm-MR-PHILIPS-16-Multi-Seq.dcm happens to 01670 // causes extra troubles... 01671 if ( entry->GetElement() != 0x0000 ) 01672 { 01673 foundLength = 0; 01674 } 01675 else 01676 { 01677 foundLength=12; // to skip the mess that follows this bugged Tag ! 01678 } 01679 } 01680 entry->SetLength(foundLength); 01681 }
|
|
|
|
|
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 520 of file gdcmDocEntrySet.cxx. References gdcm::GDCM_VRUNKNOWN, gdcm::DocEntrySet::GetDictEntry(), gdcm::DicomEntry::GetVR(), gdcm::DictEntry::New(), gdcm::RefCounter::Register(), and gdcm::RefCounter::Unregister(). 00522 { 00523 DictEntry *dictEntry = GetDictEntry(group,elem); 00524 DictEntry *goodEntry = dictEntry; 00525 VRKey goodVR = vr; 00526 00527 if (elem == 0x0000) 00528 goodVR="UL"; 00529 00530 if ( goodEntry ) 00531 { 00532 if ( goodVR != goodEntry->GetVR() 00533 && goodVR != GDCM_VRUNKNOWN ) 00534 { 00535 goodEntry = NULL; 00536 } 00537 dictEntry->Unregister(); 00538 } 00539 00540 // Create a new virtual DictEntry if necessary 00541 if (!goodEntry) 00542 { 00543 if (dictEntry) 00544 { 00545 goodEntry = DictEntry::New(group, elem, goodVR, "FIXME", 00546 dictEntry->GetName() ); 00547 } 00548 else 00549 { 00550 goodEntry = DictEntry::New(group, elem, goodVR); 00551 } 00552 } 00553 else 00554 { 00555 goodEntry->Register(); 00556 } 00557 return goodEntry; 00558 }
|
|
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 493 of file gdcmDocEntrySet.cxx. References gdcmWarningMacro, gdcm::DictSet::GetDefaultPubDict(), gdcm::Global::GetDicts(), gdcm::Dict::GetEntry(), and gdcm::RefCounter::Register(). Referenced by gdcm::DocEntrySet::GetDictEntry(), gdcm::DocEntrySet::NewDataEntry(), gdcm::DocEntrySet::NewSeqEntry(), and ReadNextDocEntry(). 00494 { 00495 DictEntry *found = 0; 00496 Dict *pubDict = Global::GetDicts()->GetDefaultPubDict(); 00497 if (!pubDict) 00498 { 00499 gdcmWarningMacro( "We SHOULD have a default dictionary"); 00500 } 00501 else 00502 { 00503 found = pubDict->GetEntry(group, elem); 00504 if( found ) 00505 found->Register(); 00506 } 00507 return found; 00508 }
|
|
retrieves a Dicom Element using (group, element)
Implements gdcm::DocEntrySet. Definition at line 163 of file gdcmElementSet.cxx. References gdcm::ElementSet::TagHT, and gdcm::DicomEntry::TranslateToKey(). Referenced by gdcm::File::AnonymizeFile(), gdcm::File::AnonymizeNoLoad(), gdcm::FileHelper::CopyDataEntry(), gdcm::DicomDir::CreateDicomDir(), DoTheLoadingDocumentJob(), gdcm::File::DoTheLoadingJob(), gdcm::DicomDir::DoTheLoadingJob(), gdcm::File::GetPixelAreaLength(), gdcm::File::GetPixelOffset(), GetTransferSyntax(), gdcm::File::HasLUT(), IsDicomV3(), IsPapyrus(), gdcm::File::IsReadable(), LoadEntryBinArea(), gdcm::DocEntryArchive::Push(), and gdcm::DocEntryArchive::Restore(). 00164 { 00165 TagKey key = DictEntry::TranslateToKey(group, elem); 00166 TagDocEntryHT::iterator it = TagHT.find(key); 00167 00168 if ( it!=TagHT.end() ) 00169 return it->second; 00170 return NULL; 00171 }
|
|
Gets (from Header) a 'non string' element value.
Definition at line 69 of file gdcmDocEntrySet.cxx. References gdcm::DataEntry::GetBinArea(), and gdcm::DocEntrySet::GetDataEntry(). Referenced by gdcm::PixelReadConvert::GrabInformationsFromFile(). 00070 { 00071 DataEntry *entry = GetDataEntry(group, elem); 00072 if ( entry ) 00073 return entry->GetBinArea(); 00074 return 0; 00075 }
|
|
Return the value of the DataEntry if it's "std::string representable".
Definition at line 84 of file gdcmDocEntrySet.cxx. References gdcm::Util::CreateCleanString(), gdcm::GDCM_NOTASCII, gdcm::GDCM_NOTLOADED, gdcm::GDCM_UNFOUND, gdcm::GDCM_UNREAD, gdcm::DataEntry::GetBinArea(), gdcm::DocEntrySet::GetDocEntry(), gdcm::DocEntry::GetLength(), gdcm::DataEntry::GetString(), gdcm::DocEntry::GetVR(), gdcm::Global::GetVR(), gdcm::Util::IsCleanArea(), gdcm::DataEntry::IsNotLoaded(), gdcm::DataEntry::IsUnfound(), gdcm::DataEntry::IsUnread(), and gdcm::VR::IsVROfStringRepresentable(). 00085 { 00086 DocEntry *d = GetDocEntry(group,elem); 00087 if ( !d ) 00088 return GDCM_UNFOUND; 00089 00090 DataEntry *de = dynamic_cast<DataEntry *>(d); 00091 if ( de ) 00092 { 00093 if( de->IsNotLoaded() ) 00094 return GDCM_NOTLOADED; 00095 if( de->IsUnfound() ) 00096 return GDCM_UNFOUND; 00097 if( de->IsUnread() ) 00098 return GDCM_UNREAD; 00099 } 00100 00101 if( Global::GetVR()->IsVROfStringRepresentable( de->GetVR() ) ) 00102 return de->GetString(); 00103 else 00104 { 00105 uint8_t *a = de->GetBinArea(); 00106 if( Util::IsCleanArea(a, de->GetLength()) ) 00107 return Util::CreateCleanString(a, de->GetLength()); 00108 } 00109 return GDCM_NOTASCII; 00110 }
|
|
Searches within Header Entries (Dicom Elements) parsed with the public and private dictionaries for the value length of a given tag..
Definition at line 120 of file gdcmDocEntrySet.cxx. References gdcm::DocEntrySet::GetDocEntry(), and gdcm::DocEntry::GetLength(). Referenced by gdcm::DicomDir::SetElement(), and gdcm::File::Write(). 00121 { 00122 DocEntry *entry = GetDocEntry(group, elem); 00123 if ( entry ) 00124 return entry->GetLength(); 00125 return -1; 00126 }
|
|
Get the "std::string representable" value of the Dicom entry.
Definition at line 47 of file gdcmDocEntrySet.cxx. References gdcm::GDCM_NOTLOADED, gdcm::GDCM_UNFOUND, gdcm::GDCM_UNREAD, gdcm::DocEntrySet::GetDocEntry(), gdcm::DataEntry::GetString(), gdcm::DataEntry::IsNotLoaded(), gdcm::DataEntry::IsUnfound(), and gdcm::DataEntry::IsUnread(). Referenced by gdcm::SerieHelper::AddFileName(), gdcm::File::AnonymizeFile(), gdcm::FileHelper::CheckMandatoryElements(), DoTheLoadingDocumentJob(), gdcm::File::DoTheLoadingJob(), gdcm::File::GetImageNumber(), gdcm::File::GetImageOrientationPatient(), gdcm::File::GetLUTNbits(), gdcm::File::GetModality(), gdcm::File::GetNumberOfScalarComponents(), gdcm::File::GetNumberOfScalarComponentsRaw(), gdcm::File::GetPixelSize(), gdcm::File::GetPixelType(), GetTransferSyntaxName(), gdcm::PixelReadConvert::GrabInformationsFromFile(), gdcm::File::IsMonochrome(), gdcm::File::IsMonochrome1(), gdcm::File::IsPaletteColor(), gdcm::File::IsReadable(), gdcm::File::IsYBRFull(), operator<(), and gdcm::DicomDir::SetElement(). 00048 { 00049 DataEntry *entry = dynamic_cast<DataEntry *>(GetDocEntry(group,elem)); 00050 if ( entry ) 00051 { 00052 if( entry->IsNotLoaded() ) 00053 return GDCM_NOTLOADED; 00054 if( entry->IsUnfound() ) 00055 return GDCM_UNFOUND; 00056 if( entry->IsUnread() ) 00057 return GDCM_UNREAD; 00058 return entry->GetString(); 00059 } 00060 return GDCM_UNFOUND; 00061 }
|
|
Accessor to Filename.
Definition at line 74 of file gdcmDocument.h. Referenced by gdcm::DicomDir::DoTheLoadingJob(), gdcm::SerieHelper::FileNameGreaterThan(), gdcm::SerieHelper::FileNameLessThan(), IsParsable(), gdcm::DicomDir::IsReadable(), Load(), gdcm::DicomDir::ParseDirectory(), and gdcm::DicomDir::SetElement(). 00074 { return Filename; }
|
|
returns the File Type (ACR, ACR_LIBIDO, ExplicitVR, ImplicitVR, Unknown)
Definition at line 403 of file gdcmDocument.cxx. References Filetype. 00404 { 00405 return Filetype; 00406 }
|
|
Get the first entry while visiting *the* 'zero level' DocEntrySet (DocEntries out of any Sequence).
Implements gdcm::DocEntrySet. Definition at line 133 of file gdcmElementSet.cxx. References gdcm::ElementSet::ItTagHT, and gdcm::ElementSet::TagHT. Referenced by ComputeGroup0002Length(), gdcm::DicomDir::DoTheLoadingJob(), gdcm::DicomDir::NewMeta(), and gdcm::Validator::SetInput(). 00134 { 00135 ItTagHT = TagHT.begin(); 00136 if (ItTagHT != TagHT.end()) 00137 return ItTagHT->second; 00138 return NULL; 00139 }
|
|
Get the next entry while visiting *the* 'zero level' DocEntrySet (DocEntries out of any Sequence).
Implements gdcm::DocEntrySet. Definition at line 147 of file gdcmElementSet.cxx. References gdcmAssertMacro, gdcm::ElementSet::ItTagHT, and gdcm::ElementSet::TagHT. Referenced by ComputeGroup0002Length(), and gdcm::Validator::SetInput(). 00148 { 00149 gdcmAssertMacro (ItTagHT != TagHT.end()); 00150 00151 ++ItTagHT; 00152 if (ItTagHT != TagHT.end()) 00153 return ItTagHT->second; 00154 return NULL; 00155 }
|
|
Gets the print level for the Dicom Entries.
Definition at line 50 of file gdcmBase.h. 00050 { return PrintLevel; }
|
|
Get the public dictionary used.
Definition at line 300 of file gdcmDocument.cxx. References RefPubDict. Referenced by gdcm::DicomDir::SetElement(). 00301 { 00302 return RefPubDict; 00303 }
|
|
Get the reference counting.
Definition at line 57 of file gdcmRefCounter.h. 00058 { 00059 return RefCount; 00060 }
|
|
Same as Document::GetDocEntry except it only returns a result when the corresponding entry is of type SeqEntry.
Definition at line 153 of file gdcmDocEntrySet.cxx. References gdcm::DocEntrySet::GetDocEntry(). Referenced by DoTheLoadingDocumentJob(). 00154 { 00155 DocEntry *currentEntry = GetDocEntry(group, elem); 00156 if ( !currentEntry ) 00157 return NULL; 00158 00159 return dynamic_cast<SeqEntry*>(currentEntry); 00160 }
|
|
Get the shadow dictionary used.
Definition at line 308 of file gdcmDocument.cxx. References RefShaDict. 00309 { 00310 return RefShaDict; 00311 }
|
|
'Swap code' accessor (see SwapCode )
Definition at line 70 of file gdcmDocument.h. Referenced by gdcm::PixelReadConvert::GrabInformationsFromFile(). 00070 { 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 415 of file gdcmDocument.cxx. References gdcm::GDCM_UNKNOWN, gdcmWarningMacro, gdcm::ElementSet::GetDocEntry(), and LoadDocEntrySafe(). Referenced by gdcm::File::ComputeJPEGFragmentInfo(), gdcm::File::ComputeRLEInfo(), gdcm::File::DoTheLoadingJob(), gdcm::PixelReadConvert::GrabInformationsFromFile(), and HandleOutOfGroup0002(). 00416 { 00417 DocEntry *entry = GetDocEntry(0x0002, 0x0010); 00418 if ( !entry ) 00419 { 00420 return GDCM_UNKNOWN; 00421 } 00422 00423 // The entry might be present but not loaded (parsing and loading 00424 // happen at different stages): try loading and proceed with check... 00425 LoadDocEntrySafe(entry); 00426 if (DataEntry *dataEntry = dynamic_cast<DataEntry *>(entry) ) 00427 { 00428 std::string transfer = dataEntry->GetString(); 00429 // The actual transfer (as read from disk) might be padded. We 00430 // first need to remove the potential padding. We can make the 00431 // weak assumption that padding was not executed with digits... 00432 if ( transfer.length() == 0 ) 00433 { 00434 // for brain damaged headers 00435 gdcmWarningMacro( "Transfer Syntax has length = 0."); 00436 return GDCM_UNKNOWN; 00437 } 00438 while ( !isdigit((unsigned char)transfer[transfer.length()-1]) ) 00439 { 00440 transfer.erase(transfer.length()-1, 1); 00441 if ( transfer.length() == 0 ) 00442 { 00443 // for brain damaged headers 00444 gdcmWarningMacro( "Transfer Syntax contains no valid character."); 00445 return GDCM_UNKNOWN; 00446 } 00447 } 00448 return transfer; 00449 } 00450 return GDCM_UNKNOWN; 00451 }
|
|
Accesses the info from 0002,0010 : Transfer Syntax and TS.
Definition at line 457 of file gdcmDocument.cxx. References gdcm::GDCM_NOTLOADED, gdcm::GDCM_UNFOUND, gdcmDebugMacro, gdcmErrorMacro, gdcm::DocEntrySet::GetEntryString(), and gdcm::Global::GetTS(). Referenced by HandleOutOfGroup0002(). 00458 { 00459 // use the TS (TS : Transfer Syntax) 00460 std::string transferSyntax = GetEntryString(0x0002,0x0010); 00461 00462 if ( (transferSyntax.find(GDCM_NOTLOADED) < transferSyntax.length()) ) 00463 { 00464 gdcmErrorMacro( "Transfer Syntax not loaded. " << std::endl 00465 << "Better you increase MAX_SIZE_LOAD_ELEMENT_VALUE" ); 00466 return "Uncompressed ACR-NEMA"; 00467 } 00468 if ( transferSyntax == GDCM_UNFOUND ) 00469 { 00470 gdcmDebugMacro( "Unfound Transfer Syntax (0002,0010)"); 00471 return "Uncompressed ACR-NEMA"; 00472 } 00473 00474 // we do it only when we need it 00475 const TSKey &tsName = Global::GetTS()->GetValue( transferSyntax ); 00476 00477 // Global::GetTS() is a global static you shall never try to delete it! 00478 return tsName; 00479 }
|
|
Handle broken private tag from Philips NTSCAN where the endianess is being switched to BigEndian for no apparent reason.
Definition at line 2086 of file gdcmDocument.cxx. References gdcmDebugMacro, gdcmWarningMacro, and SwitchByteSwapCode(). Referenced by ReadNextDocEntry(). 02087 { 02088 // Endian reversion. 02089 // Some files contain groups of tags with reversed endianess. 02090 static int reversedEndian = 0; 02091 // try to fix endian switching in the middle of headers 02092 if ((group == 0xfeff) && (elem == 0x00e0)) 02093 { 02094 // start endian swap mark for group found 02095 gdcmDebugMacro( "Start endian swap mark found." ); 02096 reversedEndian++; 02097 SwitchByteSwapCode(); 02098 // fix the tag 02099 group = 0xfffe; 02100 elem = 0xe000; 02101 } 02102 else if (group == 0xfffe && elem == 0xe00d && reversedEndian) 02103 { 02104 // end of reversed endian group 02105 gdcmDebugMacro( "End of reversed endian." ); 02106 reversedEndian--; 02107 SwitchByteSwapCode(); 02108 } 02109 else if (group == 0xfeff && elem == 0xdde0) 02110 { 02111 // reversed Sequence Terminator found 02112 // probabely a bug in the header ! 02113 // Do what you want, it breaks ! 02114 //reversedEndian--; 02115 //SwitchByteSwapCode(); 02116 gdcmWarningMacro( "Should never get here! reversed Sequence Terminator!" ); 02117 // fix the tag 02118 group = 0xfffe; 02119 elem = 0xe0dd; 02120 } 02121 else if (group == 0xfffe && elem == 0xe0dd) 02122 { 02123 gdcmDebugMacro( "Straight Sequence Terminator." ); 02124 } 02125 }
|
|
Group 0002 is always coded Little Endian whatever Transfer Syntax is.
Definition at line 2132 of file gdcmDocument.cxx. References Filetype, gdcm::GDCM_UNKNOWN, gdcmDebugMacro, gdcmWarningMacro, GetTransferSyntax(), GetTransferSyntaxName(), gdcm::Global::GetTS(), Group0002Parsed, gdcm::ImplicitVR, SwapShort(), and SwitchByteSwapCode(). Referenced by ReadNextDocEntry(). 02133 { 02134 // Endian reversion. 02135 // Some files contain groups of tags with reversed endianess. 02136 if ( !Group0002Parsed && group != 0x0002) 02137 { 02138 Group0002Parsed = true; 02139 // we just came out of group 0002 02140 // if Transfer Syntax is Big Endian we have to change CheckSwap 02141 02142 std::string ts = GetTransferSyntax(); 02143 if ( ts == GDCM_UNKNOWN ) 02144 { 02145 gdcmDebugMacro("True DICOM File, with NO Transfer Syntax (?!) " ); 02146 return; 02147 } 02148 if ( !Global::GetTS()->IsTransferSyntax(ts) ) 02149 { 02150 gdcmWarningMacro("True DICOM File, with illegal Transfer Syntax: [" 02151 << ts << "]"); 02152 return; 02153 } 02154 02155 // Group 0002 is always 'Explicit ...' 02156 // even when Transfer Syntax says 'Implicit ..." 02157 02158 if ( Global::GetTS()->GetSpecialTransferSyntax(ts) == 02159 TS::ImplicitVRLittleEndian ) 02160 { 02161 Filetype = ImplicitVR; 02162 } 02163 02164 // FIXME Strangely, this works with 02165 //'Implicit VR BigEndian Transfer Syntax (GE Private) 02166 // 02167 // --> Probabely normal, since we considered we never have 02168 // to trust manufacturers. 02169 // (we find very often 'Implicit VR' tag, 02170 // even when Transfer Syntax tells us it's Explicit ... 02171 if ( Global::GetTS()->GetSpecialTransferSyntax(ts) == 02172 TS::ExplicitVRBigEndian ) 02173 { 02174 gdcmDebugMacro("Transfer Syntax Name = [" 02175 << GetTransferSyntaxName() << "]" ); 02176 SwitchByteSwapCode(); 02177 group = SwapShort(group); 02178 elem = SwapShort(elem); 02179 } 02180 } 02181 }
|
|
Loads all the needed Dictionaries.
Reimplemented in gdcm::DicomDir. Definition at line 1002 of file gdcmDocument.cxx. References Filetype, gdcm::DictSet::GetDefaultPubDict(), gdcm::Global::GetDicts(), RefPubDict, RefShaDict, and gdcm::Unknown. Referenced by Document(). 01003 { 01004 RefPubDict = Global::GetDicts()->GetDefaultPubDict(); 01005 RefShaDict = NULL; 01006 Filetype = Unknown; 01007 }
|
|
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 308 of file gdcmDocEntrySet.cxx. References gdcm::DocEntrySet::AddEntry(), gdcm::RefCounter::Delete(), gdcmWarningMacro, gdcm::DocEntrySet::GetDocEntry(), gdcm::DocEntry::GetVR(), gdcm::DocEntrySet::NewDataEntry(), gdcm::DocEntrySet::RemoveEntry(), and gdcm::DocEntrySet::SetEntryBinArea(). Referenced by gdcm::FileHelper::InsertEntryBinArea(). 00311 { 00312 DataEntry *dataEntry = 0; 00313 DocEntry *currentEntry = GetDocEntry( group, elem ); 00314 00315 // Verify the currentEntry 00316 if (currentEntry) 00317 { 00318 dataEntry = dynamic_cast<DataEntry *>(currentEntry); 00319 00320 // Verify the VR 00321 if ( dataEntry ) 00322 if ( dataEntry->GetVR()!=vr ) 00323 dataEntry = NULL; 00324 00325 // if currentEntry doesn't correspond to the requested dataEntry 00326 if ( !dataEntry) 00327 { 00328 if ( !RemoveEntry(currentEntry) ) 00329 { 00330 gdcmWarningMacro( "Removal of previous DocEntry failed."); 00331 return NULL; 00332 } 00333 } 00334 } 00335 00336 // Create a new dataEntry if necessary 00337 if ( !dataEntry) 00338 { 00339 dataEntry = NewDataEntry(group, elem, vr); 00340 00341 if ( !AddEntry(dataEntry) ) 00342 { 00343 gdcmWarningMacro( "AddEntry failed although this is a creation."); 00344 dataEntry->Delete(); 00345 return NULL; 00346 } 00347 dataEntry->Delete(); 00348 } 00349 00350 // Set the dataEntry value 00351 uint8_t *tmpArea; 00352 if ( lgth>0 && binArea ) 00353 { 00354 tmpArea = new uint8_t[lgth]; 00355 memcpy(tmpArea,binArea,lgth); 00356 } 00357 else 00358 { 00359 tmpArea = 0; 00360 } 00361 if ( !SetEntryBinArea(tmpArea,lgth,dataEntry) ) 00362 { 00363 if ( tmpArea ) 00364 { 00365 delete[] tmpArea; 00366 } 00367 } 00368 00369 return dataEntry; 00370 }
|
|
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(), gdcm::RefCounter::Delete(), gdcmWarningMacro, gdcm::DocEntrySet::GetDocEntry(), gdcm::DocEntry::GetVR(), gdcm::DocEntrySet::NewDataEntry(), gdcm::DocEntrySet::RemoveEntry(), and gdcm::DocEntrySet::SetEntryString(). Referenced by gdcm::FileHelper::InsertEntryString(), gdcm::FileHelper::Write(), and gdcm::File::Write(). 00253 { 00254 DataEntry *dataEntry = 0; 00255 DocEntry *currentEntry = GetDocEntry( group, elem ); 00256 00257 if (currentEntry) 00258 { 00259 dataEntry = dynamic_cast<DataEntry *>(currentEntry); 00260 00261 // Verify the VR 00262 if ( dataEntry ) 00263 if ( dataEntry->GetVR()!=vr ) 00264 dataEntry = NULL; 00265 00266 // if currentEntry doesn't correspond to the requested dataEntry 00267 if ( !dataEntry) 00268 { 00269 if ( !RemoveEntry(currentEntry) ) 00270 { 00271 gdcmWarningMacro( "Removal of previous DocEntry failed."); 00272 return NULL; 00273 } 00274 } 00275 } 00276 00277 // Create a new dataEntry if necessary 00278 if ( !dataEntry ) 00279 { 00280 dataEntry = NewDataEntry( group, elem, vr ); 00281 00282 if ( !AddEntry(dataEntry) ) 00283 { 00284 gdcmWarningMacro("AddEntry failed although this is a creation."); 00285 dataEntry->Delete(); 00286 return NULL; 00287 } 00288 dataEntry->Delete(); 00289 } 00290 00291 // Set the dataEntry value 00292 SetEntryString(value, dataEntry); // The std::string value 00293 return dataEntry; 00294 }
|
|
Modifies the value of a given Doc Entry (Dicom Element) when it exists. Creates it when unexistant.
Definition at line 380 of file gdcmDocEntrySet.cxx. References gdcm::DocEntrySet::AddEntry(), gdcm::RefCounter::Delete(), gdcmWarningMacro, gdcm::DocEntrySet::GetDocEntry(), gdcm::DocEntrySet::NewSeqEntry(), and gdcm::DocEntrySet::RemoveEntry(). Referenced by gdcm::FileHelper::InsertSeqEntry(). 00381 { 00382 SeqEntry *seqEntry = 0; 00383 DocEntry *currentEntry = GetDocEntry( group, elem ); 00384 00385 // Verify the currentEntry 00386 if ( currentEntry ) 00387 { 00388 seqEntry = dynamic_cast<SeqEntry *>(currentEntry); 00389 00390 // Verify the VR 00391 if ( seqEntry ) 00392 seqEntry = NULL; 00393 00394 // if currentEntry doesn't correspond to the requested seqEntry 00395 if ( !seqEntry ) 00396 { 00397 if (!RemoveEntry(currentEntry)) 00398 { 00399 gdcmWarningMacro( "Removal of previous DocEntry failed."); 00400 00401 return NULL; 00402 } 00403 } 00404 } 00405 // Create a new seqEntry if necessary 00406 if ( !seqEntry ) 00407 { 00408 seqEntry = NewSeqEntry(group, elem); 00409 00410 if ( !AddEntry(seqEntry) ) 00411 { 00412 gdcmWarningMacro( "AddEntry failed although this is a creation."); 00413 seqEntry->Delete(); 00414 return NULL; 00415 } 00416 seqEntry->Delete(); 00417 } 00418 00419 // TODO : Find a trick to insert a SequenceDelimitationItem 00420 // in the SeqEntry, at the end. 00421 return seqEntry; 00422 }
|
|
Predicate for dicom version 3 file.
Definition at line 372 of file gdcmDocument.cxx. References gdcm::ElementSet::GetDocEntry(). Referenced by gdcm::File::GetYSize(), and gdcm::PixelReadConvert::GrabInformationsFromFile(). 00373 { 00374 // Checking if Transfer Syntax exists is enough 00375 // Anyway, it's too late check if the 'Preamble' was found ... 00376 // And ... would it be a rich idea to check ? 00377 // (some 'no Preamble' DICOM images exist !) 00378 return GetDocEntry(0x0002, 0x0010) != NULL; 00379 }
|
|
Apply some heuristics to predict whether the considered element value contains/represents an integer or not.
Definition at line 1689 of file gdcmDocument.cxx. References Fp, gdcmWarningMacro, gdcm::DocEntry::GetElement(), gdcm::DocEntry::GetGroup(), gdcm::DocEntry::GetLength(), and gdcm::DocEntry::GetVR(). 01690 { 01691 uint16_t elem = entry->GetElement(); 01692 uint16_t group = entry->GetGroup(); 01693 const VRKey &vr = entry->GetVR(); 01694 uint32_t length = entry->GetLength(); 01695 01696 // When we have some semantics on the element we just read, and if we 01697 // a priori know we are dealing with an integer, then we shall be 01698 // able to swap it's element value properly. 01699 if ( elem == 0 ) // This is the group length of the group 01700 { 01701 if ( length == 4 ) 01702 { 01703 return true; 01704 } 01705 else 01706 { 01707 // Although this should never happen, still some images have a 01708 // corrupted group length [e.g. have a glance at offset x(8336) of 01709 // gdcmData/gdcm-MR-PHILIPS-16-Multi-Seq.dcm. 01710 // Since for dicom compliant and well behaved headers, the present 01711 // test is useless (and might even look a bit paranoid), when we 01712 // encounter such an ill-formed image, we simply display a warning 01713 // message and proceed on parsing (while crossing fingers). 01714 long filePosition = Fp->tellg(); 01715 gdcmWarningMacro( "Erroneous Group Length element length on : (" 01716 << std::hex << group << " , " << elem 01717 << ") -before- position x(" << filePosition << ")" 01718 << "lgt : " << length ); 01719 } 01720 } 01721 01722 if ( vr == "UL" || vr == "US" || vr == "SL" || vr == "SS" ) 01723 { 01724 return true; 01725 } 01726 return false; 01727 }
|
|
Tells us if the ElementSet contains no entry.
Implements gdcm::DocEntrySet. Definition at line 60 of file gdcmElementSet.h. Referenced by DoTheLoadingDocumentJob(), and IsParsable(). 00060 { return TagHT.empty(); }
|
|
Predicate for Papyrus file Dedicated to whomsoever it may concern.
Definition at line 386 of file gdcmDocument.cxx. References gdcm::ElementSet::GetDocEntry(). 00387 { 00388 // check for Papyrus private Sequence 00389 DocEntry *e = GetDocEntry(0x0041, 0x1050); 00390 if ( !e ) 00391 return false; 00392 // check if it's actually a Sequence 00393 if ( !dynamic_cast<SeqEntry*>(e) ) 00394 return false; 00395 return true; 00396 }
|
|
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 340 of file gdcmDocument.cxx. References Filetype, gdcmWarningMacro, GetFileName(), gdcm::ElementSet::IsEmpty(), and gdcm::Unknown. Referenced by IsReadable(). 00341 { 00342 if ( Filetype == Unknown ) 00343 { 00344 gdcmWarningMacro( "Wrong filetype for " << GetFileName()); 00345 return false; 00346 } 00347 00348 if ( IsEmpty() ) 00349 { 00350 gdcmWarningMacro( "No tag in internal hash table."); 00351 return false; 00352 } 00353 00354 return true; 00355 }
|
|
This predicate tells us whether or not the current Document was properly parsed and contains at least *one* Dicom Element (and nothing more, sorry).
Reimplemented in gdcm::DicomDir, and gdcm::File. Definition at line 363 of file gdcmDocument.cxx. References IsParsable(). Referenced by gdcm::File::IsReadable(). 00364 { 00365 return IsParsable(); 00366 }
|
|
Loader. use SetLoadMode(), SetFileName() before !
Reimplemented in gdcm::DicomDir, and gdcm::File. Definition at line 84 of file gdcmDocument.cxx. References DoTheLoadingDocumentJob(), gdcmWarningMacro, and GetFileName(). Referenced by gdcm::DicomDir::DoTheLoadingJob(). 00085 { 00086 if ( GetFileName() == "" ) 00087 { 00088 gdcmWarningMacro( "Use SetFileName, before !" ); 00089 return false; 00090 } 00091 return DoTheLoadingDocumentJob( ); 00092 }
|
|
Loader. (DEPRECATED : not to break the API).
Definition at line 99 of file gdcmDocument.cxx. References DoTheLoadingDocumentJob(), and Filename. 00100 { 00101 Filename = fileName; 00102 return DoTheLoadingDocumentJob( ); 00103 }
|
|
Loads (or not) the element content depending if its length exceeds or not the value specified with Document::SetMaxSizeLoadEntry().
Definition at line 1331 of file gdcmDocument.cxx. References Fp, gdcm::DocEntry::GetElement(), gdcm::DocEntry::GetGroup(), gdcm::DocEntry::GetLength(), gdcm::DocEntry::GetOffset(), gdcm::DocEntry::GetVR(), LoadEntryBinArea(), MaxSizeLoadEntry, gdcm::DataEntry::SetBinArea(), gdcm::DataEntry::SetState(), and gdcm::DataEntry::STATE_NOTLOADED. Referenced by DoTheLoadingDocumentJob(), LoadDocEntrySafe(), and ParseDES(). 01332 { 01333 uint16_t group = entry->GetGroup(); 01334 uint16_t elem = entry->GetElement(); 01335 const VRKey &vr = entry->GetVR(); 01336 uint32_t length = entry->GetLength(); 01337 01338 Fp->seekg((long)entry->GetOffset(), std::ios::beg); 01339 01340 // A SeQuence "contains" a set of Elements. 01341 // (fffe e000) tells us an Element is beginning 01342 // (fffe e00d) tells us an Element just ended 01343 // (fffe e0dd) tells us the current SeQuence just ended 01344 // 01345 // (fffe 0000) is an 'impossible' tag value, 01346 // found in MR-PHILIPS-16-Multi-Seq.dcm 01347 01348 if ( (group == 0xfffe && elem != 0x0000 ) || vr == "SQ" ) 01349 { 01350 // NO more value field for SQ ! 01351 return; 01352 } 01353 01354 DataEntry *dataEntryPtr = dynamic_cast< DataEntry* >(entry); 01355 if( !dataEntryPtr ) 01356 { 01357 return; 01358 } 01359 01360 // When the length is zero things are easy: 01361 if ( length == 0 ) 01362 { 01363 dataEntryPtr->SetBinArea(NULL,true); 01364 return; 01365 } 01366 01367 // The elements whose length is bigger than the specified upper bound 01368 // are not loaded. 01369 01370 std::ostringstream s; 01371 01372 if (!forceLoad) 01373 { 01374 if (length > MaxSizeLoadEntry) 01375 { 01376 dataEntryPtr->SetBinArea(NULL,true); 01377 dataEntryPtr->SetState(DataEntry::STATE_NOTLOADED); 01378 01379 // to be sure we are at the end of the value ... 01380 Fp->seekg((long)entry->GetOffset()+(long)entry->GetLength(), 01381 std::ios::beg); 01382 return; 01383 } 01384 } 01385 01386 LoadEntryBinArea(dataEntryPtr); // last one, not to erase length ! 01387 }
|
|
Loads the element while preserving the current underlying file position indicator as opposed to LoadDocEntry that modifies it.
Definition at line 822 of file gdcmDocument.cxx. References Fp, and LoadDocEntry(). Referenced by GetTransferSyntax(). 00823 { 00824 if ( Fp ) 00825 { 00826 long PositionOnEntry = Fp->tellg(); 00827 LoadDocEntry(entry); 00828 Fp->seekg(PositionOnEntry, std::ios::beg); 00829 } 00830 }
|
|
Loads (from disk) the element content when a string is not suitable.
Definition at line 741 of file gdcmDocument.cxx. References CloseFile(), Fp, gdcmWarningMacro, gdcm::VR::GetAtomicElementLength(), gdcm::DataEntry::GetBinArea(), gdcm::DocEntry::GetElement(), gdcm::DocEntry::GetGroup(), gdcm::DocEntry::GetLength(), gdcm::DocEntry::GetOffset(), gdcm::DocEntry::GetVR(), gdcm::Global::GetVR(), OpenFile(), gdcm::DataEntry::SetBinArea(), gdcm::DataEntry::SetState(), gdcm::DataEntry::STATE_UNREAD, SwapDouble(), SwapLong(), and SwapShort(). 00742 { 00743 if( entry->GetBinArea() ) 00744 return; 00745 00746 bool openFile = !Fp; 00747 if ( openFile ) 00748 OpenFile(); 00749 00750 size_t o =(size_t)entry->GetOffset(); 00751 Fp->seekg(o, std::ios::beg); 00752 00753 size_t l = entry->GetLength(); 00754 uint8_t *data = new uint8_t[l]; 00755 if ( !data ) 00756 { 00757 gdcmWarningMacro( "Cannot allocate DataEntry content for : " 00758 << std::hex << entry->GetGroup() 00759 << "|" << entry->GetElement() ); 00760 return; 00761 } 00762 00763 // Read the data 00764 Fp->read((char*)data, l); 00765 if ( Fp->fail() || Fp->eof() ) 00766 { 00767 delete[] data; 00768 entry->SetState(DataEntry::STATE_UNREAD); 00769 return; 00770 } 00771 00772 // Swap the data content if necessary 00773 uint32_t i; 00774 unsigned short vrLgth = 00775 Global::GetVR()->GetAtomicElementLength(entry->GetVR()); 00776 00777 // FIXME : trouble expected if we read an ... OW Entry (LUT, etc ..) 00778 // if( entry->GetVR() == "OW" ) 00779 // vrLgth = 1; 00780 00781 switch(vrLgth) 00782 { 00783 case 1: 00784 { 00785 break; 00786 } 00787 case 2: 00788 { 00789 uint16_t *data16 = (uint16_t *)data; 00790 for(i=0;i<l/vrLgth;i++) 00791 data16[i] = SwapShort(data16[i]); 00792 break; 00793 } 00794 case 4: 00795 { 00796 uint32_t *data32 = (uint32_t *)data; 00797 for(i=0;i<l/vrLgth;i++) 00798 data32[i] = SwapLong(data32[i]); 00799 break; 00800 } 00801 case 8: 00802 { 00803 double *data64 = (double *)data; 00804 for(i=0;i<l/vrLgth;i++) 00805 data64[i] = SwapDouble(data64[i]); 00806 break; 00807 } 00808 } 00809 00810 entry->SetBinArea(data); 00811 00812 if ( openFile ) 00813 CloseFile(); 00814 }
|
|
Loads (from disk) the element content when a string is not suitable.
Definition at line 716 of file gdcmDocument.cxx. References gdcmDebugMacro, gdcmWarningMacro, and gdcm::ElementSet::GetDocEntry(). Referenced by DoTheLoadingDocumentJob(), gdcm::PixelReadConvert::GrabInformationsFromFile(), and LoadDocEntry(). 00717 { 00718 // Search the corresponding DocEntry 00719 DocEntry *docEntry = GetDocEntry(group, elem); 00720 if ( !docEntry ) 00721 { 00722 gdcmDebugMacro(std::hex << group << "|" << elem 00723 << " doesn't exist" ); 00724 return; 00725 } 00726 DataEntry *dataEntry = dynamic_cast<DataEntry *>(docEntry); 00727 if ( !dataEntry ) 00728 { 00729 gdcmWarningMacro(std::hex << group << "|" << elem 00730 << " is NOT a DataEntry"); 00731 return; 00732 } 00733 LoadEntryBinArea(dataEntry); 00734 }
|
|
Some group are illegal withing some Dicom Documents Only the Document knows it.
Reimplemented in gdcm::File. Definition at line 67 of file gdcmElementSet.h. Referenced by gdcm::ElementSet::WriteContent().
|
|
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 444 of file gdcmDocEntrySet.cxx. References gdcmWarningMacro, gdcm::DocEntrySet::GetDictEntry(), gdcm::DataEntry::New(), and gdcm::RefCounter::Unregister(). Referenced by gdcm::FileHelper::CopyDataEntry(), gdcm::DocEntrySet::InsertEntryBinArea(), gdcm::DocEntrySet::InsertEntryString(), and ReadNextDocEntry(). 00446 { 00447 DictEntry *dictEntry = GetDictEntry(group, elem, vr); 00448 00449 DataEntry *newEntry = DataEntry::New(dictEntry); 00450 dictEntry->Unregister(); // GetDictEntry register it 00451 if (!newEntry) 00452 { 00453 gdcmWarningMacro( "Failed to allocate DataEntry"); 00454 return 0; 00455 } 00456 return newEntry; 00457 }
|
|
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 467 of file gdcmDocEntrySet.cxx. References gdcmWarningMacro, gdcm::DocEntrySet::GetDictEntry(), gdcm::SeqEntry::New(), and gdcm::RefCounter::Unregister(). Referenced by Backtrack(), gdcm::DocEntrySet::InsertSeqEntry(), and ReadNextDocEntry(). 00468 { 00469 DictEntry *dictEntry = GetDictEntry(group, elem, "SQ"); 00470 00471 SeqEntry *newEntry = SeqEntry::New( dictEntry ); 00472 dictEntry->Unregister(); // GetDictEntry register it 00473 if (!newEntry) 00474 { 00475 gdcmWarningMacro( "Failed to allocate SeqEntry"); 00476 return 0; 00477 } 00478 return newEntry; 00479 }
|
|
Tries to open the file Document::Filename and checks the preamble when existing.
Definition at line 572 of file gdcmDocument.cxx. References CloseFile(), Filename, gdcm::Util::Format(), Fp, gdcmDebugMacro, gdcmWarningMacro, and HasDCMPreamble. Referenced by DoTheLoadingDocumentJob(), gdcm::File::DoTheLoadingJob(), gdcm::FileHelper::GetRaw(), and LoadEntryBinArea(). 00573 { 00574 HasDCMPreamble = false; 00575 if (Filename.length() == 0) 00576 { 00577 return 0; 00578 } 00579 00580 if ( Fp ) 00581 { 00582 gdcmDebugMacro( "File already open: " << Filename.c_str()); 00583 CloseFile(); 00584 } 00585 00586 Fp = new std::ifstream(Filename.c_str(), std::ios::in | std::ios::binary); 00587 if ( ! *Fp ) 00588 { 00589 // Don't user gdcmErrorMacro : 00590 // a spurious message will appear when you use, for instance 00591 // gdcm::FileHelper *fh = new gdcm::FileHelper( outputFileName ); 00592 // to create outputFileName. 00593 00594 // FIXME : if the upper comment is still usefull 00595 // --> the constructor is not so good ... 00596 00597 gdcmWarningMacro( "Cannot open file: " << Filename.c_str()); 00598 delete Fp; 00599 Fp = 0; 00600 return 0; 00601 //exit(1); // No function is allowed to leave the application instead 00602 // of warning the caller 00603 } 00604 00605 uint16_t zero = 0; 00606 Fp->read((char*)&zero, (size_t)2); 00607 if ( Fp->eof() ) 00608 { 00609 CloseFile(); 00610 return 0; 00611 } 00612 00613 //-- Broken ACR or DICOM with no Preamble; may start with a Shadow Group -- 00614 00615 // FIXME : We cannot be sure the preable is only zeroes.. 00616 // (see ACUSON-24-YBR_FULL-RLE.dcm ) 00617 if ( 00618 zero == 0x0001 || zero == 0x0100 || zero == 0x0002 || zero == 0x0200 || 00619 zero == 0x0003 || zero == 0x0300 || zero == 0x0004 || zero == 0x0400 || 00620 zero == 0x0005 || zero == 0x0500 || zero == 0x0006 || zero == 0x0600 || 00621 zero == 0x0007 || zero == 0x0700 || zero == 0x0008 || zero == 0x0800 ) 00622 { 00623 std::string msg = Util::Format( 00624 "ACR/DICOM starting by 0x(%04x) at the beginning of the file\n", zero); 00625 // FIXME : is it a Warning message, or a Debug message? 00626 gdcmWarningMacro( msg.c_str() ); 00627 return Fp; 00628 } 00629 00630 //-- DICOM -- 00631 Fp->seekg(126L, std::ios::cur); 00632 char dicm[4]; // = {' ',' ',' ',' '}; 00633 Fp->read(dicm, (size_t)4); 00634 if ( Fp->eof() ) 00635 { 00636 CloseFile(); 00637 return 0; 00638 } 00639 if ( memcmp(dicm, "DICM", 4) == 0 ) 00640 { 00641 HasDCMPreamble = true; 00642 return Fp; 00643 } 00644 00645 // -- Neither ACR/No Preamble Dicom nor DICOMV3 file 00646 CloseFile(); 00647 // Don't user Warning nor Error, not to polute the output 00648 // while directory recursive parsing ... 00649 gdcmDebugMacro( "Neither ACR/No Preamble Dicom nor DICOMV3 file: " 00650 << Filename.c_str()); 00651 return 0; 00652 }
|
|
Compares two documents, according to DicomDir rules.
Definition at line 839 of file gdcmDocument.cxx. References gdcm::DocEntrySet::GetEntryString(). 00840 { 00841 // Patient Name 00842 std::string s1 = GetEntryString(0x0010,0x0010); 00843 std::string s2 = document.GetEntryString(0x0010,0x0010); 00844 if (s1 < s2) 00845 { 00846 return true; 00847 } 00848 else if ( s1 > s2 ) 00849 { 00850 return false; 00851 } 00852 else 00853 { 00854 // Patient ID 00855 s1 = GetEntryString(0x0010,0x0020); 00856 s2 = document.GetEntryString(0x0010,0x0020); 00857 if ( s1 < s2 ) 00858 { 00859 return true; 00860 } 00861 else if ( s1 > s2 ) 00862 { 00863 return false; 00864 } 00865 else 00866 { 00867 // Study Instance UID 00868 s1 = GetEntryString(0x0020,0x000d); 00869 s2 = document.GetEntryString(0x0020,0x000d); 00870 if ( s1 < s2 ) 00871 { 00872 return true; 00873 } 00874 else if ( s1 > s2 ) 00875 { 00876 return false; 00877 } 00878 else 00879 { 00880 // Serie Instance UID 00881 s1 = GetEntryString(0x0020,0x000e); 00882 s2 = document.GetEntryString(0x0020,0x000e); 00883 if ( s1 < s2 ) 00884 { 00885 return true; 00886 } 00887 else if ( s1 > s2 ) 00888 { 00889 return false; 00890 } 00891 } 00892 } 00893 } 00894 return false; 00895 }
|
|
Parses a DocEntrySet (Zero-level DocEntries or SQ Item DocEntries).
Definition at line 1016 of file gdcmDocument.cxx. References gdcm::DocEntrySet::AddEntry(), Backtrack(), gdcm::RefCounter::Delete(), Fp, gdcmDebugMacro, gdcmWarningMacro, gdcm::Debug::GetDebugFlag(), gdcm::DocEntry::GetElement(), gdcm::DocEntry::GetGroup(), gdcm::DocEntry::GetKey(), gdcm::DocEntry::GetOffset(), gdcm::DocEntry::GetReadLength(), gdcm::DataEntry::GetString(), gdcm::DocEntry::GetVR(), gdcm::DocEntry::IsItemDelimitor(), gdcm::DocEntry::IsItemStarter(), gdcm::DataEntry::IsUnfound(), gdcm::LD_NOSEQ, gdcm::LD_NOSHADOW, gdcm::LD_NOSHADOWSEQ, LoadDocEntry(), LoadMode, ParseSQ(), gdcm::DocEntrySet::PreviousDocEntry, ReadNextDocEntry(), gdcm::ElementSet::RemoveEntry(), gdcm::SeqEntry::SetDelimitorMode(), gdcm::SeqEntry::SetDepthLevel(), and SkipToNextDocEntry(). Referenced by DoTheLoadingDocumentJob(), and ParseSQ(). 01018 { 01019 DocEntry *newDocEntry; 01020 DataEntry *newDataEntry; 01021 SeqEntry *newSeqEntry; 01022 VRKey vr; 01023 bool used; // will be set to false when something wrong happens to an Entry. 01024 // (Entry will then be deleted) 01025 bool delim_mode_intern = delim_mode; 01026 bool first = true; 01027 gdcmDebugMacro( "Enter in ParseDES, delim-mode " << delim_mode 01028 << " at offset " << std::hex << offset ); 01029 while (true) 01030 { 01031 if ( !delim_mode && ((long)(Fp->tellg())-offset) >= l_max) 01032 { 01033 break; 01034 } 01035 01036 newDocEntry = ReadNextDocEntry( ); 01037 01038 // Uncoment this cerr line to be able to 'follow' the DocEntries 01039 // when something *very* strange happens 01040 if( Debug::GetDebugFlag() ) 01041 std::cerr<<newDocEntry->GetKey()<<" "<<newDocEntry->GetVR()<<std::endl; 01042 01043 if ( !newDocEntry ) 01044 { 01045 break; 01046 } 01047 01048 // an Item Starter found elsewhere but the first position 01049 // of a SeqEntry means previous entry was a Sequence 01050 // but we didn't get it (private Sequence + Implicit VR) 01051 // we have to backtrack. 01052 if ( !first && newDocEntry->IsItemStarter() ) 01053 { 01054 // Debug message within the method ! 01055 newDocEntry = Backtrack(newDocEntry); 01056 } 01057 else 01058 { 01059 PreviousDocEntry = newDocEntry; 01060 } 01061 01062 used = true; 01063 newDataEntry = dynamic_cast<DataEntry*>(newDocEntry); 01064 01065 if ( newDataEntry ) 01066 { 01068 01069 vr = newDocEntry->GetVR(); 01070 01071 if ( !set->AddEntry( newDataEntry ) ) 01072 { 01073 gdcmDebugMacro( "in ParseDES : cannot add a DataEntry " 01074 << newDataEntry->GetKey() 01075 << " (at offset : " 01076 << newDataEntry->GetOffset() << " )" ); 01077 used=false; 01078 } 01079 else 01080 { 01081 newDataEntry->Delete(); 01082 // Load only if we can add (not a duplicate key) 01083 LoadDocEntry( newDataEntry ); 01084 } 01085 01086 if ( newDataEntry->GetElement() == 0x0000 ) // if on group length 01087 { 01088 if ( newDataEntry->GetGroup()%2 != 0 ) // if Shadow Group 01089 { 01090 if ( LoadMode & LD_NOSHADOW ) // if user asked to skip shad.gr 01091 { 01092 std::string strLgrGroup = newDataEntry->GetString(); 01093 int lgrGroup; 01094 if ( newDataEntry->IsUnfound() ) 01095 { 01096 lgrGroup = atoi(strLgrGroup.c_str()); 01097 Fp->seekg(lgrGroup, std::ios::cur); 01098 //used = false; // never used 01099 RemoveEntry( newDocEntry ); // Remove and delete 01100 // bcc 5.5 is right "assigned a value that's never used" 01101 // newDocEntry = 0; 01102 continue; 01103 } 01104 } 01105 } 01106 } 01107 01108 bool delimitor = newDataEntry->IsItemDelimitor(); 01109 01110 if ( (delimitor) || 01111 (!delim_mode && ((long)(Fp->tellg())-offset) >= l_max) ) 01112 { 01113 if ( !used ) 01114 newDocEntry->Delete(); 01115 break; 01116 } 01117 01118 // Just to make sure we are at the beginning of next entry. 01119 SkipToNextDocEntry(newDocEntry); 01120 } 01121 else 01122 { 01124 01125 unsigned long l = newDocEntry->GetReadLength(); 01126 if ( l != 0 ) // don't mess the delim_mode for 'zero-length sequence' 01127 { 01128 if ( l == 0xffffffff ) 01129 { 01130 delim_mode_intern = true; 01131 } 01132 else 01133 { 01134 delim_mode_intern = false; 01135 } 01136 } 01137 01138 if ( (LoadMode & LD_NOSHADOWSEQ) && ! delim_mode_intern ) 01139 { 01140 // User asked to skip SeQuences *only* if they belong to Shadow Group 01141 if ( newDocEntry->GetGroup()%2 != 0 ) 01142 { 01143 Fp->seekg( l, std::ios::cur); 01144 newDocEntry->Delete(); // Delete, not in the set 01145 continue; 01146 } 01147 } 01148 if ( (LoadMode & LD_NOSEQ) && ! delim_mode_intern ) 01149 { 01150 // User asked to skip *any* SeQuence 01151 Fp->seekg( l, std::ios::cur); 01152 newDocEntry->Delete(); // Delete, not in the set 01153 continue; 01154 } 01155 // delay the dynamic cast as late as possible 01156 newSeqEntry = dynamic_cast<SeqEntry*>(newDocEntry); 01157 01158 // no other way to create the Delimitor ... 01159 newSeqEntry->SetDelimitorMode( delim_mode_intern ); 01160 01161 // At the top of the hierarchy, stands a Document. When "set" 01162 // is a Document, then we are building the first depth level. 01163 // Hence the SeqEntry we are building simply has a depth 01164 // level of one: 01165 if ( set == this ) // ( dynamic_cast< Document* > ( set ) ) 01166 { 01167 newSeqEntry->SetDepthLevel( 1 ); 01168 } 01169 // But when "set" is already a SQItem, we are building a nested 01170 // sequence, and hence the depth level of the new SeqEntry 01171 // we are building, is one level deeper: 01172 01173 // time waste hunting 01174 else if (SQItem *parentSQItem = dynamic_cast< SQItem* > ( set ) ) 01175 { 01176 newSeqEntry->SetDepthLevel( parentSQItem->GetDepthLevel() + 1 ); 01177 } 01178 01179 if ( l != 0 ) 01180 { // Don't try to parse zero-length sequences 01181 01182 gdcmDebugMacro( "Entry in ParseSQ, delim " << delim_mode_intern 01183 << " at offset " << std::hex 01184 << newDocEntry->GetOffset() ); 01185 01186 ParseSQ( newSeqEntry, 01187 newDocEntry->GetOffset(), 01188 l, delim_mode_intern); 01189 01190 gdcmDebugMacro( "Exit from ParseSQ, delim " << delim_mode_intern); 01191 01192 } 01193 if ( !set->AddEntry( newSeqEntry ) ) 01194 { 01195 gdcmWarningMacro( "in ParseDES : cannot add a SeqEntry " 01196 << newSeqEntry->GetKey() 01197 << " (at offset : " 01198 << newSeqEntry->GetOffset() << " )" ); 01199 used = false; 01200 } 01201 else 01202 { 01203 newDocEntry->Delete(); 01204 } 01205 01206 if ( !delim_mode && ((long)(Fp->tellg())-offset) >= l_max) 01207 { 01208 if ( !used ) 01209 newDocEntry->Delete(); 01210 break; 01211 } 01212 } // end SeqEntry : VR = "SQ" 01213 01214 if ( !used ) 01215 { 01216 newDocEntry->Delete(); 01217 } 01218 first = false; 01219 } // end While 01220 gdcmDebugMacro( "Exit from ParseDES, delim-mode " << delim_mode ); 01221 }
|
|
Parses a Sequence ( SeqEntry after SeqEntry).
Definition at line 1227 of file gdcmDocument.cxx. References gdcm::SeqEntry::AddSQItem(), gdcm::RefCounter::Delete(), Fp, gdcmWarningMacro, gdcm::SeqEntry::GetDepthLevel(), gdcm::DocEntry::GetReadLength(), gdcm::DocEntry::IsSequenceDelimitor(), gdcm::SQItem::New(), ParseDES(), ReadNextDocEntry(), and gdcm::SeqEntry::SetDelimitationItem(). Referenced by ParseDES(). 01229 { 01230 int SQItemNumber = 0; 01231 bool dlm_mod; 01232 long offsetStartCurrentSQItem = offset; 01233 01234 while (true) 01235 { 01236 // the first time, we read the fff0,e000 of the first SQItem 01237 DocEntry *newDocEntry = ReadNextDocEntry(); 01238 01239 if ( !newDocEntry ) 01240 { 01241 gdcmWarningMacro("in ParseSQ : should never get here!"); 01242 break; 01243 } 01244 if ( delim_mode ) 01245 { 01246 if ( newDocEntry->IsSequenceDelimitor() ) 01247 { 01248 seqEntry->SetDelimitationItem( newDocEntry ); 01249 newDocEntry->Delete(); 01250 break; 01251 } 01252 } 01253 if ( !delim_mode && ((long)(Fp->tellg())-offset) >= l_max) 01254 { 01255 newDocEntry->Delete(); 01256 break; 01257 } 01258 // create the current SQItem 01259 SQItem *itemSQ = SQItem::New( seqEntry->GetDepthLevel() ); 01260 unsigned int l = newDocEntry->GetReadLength(); 01261 01262 if ( l == 0xffffffff ) 01263 { 01264 dlm_mod = true; 01265 } 01266 else 01267 { 01268 dlm_mod = false; 01269 } 01270 01271 // remove fff0,e000, created out of the SQItem 01272 Fp->seekg(offsetStartCurrentSQItem, std::ios::beg); 01273 // fill up the current SQItem, starting at the beginning of fff0,e000 01274 01275 ParseDES(itemSQ, offsetStartCurrentSQItem, l+8, dlm_mod); 01276 01277 offsetStartCurrentSQItem = Fp->tellg(); 01278 01279 seqEntry->AddSQItem( itemSQ, SQItemNumber ); 01280 itemSQ->Delete(); 01281 newDocEntry->Delete(); 01282 SQItemNumber++; 01283 if ( !delim_mode && ((long)(Fp->tellg())-offset ) >= l_max ) 01284 { 01285 break; 01286 } 01287 } 01288 }
|
|
Prints the Header Entries (Dicom Elements) from the H Table.
Reimplemented from gdcm::Base. Reimplemented in gdcm::DicomDir. Definition at line 186 of file gdcmElementSet.cxx. References gdcm::DataEntry::FLAG_PIXELDATA, gdcm::DocEntrySet::GetDataEntry(), gdcm::DocEntry::Print(), gdcm::Base::PrintLevel, gdcm::DataEntry::SetFlag(), gdcm::Base::SetPrintLevel(), and gdcm::ElementSet::TagHT. Referenced by gdcm::FileHelper::Print(). 00187 { 00188 // Let's change the 'warning value' for Pixel Data, 00189 // to avoid human reader to be confused by 'gdcm::NotLoaded'. 00190 DataEntry *pixelElement = GetDataEntry(0x7fe0,0x0010); 00191 if ( pixelElement != 0 ) 00192 { 00193 pixelElement->SetFlag( DataEntry::FLAG_PIXELDATA ); 00194 } 00195 00196 for( TagDocEntryHT::const_iterator i = TagHT.begin(); i != TagHT.end(); ++i) 00197 { 00198 DocEntry *entry = i->second; 00199 00200 entry->SetPrintLevel(PrintLevel); 00201 entry->Print(os); 00202 00203 if ( dynamic_cast<SeqEntry *>(entry) ) 00204 { 00205 // Avoid the newline for a sequence: 00206 continue; 00207 } 00208 os << std::endl; 00209 } 00210 }
|
|
Reads a supposed to be 16 Bits integer (swaps it depending on processor endianness).
Definition at line 904 of file gdcmDocument.cxx. References Fp, and SwapShort(). Referenced by FindDocEntryLengthOBOrOW(), ReadNextDocEntry(), and gdcm::File::ReadTag(). 00906 { 00907 uint16_t g; 00908 Fp->read ((char*)&g, (size_t)2); 00909 if ( Fp->fail() ) 00910 { 00911 throw FormatError( "Document::ReadInt16()", " file error." ); 00912 } 00913 if ( Fp->eof() ) 00914 { 00915 throw FormatError( "Document::ReadInt16()", "EOF." ); 00916 } 00917 g = SwapShort(g); 00918 return g; 00919 }
|
|
Reads a supposed to be 32 Bits integer (swaps it depending on processor endianness).
Definition at line 926 of file gdcmDocument.cxx. References Fp, and SwapLong(). Referenced by gdcm::File::ComputeRLEInfo(), FindDocEntryLengthOBOrOW(), and gdcm::File::ReadTagLength(). 00928 { 00929 uint32_t g; 00930 Fp->read ((char*)&g, (size_t)4); 00931 if ( Fp->fail() ) 00932 { 00933 throw FormatError( "Document::ReadInt32()", " file error." ); 00934 } 00935 if ( Fp->eof() ) 00936 { 00937 throw FormatError( "Document::ReadInt32()", "EOF." ); 00938 } 00939 g = SwapLong(g); 00940 return g; 00941 }
|
|
Read the next tag WITHOUT loading it's value (read the 'Group Number', the 'Element Number', gets the Dict Entry gets the VR, gets the length, gets the offset value).
Definition at line 1986 of file gdcmDocument.cxx. References CurrentElem, CurrentGroup, gdcm::RefCounter::Delete(), gdcm::ExplicitVR, Filetype, FindDocEntryLength(), FindDocEntryVR(), gdcm::Util::Format(), Fp, gdcm::GDCM_VRUNKNOWN, gdcmWarningMacro, gdcm::DocEntrySet::GetDictEntry(), gdcm::DocEntry::GetElement(), gdcm::DocEntry::GetGroup(), gdcm::Global::GetVR(), gdcm::DicomEntry::GetVR(), HandleBrokenEndian(), HandleOutOfGroup0002(), HasDCMPreamble, gdcm::DocEntrySet::NewDataEntry(), gdcm::DocEntrySet::NewSeqEntry(), ReadInt16(), gdcm::DocEntry::SetImplicitVR(), gdcm::DocEntry::SetOffset(), gdcm::DataEntry::STATE_NOTLOADED, and gdcm::RefCounter::Unregister(). Referenced by ParseDES(), and ParseSQ(). 01987 { 01988 try 01989 { 01990 CurrentGroup = ReadInt16(); 01991 CurrentElem = ReadInt16(); 01992 } 01993 catch ( FormatError ) 01994 { 01995 // We reached the EOF (or an error occured) therefore 01996 // header parsing has to be considered as finished. 01997 return 0; 01998 } 01999 02000 // Sometimes file contains groups of tags with reversed endianess. 02001 HandleBrokenEndian(CurrentGroup, CurrentElem); 02002 02003 // In 'true DICOM' files Group 0002 is always little endian 02004 if ( HasDCMPreamble ) 02005 HandleOutOfGroup0002(CurrentGroup, CurrentElem); 02006 02007 VRKey vr = FindDocEntryVR(); 02008 02009 VRKey realVR = vr; 02010 02011 if ( vr == GDCM_VRUNKNOWN ) 02012 { 02013 if ( CurrentElem == 0x0000 ) // Group Length 02014 { 02015 realVR = "UL"; // must be UL 02016 } 02017 else if (CurrentGroup%2 == 1 && 02018 (CurrentElem >= 0x0010 && CurrentElem <=0x00ff )) 02019 { 02020 // DICOM PS 3-5 7.8.1 a) states that those 02021 // (gggg-0010->00FF where gggg is odd) attributes have to be LO 02022 realVR = "LO"; 02023 } 02024 else 02025 { 02026 DictEntry *dictEntry = GetDictEntry(CurrentGroup,CurrentElem); 02027 if ( dictEntry ) 02028 { 02029 realVR = dictEntry->GetVR(); 02030 dictEntry->Unregister(); 02031 } 02032 } 02033 } 02034 // gdcmDebugMacro( "Found VR: " << vr << " / Real VR: " << realVR ); 02035 02036 DocEntry *newEntry; 02037 if ( Global::GetVR()->IsVROfSequence(realVR) ) 02038 newEntry = NewSeqEntry(CurrentGroup, CurrentElem); 02039 else 02040 { 02041 newEntry = NewDataEntry(CurrentGroup, CurrentElem, realVR); 02042 static_cast<DataEntry *>(newEntry)->SetState(DataEntry::STATE_NOTLOADED); 02043 } 02044 02045 if ( vr == GDCM_VRUNKNOWN ) 02046 { 02047 if ( Filetype == ExplicitVR ) 02048 { 02049 // We thought this was explicit VR, but we end up with an 02050 // implicit VR tag. Let's backtrack. 02051 if ( newEntry->GetGroup() != 0xfffe ) 02052 { 02053 std::string msg; 02054 int offset = Fp->tellg(); 02055 msg = Util::Format( 02056 "Entry (%04x,%04x) at x(%x) should be Explicit VR\n", 02057 newEntry->GetGroup(), newEntry->GetElement(), offset ); 02058 gdcmWarningMacro( msg.c_str() ); 02059 } 02060 } 02061 newEntry->SetImplicitVR(); 02062 } 02063 02064 try 02065 { 02066 FindDocEntryLength(newEntry); 02067 } 02068 catch ( FormatError ) 02069 { 02070 // Call it quits 02071 newEntry->Delete(); 02072 return 0; 02073 } 02074 02075 newEntry->SetOffset(Fp->tellg()); 02076 02077 return newEntry; 02078 }
|
|
Register the object.
Definition at line 45 of file gdcmRefCounter.h. Referenced by gdcm::SQItem::AddEntry(), gdcm::ElementSet::AddEntry(), gdcm::Dict::AddEntry(), gdcm::SeqEntry::AddSQItem(), gdcm::DocEntry::DocEntry(), gdcm::FileHelper::FileHelper(), gdcm::DocEntrySet::GetDictEntry(), gdcm::DocEntryArchive::Push(), gdcm::Dict::ReplaceEntry(), and gdcm::SeqEntry::SetDelimitationItem(). 00045 { RefCount++; }
|
|
Clear the hash table from given entry AND delete the entry.
Implements gdcm::DocEntrySet. Definition at line 99 of file gdcmElementSet.cxx. References gdcmWarningMacro, gdcm::DocEntry::GetKey(), gdcm::ElementSet::TagHT, and gdcm::RefCounter::Unregister(). Referenced by Backtrack(), gdcm::File::DoTheLoadingJob(), gdcm::DicomDir::NewMeta(), ParseDES(), gdcm::DocEntryArchive::Push(), and gdcm::DocEntryArchive::Restore(). 00100 { 00101 const TagKey &key = entryToRemove->GetKey(); 00102 if ( TagHT.count(key) == 1 ) 00103 { 00104 TagHT.erase(key); 00105 entryToRemove->Unregister(); 00106 return true; 00107 } 00108 00109 gdcmWarningMacro( "Key not present : " << key); 00110 return false ; 00111 }
|
|
Accesses an existing DataEntry (i.e. a Dicom Element) and modifies it's content with the given value.
Definition at line 229 of file gdcmDocEntrySet.cxx. References gdcm::DataEntry::SetBinArea(), and gdcm::DocEntry::SetLength(). 00230 { 00231 if (entry) 00232 { 00233 entry->SetLength(lgth); 00234 entry->SetBinArea(content); 00235 return true; 00236 } 00237 return false; 00238 }
|
|
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 192 of file gdcmDocEntrySet.cxx. References gdcmWarningMacro, and gdcm::DocEntrySet::GetDataEntry(). Referenced by gdcm::DocEntrySet::InsertEntryBinArea(), and gdcm::FileHelper::SetEntryBinArea(). 00194 { 00195 DataEntry *entry = GetDataEntry(group, elem); 00196 if (!entry ) 00197 { 00198 gdcmWarningMacro( "No corresponding DataEntry " << std::hex << group << 00199 "," << elem << " element (try promotion first)."); 00200 return false; 00201 } 00202 00203 return SetEntryBinArea(content,lgth,entry); 00204 }
|
|
Accesses an existing DocEntry (i.e. a Dicom Element) and modifies it's content with the given value.
Definition at line 212 of file gdcmDocEntrySet.cxx. References gdcm::DataEntry::SetString(). 00213 { 00214 if (entry) 00215 { 00216 entry->SetString(content); 00217 return true; 00218 } 00219 return false; 00220 }
|
|
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 170 of file gdcmDocEntrySet.cxx. References gdcmWarningMacro, and gdcm::DocEntrySet::GetDataEntry(). Referenced by gdcm::File::AnonymizeFile(), DoTheLoadingDocumentJob(), gdcm::DocEntrySet::InsertEntryString(), and gdcm::FileHelper::SetEntryString(). 00172 { 00173 DataEntry *entry = GetDataEntry(group, elem); 00174 if (!entry ) 00175 { 00176 gdcmWarningMacro( "No corresponding DataEntry " << std::hex << group << 00177 "," << elem << " element (try promotion first)."); 00178 return false; 00179 } 00180 return SetEntryString(content,entry); 00181 }
|
|
Accessor to Filename.
Reimplemented in gdcm::DicomDir. Definition at line 76 of file gdcmDocument.h. Referenced by gdcm::SerieHelper::AddFileName(), gdcm::DicomDir::CreateDicomDirChainedList(), Document(), and gdcm::FileHelper::SetFileName(). 00077 { if (Filename != fileName) 00078 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 103 of file gdcmDocument.h. Referenced by gdcm::SerieHelper::AddFileName(), gdcm::DicomDir::CreateDicomDirChainedList(), and gdcm::FileHelper::SetLoadMode(). 00103 { if (LoadMode != mode) 00104 LoadMode=mode, IsDocumentModified = true; }
|
|
during parsing, Header Elements too long are not loaded in memory
Definition at line 1965 of file gdcmDocument.cxx. References MaxSizeLoadEntry. Referenced by Document(). 01966 { 01967 if ( newSize < 0 ) 01968 { 01969 return; 01970 } 01971 if ((uint32_t)newSize >= (uint32_t)0xffffffff ) 01972 { 01973 MaxSizeLoadEntry = 0xffffffff; 01974 return; 01975 } 01976 MaxSizeLoadEntry = newSize; 01977 }
|
|
Sets the print level for the Dicom Header Elements.
Definition at line 47 of file gdcmBase.h. Referenced by gdcm::SQItem::Print(), gdcm::SeqEntry::Print(), gdcm::FileHelper::Print(), gdcm::ElementSet::Print(), and gdcm::DicomDir::Print(). 00047 { PrintLevel = level; }
|
|
Set the shadow dictionary used.
Definition at line 327 of file gdcmDocument.cxx. References gdcm::DictSet::GetDict(), gdcm::Global::GetDicts(), and RefShaDict. 00328 { 00329 RefShaDict = Global::GetDicts()->GetDict(dictName); 00330 return !RefShaDict; 00331 }
|
|
Set the shadow dictionary used.
Definition at line 317 of file gdcmDocument.cxx. References RefShaDict. 00318 { 00319 RefShaDict = dict; 00320 return !RefShaDict; 00321 }
|
|
skips bytes inside the source file
Definition at line 947 of file gdcmDocument.cxx. References Fp. Referenced by gdcm::File::ComputeJPEGFragmentInfo(), gdcm::File::ComputeRLEInfo(), FindDocEntryLengthOBOrOW(), and SkipDocEntry(). 00948 { 00949 //FIXME don't dump the returned value 00950 Fp->seekg((long)nBytes, std::ios::cur); 00951 }
|
|
Skip a given Header Entry.
Definition at line 1585 of file gdcmDocument.cxx. References gdcm::DocEntry::GetLength(), and SkipBytes(). 01586 { 01587 SkipBytes(entry->GetLength()); 01588 }
|
|
Skips to the beginning of the next Header Entry.
Definition at line 1594 of file gdcmDocument.cxx. References Fp, gdcm::DocEntry::GetGroup(), gdcm::DocEntry::GetOffset(), and gdcm::DocEntry::GetReadLength(). Referenced by ParseDES(). 01595 { 01596 int l = currentDocEntry->GetReadLength(); 01597 if ( l == -1 ) // length = 0xffff shouldn't appear here ... 01598 // ... but PMS imagers happen ! 01599 return; 01600 Fp->seekg((long)(currentDocEntry->GetOffset()), std::ios::beg); 01601 if (currentDocEntry->GetGroup() != 0xfffe) // for fffe pb 01602 { 01603 Fp->seekg( (long)(currentDocEntry->GetReadLength()),std::ios::cur); 01604 } 01605 }
|
|
Swaps back the bytes of 8-byte long 'double' accordingly to processor order.
Definition at line 534 of file gdcmDocument.cxx. References gdcmErrorMacro, and SwapCode. Referenced by LoadEntryBinArea(). 00535 { 00536 switch (SwapCode) 00537 { 00538 // There were no 'double' at ACR-NEMA time. 00539 // We just have to deal with 'straight Little Endian' and 00540 // 'straight Big Endian' 00541 case 1234 : 00542 break; 00543 case 4321 : 00544 { 00545 char *beg = (char *)&a; 00546 char *end = beg + 7; 00547 char t; 00548 for (unsigned int i = 0; i<7; i++) 00549 { 00550 t = *beg; 00551 *beg = *end; 00552 *end = t; 00553 beg++, 00554 end--; 00555 } 00556 } 00557 break; 00558 default : 00559 gdcmErrorMacro( "Unexpected swap code:" << SwapCode ); 00560 a = 0.; 00561 } 00562 return a; 00563 }
|
|
Swaps back the bytes of 4-byte long integer accordingly to processor order.
Definition at line 502 of file gdcmDocument.cxx. References gdcmErrorMacro, and SwapCode. Referenced by LoadEntryBinArea(), and ReadInt32(). 00503 { 00504 switch (SwapCode) 00505 { 00506 case 1234 : 00507 break; 00508 case 4321 : 00509 // a=( ((a<<24) & 0xff000000) | ((a<<8) & 0x00ff0000) | 00510 // ((a>>8) & 0x0000ff00) | ((a>>24) & 0x000000ff) ); 00511 // save CPU time 00512 a=( ( a<<24) | ((a<<8) & 0x00ff0000) | 00513 ((a>>8) & 0x0000ff00) | (a>>24) ); 00514 break; 00515 case 3412 : 00516 // a=( ((a<<16) & 0xffff0000) | ((a>>16) & 0x0000ffff) ); 00517 a=( (a<<16) | (a>>16) ); 00518 break; 00519 case 2143 : 00520 a=( ((a<< 8) & 0xff00ff00) | ((a>>8) & 0x00ff00ff) ); 00521 break; 00522 default : 00523 gdcmErrorMacro( "Unexpected swap code:" << SwapCode ); 00524 a = 0; 00525 } 00526 return a; 00527 }
|
|
Swaps the bytes so they agree with the processor order.
Definition at line 486 of file gdcmDocument.cxx. References SwapCode. Referenced by HandleOutOfGroup0002(), LoadEntryBinArea(), and ReadInt16(). 00487 { 00488 if ( SwapCode == 4321 || SwapCode == 2143 ) 00489 { 00490 //a = ((( a << 8 ) & 0xff00 ) | (( a >> 8 ) & 0x00ff ) ); 00491 // Save CPU time 00492 a = ( a << 8 ) | ( a >> 8 ); 00493 } 00494 return a; 00495 }
|
|
Change the Byte Swap code.
Definition at line 1938 of file gdcmDocument.cxx. References Fp, gdcmDebugMacro, and SwapCode. Referenced by HandleBrokenEndian(), and HandleOutOfGroup0002(). 01939 { 01940 gdcmDebugMacro( "Switching Byte Swap code from "<< SwapCode 01941 << " at: 0x" << std::hex << Fp->tellg() ); 01942 if ( SwapCode == 1234 ) 01943 { 01944 SwapCode = 4321; 01945 } 01946 else if ( SwapCode == 4321 ) 01947 { 01948 SwapCode = 1234; 01949 } 01950 else if ( SwapCode == 3412 ) 01951 { 01952 SwapCode = 2143; 01953 } 01954 else if ( SwapCode == 2143 ) 01955 { 01956 SwapCode = 3412; 01957 } 01958 gdcmDebugMacro( " Into: "<< SwapCode ); 01959 }
|
|
Unregister the object.
Definition at line 49 of file gdcmRefCounter.h. Referenced by gdcm::SeqEntry::ClearSQItem(), gdcm::DocEntrySet::GetDictEntry(), gdcm::DocEntrySet::NewDataEntry(), gdcm::DocEntrySet::NewSeqEntry(), ReadNextDocEntry(), gdcm::SQItem::RemoveEntry(), gdcm::ElementSet::RemoveEntry(), gdcm::SeqEntry::SetDelimitationItem(), gdcm::DocEntry::~DocEntry(), and gdcm::FileHelper::~FileHelper().
|
|
Unswaps back the bytes of 4-byte long integer so they agree with the processor order.
Definition at line 189 of file gdcmDocument.h. 00189 { return SwapLong(a);}
|
|
Unswaps back the bytes of 2-bytes long integer so they agree with the processor order.
Definition at line 186 of file gdcmDocument.h. 00186 { return SwapShort(a);}
|
|
Writes in a file all the Entries (Dicom Elements).
Reimplemented from gdcm::ElementSet. Definition at line 675 of file gdcmDocument.cxx. References gdcm::ExplicitVR, gdcm::ImplicitVR, gdcm::JPEG, and gdcm::ElementSet::WriteContent(). Referenced by gdcm::File::Write(). 00676 { 00677 // Skip if user wants to write an ACR-NEMA file 00678 00679 if ( filetype == ImplicitVR || filetype == ExplicitVR || 00680 filetype == JPEG ) 00681 { 00682 // writing Dicom File Preamble 00683 char filePreamble[128]; 00684 memset(filePreamble, 0, 128); 00685 fp->write(filePreamble, 128); 00686 fp->write("DICM", 4); 00687 } 00688 00689 /* 00690 * \todo rewrite later, if really usefull 00691 * - 'Group Length' element is optional in DICOM 00692 * - but un-updated odd groups lengthes can causes pb 00693 * (xmedcon breaker) 00694 * 00695 * if ( (filetype == ImplicitVR) || (filetype == ExplicitVR) ) 00696 * UpdateGroupLength(false,filetype); 00697 * if ( filetype == ACR) 00698 * UpdateGroupLength(true,ACR); 00699 * 00700 * --> Computing group length for groups with embeded Sequences 00701 * --> was too much tricky / we were [in a hurry / too lazy] 00702 * --> We don't write the element 0x0000 (group length) 00703 */ 00704 00705 ElementSet::WriteContent(fp, filetype); // This one is recursive 00706 }
|
|
to allow any inner method to know current tag Element number
Definition at line 234 of file gdcmDocument.h. Referenced by ReadNextDocEntry(). |
|
to allow any inner method to know current tag Group number
Definition at line 232 of file gdcmDocument.h. Referenced by FindDocEntryVR(), and ReadNextDocEntry(). |
|
Refering underlying filename.
Definition at line 121 of file gdcmDocument.h. Referenced by gdcm::File::AnonymizeNoLoad(), DoTheLoadingDocumentJob(), Load(), and OpenFile(). |
|
ACR, ACR_LIBIDO, ExplicitVR, ImplicitVR, Unknown.
Definition at line 147 of file gdcmDocument.h. Referenced by CheckSwap(), Document(), DoTheLoadingDocumentJob(), FindDocEntryVR(), GetFileType(), HandleOutOfGroup0002(), Initialize(), IsParsable(), gdcm::DicomDir::IsReadable(), and ReadNextDocEntry(). |
|
File Pointer, opened during Document parsing.
Definition at line 144 of file gdcmDocument.h. Referenced by Backtrack(), CheckSwap(), CloseFile(), gdcm::File::ComputeJPEGFragmentInfo(), gdcm::File::ComputeRLEInfo(), Document(), DoTheLoadingDocumentJob(), gdcm::File::DoTheLoadingJob(), gdcm::DicomDir::DoTheLoadingJob(), FindDocEntryLengthOBOrOW(), FindDocEntryVR(), IsDocEntryAnInteger(), LoadDocEntry(), LoadDocEntrySafe(), LoadEntryBinArea(), OpenFile(), ParseDES(), ParseSQ(), gdcm::File::ReadEncapsulatedBasicOffsetTable(), ReadInt16(), ReadInt32(), ReadNextDocEntry(), gdcm::File::ReadTag(), gdcm::File::ReadTagLength(), SkipBytes(), SkipToNextDocEntry(), and SwitchByteSwapCode(). |
|
whether we already parsed group 0002 (Meta Elements)
Definition at line 138 of file gdcmDocument.h. Referenced by Document(), DoTheLoadingDocumentJob(), and HandleOutOfGroup0002(). |
|
whether file has a DCM Preamble
Definition at line 141 of file gdcmDocument.h. Referenced by OpenFile(), and ReadNextDocEntry(). |
|
After opening the file, we read HEADER_LENGTH_TO_READ bytes.
Definition at line 150 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 170 of file gdcmDocument.h. Referenced by Document(), and DoTheLoadingDocumentJob(). |
|
Whether the gdcm::Document was modified since the last Load().
Definition at line 173 of file gdcmDocument.h. Referenced by Document(), and DoTheLoadingDocumentJob(). |
|
Bit string integer (each one considered as a boolean) Bit 0 : Skip Sequences, if possible Bit 1 : Skip Shadow Groups if possible Probabely, some more to add.
Definition at line 165 of file gdcmDocument.h. Referenced by gdcm::DicomDir::CreateDicomDirChainedList(), Document(), and ParseDES(). |
|
Elements whose value is longer than MAX_SIZE_LOAD_ELEMENT_VALUE are NOT loaded.
Definition at line 153 of file gdcmDocument.h. Referenced by 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 229 of file gdcmDocument.h. Referenced by LoadDocEntry(), and SetMaxSizeLoadEntry(). |
|
To be able to backtrack (Private Sequence, Implicit VR related pb).
Definition at line 124 of file gdcmDocEntrySet.h. Referenced by Backtrack(), gdcm::DocEntrySet::DocEntrySet(), and ParseDES(). |
|
Amount of printed details for each Dicom Entries : 0 : stands for the least detail level.
Definition at line 55 of file gdcmBase.h. Referenced by gdcm::SQItem::Print(), gdcm::SeqEntry::Print(), gdcm::FileHelper::Print(), gdcm::ElementSet::Print(), gdcm::DocEntry::Print(), gdcm::DictEntry::Print(), gdcm::DicomDirStudy::Print(), gdcm::DicomDirSerie::Print(), gdcm::DicomDirPatient::Print(), gdcm::DicomDirMeta::Print(), gdcm::DicomDir::Print(), and gdcm::DataEntry::Print(). |
|
Public dictionary used to parse this header.
Definition at line 220 of file gdcmDocument.h. Referenced by GetPubDict(), and Initialize(). |
|
Optional "shadow dictionary" (private elements) used to parse this header.
Definition at line 223 of file gdcmDocument.h. Referenced by GetShaDict(), Initialize(), and 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 135 of file gdcmDocument.h. Referenced by CheckSwap(), Document(), SwapDouble(), SwapLong(), SwapShort(), and SwitchByteSwapCode(). |
|
User supplied list of elements to Anonymize.
Definition at line 156 of file gdcmDocument.h. Referenced by gdcm::File::AddAnonymizeElement(), gdcm::File::AnonymizeFile(), and gdcm::File::AnonymizeNoLoad(). |
|
User supplied list of elements to force Load.
Definition at line 159 of file gdcmDocument.h. Referenced by AddForceLoadElement(), and DoTheLoadingDocumentJob(). |