#include <gdcmDocument.h>
Inheritance diagram for gdcm::Document:
Public Types | |
typedef std::list< DicomElement > | ListElements |
Public Member Functions | |
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 void | Copy (DocEntrySet *set) |
Copies all the attributes from an other DocEntrySet. | |
virtual std::string | GetEntryString (uint16_t group, uint16_t elem) |
Get the "std::string representable" value of the Dicom entry. | |
virtual void * | GetEntryBinArea (uint16_t group, uint16_t elem) |
Gets (from Header) a 'non string' element value. | |
virtual int | GetEntryLength (uint16_t group, uint16_t elem) |
Searches within the DocEntrySet for the value length of a given tag.. | |
DataEntry * | GetDataEntry (uint16_t group, uint16_t elem) |
Same as Document::GetDocEntry except it returns a result only when the corresponding entry is of type DataEntry. | |
SeqEntry * | GetSeqEntry (uint16_t group, uint16_t elem) |
Same as Document::GetDocEntry except it returns a result only when the corresponding entry is of type SeqEntry. | |
bool | SetEntryString (std::string const &content, uint16_t group, uint16_t elem) |
Accesses an existing DocEntry (i.e. a Dicom Element) through 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) |
Creates a new gdcm::SeqEntry and adds it to the current DocEntrySet. (remove any existing entry with same group,elem). | |
virtual bool | CheckIfEntryExist (uint16_t group, uint16_t elem) |
Checks if a given Dicom Element exists within the DocEntrySet. | |
DataEntry * | NewDataEntry (uint16_t group, uint16_t elem, VRKey const &vr=GDCM_VRUNKNOWN) |
Build a new DataEntry from all the low level arguments. Check for existence of dictionary entry, and build a default one when absent. | |
SeqEntry * | NewSeqEntry (uint16_t group, uint16_t elem) |
Build a new SeqEntry from all the low level arguments. Check for existence of dictionary entry, and build a default one when absent. | |
void | Delete () |
Delete the object. | |
void | Register () |
Register the object. | |
void | Unregister () |
Unregister the object. | |
const unsigned long & | GetRefCount () const |
Get the reference counting. | |
void | SetPrintLevel (int level) |
Sets the print level for the Dicom Header Elements. | |
int | GetPrintLevel () |
Gets the print level for the Dicom Entries. | |
Protected Member Functions | |
Document () | |
This default constructor neither loads nor parses the file. You should then invoke Document::Load. | |
virtual | ~Document () |
Canonical destructor. | |
virtual void | CallStartMethod () |
CallStartMethod. | |
virtual void | CallProgressMethod () |
CallProgressMethod. | |
virtual void | CallEndMethod () |
CallEndMethod. | |
uint16_t | ReadInt16 () throw ( FormatError ) |
Reads a supposed to be 16 Bits integer (swaps it depending on processor endianness). | |
uint32_t | ReadInt32 () throw ( FormatError ) |
Reads a supposed to be 32 Bits integer (swaps it depending on processor endianness). | |
void | SkipBytes (uint32_t) |
skips bytes inside the source file | |
int | ComputeGroup0002Length () |
Re-computes the length of the Dicom group 0002. | |
bool | MayIWrite (uint16_t) |
Some group are illegal withing some Dicom Documents Only the Document knows it. | |
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(). | |
float | Progress |
value of the ??? for any progress bar | |
bool | Abort |
Dict * | RefPubDict |
Public dictionary used to parse this header. | |
Dict * | RefShaDict |
Optional "shadow dictionary" (private elements) used to parse this header. | |
uint32_t | MaxSizeLoadEntry |
Size threshold above which an element value will NOT be loaded in memory (to avoid loading the image/volume itself). By default, this upper bound is fixed to 1024 bytes (which might look reasonable when one considers the definition of the various VR contents). | |
uint16_t | CurrentGroup |
to allow any inner method to know current tag Group number | |
uint16_t | CurrentElem |
to allow any inner method to know current tag Element number | |
DocEntry * | PreviousDocEntry |
To be able to backtrack (Private Sequence, Implicit VR related pb). | |
int | PrintLevel |
Amount of printed details for each Dicom Entries : 0 : stands for the least detail level. | |
Static Protected Attributes | |
static const unsigned int | HEADER_LENGTH_TO_READ |
After opening the file, we read HEADER_LENGTH_TO_READ bytes. | |
static const unsigned int | MAX_SIZE_LOAD_ELEMENT_VALUE = 0xfff |
Elements whose value is longer than MAX_SIZE_LOAD_ELEMENT_VALUE are NOT loaded. | |
Private Member Functions | |
gdcmTypeMacro (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. |
Definition at line 42 of file gdcmDocument.h.
|
Definition at line 47 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 279 of file gdcmDocument.cxx. References gdcm::DicomElement::Elem, gdcm::DicomElement::Group, and UserForceLoadList. 00280 { 00281 DicomElement el; 00282 el.Group = group; 00283 el.Elem = elem; 00284 UserForceLoadList.push_back(el); 00285 }
|
|
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 1312 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(). 01313 { 01314 // delete the Item Starter, built erroneously out of any Sequence 01315 // it's not yet in the HTable/chained list 01316 docEntry->Delete(); 01317 01318 // Get all info we can from PreviousDocEntry 01319 uint16_t group = PreviousDocEntry->GetGroup(); 01320 uint16_t elem = PreviousDocEntry->GetElement(); 01321 uint32_t lgt = PreviousDocEntry->GetLength(); 01322 long offset = PreviousDocEntry->GetOffset(); 01323 01324 gdcmDebugMacro( "Backtrack :" << std::hex << group 01325 << "|" << elem 01326 << " at offset 0x(" <<offset << ")" ); 01327 RemoveEntry( PreviousDocEntry ); 01328 01329 // forge the Seq Entry 01330 DocEntry *newEntry = NewSeqEntry(group, elem); 01331 newEntry->SetLength(lgt); 01332 newEntry->SetOffset(offset); 01333 01334 // Move back to the beginning of the Sequence 01335 Fp->seekg( 0, std::ios::beg); 01336 Fp->seekg(offset, std::ios::cur); 01337 01338 return newEntry; 01339 }
|
|
CallEndMethod.
Definition at line 1007 of file gdcmDocument.cxx. References gdcm::CMD_ENDPROGRESS, gdcm::CommandManager::ExecuteCommand(), and Progress. Referenced by gdcm::DicomDir::CreateDicomDirChainedList(). 01008 { 01009 Progress = 1.0f; 01010 CommandManager::ExecuteCommand(this,CMD_ENDPROGRESS); 01011 }
|
|
CallProgressMethod.
Definition at line 999 of file gdcmDocument.cxx. References gdcm::CMD_PROGRESS, and gdcm::CommandManager::ExecuteCommand(). Referenced by gdcm::DicomDir::CreateDicomDirChainedList(). 01000 { 01001 CommandManager::ExecuteCommand(this,CMD_PROGRESS); 01002 }
|
|
CallStartMethod.
Definition at line 989 of file gdcmDocument.cxx. References Abort, gdcm::CMD_STARTPROGRESS, gdcm::CommandManager::ExecuteCommand(), and Progress. Referenced by gdcm::DicomDir::CreateDicomDirChainedList(). 00990 { 00991 Progress = 0.0f; 00992 Abort = false; 00993 CommandManager::ExecuteCommand(this,CMD_STARTPROGRESS); 00994 }
|
|
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 1592 of file gdcmDocument.cxx. References gdcm::Global::GetVR(), and gdcm::VR::IsValidVR(). Referenced by FindDocEntryVR(). 01593 { 01594 return Global::GetVR()->IsValidVR(vr); 01595 }
|
|
Checks if a given Dicom Element exists within the DocEntrySet.
Definition at line 392 of file gdcmDocEntrySet.cxx. References gdcm::DocEntrySet::GetDocEntry(). 00393 { 00394 return GetDocEntry(group,elem)!=NULL; 00395 }
|
|
Discover what the swap code is (among little endian, big endian, bad little endian, bad big endian). sw is set.
Definition at line 1753 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(). 01754 { 01755 uint32_t s32; 01756 uint16_t s16; 01757 01758 char deb[256]; 01759 01760 // First, compare HostByteOrder and NetworkByteOrder in order to 01761 // determine if we shall need to swap bytes (i.e. the Endian type). 01762 bool net2host = Util::IsCurrentProcessorBigEndian(); 01763 01764 // The easiest case is the one of a 'true' DICOM header, we just have 01765 // to look for the string "DICM" inside the file preamble. 01766 Fp->read(deb, 256); 01767 01768 char *entCur = deb + 128; 01769 if ( memcmp(entCur, "DICM", (size_t)4) == 0 ) 01770 { 01771 gdcmDebugMacro( "Looks like DICOM Version3 (preamble + DCM)" ); 01772 01773 // Group 0002 should always be VR, and the first element 0000 01774 // Let's be carefull (so many wrong headers ...) 01775 // and determine the value representation (VR) : 01776 // Let's skip to the first element (0002,0000) and check there if we find 01777 // "UL" - or "OB" if the 1st one is (0002,0001) -, 01778 // in which case we (almost) know it is explicit VR. 01779 // WARNING: if it happens to be implicit VR then what we will read 01780 // is the length of the group. If this ascii representation of this 01781 // length happens to be "UL" then we shall believe it is explicit VR. 01782 // We need to skip : 01783 // * the 128 bytes of File Preamble (often padded with zeroes), 01784 // * the 4 bytes of "DICM" string, 01785 // * the 4 bytes of the first tag (0002, 0000),or (0002, 0001) 01786 // i.e. a total of 136 bytes. 01787 entCur = deb + 136; 01788 01789 // group 0x0002 *is always* Explicit VR Sometimes , 01790 // even if elem 0002,0010 (Transfer Syntax) tells us the file is 01791 // *Implicit* VR (see former 'gdcmData/icone.dcm') 01792 01793 if ( memcmp(entCur, "UL", (size_t)2) == 0 || 01794 memcmp(entCur, "OB", (size_t)2) == 0 || 01795 memcmp(entCur, "UI", (size_t)2) == 0 || 01796 memcmp(entCur, "CS", (size_t)2) == 0 ) // CS, to remove later 01797 // when Write DCM *adds* 01798 // FIXME 01799 // Use Document::dicom_vr to test all the possibilities 01800 // instead of just checking for UL, OB and UI !? group 0000 01801 { 01802 Filetype = ExplicitVR; 01803 gdcmDebugMacro( "Group 0002 : Explicit Value Representation"); 01804 } 01805 else 01806 { 01807 Filetype = ImplicitVR; 01808 gdcmWarningMacro( "Group 0002 :Not an explicit Value Representation;" 01809 << "Looks like a bugged Header!"); 01810 } 01811 01812 if ( net2host ) 01813 { 01814 SwapCode = 4321; 01815 gdcmDebugMacro( "HostByteOrder != NetworkByteOrder, SwapCode = 4321"); 01816 } 01817 else 01818 { 01819 SwapCode = 1234; 01820 gdcmDebugMacro( "HostByteOrder = NetworkByteOrder, SwapCode = 1234"); 01821 } 01822 01823 // Position the file position indicator at first tag 01824 // (i.e. after the file preamble and the "DICM" string). 01825 01826 Fp->seekg(0, std::ios::beg); // FIXME : Is it usefull? 01827 01828 Fp->seekg ( 132L, std::ios::beg); 01829 return true; 01830 } // ------------------------------- End of DicomV3 ---------------- 01831 01832 // Alas, this is not a DicomV3 file and whatever happens there is no file 01833 // preamble. We can reset the file position indicator to where the data 01834 // is (i.e. the beginning of the file). 01835 01836 gdcmWarningMacro( "Not a Kosher DICOM Version3 file (no preamble)"); 01837 01838 Fp->seekg(0, std::ios::beg); 01839 01840 // Let's check 'No Preamble Dicom File' : 01841 // Should start with group 0x0002 01842 // and be Explicit Value Representation 01843 01844 s16 = *((uint16_t *)(deb)); 01845 SwapCode = 0; 01846 switch ( s16 ) 01847 { 01848 case 0x0002 : 01849 SwapCode = 1234; 01850 entCur = deb + 4; 01851 break; 01852 case 0x0200 : 01853 SwapCode = 4321; 01854 entCur = deb + 6; 01855 } 01856 01857 if ( SwapCode != 0 ) 01858 { 01859 if ( memcmp(entCur, "UL", (size_t)2) == 0 || 01860 memcmp(entCur, "OB", (size_t)2) == 0 || 01861 memcmp(entCur, "UI", (size_t)2) == 0 || 01862 memcmp(entCur, "SH", (size_t)2) == 0 || 01863 memcmp(entCur, "AE", (size_t)2) == 0 || 01864 memcmp(entCur, "OB", (size_t)2) == 0 ) 01865 { 01866 Filetype = ExplicitVR; 01867 gdcmDebugMacro( "Group 0002 : Explicit Value Representation"); 01868 return true; 01869 } 01870 } 01871 // ------------------------------- End of 'No Preamble' DicomV3 ------------- 01872 01873 // Our next best chance would be to be considering a 'clean' ACR/NEMA file. 01874 // By clean we mean that the length of the first group is written down. 01875 // If this is the case and since the length of the first group HAS to be 01876 // four (bytes), then determining the proper swap code is straightforward. 01877 01878 entCur = deb + 4; 01879 // We assume the array of char we are considering contains the binary 01880 // representation of a 32 bits integer. Hence the following dirty 01881 // trick : 01882 s32 = *((uint32_t *)(entCur)); 01883 switch( s32 ) 01884 { 01885 case 0x00040000 : 01886 SwapCode = 3412; 01887 Filetype = ACR; 01888 return true; 01889 case 0x04000000 : 01890 SwapCode = 4321; 01891 Filetype = ACR; 01892 return true; 01893 case 0x00000400 : 01894 SwapCode = 2143; 01895 Filetype = ACR; 01896 return true; 01897 case 0x00000004 : 01898 SwapCode = 1234; 01899 Filetype = ACR; 01900 return true; 01901 default : 01902 // We are out of luck. It is not a DicomV3 nor a 'clean' ACR/NEMA file. 01903 // It is time for despaired wild guesses. 01904 // So, let's check if this file wouldn't happen to be 'dirty' ACR/NEMA, 01905 // i.e. the 'group length' element is not present : 01906 01907 // check the supposed-to-be 'group number' 01908 // in ( 0x0001 .. 0x0008 ) 01909 // to determine ' SwapCode' value . 01910 // Only 0 or 4321 will be possible 01911 // (no oportunity to check for the formerly well known 01912 // ACR-NEMA 'Bad Big Endian' or 'Bad Little Endian' 01913 // if unsuccessfull (i.e. neither 0x0002 nor 0x0200 etc-3, 4, ..., 8-) 01914 // the file IS NOT ACR-NEMA nor DICOM V3 01915 // Find a trick to tell it the caller... 01916 01917 s16 = *((uint16_t *)(deb)); 01918 01919 switch ( s16 ) 01920 { 01921 case 0x0001 : 01922 case 0x0002 : 01923 case 0x0003 : 01924 case 0x0004 : 01925 case 0x0005 : 01926 case 0x0006 : 01927 case 0x0007 : 01928 case 0x0008 : 01929 SwapCode = 1234; 01930 Filetype = ACR; 01931 return true; 01932 case 0x0100 : 01933 case 0x0200 : 01934 case 0x0300 : 01935 case 0x0400 : 01936 case 0x0500 : 01937 case 0x0600 : 01938 case 0x0700 : 01939 case 0x0800 : 01940 SwapCode = 4321; 01941 Filetype = ACR; 01942 return true; 01943 default : 01944 gdcmWarningMacro("ACR/NEMA unfound swap info (Hopeless !)"); 01945 Filetype = Unknown; 01946 return false; 01947 } 01948 } 01949 }
|
|
delete all entries in the ElementSet
Implements gdcm::DocEntrySet. Definition at line 116 of file gdcmElementSet.cxx. References gdcm::ElementSet::TagHT. Referenced by gdcm::ElementSet::Copy(), 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 647 of file gdcmDocument.cxx. References Fp. Referenced by DoTheLoadingDocumentJob(), gdcm::File::DoTheLoadingJob(), gdcm::FileHelper::GetRaw(), LoadEntryBinArea(), OpenFile(), and ~Document(). 00648 { 00649 if ( Fp ) 00650 { 00651 Fp->close(); 00652 delete Fp; 00653 Fp = 0; 00654 } 00655 return true; 00656 }
|
|
Re-computes the length of the Dicom group 0002.
Definition at line 945 of file gdcmDocument.cxx. References gdcm::DocEntry::GetElement(), gdcm::ElementSet::GetFirstEntry(), gdcm::DocEntry::GetGroup(), gdcm::DocEntry::GetLength(), gdcm::ElementSet::GetNextEntry(), and gdcm::DocEntry::GetVR(). Referenced by gdcm::File::Write(). 00946 { 00947 uint16_t gr; 00948 VRKey vr; 00949 00950 int groupLength = 0; 00951 bool found0002 = false; 00952 00953 // for each zero-level Tag in the DCM Header 00954 DocEntry *entry = GetFirstEntry(); 00955 while( entry ) 00956 { 00957 gr = entry->GetGroup(); 00958 00959 if ( gr == 0x0002 ) 00960 { 00961 found0002 = true; 00962 00963 if ( entry->GetElement() != 0x0000 ) 00964 { 00965 vr = entry->GetVR(); 00966 00967 //if ( (vr == "OB")||(vr == "OW")||(vr == "UT")||(vr == "SQ")) 00968 // (no SQ, OW, UT in group 0x0002;) 00969 if ( vr == "OB" ) 00970 { 00971 // explicit VR AND (OB, OW, SQ, UT) : 4 more bytes 00972 groupLength += 4; 00973 } 00974 00975 groupLength += 2 + 2 + 4 + entry->GetLength(); 00976 } 00977 } 00978 else if (found0002 ) 00979 break; 00980 00981 entry = GetNextEntry(); 00982 } 00983 return groupLength; 00984 }
|
|
Copies all the attributes from an other DocEntrySet.
Reimplemented from gdcm::DocEntrySet. Reimplemented in gdcm::DicomDir. Definition at line 178 of file gdcmElementSet.cxx. References gdcm::ElementSet::ClearEntry(), gdcm::DocEntrySet::Copy(), gdcm::ElementSet::ItTagHT, and gdcm::ElementSet::TagHT. Referenced by gdcm::DicomDir::Copy(). 00179 { 00180 // Remove all previous entries 00181 ClearEntry(); 00182 00183 DocEntrySet::Copy(set); 00184 00185 ElementSet *eltSet = dynamic_cast<ElementSet *>(set); 00186 if( eltSet ) 00187 { 00188 TagHT = eltSet->TagHT; 00189 for(ItTagHT = TagHT.begin();ItTagHT != TagHT.end();++ItTagHT) 00190 { 00191 (ItTagHT->second)->Register(); 00192 } 00193 } 00194 }
|
|
|
Performs the Loading Job (internal use only).
Definition at line 99 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(). 00100 { 00101 if ( ! IsDocumentModified ) // Nothing to do ! 00102 return true; 00103 00104 ClearEntry(); 00105 00106 Fp = 0; 00107 if ( !OpenFile() ) 00108 { 00109 // warning already performed in OpenFile() 00110 Filetype = Unknown; 00111 return false; 00112 } 00113 00114 Group0002Parsed = false; 00115 00116 gdcmDebugMacro( "Starting parsing of file: " << Filename.c_str()); 00117 00118 Fp->seekg(0, std::ios::end); 00119 long lgt = Fp->tellg(); // total length of the file 00120 00121 Fp->seekg(0, std::ios::beg); 00122 00123 // CheckSwap returns a boolean 00124 // (false if no swap info of any kind was found) 00125 if (! CheckSwap() ) 00126 { 00127 gdcmWarningMacro( "Neither a DICOM V3 nor an ACR-NEMA file: " 00128 << Filename.c_str()); 00129 CloseFile(); 00130 return false; 00131 } 00132 00133 long beg = Fp->tellg(); // just after DICOM preamble (if any) 00134 00135 lgt -= beg; // remaining length to parse 00136 00137 // Recursive call. 00138 // Loading is done during parsing 00139 ParseDES( this, beg, lgt, false); // delim_mode is first defaulted to false 00140 00141 if ( IsEmpty() ) 00142 { 00143 gdcmErrorMacro( "No tag in internal hash table for: " 00144 << Filename.c_str()); 00145 CloseFile(); 00146 return false; 00147 } 00148 IsDocumentAlreadyLoaded = true; 00149 00150 Fp->seekg( 0, std::ios::beg); 00151 00152 // Load 'non string' values 00153 00154 std::string PhotometricInterpretation = GetEntryString(0x0028,0x0004); 00155 if ( PhotometricInterpretation == "PALETTE COLOR " ) 00156 { 00157 // FIXME 00158 // Probabely this line should be outside the 'if' 00159 // Try to find an image sample holding a 'gray LUT' 00160 LoadEntryBinArea(0x0028,0x1200); // gray LUT 00161 00184 00185 // --> OB (byte aray) or OW (short int aray) 00186 // The actual VR has to be deduced from other entries. 00187 // Our way of loading them may fail in some cases : 00188 // We must or not SwapByte depending on other field values. 00189 00190 LoadEntryBinArea(0x0028,0x1201); // R LUT 00191 LoadEntryBinArea(0x0028,0x1202); // G LUT 00192 LoadEntryBinArea(0x0028,0x1203); // B LUT 00193 00194 // Segmented Red Palette Color LUT Data 00195 LoadEntryBinArea(0x0028,0x1221); 00196 // Segmented Green Palette Color LUT Data 00197 LoadEntryBinArea(0x0028,0x1222); 00198 // Segmented Blue Palette Color LUT Data 00199 LoadEntryBinArea(0x0028,0x1223); 00200 } 00201 00202 //FIXME later : how to use it? 00203 SeqEntry *modLutSeq = GetSeqEntry(0x0028,0x3000); 00204 if ( modLutSeq !=0 ) 00205 { 00206 SQItem *sqi= modLutSeq->GetFirstSQItem(); 00207 if ( sqi != 0 ) 00208 { 00209 DataEntry *dataEntry = sqi->GetDataEntry(0x0028,0x3006); 00210 if ( dataEntry != 0 ) 00211 { 00212 if ( dataEntry->GetLength() != 0 ) 00213 { 00214 // FIXME : CTX dependent means : contexted dependant. 00215 // see upper comment. 00216 LoadEntryBinArea(dataEntry); //LUT Data (CTX dependent) 00217 } 00218 } 00219 } 00220 } 00221 00222 // Force Loading some more elements if user asked to. 00223 00224 gdcm::DocEntry *d; 00225 for (ListElements::iterator it = UserForceLoadList.begin(); 00226 it != UserForceLoadList.end(); 00227 ++it) 00228 { 00229 gdcmDebugMacro( "Force Load " << std::hex 00230 << (*it).Group << "|" <<(*it).Elem ); 00231 00232 d = GetDocEntry( (*it).Group, (*it).Elem); 00233 00234 if ( d == NULL) 00235 { 00236 gdcmWarningMacro( "You asked toForce Load " << std::hex 00237 << (*it).Group <<"|"<< (*it).Elem 00238 << " that doesn't exist" ); 00239 continue; 00240 } 00241 00242 LoadDocEntry(d, true); 00243 } 00244 00245 CloseFile(); 00246 00247 // ---------------------------- 00248 // Specific code to allow gdcm to read ACR-LibIDO formated images 00249 // Note: ACR-LibIDO is an extension of the ACR standard that was 00250 // used at CREATIS. For the time being (say a couple of years) 00251 // we keep this kludge to allow CREATIS users 00252 // reading their old images. 00253 // 00254 // if recognition code tells us we deal with a LibIDO image 00255 // we switch lineNumber and columnNumber 00256 // 00257 std::string RecCode; 00258 RecCode = GetEntryString(0x0008, 0x0010); // recognition code (RET) 00259 if (RecCode == "ACRNEMA_LIBIDO_1.1" || 00260 RecCode == "CANRME_AILIBOD1_1." ) // for brain-damaged softwares 00261 // with "little-endian strings" 00262 { 00263 Filetype = ACR_LIBIDO; 00264 std::string rows = GetEntryString(0x0028, 0x0010); 00265 std::string columns = GetEntryString(0x0028, 0x0011); 00266 SetEntryString(columns, 0x0028, 0x0010); 00267 SetEntryString(rows , 0x0028, 0x0011); 00268 } 00269 // --- End of ACR-LibIDO kludge --- 00270 return true; 00271 }
|
|
Find the value Length of the passed Doc Entry.
Definition at line 1409 of file gdcmDocument.cxx. References gdcm::ExplicitVR, and gdcmWarningMacro. Referenced by ReadNextDocEntry(). 01411 { 01412 const VRKey &vr = entry->GetVR(); 01413 uint16_t length16; 01414 01415 if ( Filetype == ExplicitVR && !entry->IsImplicitVR() ) 01416 { 01417 if ( vr == "OB" || vr == "OW" || vr == "SQ" || vr == "UT" 01418 || vr == "UN" ) 01419 { 01420 // The following reserved two bytes (see PS 3.5-2003, section 01421 // "7.1.2 Data element structure with explicit vr", p 27) must be 01422 // skipped before proceeding on reading the length on 4 bytes. 01423 Fp->seekg( 2L, std::ios::cur); 01424 uint32_t length32 = ReadInt32(); 01425 01426 if ( (vr == "OB" || vr == "OW") && length32 == 0xffffffff ) 01427 { 01428 uint32_t lengthOB; 01429 try 01430 { 01431 lengthOB = FindDocEntryLengthOBOrOW(); 01432 } 01433 catch ( FormatUnexpected ) 01434 { 01435 // Computing the length failed (this happens with broken 01436 // files like gdcm-JPEG-LossLess3a.dcm). We still have a 01437 // chance to get the pixels by deciding the element goes 01438 // until the end of the file. Hence we artificially fix the 01439 // the length and proceed. 01440 gdcmWarningMacro( " Computing the length failed for " << 01441 entry->GetKey() <<" in " <<GetFileName()); 01442 01443 long currentPosition = Fp->tellg(); 01444 Fp->seekg(0L,std::ios::end); 01445 01446 long lengthUntilEOF = (long)(Fp->tellg())-currentPosition; 01447 Fp->seekg(currentPosition, std::ios::beg); 01448 01449 entry->SetReadLength(lengthUntilEOF); 01450 entry->SetLength(lengthUntilEOF); 01451 return; 01452 } 01453 entry->SetReadLength(lengthOB); 01454 entry->SetLength(lengthOB); 01455 return; 01456 } 01457 FixDocEntryFoundLength(entry, length32); 01458 return; 01459 } 01460 01461 // Length is encoded on 2 bytes. 01462 length16 = ReadInt16(); 01463 01464 // 0xffff means that we deal with 'No Length' Sequence 01465 // or 'No Length' SQItem 01466 if ( length16 == 0xffff) 01467 { 01468 length16 = 0; 01469 } 01470 FixDocEntryFoundLength( entry, (uint32_t)length16 ); 01471 return; 01472 } 01473 else 01474 { 01475 // Either implicit VR or a non DICOM conformal (see note below) explicit 01476 // VR that ommited the VR of (at least) this element. Farts happen. 01477 // [Note: according to the part 5, PS 3.5-2001, section 7.1 p25 01478 // on Data elements "Implicit and Explicit VR Data Elements shall 01479 // not coexist in a Data Set and Data Sets nested within it".] 01480 // Length is on 4 bytes. 01481 01482 // Well ... group 0002 is always coded in 'Explicit VR Litle Endian' 01483 // even if Transfer Syntax is 'Implicit VR ...' 01484 // --> Except for 'Implicit VR Big Endian Transfer Syntax GE Private' 01485 01486 FixDocEntryFoundLength( entry, ReadInt32() ); 01487 return; 01488 } 01489 }
|
|
Find the Length till the next sequence delimiter.
Definition at line 1495 of file gdcmDocument.cxx. References Fp, gdcmWarningMacro, ReadInt16(), ReadInt32(), and SkipBytes(). 01497 { 01498 // See PS 3.5-2001, section A.4 p. 49 on encapsulation of encoded pixel data. 01499 long positionOnEntry = Fp->tellg(); 01500 bool foundSequenceDelimiter = false; 01501 uint32_t totalLength = 0; 01502 01503 while ( !foundSequenceDelimiter ) 01504 { 01505 uint16_t group; 01506 uint16_t elem; 01507 try 01508 { 01509 group = ReadInt16(); 01510 elem = ReadInt16(); 01511 } 01512 catch ( FormatError ) 01513 { 01514 throw FormatError("Unexpected end of file encountered during ", 01515 "Document::FindDocEntryLengthOBOrOW()"); 01516 } 01517 // We have to decount the group and element we just read 01518 totalLength += 4; 01519 if ( group != 0xfffe || ( ( elem != 0xe0dd ) && ( elem != 0xe000 ) ) ) 01520 { 01521 long filePosition = Fp->tellg(); 01522 gdcmWarningMacro( 01523 "Neither an Item tag nor a Sequence delimiter tag on :" 01524 << std::hex << group << " , " << elem 01525 << ") -before- position x(" << filePosition << ")" ); 01526 01527 Fp->seekg(positionOnEntry, std::ios::beg); 01528 throw FormatUnexpected( 01529 "Neither an Item tag nor a Sequence delimiter tag."); 01530 } 01531 if ( elem == 0xe0dd ) 01532 { 01533 foundSequenceDelimiter = true; 01534 } 01535 uint32_t itemLength = ReadInt32(); 01536 // We add 4 bytes since we just read the ItemLength with ReadInt32 01537 totalLength += itemLength + 4; 01538 SkipBytes(itemLength); 01539 01540 if ( foundSequenceDelimiter ) 01541 { 01542 break; 01543 } 01544 } 01545 Fp->seekg( positionOnEntry, std::ios::beg); 01546 return totalLength; 01547 }
|
|
Find the Value Representation of the current Dicom Element.
Definition at line 1553 of file gdcmDocument.cxx. References CheckDocEntryVR(), CurrentGroup, gdcm::ExplicitVR, Filetype, Fp, gdcm::GDCM_VRUNKNOWN, and gdcmWarningMacro. Referenced by ReadNextDocEntry(). 01554 { 01555 if ( Filetype != ExplicitVR ) 01556 return GDCM_VRUNKNOWN; 01557 01558 long positionOnEntry = Fp->tellg(); 01559 // Warning: we believe this is explicit VR (Value Representation) because 01560 // we used a heuristic that found "UL" in the first tag and/or 01561 // 'Transfer Syntax' told us it is. 01562 // Alas this doesn't guarantee that all the tags will be in explicit VR. 01563 // In some cases one finds implicit VR tags mixed within an explicit VR file. 01564 // Hence we make sure the present tag is in explicit VR and try to fix things 01565 // if it happens not to be the case. 01566 01567 VRKey vr; 01568 Fp->read(&(vr[0]),(size_t)2); 01569 01570 if ( !CheckDocEntryVR(vr) ) 01571 { 01572 // Don't warn user with useless messages 01573 // Often, delimiters (0xfffe), are not explicit VR ... 01574 if ( CurrentGroup != 0xfffe ) 01575 gdcmWarningMacro( "Unknown VR " << std::hex << "0x(" 01576 << (unsigned int)vr[0] << "|" << (unsigned int)vr[1] 01577 << ") at offset : 0x(" << positionOnEntry<< ")" ); 01578 Fp->seekg(positionOnEntry, std::ios::beg); 01579 return GDCM_VRUNKNOWN; 01580 } 01581 return vr; 01582 }
|
|
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 1630 of file gdcmDocument.cxx. References gdcmWarningMacro, gdcm::DocEntry::GetElement(), gdcm::DocEntry::GetGroup(), gdcm::DocEntry::GetVR(), gdcm::DocEntry::SetLength(), and gdcm::DocEntry::SetReadLength(). 01632 { 01633 entry->SetReadLength( foundLength );// will be updated only if a bug is found 01634 if ( foundLength == 0xffffffff) 01635 { 01636 foundLength = 0; 01637 } 01638 01639 uint16_t gr = entry->GetGroup(); 01640 uint16_t elem = entry->GetElement(); 01641 01642 if ( foundLength % 2) 01643 { 01644 gdcmWarningMacro( "Warning : Tag with uneven length " << foundLength 01645 << " in x(" << std::hex << gr << "," << elem <<")"); 01646 } 01647 01649 // Allthough not recent many such GE corrupted images are still present 01650 // on Creatis hard disks. Hence this fix shall remain when such images 01651 // are no longer in use (we are talking a few years, here)... 01652 // Note: XMedCon probably uses such a trick since it is able to read 01653 // those pesky GE images ... 01654 if ( foundLength == 13) 01655 { 01656 // Only happens for this length ! 01657 if ( gr != 0x0008 || ( elem != 0x0070 && elem != 0x0080 ) ) 01658 { 01659 foundLength = 10; 01660 entry->SetReadLength(10); // a bug is to be fixed !? 01661 } 01662 } 01663 01665 // Occurence of such images is quite low (unless one leaves close to a 01666 // 'Leonardo' source. Hence, one might consider commenting out the 01667 // following fix on efficiency reasons. 01668 else if ( gr == 0x0009 && ( elem == 0x1113 || elem == 0x1114 ) ) 01669 { 01670 foundLength = 4; 01671 entry->SetReadLength(4); // a bug is to be fixed ! 01672 } 01673 01674 else if ( entry->GetVR() == "SQ" ) 01675 { 01676 foundLength = 0; // ReadLength is unchanged 01677 } 01678 01680 // "fffe|xxxx" which is just a marker. Delimiters length should not be 01681 // taken into account. 01682 else if ( gr == 0xfffe ) 01683 { 01684 // According to the norm, fffe|0000 shouldn't exist. BUT the Philips 01685 // image gdcmData/gdcm-MR-PHILIPS-16-Multi-Seq.dcm happens to 01686 // causes extra troubles... 01687 if ( entry->GetElement() != 0x0000 ) 01688 { 01689 foundLength = 0; 01690 } 01691 else 01692 { 01693 foundLength=12; // to skip the mess that follows this bugged Tag ! 01694 } 01695 } 01696 entry->SetLength(foundLength); 01697 }
|
|
|
|
|
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 484 of file gdcmDocEntrySet.cxx. References gdcm::GDCM_VRUNKNOWN, gdcmWarningMacro, gdcm::DocEntrySet::GetDictEntry(), gdcm::DictEntry::GetVM(), gdcm::DictEntry::GetVR(), gdcm::DictEntry::New(), gdcm::RefCounter::Register(), and gdcm::RefCounter::Unregister(). 00486 { 00487 DictEntry *dictEntry = GetDictEntry(group,elem); 00488 DictEntry *goodEntry = dictEntry; 00489 VRKey goodVR = vr; 00490 TagName vm; 00491 if (elem == 0x0000) 00492 goodVR="UL"; 00493 00494 if ( goodEntry ) 00495 { 00496 if ( goodVR != goodEntry->GetVR() 00497 && goodVR != GDCM_VRUNKNOWN ) 00498 { 00499 gdcmWarningMacro("For (" << std::hex << group << "|" 00500 << elem << "), found VR : [" << vr << "]" 00501 << " expected: [" << goodEntry->GetVR() << "]" ) ; 00502 // avoid confusing further validator with "FIXME" VM 00503 // when possible 00504 vm = dictEntry->GetVM(); 00505 goodEntry = NULL; 00506 } 00507 dictEntry->Unregister(); 00508 } 00509 else 00510 { 00511 vm = "FIXME"; 00512 } 00513 // Create a new virtual DictEntry if necessary 00514 if (!goodEntry) 00515 { 00516 if (dictEntry) 00517 { 00518 00519 goodEntry = DictEntry::New(group, elem, goodVR, vm,//"FIXME", 00520 dictEntry->GetName() ); 00521 } 00522 else 00523 { 00524 goodEntry = DictEntry::New(group, elem, goodVR); 00525 } 00526 } 00527 else 00528 { 00529 goodEntry->Register(); 00530 } 00531 return goodEntry; 00532 }
|
|
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 457 of file gdcmDocEntrySet.cxx. References gdcmWarningMacro, gdcm::DictSet::GetDefaultPubDict(), gdcm::Global::GetDicts(), gdcm::Dict::GetEntry(), and gdcm::RefCounter::Register(). Referenced by gdcm::DocEntrySet::GetDictEntry(), gdcm::DocEntrySet::NewDataEntry(), gdcm::DocEntrySet::NewSeqEntry(), and ReadNextDocEntry(). 00458 { 00459 DictEntry *found = 0; 00460 Dict *pubDict = Global::GetDicts()->GetDefaultPubDict(); 00461 if (!pubDict) 00462 { 00463 gdcmWarningMacro( "We SHOULD have a default dictionary"); 00464 } 00465 else 00466 { 00467 found = pubDict->GetEntry(group, elem); 00468 if( found ) 00469 found->Register(); 00470 } 00471 return found; 00472 }
|
|
retrieves a Dicom Element using (group, element)
Implements gdcm::DocEntrySet. Definition at line 163 of file gdcmElementSet.cxx. References gdcm::ElementSet::TagHT, and gdcm::DictEntry::TranslateToKey(). Referenced by gdcm::File::AnonymizeFile(), gdcm::File::AnonymizeNoLoad(), gdcm::FileHelper::CopyDataEntry(), 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 }
|
|
Searches within the DocEntrySet for the value length of a given tag..
Definition at line 84 of file gdcmDocEntrySet.cxx. References gdcm::DocEntrySet::GetDocEntry(), and gdcm::DocEntry::GetLength(). Referenced by gdcm::DicomDir::SetElement(), and gdcm::File::Write(). 00085 { 00086 DocEntry *entry = GetDocEntry(group, elem); 00087 if ( entry ) 00088 return entry->GetLength(); 00089 return -1; 00090 }
|
|
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(), gdcm::SerieHelper::CreateUniqueSeriesIdentifier(), gdcm::SerieHelper::CreateUserDefinedFileIdentifier(), 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 77 of file gdcmDocument.h. Referenced by gdcm::DicomDir::DoTheLoadingJob(), gdcm::SerieHelper::FileNameGreaterThan(), gdcm::SerieHelper::FileNameLessThan(), IsParsable(), gdcm::DicomDir::IsReadable(), Load(), vtkGdcmReader::LoadImageInMemory(), gdcm::DicomDir::ParseDirectory(), gdcm::DicomDir::SetElement(), vtkGdcmReader::TestFileInformation(), and userSuppliedLessThanFunction2(). 00077 { return Filename; }
|
|
returns the File Type (ACR, ACR_LIBIDO, ExplicitVR, ImplicitVR, Unknown)
Definition at line 392 of file gdcmDocument.cxx. References Filetype. 00393 { 00394 return Filetype; 00395 }
|
|
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 289 of file gdcmDocument.cxx. References RefPubDict. Referenced by gdcm::DicomDir::SetElement(). 00290 { 00291 return RefPubDict; 00292 }
|
|
Get the reference counting.
Definition at line 56 of file gdcmRefCounter.h. 00057 { 00058 return RefCount; 00059 }
|
|
Same as Document::GetDocEntry except it returns a result only when the corresponding entry is of type SeqEntry.
Definition at line 115 of file gdcmDocEntrySet.cxx. References gdcm::DocEntrySet::GetDocEntry(). Referenced by DoTheLoadingDocumentJob(). 00116 { 00117 DocEntry *currentEntry = GetDocEntry(group, elem); 00118 if ( !currentEntry ) 00119 return NULL; 00120 00121 return dynamic_cast<SeqEntry*>(currentEntry); 00122 }
|
|
Get the shadow dictionary used.
Definition at line 297 of file gdcmDocument.cxx. References RefShaDict. 00298 { 00299 return RefShaDict; 00300 }
|
|
'Swap code' accessor (see SwapCode )
Definition at line 73 of file gdcmDocument.h. Referenced by gdcm::PixelReadConvert::GrabInformationsFromFile(). 00073 { 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 404 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(). 00405 { 00406 DocEntry *entry = GetDocEntry(0x0002, 0x0010); 00407 if ( !entry ) 00408 { 00409 return GDCM_UNKNOWN; 00410 } 00411 00412 // The entry might be present but not loaded (parsing and loading 00413 // happen at different stages): try loading and proceed with check... 00414 LoadDocEntrySafe(entry); 00415 if (DataEntry *dataEntry = dynamic_cast<DataEntry *>(entry) ) 00416 { 00417 std::string transfer = dataEntry->GetString(); 00418 // The actual transfer (as read from disk) might be padded. We 00419 // first need to remove the potential padding. We can make the 00420 // weak assumption that padding was not executed with digits... 00421 if ( transfer.length() == 0 ) 00422 { 00423 // for brain damaged headers 00424 gdcmWarningMacro( "Transfer Syntax has length = 0."); 00425 return GDCM_UNKNOWN; 00426 } 00427 while ( !isdigit((unsigned char)transfer[transfer.length()-1]) ) 00428 { 00429 transfer.erase(transfer.length()-1, 1); 00430 if ( transfer.length() == 0 ) 00431 { 00432 // for brain damaged headers 00433 gdcmWarningMacro( "Transfer Syntax contains no valid character."); 00434 return GDCM_UNKNOWN; 00435 } 00436 } 00437 return transfer; 00438 } 00439 return GDCM_UNKNOWN; 00440 }
|
|
Accesses the info from 0002,0010 : Transfer Syntax and TS.
Definition at line 446 of file gdcmDocument.cxx. References gdcm::GDCM_NOTLOADED, gdcm::GDCM_UNFOUND, gdcmDebugMacro, gdcmErrorMacro, gdcm::DocEntrySet::GetEntryString(), and gdcm::Global::GetTS(). Referenced by HandleOutOfGroup0002(). 00447 { 00448 // use the TS (TS : Transfer Syntax) 00449 std::string transferSyntax = GetEntryString(0x0002,0x0010); 00450 00451 if ( (transferSyntax.find(GDCM_NOTLOADED) < transferSyntax.length()) ) 00452 { 00453 gdcmErrorMacro( "Transfer Syntax not loaded. " << std::endl 00454 << "Better you increase MAX_SIZE_LOAD_ELEMENT_VALUE" ); 00455 return "Uncompressed ACR-NEMA"; 00456 } 00457 if ( transferSyntax == GDCM_UNFOUND ) 00458 { 00459 gdcmDebugMacro( "Unfound Transfer Syntax (0002,0010)"); 00460 return "Uncompressed ACR-NEMA"; 00461 } 00462 00463 // we do it only when we need it 00464 const TSKey &tsName = Global::GetTS()->GetValue( transferSyntax ); 00465 00466 // Global::GetTS() is a global static you shall never try to delete it! 00467 return tsName; 00468 }
|
|
Handle broken private tag from Philips NTSCAN where the endianess is being switched to BigEndian for no apparent reason.
Definition at line 2102 of file gdcmDocument.cxx. References gdcmDebugMacro, gdcmWarningMacro, and SwitchByteSwapCode(). Referenced by ReadNextDocEntry(). 02103 { 02104 // Endian reversion. 02105 // Some files contain groups of tags with reversed endianess. 02106 static int reversedEndian = 0; 02107 // try to fix endian switching in the middle of headers 02108 if ((group == 0xfeff) && (elem == 0x00e0)) 02109 { 02110 // start endian swap mark for group found 02111 gdcmDebugMacro( "Start endian swap mark found." ); 02112 reversedEndian++; 02113 SwitchByteSwapCode(); 02114 // fix the tag 02115 group = 0xfffe; 02116 elem = 0xe000; 02117 } 02118 else if (group == 0xfffe && elem == 0xe00d && reversedEndian) 02119 { 02120 // end of reversed endian group 02121 gdcmDebugMacro( "End of reversed endian." ); 02122 reversedEndian--; 02123 SwitchByteSwapCode(); 02124 } 02125 else if (group == 0xfeff && elem == 0xdde0) 02126 { 02127 // reversed Sequence Terminator found 02128 // probabely a bug in the header ! 02129 // Do what you want, it breaks ! 02130 //reversedEndian--; 02131 //SwitchByteSwapCode(); 02132 gdcmWarningMacro( "Should never get here! reversed Sequence Terminator!" ); 02133 // fix the tag 02134 group = 0xfffe; 02135 elem = 0xe0dd; 02136 } 02137 else if (group == 0xfffe && elem == 0xe0dd) 02138 { 02139 gdcmDebugMacro( "Straight Sequence Terminator." ); 02140 } 02141 }
|
|
Group 0002 is always coded Little Endian whatever Transfer Syntax is.
Definition at line 2148 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(). 02149 { 02150 // Endian reversion. 02151 // Some files contain groups of tags with reversed endianess. 02152 if ( !Group0002Parsed && group != 0x0002) 02153 { 02154 Group0002Parsed = true; 02155 // we just came out of group 0002 02156 // if Transfer Syntax is Big Endian we have to change CheckSwap 02157 02158 std::string ts = GetTransferSyntax(); 02159 if ( ts == GDCM_UNKNOWN ) 02160 { 02161 gdcmDebugMacro("True DICOM File, with NO Transfer Syntax (?!) " ); 02162 return; 02163 } 02164 if ( !Global::GetTS()->IsTransferSyntax(ts) ) 02165 { 02166 gdcmWarningMacro("True DICOM File, with illegal Transfer Syntax: [" 02167 << ts << "]"); 02168 return; 02169 } 02170 02171 // Group 0002 is always 'Explicit ...' 02172 // even when Transfer Syntax says 'Implicit ..." 02173 02174 if ( Global::GetTS()->GetSpecialTransferSyntax(ts) == 02175 TS::ImplicitVRLittleEndian ) 02176 { 02177 Filetype = ImplicitVR; 02178 } 02179 02180 // FIXME Strangely, this works with 02181 //'Implicit VR BigEndian Transfer Syntax (GE Private) 02182 // 02183 // --> Probabely normal, since we considered we never have 02184 // to trust manufacturers. 02185 // (we find very often 'Implicit VR' tag, 02186 // even when Transfer Syntax tells us it's Explicit ... 02187 if ( Global::GetTS()->GetSpecialTransferSyntax(ts) == 02188 TS::ExplicitVRBigEndian ) 02189 { 02190 gdcmDebugMacro("Transfer Syntax Name = [" 02191 << GetTransferSyntaxName() << "]" ); 02192 SwitchByteSwapCode(); 02193 group = SwapShort(group); 02194 elem = SwapShort(elem); 02195 } 02196 } 02197 }
|
|
Loads all the needed Dictionaries.
Reimplemented in gdcm::DicomDir. Definition at line 1018 of file gdcmDocument.cxx. References Filetype, gdcm::DictSet::GetDefaultPubDict(), gdcm::Global::GetDicts(), RefPubDict, RefShaDict, and gdcm::Unknown. Referenced by Document(). 01019 { 01020 RefPubDict = Global::GetDicts()->GetDefaultPubDict(); 01021 RefShaDict = NULL; 01022 Filetype = Unknown; 01023 }
|
|
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 270 of file gdcmDocEntrySet.cxx. References gdcm::DocEntrySet::AddEntry(), gdcm::RefCounter::Delete(), gdcmWarningMacro, gdcm::DocEntrySet::GetDocEntry(), gdcm::DocEntry::GetVR(), gdcm::DocEntrySet::NewDataEntry(), gdcm::DocEntrySet::RemoveEntry(), and gdcm::DocEntrySet::SetEntryBinArea(). Referenced by gdcm::FileHelper::InsertEntryBinArea(). 00273 { 00274 DataEntry *dataEntry = 0; 00275 DocEntry *currentEntry = GetDocEntry( group, elem ); 00276 00277 // Verify the currentEntry 00278 if (currentEntry) 00279 { 00280 dataEntry = dynamic_cast<DataEntry *>(currentEntry); 00281 00282 // Verify the VR 00283 if ( dataEntry ) 00284 if ( dataEntry->GetVR()!=vr ) 00285 dataEntry = NULL; 00286 00287 // if currentEntry doesn't correspond to the requested dataEntry 00288 if ( !dataEntry) 00289 { 00290 if ( !RemoveEntry(currentEntry) ) 00291 { 00292 gdcmWarningMacro( "Removal of previous DocEntry failed."); 00293 return NULL; 00294 } 00295 } 00296 } 00297 00298 // Create a new dataEntry if necessary 00299 if ( !dataEntry) 00300 { 00301 dataEntry = NewDataEntry(group, elem, vr); 00302 00303 if ( !AddEntry(dataEntry) ) 00304 { 00305 gdcmWarningMacro( "AddEntry failed although this is a creation."); 00306 dataEntry->Delete(); 00307 return NULL; 00308 } 00309 dataEntry->Delete(); 00310 } 00311 00312 // Set the dataEntry value 00313 uint8_t *tmpArea; 00314 if ( lgth>0 && binArea ) 00315 { 00316 tmpArea = new uint8_t[lgth]; 00317 memcpy(tmpArea,binArea,lgth); 00318 } 00319 else 00320 { 00321 tmpArea = 0; 00322 } 00323 if ( !SetEntryBinArea(tmpArea,lgth,dataEntry) ) 00324 { 00325 if ( tmpArea ) 00326 { 00327 delete[] tmpArea; 00328 } 00329 } 00330 return dataEntry; 00331 }
|
|
Modifies the value of a given Doc Entry (Dicom Element) when it exists. Create it with the given value when unexistant.
Definition at line 212 of file gdcmDocEntrySet.cxx. References gdcm::DocEntrySet::AddEntry(), gdcm::RefCounter::Delete(), gdcmWarningMacro, gdcm::DocEntrySet::GetDocEntry(), gdcm::DocEntry::GetVR(), gdcm::DocEntrySet::NewDataEntry(), gdcm::DocEntrySet::RemoveEntry(), and gdcm::DocEntrySet::SetEntryString(). Referenced by gdcm::FileHelper::InsertEntryString(), gdcm::FileHelper::Write(), and gdcm::File::Write(). 00215 { 00216 DataEntry *dataEntry = 0; 00217 DocEntry *currentEntry = GetDocEntry( group, elem ); 00218 00219 if (currentEntry) 00220 { 00221 dataEntry = dynamic_cast<DataEntry *>(currentEntry); 00222 00223 // Verify the VR 00224 if ( dataEntry ) 00225 if ( dataEntry->GetVR()!=vr ) 00226 dataEntry = NULL; 00227 00228 // if currentEntry doesn't correspond to the requested dataEntry 00229 if ( !dataEntry) 00230 { 00231 if ( !RemoveEntry(currentEntry) ) 00232 { 00233 gdcmWarningMacro( "Removal of previous DocEntry failed."); 00234 return NULL; 00235 } 00236 } 00237 } 00238 00239 // Create a new dataEntry if necessary 00240 if ( !dataEntry ) 00241 { 00242 dataEntry = NewDataEntry( group, elem, vr ); 00243 00244 if ( !AddEntry(dataEntry) ) 00245 { 00246 gdcmWarningMacro("AddEntry failed although this is a creation."); 00247 dataEntry->Delete(); 00248 return NULL; 00249 } 00250 dataEntry->Delete(); 00251 } 00252 00253 // Set the dataEntry value 00254 SetEntryString(value, dataEntry); // The std::string value 00255 return dataEntry; 00256 }
|
|
Creates a new gdcm::SeqEntry and adds it to the current DocEntrySet. (remove any existing entry with same group,elem).
Definition at line 341 of file gdcmDocEntrySet.cxx. References gdcm::DocEntrySet::AddEntry(), gdcm::RefCounter::Delete(), gdcmWarningMacro, gdcm::DocEntrySet::GetDocEntry(), gdcm::DocEntrySet::NewSeqEntry(), and gdcm::DocEntrySet::RemoveEntry(). Referenced by gdcm::FileHelper::InsertSeqEntry(). 00342 { 00343 SeqEntry *seqEntry = 0; 00344 DocEntry *currentEntry = GetDocEntry( group, elem ); 00345 00346 // Verify the currentEntry 00347 if ( currentEntry ) 00348 { 00349 seqEntry = dynamic_cast<SeqEntry *>(currentEntry); 00350 00351 // Verify the VR 00352 if ( seqEntry ) 00353 seqEntry = NULL; 00354 00355 // if currentEntry doesn't correspond to the requested seqEntry 00356 if ( !seqEntry ) 00357 { 00358 if (!RemoveEntry(currentEntry)) 00359 { 00360 gdcmWarningMacro( "Removal of previous DocEntry failed for (" 00361 <<std::hex << group << "|" << elem <<")" ); 00362 return NULL; 00363 } 00364 } 00365 } 00366 // Create a new seqEntry if necessary 00367 if ( !seqEntry ) 00368 { 00369 seqEntry = NewSeqEntry(group, elem); 00370 00371 if ( !AddEntry(seqEntry) ) 00372 { 00373 gdcmWarningMacro( "AddEntry failed although this is a creation for (" 00374 <<std::hex << group << "|" << elem <<")" ); 00375 seqEntry->Delete(); 00376 return NULL; 00377 } 00378 seqEntry->Delete(); 00379 } 00380 // Remark : 00381 // SequenceDelimitationItem will be added at the end of the SeqEntry, 00382 // at write time 00383 return seqEntry; 00384 }
|
|
Predicate for dicom version 3 file.
Definition at line 361 of file gdcmDocument.cxx. References gdcm::ElementSet::GetDocEntry(). Referenced by gdcm::File::GetYSize(), and gdcm::PixelReadConvert::GrabInformationsFromFile(). 00362 { 00363 // Checking if Transfer Syntax exists is enough 00364 // Anyway, it's too late check if the 'Preamble' was found ... 00365 // And ... would it be a rich idea to check ? 00366 // (some 'no Preamble' DICOM images exist !) 00367 return GetDocEntry(0x0002, 0x0010) != NULL; 00368 }
|
|
Apply some heuristics to predict whether the considered element value contains/represents an integer or not.
Definition at line 1705 of file gdcmDocument.cxx. References Fp, gdcmWarningMacro, gdcm::DocEntry::GetElement(), gdcm::DocEntry::GetGroup(), gdcm::DocEntry::GetLength(), and gdcm::DocEntry::GetVR(). 01706 { 01707 uint16_t elem = entry->GetElement(); 01708 uint16_t group = entry->GetGroup(); 01709 const VRKey &vr = entry->GetVR(); 01710 uint32_t length = entry->GetLength(); 01711 01712 // When we have some semantics on the element we just read, and if we 01713 // a priori know we are dealing with an integer, then we shall be 01714 // able to swap it's element value properly. 01715 if ( elem == 0 ) // This is the group length of the group 01716 { 01717 if ( length == 4 ) 01718 { 01719 return true; 01720 } 01721 else 01722 { 01723 // Although this should never happen, still some images have a 01724 // corrupted group length [e.g. have a glance at offset x(8336) of 01725 // gdcmData/gdcm-MR-PHILIPS-16-Multi-Seq.dcm. 01726 // Since for dicom compliant and well behaved headers, the present 01727 // test is useless (and might even look a bit paranoid), when we 01728 // encounter such an ill-formed image, we simply display a warning 01729 // message and proceed on parsing (while crossing fingers). 01730 long filePosition = Fp->tellg(); 01731 gdcmWarningMacro( "Erroneous Group Length element length on : (" 01732 << std::hex << group << " , " << elem 01733 << ") -before- position x(" << filePosition << ")" 01734 << "lgt : " << length ); 01735 } 01736 } 01737 01738 if ( vr == "UL" || vr == "US" || vr == "SL" || vr == "SS" ) 01739 { 01740 return true; 01741 } 01742 return false; 01743 }
|
|
Tells us if the ElementSet contains no entry.
Implements gdcm::DocEntrySet. Definition at line 58 of file gdcmElementSet.h. Referenced by DoTheLoadingDocumentJob(), and IsParsable(). 00058 { return TagHT.empty(); }
|
|
Predicate for Papyrus file Dedicated to whomsoever it may concern.
Definition at line 375 of file gdcmDocument.cxx. References gdcm::ElementSet::GetDocEntry(). 00376 { 00377 // check for Papyrus private Sequence 00378 DocEntry *e = GetDocEntry(0x0041, 0x1050); 00379 if ( !e ) 00380 return false; 00381 // check if it's actually a Sequence 00382 if ( !dynamic_cast<SeqEntry*>(e) ) 00383 return false; 00384 return true; 00385 }
|
|
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 329 of file gdcmDocument.cxx. References Filetype, gdcmWarningMacro, GetFileName(), gdcm::ElementSet::IsEmpty(), and gdcm::Unknown. Referenced by IsReadable(). 00330 { 00331 if ( Filetype == Unknown ) 00332 { 00333 gdcmWarningMacro( "Wrong filetype for " << GetFileName()); 00334 return false; 00335 } 00336 00337 if ( IsEmpty() ) 00338 { 00339 gdcmWarningMacro( "No tag in internal hash table."); 00340 return false; 00341 } 00342 00343 return true; 00344 }
|
|
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 352 of file gdcmDocument.cxx. References IsParsable(). Referenced by gdcm::File::IsReadable(). 00353 { 00354 return IsParsable(); 00355 }
|
|
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 }
|
|
Loads (or not) the element content depending if its length exceeds or not the value specified with Document::SetMaxSizeLoadEntry().
Definition at line 1347 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(). 01348 { 01349 uint16_t group = entry->GetGroup(); 01350 uint16_t elem = entry->GetElement(); 01351 const VRKey &vr = entry->GetVR(); 01352 uint32_t length = entry->GetLength(); 01353 01354 Fp->seekg((long)entry->GetOffset(), std::ios::beg); 01355 01356 // A SeQuence "contains" a set of Elements. 01357 // (fffe e000) tells us an Element is beginning 01358 // (fffe e00d) tells us an Element just ended 01359 // (fffe e0dd) tells us the current SeQuence just ended 01360 // 01361 // (fffe 0000) is an 'impossible' tag value, 01362 // found in MR-PHILIPS-16-Multi-Seq.dcm 01363 01364 if ( (group == 0xfffe && elem != 0x0000 ) || vr == "SQ" ) 01365 { 01366 // NO more value field for SQ ! 01367 return; 01368 } 01369 01370 DataEntry *dataEntryPtr = dynamic_cast< DataEntry* >(entry); 01371 if( !dataEntryPtr ) 01372 { 01373 return; 01374 } 01375 01376 // When the length is zero things are easy: 01377 if ( length == 0 ) 01378 { 01379 dataEntryPtr->SetBinArea(NULL,true); 01380 return; 01381 } 01382 01383 // The elements whose length is bigger than the specified upper bound 01384 // are not loaded. 01385 01386 std::ostringstream s; 01387 01388 if (!forceLoad) 01389 { 01390 if (length > MaxSizeLoadEntry) 01391 { 01392 dataEntryPtr->SetBinArea(NULL,true); 01393 dataEntryPtr->SetState(DataEntry::STATE_NOTLOADED); 01394 01395 // to be sure we are at the end of the value ... 01396 Fp->seekg((long)entry->GetOffset()+(long)entry->GetLength(), 01397 std::ios::beg); 01398 return; 01399 } 01400 } 01401 01402 LoadEntryBinArea(dataEntryPtr); // last one, not to erase length ! 01403 }
|
|
Loads the element while preserving the current underlying file position indicator as opposed to LoadDocEntry that modifies it.
Definition at line 811 of file gdcmDocument.cxx. References Fp, and LoadDocEntry(). Referenced by GetTransferSyntax(). 00812 { 00813 if ( Fp ) 00814 { 00815 long PositionOnEntry = Fp->tellg(); 00816 LoadDocEntry(entry); 00817 Fp->seekg(PositionOnEntry, std::ios::beg); 00818 } 00819 }
|
|
Loads (from disk) the element content when a string is not suitable.
Definition at line 730 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(). 00731 { 00732 if( entry->GetBinArea() ) 00733 return; 00734 00735 bool openFile = !Fp; 00736 if ( openFile ) 00737 OpenFile(); 00738 00739 size_t o =(size_t)entry->GetOffset(); 00740 Fp->seekg(o, std::ios::beg); 00741 00742 size_t l = entry->GetLength(); 00743 uint8_t *data = new uint8_t[l]; 00744 if ( !data ) 00745 { 00746 gdcmWarningMacro( "Cannot allocate DataEntry content for : " 00747 << std::hex << entry->GetGroup() 00748 << "|" << entry->GetElement() ); 00749 return; 00750 } 00751 00752 // Read the data 00753 Fp->read((char*)data, l); 00754 if ( Fp->fail() || Fp->eof() ) 00755 { 00756 delete[] data; 00757 entry->SetState(DataEntry::STATE_UNREAD); 00758 return; 00759 } 00760 00761 // Swap the data content if necessary 00762 uint32_t i; 00763 unsigned short vrLgth = 00764 Global::GetVR()->GetAtomicElementLength(entry->GetVR()); 00765 00766 // FIXME : trouble expected if we read an ... OW Entry (LUT, etc ..) 00767 // if( entry->GetVR() == "OW" ) 00768 // vrLgth = 1; 00769 00770 switch(vrLgth) 00771 { 00772 case 1: 00773 { 00774 break; 00775 } 00776 case 2: 00777 { 00778 uint16_t *data16 = (uint16_t *)data; 00779 for(i=0;i<l/vrLgth;i++) 00780 data16[i] = SwapShort(data16[i]); 00781 break; 00782 } 00783 case 4: 00784 { 00785 uint32_t *data32 = (uint32_t *)data; 00786 for(i=0;i<l/vrLgth;i++) 00787 data32[i] = SwapLong(data32[i]); 00788 break; 00789 } 00790 case 8: 00791 { 00792 double *data64 = (double *)data; 00793 for(i=0;i<l/vrLgth;i++) 00794 data64[i] = SwapDouble(data64[i]); 00795 break; 00796 } 00797 } 00798 00799 entry->SetBinArea(data); 00800 00801 if ( openFile ) 00802 CloseFile(); 00803 }
|
|
Loads (from disk) the element content when a string is not suitable.
Definition at line 705 of file gdcmDocument.cxx. References gdcmDebugMacro, gdcmWarningMacro, and gdcm::ElementSet::GetDocEntry(). Referenced by DoTheLoadingDocumentJob(), gdcm::PixelReadConvert::GrabInformationsFromFile(), and LoadDocEntry(). 00706 { 00707 // Search the corresponding DocEntry 00708 DocEntry *docEntry = GetDocEntry(group, elem); 00709 if ( !docEntry ) 00710 { 00711 gdcmDebugMacro(std::hex << group << "|" << elem 00712 << " doesn't exist" ); 00713 return; 00714 } 00715 DataEntry *dataEntry = dynamic_cast<DataEntry *>(docEntry); 00716 if ( !dataEntry ) 00717 { 00718 gdcmWarningMacro(std::hex << group << "|" << elem 00719 << " is NOT a DataEntry"); 00720 return; 00721 } 00722 LoadEntryBinArea(dataEntry); 00723 }
|
|
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 DataEntry from all the low level arguments. Check for existence of dictionary entry, and build a default one when absent.
Definition at line 406 of file gdcmDocEntrySet.cxx. References gdcmWarningMacro, gdcm::DocEntrySet::GetDictEntry(), gdcm::DataEntry::New(), and gdcm::RefCounter::Unregister(). Referenced by gdcm::FileHelper::CopyDataEntry(), gdcm::DocEntrySet::InsertEntryBinArea(), gdcm::DocEntrySet::InsertEntryString(), and ReadNextDocEntry(). 00408 { 00409 DictEntry *dictEntry = GetDictEntry(group, elem, vr); 00410 00411 DataEntry *newEntry = DataEntry::New(dictEntry); 00412 dictEntry->Unregister(); // GetDictEntry register it 00413 if (!newEntry) 00414 { 00415 gdcmWarningMacro( "Failed to allocate DataEntry for (" 00416 <<std::hex << group << "|" << elem <<")" ); 00417 return 0; 00418 } 00419 return newEntry; 00420 }
|
|
Build a new SeqEntry from all the low level arguments. Check for existence of dictionary entry, and build a default one when absent.
Definition at line 430 of file gdcmDocEntrySet.cxx. References gdcmWarningMacro, gdcm::DocEntrySet::GetDictEntry(), gdcm::SeqEntry::New(), and gdcm::RefCounter::Unregister(). Referenced by Backtrack(), gdcm::DocEntrySet::InsertSeqEntry(), and ReadNextDocEntry(). 00431 { 00432 DictEntry *dictEntry = GetDictEntry(group, elem, "SQ"); 00433 00434 SeqEntry *newEntry = SeqEntry::New( dictEntry ); 00435 dictEntry->Unregister(); // GetDictEntry register it 00436 if (!newEntry) 00437 { 00438 gdcmWarningMacro( "Failed to allocate SeqEntry for (" 00439 <<std::hex << group << "|" << elem <<")" ); 00440 return 0; 00441 } 00442 return newEntry; 00443 }
|
|
Tries to open the file Document::Filename and checks the preamble when existing.
Definition at line 561 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(). 00562 { 00563 HasDCMPreamble = false; 00564 if (Filename.length() == 0) 00565 { 00566 return 0; 00567 } 00568 00569 if ( Fp ) 00570 { 00571 gdcmDebugMacro( "File already open: " << Filename.c_str()); 00572 CloseFile(); 00573 } 00574 00575 Fp = new std::ifstream(Filename.c_str(), std::ios::in | std::ios::binary); 00576 if ( ! *Fp ) 00577 { 00578 // Don't user gdcmErrorMacro : 00579 // a spurious message will appear when you use, for instance 00580 // gdcm::FileHelper *fh = new gdcm::FileHelper( outputFileName ); 00581 // to create outputFileName. 00582 00583 // FIXME : if the upper comment is still usefull 00584 // --> the constructor is not so good ... 00585 00586 gdcmWarningMacro( "Cannot open file: " << Filename.c_str()); 00587 delete Fp; 00588 Fp = 0; 00589 return 0; 00590 //exit(1); // No function is allowed to leave the application instead 00591 // of warning the caller 00592 } 00593 00594 uint16_t zero = 0; 00595 Fp->read((char*)&zero, (size_t)2); 00596 if ( Fp->eof() ) 00597 { 00598 CloseFile(); 00599 return 0; 00600 } 00601 00602 //-- Broken ACR or DICOM with no Preamble; may start with a Shadow Group -- 00603 00604 // FIXME : We cannot be sure the preable is only zeroes.. 00605 // (see ACUSON-24-YBR_FULL-RLE.dcm ) 00606 if ( 00607 zero == 0x0001 || zero == 0x0100 || zero == 0x0002 || zero == 0x0200 || 00608 zero == 0x0003 || zero == 0x0300 || zero == 0x0004 || zero == 0x0400 || 00609 zero == 0x0005 || zero == 0x0500 || zero == 0x0006 || zero == 0x0600 || 00610 zero == 0x0007 || zero == 0x0700 || zero == 0x0008 || zero == 0x0800 ) 00611 { 00612 std::string msg = Util::Format( 00613 "ACR/DICOM starting by 0x(%04x) at the beginning of the file\n", zero); 00614 // FIXME : is it a Warning message, or a Debug message? 00615 gdcmWarningMacro( msg.c_str() ); 00616 return Fp; 00617 } 00618 00619 //-- DICOM -- 00620 Fp->seekg(126L, std::ios::cur); 00621 char dicm[4]; // = {' ',' ',' ',' '}; 00622 Fp->read(dicm, (size_t)4); 00623 if ( Fp->eof() ) 00624 { 00625 CloseFile(); 00626 return 0; 00627 } 00628 if ( memcmp(dicm, "DICM", 4) == 0 ) 00629 { 00630 HasDCMPreamble = true; 00631 return Fp; 00632 } 00633 00634 // -- Neither ACR/No Preamble Dicom nor DICOMV3 file 00635 CloseFile(); 00636 // Don't user Warning nor Error, not to polute the output 00637 // while directory recursive parsing ... 00638 gdcmDebugMacro( "Neither ACR/No Preamble Dicom nor DICOMV3 file: " 00639 << Filename.c_str()); 00640 return 0; 00641 }
|
|
Compares two documents, according to DicomDir rules.
Definition at line 828 of file gdcmDocument.cxx. References gdcm::DocEntrySet::GetEntryString(). 00829 { 00830 // Patient Name 00831 std::string s1 = GetEntryString(0x0010,0x0010); 00832 std::string s2 = document.GetEntryString(0x0010,0x0010); 00833 if (s1 < s2) 00834 { 00835 return true; 00836 } 00837 else if ( s1 > s2 ) 00838 { 00839 return false; 00840 } 00841 else 00842 { 00843 // Patient ID 00844 s1 = GetEntryString(0x0010,0x0020); 00845 s2 = document.GetEntryString(0x0010,0x0020); 00846 if ( s1 < s2 ) 00847 { 00848 return true; 00849 } 00850 else if ( s1 > s2 ) 00851 { 00852 return false; 00853 } 00854 else 00855 { 00856 // Study Instance UID 00857 s1 = GetEntryString(0x0020,0x000d); 00858 s2 = document.GetEntryString(0x0020,0x000d); 00859 if ( s1 < s2 ) 00860 { 00861 return true; 00862 } 00863 else if ( s1 > s2 ) 00864 { 00865 return false; 00866 } 00867 else 00868 { 00869 // Serie Instance UID 00870 s1 = GetEntryString(0x0020,0x000e); 00871 s2 = document.GetEntryString(0x0020,0x000e); 00872 if ( s1 < s2 ) 00873 { 00874 return true; 00875 } 00876 else if ( s1 > s2 ) 00877 { 00878 return false; 00879 } 00880 } 00881 } 00882 } 00883 return false; 00884 }
|
|
Parses a DocEntrySet (Zero-level DocEntries or SQ Item DocEntries).
Definition at line 1032 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::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(). 01034 { 01035 DocEntry *newDocEntry; 01036 DataEntry *newDataEntry; 01037 SeqEntry *newSeqEntry; 01038 VRKey vr; 01039 bool used; // will be set to false when something wrong happens to an Entry. 01040 // (Entry will then be deleted) 01041 bool delim_mode_intern = delim_mode; 01042 bool first = true; 01043 gdcmDebugMacro( "Enter in ParseDES, delim-mode " << delim_mode 01044 << " at offset " << std::hex << "0x(" << offset << ")" ); 01045 while (true) 01046 { 01047 if ( !delim_mode && ((long)(Fp->tellg())-offset) >= l_max) 01048 { 01049 break; 01050 } 01051 01052 newDocEntry = ReadNextDocEntry( ); 01053 01054 // Uncoment this cerr line to be able to 'follow' the DocEntries 01055 // when something *very* strange happens 01056 if( Debug::GetDebugFlag() ) 01057 std::cerr<<newDocEntry->GetKey()<<" "<<newDocEntry->GetVR()<<std::endl; 01058 01059 if ( !newDocEntry ) 01060 { 01061 break; 01062 } 01063 01064 // an Item Starter found elsewhere but the first position 01065 // of a SeqEntry means previous entry was a Sequence 01066 // but we didn't get it (private Sequence + Implicit VR) 01067 // we have to backtrack. 01068 if ( !first && newDocEntry->IsItemStarter() ) 01069 { 01070 // Debug message within the method ! 01071 newDocEntry = Backtrack(newDocEntry); 01072 } 01073 else 01074 { 01075 PreviousDocEntry = newDocEntry; 01076 } 01077 01078 used = true; 01079 newDataEntry = dynamic_cast<DataEntry*>(newDocEntry); 01080 01081 if ( newDataEntry ) 01082 { 01084 01085 vr = newDocEntry->GetVR(); 01086 01087 if ( !set->AddEntry( newDataEntry ) ) 01088 { 01089 gdcmDebugMacro( "in ParseDES : cannot add a DataEntry " 01090 << newDataEntry->GetKey() 01091 << " (at offset : 0x(" 01092 << newDataEntry->GetOffset() << ") )" ); 01093 used=false; 01094 } 01095 else 01096 { 01097 newDataEntry->Delete(); 01098 // Load only if we can add (not a duplicate key) 01099 LoadDocEntry( newDataEntry ); 01100 } 01101 if ( newDataEntry->GetElement() == 0x0000 ) // if on group length 01102 { 01103 if ( newDataEntry->GetGroup()%2 != 0 ) // if Shadow Group 01104 { 01105 if ( LoadMode & LD_NOSHADOW ) // if user asked to skip shad.gr 01106 { 01107 std::string strLgrGroup = newDataEntry->GetString(); 01108 01109 int lgrGroup; 01110 //if ( newDataEntry->IsUnfound() ) /?!? JPR 01111 { 01112 lgrGroup = atoi(strLgrGroup.c_str()); 01113 Fp->seekg(lgrGroup, std::ios::cur); 01114 //used = false; // never used 01115 RemoveEntry( newDocEntry ); // Remove and delete 01116 // bcc 5.5 is right "assigned a value that's never used" 01117 // newDocEntry = 0; 01118 continue; 01119 } 01120 } 01121 } 01122 } 01123 01124 bool delimitor = newDataEntry->IsItemDelimitor(); 01125 01126 if ( (delimitor) || 01127 (!delim_mode && ((long)(Fp->tellg())-offset) >= l_max) ) 01128 { 01129 if ( !used ) 01130 newDocEntry->Delete(); 01131 break; 01132 } 01133 01134 // Just to make sure we are at the beginning of next entry. 01135 SkipToNextDocEntry(newDocEntry); 01136 } 01137 else 01138 { 01140 01141 unsigned long l = newDocEntry->GetReadLength(); 01142 if ( l != 0 ) // don't mess the delim_mode for 'zero-length sequence' 01143 { 01144 if ( l == 0xffffffff ) 01145 { 01146 delim_mode_intern = true; 01147 } 01148 else 01149 { 01150 delim_mode_intern = false; 01151 } 01152 } 01153 01154 if ( (LoadMode & LD_NOSHADOWSEQ) && ! delim_mode_intern ) 01155 { 01156 // User asked to skip SeQuences *only* if they belong to Shadow Group 01157 if ( newDocEntry->GetGroup()%2 != 0 ) 01158 { 01159 Fp->seekg( l, std::ios::cur); 01160 newDocEntry->Delete(); // Delete, not in the set 01161 continue; 01162 } 01163 } 01164 if ( (LoadMode & LD_NOSEQ) && ! delim_mode_intern ) 01165 { 01166 // User asked to skip *any* SeQuence 01167 Fp->seekg( l, std::ios::cur); 01168 newDocEntry->Delete(); // Delete, not in the set 01169 continue; 01170 } 01171 // delay the dynamic cast as late as possible 01172 newSeqEntry = dynamic_cast<SeqEntry*>(newDocEntry); 01173 01174 // no other way to create the Delimitor ... 01175 newSeqEntry->SetDelimitorMode( delim_mode_intern ); 01176 01177 // At the top of the hierarchy, stands a Document. When "set" 01178 // is a Document, then we are building the first depth level. 01179 // Hence the SeqEntry we are building simply has a depth 01180 // level of one: 01181 if ( set == this ) // ( dynamic_cast< Document* > ( set ) ) 01182 { 01183 newSeqEntry->SetDepthLevel( 1 ); 01184 } 01185 // But when "set" is already a SQItem, we are building a nested 01186 // sequence, and hence the depth level of the new SeqEntry 01187 // we are building, is one level deeper: 01188 01189 // time waste hunting 01190 else if (SQItem *parentSQItem = dynamic_cast< SQItem* > ( set ) ) 01191 { 01192 newSeqEntry->SetDepthLevel( parentSQItem->GetDepthLevel() + 1 ); 01193 } 01194 01195 if ( l != 0 ) 01196 { // Don't try to parse zero-length sequences 01197 01198 gdcmDebugMacro( "Entry in ParseSQ, delim " << delim_mode_intern 01199 << " at offset 0x(" << std::hex 01200 << newDocEntry->GetOffset() << ")"); 01201 01202 ParseSQ( newSeqEntry, 01203 newDocEntry->GetOffset(), 01204 l, delim_mode_intern); 01205 01206 gdcmDebugMacro( "Exit from ParseSQ, delim " << delim_mode_intern); 01207 01208 } 01209 if ( !set->AddEntry( newSeqEntry ) ) 01210 { 01211 gdcmWarningMacro( "in ParseDES : cannot add a SeqEntry " 01212 << newSeqEntry->GetKey() 01213 << " (at offset : 0x(" 01214 << newSeqEntry->GetOffset() << ") )" ); 01215 used = false; 01216 } 01217 else 01218 { 01219 newDocEntry->Delete(); 01220 } 01221 01222 if ( !delim_mode && ((long)(Fp->tellg())-offset) >= l_max) 01223 { 01224 if ( !used ) 01225 newDocEntry->Delete(); 01226 break; 01227 } 01228 } // end SeqEntry : VR = "SQ" 01229 01230 if ( !used ) 01231 { 01232 newDocEntry->Delete(); 01233 } 01234 first = false; 01235 } // end While 01236 gdcmDebugMacro( "Exit from ParseDES, delim-mode " << delim_mode ); 01237 }
|
|
Parses a Sequence ( SeqEntry after SeqEntry).
Definition at line 1243 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(). 01245 { 01246 int SQItemNumber = 0; 01247 bool dlm_mod; 01248 long offsetStartCurrentSQItem = offset; 01249 01250 while (true) 01251 { 01252 // the first time, we read the fff0,e000 of the first SQItem 01253 DocEntry *newDocEntry = ReadNextDocEntry(); 01254 01255 if ( !newDocEntry ) 01256 { 01257 gdcmWarningMacro("in ParseSQ : should never get here!"); 01258 break; 01259 } 01260 if ( delim_mode ) 01261 { 01262 if ( newDocEntry->IsSequenceDelimitor() ) 01263 { 01264 seqEntry->SetDelimitationItem( newDocEntry ); 01265 newDocEntry->Delete(); 01266 break; 01267 } 01268 } 01269 if ( !delim_mode && ((long)(Fp->tellg())-offset) >= l_max) 01270 { 01271 newDocEntry->Delete(); 01272 break; 01273 } 01274 // create the current SQItem 01275 SQItem *itemSQ = SQItem::New( seqEntry->GetDepthLevel() ); 01276 unsigned int l = newDocEntry->GetReadLength(); 01277 01278 if ( l == 0xffffffff ) 01279 { 01280 dlm_mod = true; 01281 } 01282 else 01283 { 01284 dlm_mod = false; 01285 } 01286 01287 // remove fff0,e000, created out of the SQItem 01288 Fp->seekg(offsetStartCurrentSQItem, std::ios::beg); 01289 // fill up the current SQItem, starting at the beginning of fff0,e000 01290 01291 ParseDES(itemSQ, offsetStartCurrentSQItem, l+8, dlm_mod); 01292 01293 offsetStartCurrentSQItem = Fp->tellg(); 01294 01295 seqEntry->AddSQItem( itemSQ, SQItemNumber ); 01296 itemSQ->Delete(); 01297 newDocEntry->Delete(); 01298 SQItemNumber++; 01299 if ( !delim_mode && ((long)(Fp->tellg())-offset ) >= l_max ) 01300 { 01301 break; 01302 } 01303 } 01304 }
|
|
Prints the Header Entries (Dicom Elements) from the H Table.
Reimplemented from gdcm::Base. Reimplemented in gdcm::DicomDir. Definition at line 209 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(). 00210 { 00211 // Let's change the 'warning value' for Pixel Data, 00212 // to avoid human reader to be confused by 'gdcm::NotLoaded'. 00213 DataEntry *pixelElement = GetDataEntry(0x7fe0,0x0010); 00214 if ( pixelElement != 0 ) 00215 { 00216 pixelElement->SetFlag( DataEntry::FLAG_PIXELDATA ); 00217 } 00218 00219 for( TagDocEntryHT::const_iterator i = TagHT.begin(); i != TagHT.end(); ++i) 00220 { 00221 DocEntry *entry = i->second; 00222 00223 entry->SetPrintLevel(PrintLevel); 00224 entry->Print(os); 00225 00226 if ( dynamic_cast<SeqEntry *>(entry) ) 00227 { 00228 // Avoid the newline for a sequence: 00229 continue; 00230 } 00231 os << std::endl; 00232 } 00233 }
|
|
Reads a supposed to be 16 Bits integer (swaps it depending on processor endianness).
Definition at line 893 of file gdcmDocument.cxx. References Fp, and SwapShort(). Referenced by FindDocEntryLengthOBOrOW(), ReadNextDocEntry(), and gdcm::File::ReadTag(). 00895 { 00896 uint16_t g; 00897 Fp->read ((char*)&g, (size_t)2); 00898 if ( Fp->fail() ) 00899 { 00900 throw FormatError( "Document::ReadInt16()", " file error." ); 00901 } 00902 if ( Fp->eof() ) 00903 { 00904 throw FormatError( "Document::ReadInt16()", "EOF." ); 00905 } 00906 g = SwapShort(g); 00907 return g; 00908 }
|
|
Reads a supposed to be 32 Bits integer (swaps it depending on processor endianness).
Definition at line 915 of file gdcmDocument.cxx. References Fp, and SwapLong(). Referenced by gdcm::File::ComputeRLEInfo(), FindDocEntryLengthOBOrOW(), and gdcm::File::ReadTagLength(). 00917 { 00918 uint32_t g; 00919 Fp->read ((char*)&g, (size_t)4); 00920 if ( Fp->fail() ) 00921 { 00922 throw FormatError( "Document::ReadInt32()", " file error." ); 00923 } 00924 if ( Fp->eof() ) 00925 { 00926 throw FormatError( "Document::ReadInt32()", "EOF." ); 00927 } 00928 g = SwapLong(g); 00929 return g; 00930 }
|
|
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 2002 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::DictEntry::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(). 02003 { 02004 try 02005 { 02006 CurrentGroup = ReadInt16(); 02007 CurrentElem = ReadInt16(); 02008 } 02009 catch ( FormatError ) 02010 { 02011 // We reached the EOF (or an error occured) therefore 02012 // header parsing has to be considered as finished. 02013 return 0; 02014 } 02015 02016 // Sometimes file contains groups of tags with reversed endianess. 02017 HandleBrokenEndian(CurrentGroup, CurrentElem); 02018 02019 // In 'true DICOM' files Group 0002 is always little endian 02020 if ( HasDCMPreamble ) 02021 HandleOutOfGroup0002(CurrentGroup, CurrentElem); 02022 02023 VRKey vr = FindDocEntryVR(); 02024 02025 VRKey realVR = vr; 02026 02027 if ( vr == GDCM_VRUNKNOWN ) 02028 { 02029 if ( CurrentElem == 0x0000 ) // Group Length 02030 { 02031 realVR = "UL"; // must be UL 02032 } 02033 else if (CurrentGroup%2 == 1 && 02034 (CurrentElem >= 0x0010 && CurrentElem <=0x00ff )) 02035 { 02036 // DICOM PS 3-5 7.8.1 a) states that those 02037 // (gggg-0010->00FF where gggg is odd) attributes have to be LO 02038 realVR = "LO"; 02039 } 02040 else 02041 { 02042 DictEntry *dictEntry = GetDictEntry(CurrentGroup,CurrentElem); 02043 if ( dictEntry ) 02044 { 02045 realVR = dictEntry->GetVR(); 02046 dictEntry->Unregister(); 02047 } 02048 } 02049 } 02050 // gdcmDebugMacro( "Found VR: " << vr << " / Real VR: " << realVR ); 02051 02052 DocEntry *newEntry; 02053 if ( Global::GetVR()->IsVROfSequence(realVR) ) 02054 newEntry = NewSeqEntry(CurrentGroup, CurrentElem); 02055 else 02056 { 02057 newEntry = NewDataEntry(CurrentGroup, CurrentElem, realVR); 02058 static_cast<DataEntry *>(newEntry)->SetState(DataEntry::STATE_NOTLOADED); 02059 } 02060 02061 if ( vr == GDCM_VRUNKNOWN ) 02062 { 02063 if ( Filetype == ExplicitVR ) 02064 { 02065 // We thought this was explicit VR, but we end up with an 02066 // implicit VR tag. Let's backtrack. 02067 if ( newEntry->GetGroup() != 0xfffe ) 02068 { 02069 std::string msg; 02070 int offset = Fp->tellg(); 02071 msg = Util::Format( 02072 "Entry (%04x,%04x) at x(%x) should be Explicit VR\n", 02073 newEntry->GetGroup(), newEntry->GetElement(), offset ); 02074 gdcmWarningMacro( msg.c_str() ); 02075 } 02076 } 02077 newEntry->SetImplicitVR(); 02078 } 02079 02080 try 02081 { 02082 FindDocEntryLength(newEntry); 02083 } 02084 catch ( FormatError ) 02085 { 02086 // Call it quits 02087 newEntry->Delete(); 02088 return 0; 02089 } 02090 02091 newEntry->SetOffset(Fp->tellg()); 02092 02093 return newEntry; 02094 }
|
|
Register the object.
Definition at line 44 of file gdcmRefCounter.h. Referenced by gdcm::SQItem::AddEntry(), gdcm::ElementSet::AddEntry(), gdcm::Dict::AddEntry(), gdcm::SeqEntry::AddSQItem(), gdcm::SeqEntry::Copy(), gdcm::DicomDir::Copy(), gdcm::DocEntry::DocEntry(), gdcm::FileHelper::FileHelper(), gdcm::DocEntrySet::GetDictEntry(), gdcm::CommandManager::InSetCommand(), gdcm::DocEntryArchive::Push(), gdcm::Dict::ReplaceEntry(), and gdcm::SeqEntry::SetDelimitationItem(). 00044 { RefCount++; }
|
|
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 191 of file gdcmDocEntrySet.cxx. References gdcm::DataEntry::SetBinArea(), and gdcm::DocEntry::SetLength(). 00192 { 00193 if (entry) 00194 { 00195 entry->SetLength(lgth); 00196 entry->SetBinArea(content); 00197 return true; 00198 } 00199 return false; 00200 }
|
|
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 154 of file gdcmDocEntrySet.cxx. References gdcmWarningMacro, and gdcm::DocEntrySet::GetDataEntry(). Referenced by gdcm::DocEntrySet::InsertEntryBinArea(), and gdcm::FileHelper::SetEntryBinArea(). 00156 { 00157 DataEntry *entry = GetDataEntry(group, elem); 00158 if (!entry ) 00159 { 00160 gdcmWarningMacro( "No corresponding DataEntry " << std::hex << group << 00161 "," << elem << " element (try promotion first)."); 00162 return false; 00163 } 00164 00165 return SetEntryBinArea(content,lgth,entry); 00166 }
|
|
Accesses an existing DocEntry (i.e. a Dicom Element) and modifies it's content with the given value.
Definition at line 174 of file gdcmDocEntrySet.cxx. References gdcm::DataEntry::SetString(). 00175 { 00176 if (entry) 00177 { 00178 entry->SetString(content); 00179 return true; 00180 } 00181 return false; 00182 }
|
|
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 132 of file gdcmDocEntrySet.cxx. References gdcmWarningMacro, and gdcm::DocEntrySet::GetDataEntry(). Referenced by gdcm::File::AnonymizeFile(), DoTheLoadingDocumentJob(), gdcm::DocEntrySet::InsertEntryString(), and gdcm::FileHelper::SetEntryString(). 00134 { 00135 DataEntry *entry = GetDataEntry(group, elem); 00136 if (!entry ) 00137 { 00138 gdcmWarningMacro( "No corresponding DataEntry " << std::hex << group << 00139 "," << elem << " element (try promotion first)."); 00140 return false; 00141 } 00142 return SetEntryString(content,entry); 00143 }
|
|
Accessor to Filename.
Reimplemented in gdcm::DicomDir. Definition at line 79 of file gdcmDocument.h. Referenced by gdcm::SerieHelper::AddFileName(), gdcm::DicomDir::CreateDicomDirChainedList(), Document(), vtkGdcmReader::LoadFileInformation(), and gdcm::FileHelper::SetFileName(). 00080 { if (Filename != fileName) 00081 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 106 of file gdcmDocument.h. Referenced by gdcm::SerieHelper::AddFileName(), gdcm::DicomDir::CreateDicomDirChainedList(), vtkGdcmReader::LoadFileInformation(), and gdcm::FileHelper::SetLoadMode(). 00106 { if (LoadMode != mode) 00107 LoadMode=mode, IsDocumentModified = true; }
|
|
during parsing, Header Elements too long are not loaded in memory
Definition at line 1981 of file gdcmDocument.cxx. References MaxSizeLoadEntry. Referenced by Document(). 01982 { 01983 if ( newSize < 0 ) 01984 { 01985 return; 01986 } 01987 if ((uint32_t)newSize >= (uint32_t)0xffffffff ) 01988 { 01989 MaxSizeLoadEntry = 0xffffffff; 01990 return; 01991 } 01992 MaxSizeLoadEntry = newSize; 01993 }
|
|
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 316 of file gdcmDocument.cxx. References gdcm::DictSet::GetDict(), gdcm::Global::GetDicts(), and RefShaDict. 00317 { 00318 RefShaDict = Global::GetDicts()->GetDict(dictName); 00319 return !RefShaDict; 00320 }
|
|
Set the shadow dictionary used.
Definition at line 306 of file gdcmDocument.cxx. References RefShaDict. 00307 { 00308 RefShaDict = dict; 00309 return !RefShaDict; 00310 }
|
|
skips bytes inside the source file
Definition at line 936 of file gdcmDocument.cxx. References Fp. Referenced by gdcm::File::ComputeJPEGFragmentInfo(), gdcm::File::ComputeRLEInfo(), FindDocEntryLengthOBOrOW(), and SkipDocEntry(). 00937 { 00938 //FIXME don't dump the returned value 00939 Fp->seekg((long)nBytes, std::ios::cur); 00940 }
|
|
Skip a given Header Entry.
Definition at line 1601 of file gdcmDocument.cxx. References gdcm::DocEntry::GetLength(), and SkipBytes(). 01602 { 01603 SkipBytes(entry->GetLength()); 01604 }
|
|
Skips to the beginning of the next Header Entry.
Definition at line 1610 of file gdcmDocument.cxx. References Fp, gdcm::DocEntry::GetGroup(), gdcm::DocEntry::GetOffset(), and gdcm::DocEntry::GetReadLength(). Referenced by ParseDES(). 01611 { 01612 int l = currentDocEntry->GetReadLength(); 01613 if ( l == -1 ) // length = 0xffff shouldn't appear here ... 01614 // ... but PMS imagers happen ! 01615 return; 01616 Fp->seekg((long)(currentDocEntry->GetOffset()), std::ios::beg); 01617 if (currentDocEntry->GetGroup() != 0xfffe) // for fffe pb 01618 { 01619 Fp->seekg( (long)(currentDocEntry->GetReadLength()),std::ios::cur); 01620 } 01621 }
|
|
Swaps back the bytes of 8-byte long 'double' accordingly to processor order.
Definition at line 523 of file gdcmDocument.cxx. References gdcmErrorMacro, and SwapCode. Referenced by LoadEntryBinArea(). 00524 { 00525 switch (SwapCode) 00526 { 00527 // There were no 'double' at ACR-NEMA time. 00528 // We just have to deal with 'straight Little Endian' and 00529 // 'straight Big Endian' 00530 case 1234 : 00531 break; 00532 case 4321 : 00533 { 00534 char *beg = (char *)&a; 00535 char *end = beg + 7; 00536 char t; 00537 for (unsigned int i = 0; i<7; i++) 00538 { 00539 t = *beg; 00540 *beg = *end; 00541 *end = t; 00542 beg++, 00543 end--; 00544 } 00545 } 00546 break; 00547 default : 00548 gdcmErrorMacro( "Unexpected swap code:" << SwapCode ); 00549 a = 0.; 00550 } 00551 return a; 00552 }
|
|
Swaps back the bytes of 4-byte long integer accordingly to processor order.
Definition at line 491 of file gdcmDocument.cxx. References gdcmErrorMacro, and SwapCode. Referenced by LoadEntryBinArea(), and ReadInt32(). 00492 { 00493 switch (SwapCode) 00494 { 00495 case 1234 : 00496 break; 00497 case 4321 : 00498 // a=( ((a<<24) & 0xff000000) | ((a<<8) & 0x00ff0000) | 00499 // ((a>>8) & 0x0000ff00) | ((a>>24) & 0x000000ff) ); 00500 // save CPU time 00501 a=( ( a<<24) | ((a<<8) & 0x00ff0000) | 00502 ((a>>8) & 0x0000ff00) | (a>>24) ); 00503 break; 00504 case 3412 : 00505 // a=( ((a<<16) & 0xffff0000) | ((a>>16) & 0x0000ffff) ); 00506 a=( (a<<16) | (a>>16) ); 00507 break; 00508 case 2143 : 00509 a=( ((a<< 8) & 0xff00ff00) | ((a>>8) & 0x00ff00ff) ); 00510 break; 00511 default : 00512 gdcmErrorMacro( "Unexpected swap code:" << SwapCode ); 00513 a = 0; 00514 } 00515 return a; 00516 }
|
|
Swaps the bytes so they agree with the processor order.
Definition at line 475 of file gdcmDocument.cxx. References SwapCode. Referenced by HandleOutOfGroup0002(), LoadEntryBinArea(), and ReadInt16(). 00476 { 00477 if ( SwapCode == 4321 || SwapCode == 2143 ) 00478 { 00479 //a = ((( a << 8 ) & 0xff00 ) | (( a >> 8 ) & 0x00ff ) ); 00480 // Save CPU time 00481 a = ( a << 8 ) | ( a >> 8 ); 00482 } 00483 return a; 00484 }
|
|
Change the Byte Swap code.
Definition at line 1954 of file gdcmDocument.cxx. References Fp, gdcmDebugMacro, and SwapCode. Referenced by HandleBrokenEndian(), and HandleOutOfGroup0002(). 01955 { 01956 gdcmDebugMacro( "Switching Byte Swap code from "<< SwapCode 01957 << " at: 0x" << std::hex << Fp->tellg() ); 01958 if ( SwapCode == 1234 ) 01959 { 01960 SwapCode = 4321; 01961 } 01962 else if ( SwapCode == 4321 ) 01963 { 01964 SwapCode = 1234; 01965 } 01966 else if ( SwapCode == 3412 ) 01967 { 01968 SwapCode = 2143; 01969 } 01970 else if ( SwapCode == 2143 ) 01971 { 01972 SwapCode = 3412; 01973 } 01974 gdcmDebugMacro( " Into: "<< SwapCode ); 01975 }
|
|
Unregister the object.
Definition at line 48 of file gdcmRefCounter.h. Referenced by gdcm::SeqEntry::ClearSQItem(), gdcm::DicomDir::Copy(), gdcm::DocEntrySet::GetDictEntry(), gdcm::CommandManager::InSetCommand(), 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 196 of file gdcmDocument.h. 00196 { return SwapLong(a);}
|
|
Unswaps back the bytes of 2-bytes long integer so they agree with the processor order.
Definition at line 193 of file gdcmDocument.h. 00193 { return SwapShort(a);}
|
|
Writes in a file all the Entries (Dicom Elements).
Reimplemented from gdcm::ElementSet. Definition at line 664 of file gdcmDocument.cxx. References gdcm::ExplicitVR, gdcm::ImplicitVR, gdcm::JPEG, and gdcm::ElementSet::WriteContent(). Referenced by gdcm::File::Write(). 00665 { 00666 // Skip if user wants to write an ACR-NEMA file 00667 00668 if ( filetype == ImplicitVR || filetype == ExplicitVR || 00669 filetype == JPEG ) 00670 { 00671 // writing Dicom File Preamble 00672 char filePreamble[128]; 00673 memset(filePreamble, 0, 128); 00674 fp->write(filePreamble, 128); 00675 fp->write("DICM", 4); 00676 } 00677 00678 /* 00679 * \todo rewrite later, if really usefull 00680 * - 'Group Length' element is optional in DICOM 00681 * - but un-updated odd groups lengthes can causes pb 00682 * (xmedcon breaker) 00683 * 00684 * if ( (filetype == ImplicitVR) || (filetype == ExplicitVR) ) 00685 * UpdateGroupLength(false,filetype); 00686 * if ( filetype == ACR) 00687 * UpdateGroupLength(true,ACR); 00688 * 00689 * --> Computing group length for groups with embeded Sequences 00690 * --> was too much tricky / we were [in a hurry / too lazy] 00691 * --> We don't write the element 0x0000 (group length) 00692 */ 00693 00694 ElementSet::WriteContent(fp, filetype); // This one is recursive 00695 }
|
|
Definition at line 229 of file gdcmDocument.h. Referenced by CallStartMethod(), gdcm::DicomDir::CreateDicomDirChainedList(), gdcm::DicomDir::DoTheLoadingJob(), and gdcm::DicomDir::Initialize(). |
|
to allow any inner method to know current tag Element number
Definition at line 246 of file gdcmDocument.h. Referenced by ReadNextDocEntry(). |
|
to allow any inner method to know current tag Group number
Definition at line 244 of file gdcmDocument.h. Referenced by FindDocEntryVR(), and ReadNextDocEntry(). |
|
Refering underlying filename.
Definition at line 128 of file gdcmDocument.h. Referenced by gdcm::File::AnonymizeNoLoad(), DoTheLoadingDocumentJob(), and OpenFile(). |
|
ACR, ACR_LIBIDO, ExplicitVR, ImplicitVR, Unknown.
Definition at line 154 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 151 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 145 of file gdcmDocument.h. Referenced by Document(), DoTheLoadingDocumentJob(), and HandleOutOfGroup0002(). |
|
whether file has a DCM Preamble
Definition at line 148 of file gdcmDocument.h. Referenced by OpenFile(), and ReadNextDocEntry(). |
|
After opening the file, we read HEADER_LENGTH_TO_READ bytes.
Definition at line 157 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 177 of file gdcmDocument.h. Referenced by Document(), and DoTheLoadingDocumentJob(). |
|
Whether the gdcm::Document was modified since the last Load().
Definition at line 180 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 172 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 160 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 241 of file gdcmDocument.h. Referenced by LoadDocEntry(), and SetMaxSizeLoadEntry(). |
|
To be able to backtrack (Private Sequence, Implicit VR related pb).
Definition at line 127 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(). |
|
value of the ??? for any progress bar
Definition at line 228 of file gdcmDocument.h. Referenced by CallEndMethod(), CallStartMethod(), gdcm::DicomDir::CreateDicomDirChainedList(), gdcm::DicomDir::DoTheLoadingJob(), and gdcm::DicomDir::Initialize(). |
|
Public dictionary used to parse this header.
Definition at line 232 of file gdcmDocument.h. Referenced by GetPubDict(), and Initialize(). |
|
Optional "shadow dictionary" (private elements) used to parse this header.
Definition at line 235 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 142 of file gdcmDocument.h. Referenced by CheckSwap(), Document(), SwapDouble(), SwapLong(), SwapShort(), and SwitchByteSwapCode(). |
|
User supplied list of elements to Anonymize.
Definition at line 163 of file gdcmDocument.h. Referenced by gdcm::File::AddAnonymizeElement(), gdcm::File::AnonymizeFile(), and gdcm::File::AnonymizeNoLoad(). |
|
User supplied list of elements to force Load.
Definition at line 166 of file gdcmDocument.h. Referenced by AddForceLoadElement(), and DoTheLoadingDocumentJob(). |