#include <gdcmFile.h>
Inheritance diagram for gdcm::File:
Public Types | |
typedef std::list< DicomElement > | ListElements |
Public Member Functions | |
GDCM_LEGACY (bool Load(std::string const &filename)) | |
bool | Load () |
Loader. | |
bool | IsReadable () |
This predicate, based on hopefully reasonable heuristics, decides whether or not the current File was properly parsed and contains the mandatory information for being considered as a well formed and usable Dicom/Acr File. | |
int | GetImageNumber () |
gets the info from 0020,0013 : Image Number else 0. | |
ModalityType | GetModality () |
gets the info from 0008,0060 : Modality | |
int | GetXSize () |
Retrieve the number of columns of image. | |
int | GetYSize () |
Retrieve the number of lines of image. | |
int | GetZSize () |
Retrieve the number of planes of volume or the number of frames of a multiframe. | |
float | GetXSpacing () |
gets the info from 0018,1164 : ImagerPixelSpacing then 0028,0030 : Pixel Spacing else 1.0 | |
float | GetYSpacing () |
gets the info from 0018,1164 : ImagerPixelSpacing then from 0028,0030 : Pixel Spacing else 1.0 | |
float | GetZSpacing () |
gets the info from 0018,0088 : Space Between Slices else from 0018,0050 : Slice Thickness else 1.0 | |
float | GetXOrigin () |
gets the info from 0020,0032 : Image Position Patient else from 0020,0030 : Image Position (RET) else 0. | |
float | GetYOrigin () |
gets the info from 0020,0032 : Image Position Patient else from 0020,0030 : Image Position (RET) else 0. | |
float | GetZOrigin () |
gets the info from 0020,0032 : Image Position Patient else from 0020,0030 : Image Position (RET) else from 0020,1041 : Slice Location else from 0020,0050 : Location else 0. | |
bool | GetImageOrientationPatient (float iop[6]) |
gets the info from 0020,0037 : Image Orientation Patient or from 0020 0035 : Image Orientation (RET) (needed to organize DICOM files based on their x,y,z position) | |
int | GetBitsStored () |
Retrieve the number of Bits Stored (actually used) (as opposed to number of Bits Allocated). | |
int | GetBitsAllocated () |
Retrieve the number of Bits Allocated (8, 12 -compacted ACR-NEMA files-, 16, 24 -old RGB ACR-NEMA files-,). | |
int | GetHighBitPosition () |
Retrieve the high bit position. | |
int | GetSamplesPerPixel () |
Retrieve the number of Samples Per Pixel (1 : gray level, 3 : RGB/YBR -1 or 3 Planes-). | |
int | GetPlanarConfiguration () |
Retrieve the Planar Configuration for RGB images (0 : RGB Pixels , 1 : R Plane + G Plane + B Plane). | |
int | GetPixelSize () |
Return the size (in bytes) of a single pixel of data. | |
std::string | GetPixelType () |
Build the Pixel Type of the image. Possible values are:
| |
bool | IsSignedPixelData () |
Check whether the pixels are signed (1) or UNsigned (0) data. | |
bool | IsMonochrome () |
Check whether this a monochrome picture (gray levels) or not, using "Photometric Interpretation" tag (0x0028,0x0004). | |
bool | IsMonochrome1 () |
Check whether this a MONOCHROME1 picture (high values = dark) or not using "Photometric Interpretation" tag (0x0028,0x0004). | |
bool | IsPaletteColor () |
Check whether this a "PALETTE COLOR" picture or not by accessing the "Photometric Interpretation" tag ( 0x0028, 0x0004 ). | |
bool | IsYBRFull () |
Check whether this a "YBR_FULL" color picture or not by accessing the "Photometric Interpretation" tag ( 0x0028, 0x0004 ). | |
bool | HasLUT () |
tells us if LUT are used | |
int | GetLUTNbits () |
gets the info from 0028,1101 : Lookup Table Desc-Red else 0 | |
float | GetRescaleIntercept () |
gets the info from 0028,1052 : Rescale Intercept | |
float | GetRescaleSlope () |
gets the info from 0028,1053 : Rescale Slope | |
int | GetNumberOfScalarComponents () |
This function is intended to user who doesn't want to have to manage a LUT and expects to get an RBG Pixel image (or a monochrome one ...). | |
int | GetNumberOfScalarComponentsRaw () |
This function is intended to user that DOESN'T want to get RGB pixels image when it's stored as a PALETTE COLOR image
| |
uint16_t | GetGrPixel () |
Accessor to File::GrPixel. | |
uint16_t | GetNumPixel () |
Accessor to File::NumPixel. | |
size_t | GetPixelOffset () |
Recover the offset (from the beginning of the file) of *image* pixels (not *icone image* pixels, if any !). | |
size_t | GetPixelAreaLength () |
Recover the pixel area length (in Bytes). | |
RLEFramesInfo * | GetRLEInfo () |
returns the RLE info | |
JPEGFragmentsInfo * | GetJPEGInfo () |
Returns the JPEG Fragments info. | |
void | AddAnonymizeElement (uint16_t group, uint16_t elem, std::string const &value) |
Adds the characteristics of a new element we want to anonymize. | |
void | ClearAnonymizeList () |
Clears the list of elements to be anonymized. | |
void | AnonymizeNoLoad () |
Overwrites in the file the values of the DicomElements held in the list. | |
bool | AnonymizeFile () |
anonymize a File (remove Patient's personal info passed with AddAnonymizeElement() | |
bool | Write (std::string fileName, FileType filetype) |
Performs some consistency checking on various 'File related' (as opposed to 'DicomDir related') entries then writes in a file all the (Dicom Elements) included the Pixels. | |
virtual bool | Load (std::string const &filename) |
Loader. (DEPRECATED : not to break the API). | |
Dict * | GetPubDict () |
Get the public dictionary used. | |
Dict * | GetShaDict () |
Get the shadow dictionary used. | |
bool | SetShaDict (Dict *dict) |
Set the shadow dictionary used. | |
bool | SetShaDict (DictKey const &dictName) |
Set the shadow dictionary used. | |
bool | IsParsable () |
This predicate tells us whether or not the current Document was properly parsed and contains at least *one* Dicom Element (and nothing more, sorry). | |
bool | IsDicomV3 () |
Predicate for dicom version 3 file. | |
bool | IsPapyrus () |
Predicate for Papyrus file Dedicated to whomsoever it may concern. | |
FileType | GetFileType () |
returns the File Type (ACR, ACR_LIBIDO, ExplicitVR, ImplicitVR, Unknown) | |
std::string | GetTransferSyntax () |
Accessor to the Transfer Syntax (when present) of the current document (it internally handles reading the value from disk when only parsing occured). | |
std::string | GetTransferSyntaxName () |
Accesses the info from 0002,0010 : Transfer Syntax and TS. | |
int | GetSwapCode () |
'Swap code' accessor (see SwapCode ) | |
const std::string & | GetFileName () const |
Accessor to Filename. | |
virtual void | SetFileName (std::string const &fileName) |
Accessor to Filename. | |
std::ifstream * | OpenFile () |
Tries to open the file Document::Filename and checks the preamble when existing. | |
bool | CloseFile () |
closes the file | |
void | WriteContent (std::ofstream *fp, FileType type) |
Writes in a file all the Entries (Dicom Elements). | |
virtual void | LoadEntryBinArea (uint16_t group, uint16_t elem) |
Loads (from disk) the element content when a string is not suitable. | |
virtual void | LoadEntryBinArea (DataEntry *entry) |
Loads (from disk) the element content when a string is not suitable. | |
void | LoadDocEntrySafe (DocEntry *entry) |
Loads the element while preserving the current underlying file position indicator as opposed to LoadDocEntry that modifies it. | |
void | AddForceLoadElement (uint16_t group, uint16_t elem) |
Adds a new element we want to load anyway. | |
bool | operator< (Document &document) |
Compares two documents, according to DicomDir rules. | |
void | SetLoadMode (int mode) |
Sets the LoadMode as a boolean string. LD_NOSEQ, LD_NOSHADOW, LD_NOSHADOWSEQ ... (nothing more, right now) WARNING : before using NO_SHADOW, be sure *all* your files contain accurate values in the 0x0000 element (if any) of *each* Shadow Group. The parser will fail if the size is wrong ! | |
virtual void | Print (std::ostream &os=std::cout, std::string const &indent="") |
Prints the Header Entries (Dicom Elements) from the H Table. | |
bool | AddEntry (DocEntry *Entry) |
add a new Dicom Element pointer to the H Table | |
bool | RemoveEntry (DocEntry *EntryToRemove) |
Clear the hash table from given entry AND delete the entry. | |
void | ClearEntry () |
delete all entries in the ElementSet | |
DocEntry * | GetFirstEntry () |
Get the first entry while visiting *the* 'zero level' DocEntrySet (DocEntries out of any Sequence). | |
DocEntry * | GetNextEntry () |
Get the next entry while visiting *the* 'zero level' DocEntrySet (DocEntries out of any Sequence). | |
DocEntry * | GetDocEntry (uint16_t group, uint16_t elem) |
retrieves a Dicom Element using (group, element) | |
bool | IsEmpty () |
Tells us if the ElementSet contains no entry. | |
virtual std::string | GetEntryString (uint16_t group, uint16_t elem) |
Get the "std::string representable" value of the Dicom entry. | |
virtual void * | GetEntryBinArea (uint16_t group, uint16_t elem) |
Gets (from Header) a 'non string' element value. | |
virtual int | GetEntryLength (uint16_t group, uint16_t elem) |
Searches within Header Entries (Dicom Elements) parsed with the public and private dictionaries for the value length of a given tag.. | |
virtual std::string | GetEntryForcedAsciiValue (uint16_t group, uint16_t elem) |
Return the value of the DataEntry if it's "std::string representable". | |
DataEntry * | GetDataEntry (uint16_t group, uint16_t elem) |
Same as Document::GetDocEntry except it only returns a result when the corresponding entry is of type DataEntry. | |
SeqEntry * | GetSeqEntry (uint16_t group, uint16_t elem) |
Same as Document::GetDocEntry except it only returns a result when the corresponding entry is of type SeqEntry. | |
bool | SetEntryString (std::string const &content, uint16_t group, uint16_t elem) |
Accesses an existing DocEntry (i.e. a Dicom Element) through it's (group, element) and modifies it's content with the given value. | |
bool | SetEntryString (std::string const &content, DataEntry *entry) |
Accesses an existing DocEntry (i.e. a Dicom Element) and modifies it's content with the given value. | |
bool | SetEntryBinArea (uint8_t *content, int lgth, uint16_t group, uint16_t elem) |
Accesses an existing DocEntry (i.e. a Dicom Element) through it's (group, element) and modifies it's content with the given value. | |
bool | SetEntryBinArea (uint8_t *content, int lgth, DataEntry *entry) |
Accesses an existing DataEntry (i.e. a Dicom Element) and modifies it's content with the given value. | |
DataEntry * | InsertEntryString (std::string const &value, uint16_t group, uint16_t elem, VRKey const &vr=GDCM_VRUNKNOWN) |
Modifies the value of a given Doc Entry (Dicom Element) when it exists. Create it with the given value when unexistant. | |
DataEntry * | InsertEntryBinArea (uint8_t *binArea, int lgth, uint16_t group, uint16_t elem, VRKey const &vr=GDCM_VRUNKNOWN) |
Modifies the value of a given Header Entry (Dicom Element) when it exists. Create it with the given value when unexistant. A copy of the binArea is made to be kept in the Document. | |
SeqEntry * | InsertSeqEntry (uint16_t group, uint16_t elem) |
Modifies the value of a given Doc Entry (Dicom Element) when it exists. Creates it when unexistant. | |
virtual bool | CheckIfEntryExist (uint16_t group, uint16_t elem) |
Checks if a given Dicom Element exists within the H table. | |
DataEntry * | NewDataEntry (uint16_t group, uint16_t elem, VRKey const &vr=GDCM_VRUNKNOWN) |
Build a new Val Entry from all the low level arguments. Check for existence of dictionary entry, and build a default one when absent. | |
SeqEntry * | NewSeqEntry (uint16_t group, uint16_t elem) |
Build a new Seq Entry from all the low level arguments. Check for existence of dictionary entry, and build a default one when absent. | |
void | Delete () |
Delete the object. | |
void | Register () |
Register the object. | |
void | Unregister () |
Unregister the object. | |
const unsigned long & | GetRefCount () const |
Get the reference counting. | |
void | SetPrintLevel (int level) |
Sets the print level for the Dicom Header Elements. | |
int | GetPrintLevel () |
Gets the print level for the Dicom Entries. | |
Static Public Member Functions | |
static File * | New () |
Protected Member Functions | |
File () | |
Constructor used when we want to generate dicom files from scratch. | |
~File () | |
Canonical destructor. | |
bool | MayIWrite (uint16_t group) |
Protect the Writer from writing illegal groups. | |
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. | |
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 | |
RLEFramesInfo * | RLEInfo |
Store the RLE frames info obtained during parsing of pixels. | |
JPEGFragmentsInfo * | JPEGInfo |
Store the JPEG fragments info obtained during parsing of pixels. | |
uint16_t | NumPixel |
In some cases (e.g. for some ACR-NEMA images) the Entry Element Number of the 'Pixel Element' is *not* found at 0x0010. In order to make things easier the parser shall store the proper value in NumPixel to provide a unique access facility. | |
uint16_t | GrPixel |
In some cases (e.g. for some ACR-NEMA images) the header entry for the group of pixels is *not* found at 0x7fe0. In order to make things easier the parser shall store the proper value in GrPixel to provide a unique access facility. | |
std::string | Filename |
Refering underlying filename. | |
int | SwapCode |
Swap code gives an information on the byte order of a supposed to be an int32, as it's read on disc (depending on the image Transfer Syntax *and* on the processor endianess) as opposed as it should in memory to be dealt as an int32. For instance :
| |
bool | Group0002Parsed |
whether we already parsed group 0002 (Meta Elements) | |
bool | HasDCMPreamble |
whether file has a DCM Preamble | |
std::ifstream * | Fp |
File Pointer, opened during Document parsing. | |
FileType | Filetype |
ACR, ACR_LIBIDO, ExplicitVR, ImplicitVR, Unknown. | |
ListElements | UserAnonymizeList |
User supplied list of elements to Anonymize. | |
ListElements | UserForceLoadList |
User supplied list of elements to force Load. | |
int | LoadMode |
Bit string integer (each one considered as a boolean) Bit 0 : Skip Sequences, if possible Bit 1 : Skip Shadow Groups if possible Probabely, some more to add. | |
bool | IsDocumentAlreadyLoaded |
Whether the gdcm::Document is already parsed/loaded : False from the creation of the gdcm::Document untill gdcm::Document:Load(). | |
bool | IsDocumentModified |
Whether the gdcm::Document was modified since the last Load(). | |
DocEntry * | PreviousDocEntry |
To be able to backtrack (Private Sequence, Implicit VR related pb). | |
int | PrintLevel |
Amount of printed details for each Dicom Entries : 0 : stands for the least detail level. | |
Static Protected Attributes | |
static const unsigned int | HEADER_LENGTH_TO_READ |
After opening the file, we read HEADER_LENGTH_TO_READ bytes. | |
static const unsigned int | MAX_SIZE_LOAD_ELEMENT_VALUE = 0xfff |
Elements whose value is longer than MAX_SIZE_LOAD_ELEMENT_VALUE are NOT loaded. | |
Private Member Functions | |
gdcmTypeMacro (File) | |
bool | DoTheLoadingJob () |
Does the Loading Job (internal use only). | |
void | ComputeRLEInfo () |
Parse pixel data from disk of [multi-]fragment RLE encoding. Compute the RLE extra information and store it in RLEInfo for later pixel retrieval usage. | |
void | ComputeJPEGFragmentInfo () |
Parse pixel data from disk of [multi-]fragment Jpeg encoding. Compute the jpeg extra information (fragment[s] offset[s] and length) and store it[them] in JPEGInfo for later pixel retrieval usage. | |
bool | ReadTag (uint16_t, uint16_t) |
Assuming the internal file pointer Document::Fp is placed at the beginning of a tag, check whether this tag is (TestGroup, TestElem). | |
uint32_t | ReadTagLength (uint16_t, uint16_t) |
Assuming the internal file pointer Document::Fp is placed at the beginning of a tag (TestGroup, TestElement), read the length associated to the Tag. | |
void | ReadEncapsulatedBasicOffsetTable () |
When parsing the Pixel Data of an encapsulated file, read the basic offset table (when present, and BTW dump it). | |
Private Attributes | |
uint32_t * | BasicOffsetTableItemValue |
The typical usage of instances of class File is to classify a set of dicom files according to header information e.g. to create a file hierarchy reflecting the Patient/Study/Serie informations, or extracting a given SerieId. Accessing the content (image[s] or volume[s]) is beyond the functionality of this class and belongs to gdcm::FileHelper.
The File::Set*Tag* family members cannot be defined as protected due to Swig limitations for as Has_a dependency between File and FileHelper.
Definition at line 99 of file gdcmFile.h.
|
Definition at line 45 of file gdcmDocument.h. |
|
Constructor used when we want to generate dicom files from scratch.
Definition at line 113 of file gdcmFile.cxx. References BasicOffsetTableItemValue, GrPixel, JPEGInfo, NumPixel, and RLEInfo. 00113 : 00114 Document() 00115 { 00116 RLEInfo = new RLEFramesInfo; 00117 JPEGInfo = new JPEGFragmentsInfo; 00118 GrPixel = 0x7fe0; // to avoid further troubles 00119 NumPixel = 0x0010; 00120 BasicOffsetTableItemValue = 0; 00121 }
|
|
Canonical destructor.
Definition at line 127 of file gdcmFile.cxx. References BasicOffsetTableItemValue, JPEGInfo, and RLEInfo. 00128 { 00129 if ( RLEInfo ) 00130 delete RLEInfo; 00131 if ( JPEGInfo ) 00132 delete JPEGInfo; 00133 delete[] BasicOffsetTableItemValue; 00134 }
|
|
Adds the characteristics of a new element we want to anonymize.
Definition at line 1291 of file gdcmFile.cxx. References gdcm::DicomElement::Elem, gdcm::DicomElement::Group, gdcm::Document::UserAnonymizeList, and gdcm::DicomElement::Value. 01293 { 01294 DicomElement el; 01295 el.Group = group; 01296 el.Elem = elem; 01297 el.Value = value; 01298 UserAnonymizeList.push_back(el); 01299 }
|
|
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 DoTheLoadingJob(), gdcm::DocEntryArchive::Push(), and gdcm::DocEntryArchive::Restore(). 00079 { 00080 const TagKey &key = newEntry->GetKey(); 00081 00082 if ( TagHT.count(key) == 1 ) 00083 { 00084 gdcmWarningMacro( "Key already present: " << key ); 00085 return false; 00086 } 00087 else 00088 { 00089 TagHT.insert(TagDocEntryHT::value_type(newEntry->GetKey(), newEntry)); 00090 newEntry->Register(); 00091 return true; 00092 } 00093 }
|
|
Adds a new element we want to load anyway.
Definition at line 290 of file gdcmDocument.cxx. References gdcm::DicomElement::Elem, gdcm::DicomElement::Group, and gdcm::Document::UserForceLoadList. 00291 { 00292 DicomElement el; 00293 el.Group = group; 00294 el.Elem = elem; 00295 UserForceLoadList.push_back(el); 00296 }
|
|
anonymize a File (remove Patient's personal info passed with AddAnonymizeElement()
Definition at line 1350 of file gdcmFile.cxx. References gdcm::GDCM_UNFOUND, gdcmWarningMacro, gdcm::ElementSet::GetDocEntry(), gdcm::DocEntrySet::GetEntryString(), gdcm::DocEntrySet::SetEntryString(), and gdcm::Document::UserAnonymizeList. 01351 { 01352 // If Anonymisation list is empty, let's perform some basic anonymization 01353 if ( UserAnonymizeList.begin() == UserAnonymizeList.end() ) 01354 { 01355 // If exist, replace by spaces 01356 SetEntryString(" ",0x0010, 0x2154); // Telephone 01357 SetEntryString(" ",0x0010, 0x1040); // Adress 01358 SetEntryString(" ",0x0010, 0x0020); // Patient ID 01359 01360 DocEntry *patientNameHE = GetDocEntry (0x0010, 0x0010); 01361 01362 if ( patientNameHE ) // we replace it by Study Instance UID (why not ?) 01363 { 01364 std::string studyInstanceUID = GetEntryString (0x0020, 0x000d); 01365 if ( studyInstanceUID != GDCM_UNFOUND ) 01366 { 01367 SetEntryString(studyInstanceUID, 0x0010, 0x0010); 01368 } 01369 else 01370 { 01371 SetEntryString("anonymized", 0x0010, 0x0010); 01372 } 01373 } 01374 } 01375 else 01376 { 01377 gdcm::DocEntry *d; 01378 for (ListElements::iterator it = UserAnonymizeList.begin(); 01379 it != UserAnonymizeList.end(); 01380 ++it) 01381 { 01382 d = GetDocEntry( (*it).Group, (*it).Elem); 01383 01384 if ( d == NULL) 01385 continue; 01386 01387 if ( dynamic_cast<SeqEntry *>(d) ) 01388 { 01389 gdcmWarningMacro( "You cannot 'Anonymize' a SeqEntry "); 01390 continue; 01391 } 01392 01393 if ( dynamic_cast<DataEntry *>(d) ) 01394 { 01395 gdcmWarningMacro( "To 'Anonymize' a DataEntry, better use AnonymizeNoLoad (FIXME) "); 01396 continue; 01397 } 01398 else 01399 SetEntryString ((*it).Value, (*it).Group, (*it).Elem); 01400 } 01401 } 01402 01403 // In order to make definitively impossible any further identification 01404 // remove or replace all the stuff that contains a Date 01405 01406 //0008 0012 DA ID Instance Creation Date 01407 //0008 0020 DA ID Study Date 01408 //0008 0021 DA ID Series Date 01409 //0008 0022 DA ID Acquisition Date 01410 //0008 0023 DA ID Content Date 01411 //0008 0024 DA ID Overlay Date 01412 //0008 0025 DA ID Curve Date 01413 //0008 002a DT ID Acquisition Datetime 01414 //0018 9074 DT ACQ Frame Acquisition Datetime 01415 //0018 9151 DT ACQ Frame Reference Datetime 01416 //0018 a002 DT ACQ Contribution Date Time 01417 //0020 3403 SH REL Modified Image Date (RET) 01418 //0032 0032 DA SDY Study Verified Date 01419 //0032 0034 DA SDY Study Read Date 01420 //0032 1000 DA SDY Scheduled Study Start Date 01421 //0032 1010 DA SDY Scheduled Study Stop Date 01422 //0032 1040 DA SDY Study Arrival Date 01423 //0032 1050 DA SDY Study Completion Date 01424 //0038 001a DA VIS Scheduled Admission Date 01425 //0038 001c DA VIS Scheduled Discharge Date 01426 //0038 0020 DA VIS Admitting Date 01427 //0038 0030 DA VIS Discharge Date 01428 //0040 0002 DA PRC Scheduled Procedure Step Start Date 01429 //0040 0004 DA PRC Scheduled Procedure Step End Date 01430 //0040 0244 DA PRC Performed Procedure Step Start Date 01431 //0040 0250 DA PRC Performed Procedure Step End Date 01432 //0040 2004 DA PRC Issue Date of Imaging Service Request 01433 //0040 4005 DT PRC Scheduled Procedure Step Start Date and Time 01434 //0040 4011 DT PRC Expected Completion Date and Time 01435 //0040 a030 DT PRC Verification Date Time 01436 //0040 a032 DT PRC Observation Date Time 01437 //0040 a120 DT PRC DateTime 01438 //0040 a121 DA PRC Date 01439 //0040 a13a DT PRC Referenced Datetime 01440 //0070 0082 DA ??? Presentation Creation Date 01441 //0100 0420 DT ??? SOP Autorization Date and Time 01442 //0400 0105 DT ??? Digital Signature DateTime 01443 //2100 0040 DA PJ Creation Date 01444 //3006 0008 DA SSET Structure Set Date 01445 //3008 0024 DA ??? Treatment Control Point Date 01446 //3008 0054 DA ??? First Treatment Date 01447 //3008 0056 DA ??? Most Recent Treatment Date 01448 //3008 0162 DA ??? Safe Position Exit Date 01449 //3008 0166 DA ??? Safe Position Return Date 01450 //3008 0250 DA ??? Treatment Date 01451 //300a 0006 DA RT RT Plan Date 01452 //300a 022c DA RT Air Kerma Rate Reference Date 01453 //300e 0004 DA RT Review Date 01454 01455 return true; 01456 }
|
|
Overwrites in the file the values of the DicomElements held in the list.
Definition at line 1305 of file gdcmFile.cxx. References gdcm::Document::Filename, gdcmWarningMacro, gdcm::ElementSet::GetDocEntry(), and gdcm::Document::UserAnonymizeList. 01306 { 01307 std::fstream *fp = new std::fstream(Filename.c_str(), 01308 std::ios::in | std::ios::out | std::ios::binary); 01309 gdcm::DocEntry *d; 01310 uint32_t offset; 01311 uint32_t lgth; 01312 uint32_t valLgth = 0; 01313 std::string *spaces; 01314 for (ListElements::iterator it = UserAnonymizeList.begin(); 01315 it != UserAnonymizeList.end(); 01316 ++it) 01317 { 01318 d = GetDocEntry( (*it).Group, (*it).Elem); 01319 01320 if ( d == NULL) 01321 continue; 01322 01323 if ( dynamic_cast<SeqEntry *>(d) ) 01324 { 01325 gdcmWarningMacro( "You cannot 'Anonymize' a SeqEntry "); 01326 continue; 01327 } 01328 01329 offset = d->GetOffset(); 01330 lgth = d->GetLength(); 01331 if (valLgth < lgth) 01332 { 01333 spaces = new std::string( lgth-valLgth, ' '); 01334 (*it).Value = (*it).Value + *spaces; 01335 delete spaces; 01336 } 01337 fp->seekp( offset, std::ios::beg ); 01338 fp->write( (*it).Value.c_str(), lgth ); 01339 01340 } 01341 fp->close(); 01342 delete fp; 01343 }
|
|
Checks if a given Dicom Element exists within the H table.
Definition at line 430 of file gdcmDocEntrySet.cxx. References gdcm::DocEntrySet::GetDocEntry(). 00431 { 00432 return GetDocEntry(group,elem)!=NULL; 00433 }
|
|
Clears the list of elements to be anonymized.
Definition at line 170 of file gdcmFile.h. 00170 { UserAnonymizeList.clear(); }
|
|
delete all entries in the ElementSet
Implements gdcm::DocEntrySet. Definition at line 116 of file gdcmElementSet.cxx. References gdcm::ElementSet::TagHT. Referenced by gdcm::DicomDir::CreateDicomDir(), gdcm::Document::DoTheLoadingDocumentJob(), gdcm::DicomDir::SetElements(), and gdcm::ElementSet::~ElementSet(). 00117 { 00118 for(TagDocEntryHT::iterator cc = TagHT.begin();cc != TagHT.end(); ++cc) 00119 { 00120 if ( cc->second ) 00121 { 00122 cc->second->Unregister(); 00123 } 00124 } 00125 TagHT.clear(); 00126 }
|
|
closes the file
Definition at line 658 of file gdcmDocument.cxx. References gdcm::Document::Fp. Referenced by gdcm::Document::DoTheLoadingDocumentJob(), DoTheLoadingJob(), gdcm::FileHelper::GetRaw(), gdcm::Document::LoadEntryBinArea(), gdcm::Document::OpenFile(), and gdcm::Document::~Document(). 00659 { 00660 if ( Fp ) 00661 { 00662 Fp->close(); 00663 delete Fp; 00664 Fp = 0; 00665 } 00666 return true; 00667 }
|
|
Re-computes the length of the Dicom group 0002.
Definition at line 956 of file gdcmDocument.cxx. References gdcm::DocEntry::GetElement(), gdcm::ElementSet::GetFirstEntry(), gdcm::DocEntry::GetGroup(), gdcm::DocEntry::GetLength(), gdcm::ElementSet::GetNextEntry(), and gdcm::DocEntry::GetVR(). Referenced by Write(). 00957 { 00958 uint16_t gr; 00959 VRKey vr; 00960 00961 int groupLength = 0; 00962 bool found0002 = false; 00963 00964 // for each zero-level Tag in the DCM Header 00965 DocEntry *entry = GetFirstEntry(); 00966 while( entry ) 00967 { 00968 gr = entry->GetGroup(); 00969 00970 if ( gr == 0x0002 ) 00971 { 00972 found0002 = true; 00973 00974 if ( entry->GetElement() != 0x0000 ) 00975 { 00976 vr = entry->GetVR(); 00977 00978 //if ( (vr == "OB")||(vr == "OW")||(vr == "UT")||(vr == "SQ")) 00979 // (no SQ, OW, UT in group 0x0002;) 00980 if ( vr == "OB" ) 00981 { 00982 // explicit VR AND (OB, OW, SQ, UT) : 4 more bytes 00983 groupLength += 4; 00984 } 00985 00986 groupLength += 2 + 2 + 4 + entry->GetLength(); 00987 } 00988 } 00989 else if (found0002 ) 00990 break; 00991 00992 entry = GetNextEntry(); 00993 } 00994 return groupLength; 00995 }
|
|
Parse pixel data from disk of [multi-]fragment Jpeg encoding. Compute the jpeg extra information (fragment[s] offset[s] and length) and store it[them] in JPEGInfo for later pixel retrieval usage.
Definition at line 1628 of file gdcmFile.cxx. References gdcm::JPEGFragmentsInfo::AddFragment(), BasicOffsetTableItemValue, gdcm::Document::Fp, gdcmWarningMacro, gdcm::Document::GetTransferSyntax(), gdcm::Global::GetTS(), JPEGInfo, ReadEncapsulatedBasicOffsetTable(), ReadTag(), ReadTagLength(), gdcm::JPEGFragment::SetLength(), gdcm::JPEGFragment::SetOffset(), and gdcm::Document::SkipBytes(). Referenced by DoTheLoadingJob(). 01629 { 01630 // If you need to, look for comments of ComputeRLEInfo(). 01631 std::string ts = GetTransferSyntax(); 01632 if ( ! Global::GetTS()->IsJPEG(ts) ) 01633 { 01634 return; 01635 } 01636 01637 ReadEncapsulatedBasicOffsetTable(); 01638 01639 // Loop on the fragments[s] and store the parsed information in a 01640 // JPEGInfo. 01641 long fragmentLength; 01642 int i=0; 01643 uint32_t sum = 0; 01644 while ( (fragmentLength = ReadTagLength(0xfffe, 0xe000)) != 0 ) 01645 { 01646 // Since we have read the basic offset table, let's check the value were correct 01647 // or else produce a warning: 01648 // A.4 Transfer syntaxes for encapsulation of encoded pixel data: 01649 // When the Item Value is present, the Basic Offset Table Item Value shall contain 01650 // concatenated 32-bit unsigned integer values that are byte offsets to the first 01651 // byte of the Item Tag of the first fragment for each frame in the Sequence of 01652 // Items. These offsets are measured from the first byte of the first Item Tag 01653 // following the Basic Offset Table item (See Table A.4-2). 01654 01655 if ( BasicOffsetTableItemValue ) 01656 { 01657 // If a BasicOffsetTableItemValue was read 01658 uint32_t individualLength = BasicOffsetTableItemValue[i]; 01659 //assert( individualLength == sum ); // Seems like 00191113.dcm is off by one ?? 01660 if( individualLength != sum ) 01661 { 01662 gdcmWarningMacro( "BasicOffsetTableItemValue differs from the fragment lenght:" << 01663 individualLength << " != " << sum ); 01664 } 01665 sum += fragmentLength + 8; 01666 i++; 01667 } 01668 01669 long fragmentOffset = Fp->tellg(); 01670 // Store the collected info 01671 JPEGFragment *newFragment = new JPEGFragment; 01672 newFragment->SetOffset(fragmentOffset); 01673 newFragment->SetLength(fragmentLength); 01674 JPEGInfo->AddFragment(newFragment); 01675 01676 SkipBytes(fragmentLength); 01677 } 01678 01679 // Make sure that we encounter a 'Sequence Delimiter Item' 01680 // at the end of the item : 01681 if ( !ReadTag(0xfffe, 0xe0dd) ) 01682 { 01683 gdcmWarningMacro( "No sequence delimiter item at end of JPEG item sequence"); 01684 } 01685 }
|
|
Parse pixel data from disk of [multi-]fragment RLE encoding. Compute the RLE extra information and store it in RLEInfo for later pixel retrieval usage.
Definition at line 1516 of file gdcmFile.cxx. References gdcm::RLEFramesInfo::AddFrame(), BasicOffsetTableItemValue, gdcm::Document::Fp, gdcmWarningMacro, gdcm::Document::GetTransferSyntax(), gdcm::Global::GetTS(), ReadEncapsulatedBasicOffsetTable(), gdcm::Document::ReadInt32(), ReadTag(), ReadTagLength(), RLEInfo, gdcm::RLEFrame::SetLength(), gdcm::RLEFrame::SetNumberOfFragments(), gdcm::RLEFrame::SetOffset(), and gdcm::Document::SkipBytes(). Referenced by DoTheLoadingJob(). 01517 { 01518 std::string ts = GetTransferSyntax(); 01519 if ( !Global::GetTS()->IsRLELossless(ts) ) 01520 { 01521 return; 01522 } 01523 01524 // Encoded pixel data: for the time being we are only concerned with 01525 // Jpeg or RLE Pixel data encodings. 01526 // As stated in PS 3.5-2003, section 8.2 p44: 01527 // "If sent in Encapsulated Format (i.e. other than the Native Format) the 01528 // value representation OB is used". 01529 // Hence we expect an OB value representation. Concerning OB VR, 01530 // the section PS 3.5-2003, section A.4.c p 58-59, states: 01531 // "For the Value Representations OB and OW, the encoding shall meet the 01532 // following specifications depending on the Data element tag:" 01533 // [...snip...] 01534 // - the first item in the sequence of items before the encoded pixel 01535 // data stream shall be basic offset table item. The basic offset table 01536 // item value, however, is not required to be present" 01537 ReadEncapsulatedBasicOffsetTable(); 01538 01539 // Encapsulated RLE Compressed Images (see PS 3.5-2003, Annex G) 01540 // Loop on the individual frame[s] and store the information 01541 // on the RLE fragments in a RLEFramesInfo. 01542 // Note: - when only a single frame is present, this is a 01543 // classical image. 01544 // - when more than one frame are present, then we are in 01545 // the case of a multi-frame image. 01546 long frameLength; 01547 int i=0; 01548 uint32_t sum = 0; 01549 while ( (frameLength = ReadTagLength(0xfffe, 0xe000)) != 0 ) 01550 { 01551 // Since we have read the basic offset table, let's check the value were correct 01552 // or else produce a warning: 01553 if ( BasicOffsetTableItemValue ) 01554 { 01555 // If a BasicOffsetTableItemValue was read 01556 uint32_t individualLength = BasicOffsetTableItemValue[i]; 01557 assert( individualLength == sum ); // REMOVE that if this is a problem 01558 if( individualLength != sum ) 01559 { 01560 gdcmWarningMacro( "BasicOffsetTableItemValue differs from the fragment lenght" ); 01561 } 01562 sum += frameLength + 8; 01563 i++; 01564 } 01565 // Parse the RLE Header and store the corresponding RLE Segment 01566 // Offset Table information on fragments of this current Frame. 01567 // Note that the fragment pixels themselves are not loaded 01568 // (but just skipped). 01569 long frameOffset = Fp->tellg(); 01570 01571 uint32_t nbRleSegments = ReadInt32(); 01572 if ( nbRleSegments > 16 ) 01573 { 01574 // There should be at most 15 segments (refer to RLEFrame class) 01575 gdcmWarningMacro( "Too many segments."); 01576 } 01577 01578 uint32_t rleSegmentOffsetTable[16]; 01579 for( int k = 1; k <= 15; k++ ) 01580 { 01581 rleSegmentOffsetTable[k] = ReadInt32(); 01582 } 01583 01584 // Deduce from both RLE Header and frameLength 01585 // the fragment length, and again store this info 01586 // in a RLEFramesInfo. 01587 long rleSegmentLength[15]; 01588 // skipping (not reading) RLE Segments 01589 if ( nbRleSegments > 1) 01590 { 01591 for(unsigned int k = 1; k <= nbRleSegments-1; k++) 01592 { 01593 rleSegmentLength[k] = rleSegmentOffsetTable[k+1] 01594 - rleSegmentOffsetTable[k]; 01595 SkipBytes(rleSegmentLength[k]); 01596 } 01597 } 01598 01599 rleSegmentLength[nbRleSegments] = frameLength 01600 - rleSegmentOffsetTable[nbRleSegments]; 01601 SkipBytes(rleSegmentLength[nbRleSegments]); 01602 01603 // Store the collected info 01604 RLEFrame *newFrame = new RLEFrame; 01605 newFrame->SetNumberOfFragments(nbRleSegments); 01606 for( unsigned int uk = 1; uk <= nbRleSegments; uk++ ) 01607 { 01608 newFrame->SetOffset(uk,frameOffset + rleSegmentOffsetTable[uk]); 01609 newFrame->SetLength(uk,rleSegmentLength[uk]); 01610 } 01611 RLEInfo->AddFrame(newFrame); 01612 } 01613 01614 // Make sure that we encounter a 'Sequence Delimiter Item' 01615 // at the end of the item : 01616 if ( !ReadTag(0xfffe, 0xe0dd) ) 01617 { 01618 gdcmWarningMacro( "No sequence delimiter item at end of RLE item sequence"); 01619 } 01620 }
|
|
|
Does the Loading Job (internal use only).
Definition at line 156 of file gdcmFile.cxx. References gdcm::ElementSet::AddEntry(), gdcm::Document::CloseFile(), ComputeJPEGFragmentInfo(), ComputeRLEInfo(), gdcm::DataEntry::Copy(), gdcm::RefCounter::Delete(), gdcm::Document::Fp, gdcm::GDCM_UNFOUND, gdcm::DataEntry::GetBinArea(), GetBitsAllocated(), gdcm::ElementSet::GetDocEntry(), gdcm::DocEntrySet::GetEntryString(), gdcm::DocEntry::GetOffset(), gdcm::Document::GetTransferSyntax(), gdcm::Global::GetTS(), gdcm::DocEntry::GetVR(), GrPixel, gdcm::DataEntry::IsSelfArea(), gdcm::DataEntry::New(), gdcm::DictEntry::New(), NumPixel, gdcm::Document::OpenFile(), gdcm::ElementSet::RemoveEntry(), gdcm::DataEntry::SetBinArea(), and gdcm::DataEntry::SetSelfArea(). Referenced by Load(). 00157 { 00158 00159 // for some ACR-NEMA images GrPixel, NumPixel is *not* 7fe0,0010 00160 // We may encounter the 'RETired' (0x0028, 0x0200) tag 00161 // (Image Location") . This entry contains the number of 00162 // the group that contains the pixel data (hence the "Pixel Data" 00163 // is found by indirection through the "Image Location"). 00164 // Inside the group pointed by "Image Location" the searched element 00165 // is conventionally the element 0x0010 (when the norm is respected). 00166 // When the "Image Location" is missing we default to group 0x7fe0. 00167 // Note: this IS the right place for the code 00168 00169 // Image Location 00170 const std::string &imgLocation = GetEntryString(0x0028, 0x0200); 00171 if ( imgLocation == GDCM_UNFOUND ) 00172 { 00173 // default value 00174 GrPixel = 0x7fe0; 00175 } 00176 else 00177 { 00178 GrPixel = (uint16_t) atoi( imgLocation.c_str() ); 00179 } 00180 00181 // sometimes Image Location value doesn't follow 00182 // the supposed processor endianness. 00183 // see gdcmData/cr172241.dcm 00184 if ( GrPixel == 0xe07f ) 00185 { 00186 GrPixel = 0x7fe0; 00187 } 00188 00189 if ( GrPixel != 0x7fe0 ) 00190 { 00191 // This is a kludge for old dirty Philips imager. 00192 NumPixel = 0x1010; 00193 } 00194 else 00195 { 00196 NumPixel = 0x0010; 00197 } 00198 00199 // Now, we know GrPixel and NumPixel. 00200 // Let's create a VirtualDictEntry to allow a further VR modification 00201 // and force VR to match with BitsAllocated. 00202 DocEntry *entry = GetDocEntry(GrPixel, NumPixel); 00203 if ( entry != 0 ) 00204 { 00205 // Compute the RLE or JPEG info 00206 OpenFile(); 00207 const std::string &ts = GetTransferSyntax(); 00208 Fp->seekg( entry->GetOffset(), std::ios::beg ); 00209 if ( Global::GetTS()->IsRLELossless(ts) ) 00210 ComputeRLEInfo(); 00211 else if ( Global::GetTS()->IsJPEG(ts) ) 00212 ComputeJPEGFragmentInfo(); 00213 CloseFile(); 00214 00215 // Create a new DataEntry to change the DictEntry 00216 // The changed DictEntry will have 00217 // - a correct PixelVR OB or OW) 00218 // - the name to "Pixel Data" 00219 DataEntry *oldEntry = dynamic_cast<DataEntry *>(entry); 00220 if (oldEntry) 00221 { 00222 VRKey PixelVR; 00223 // 8 bits allocated is a 'O Bytes' , as well as 24 (old ACR-NEMA RGB) 00224 // more than 8 (i.e 12, 16) is a 'O Words' 00225 if ( GetBitsAllocated() == 8 || GetBitsAllocated() == 24 ) 00226 PixelVR = "OB"; 00227 else 00228 PixelVR = "OW"; 00229 00230 // Change only made if usefull 00231 if ( PixelVR != oldEntry->GetVR() ) 00232 { 00233 DictEntry* newDict = DictEntry::New(GrPixel,NumPixel, 00234 PixelVR,"1","Pixel Data"); 00235 00236 DataEntry *newEntry = DataEntry::New(newDict); 00237 newDict->Delete(); 00238 newEntry->Copy(entry); 00239 newEntry->SetBinArea(oldEntry->GetBinArea(),oldEntry->IsSelfArea()); 00240 oldEntry->SetSelfArea(false); 00241 00242 RemoveEntry(oldEntry); 00243 AddEntry(newEntry); 00244 newEntry->Delete(); 00245 } 00246 } 00247 } 00248 return true; 00249 }
|
|
|
|
|
|
Retrieve the number of Bits Allocated (8, 12 -compacted ACR-NEMA files-, 16, 24 -old RGB ACR-NEMA files-,).
Definition at line 818 of file gdcmFile.cxx. References gdcmWarningMacro, gdcm::DocEntrySet::GetDataEntry(), and gdcm::DataEntry::GetValue(). Referenced by gdcm::FileHelper::CheckMandatoryElements(), gdcm::FileHelper::CheckWriteIntegrity(), DoTheLoadingJob(), gdcm::PixelReadConvert::GrabInformationsFromFile(), gdcm::FileHelper::SetWriteToRaw(), and gdcm::FileHelper::SetWriteToRGB(). 00819 { 00820 DataEntry *entry = GetDataEntry(0x0028,0x0100); 00821 if( !entry ) 00822 { 00823 gdcmWarningMacro("BitsAllocated (0028,0100) is supposed to be mandatory"); 00824 return 0; 00825 } 00826 return (int)entry->GetValue(0); 00827 }
|
|
Retrieve the number of Bits Stored (actually used) (as opposed to number of Bits Allocated).
Definition at line 801 of file gdcmFile.cxx. References gdcmWarningMacro, gdcm::DocEntrySet::GetDataEntry(), and gdcm::DataEntry::GetValue(). Referenced by gdcm::FileHelper::CheckMandatoryElements(), and gdcm::PixelReadConvert::GrabInformationsFromFile(). 00802 { 00803 DataEntry *entry = GetDataEntry(0x0028,0x0101); 00804 if( !entry ) 00805 { 00806 gdcmWarningMacro("BitsStored (0028,0101) is supposed to be mandatory"); 00807 return 0; 00808 } 00809 return (int)entry->GetValue(0); 00810 }
|
|
|
Searches [both] the public [and the shadow dictionary (when they exist)] for the presence of the DictEntry with given group and element, and create a new virtual DictEntry if necessary.
Definition at line 520 of file gdcmDocEntrySet.cxx. References gdcm::GDCM_VRUNKNOWN, gdcm::DocEntrySet::GetDictEntry(), gdcm::DicomEntry::GetVR(), gdcm::DictEntry::New(), gdcm::RefCounter::Register(), and gdcm::RefCounter::Unregister(). 00522 { 00523 DictEntry *dictEntry = GetDictEntry(group,elem); 00524 DictEntry *goodEntry = dictEntry; 00525 VRKey goodVR = vr; 00526 00527 if (elem == 0x0000) 00528 goodVR="UL"; 00529 00530 if ( goodEntry ) 00531 { 00532 if ( goodVR != goodEntry->GetVR() 00533 && goodVR != GDCM_VRUNKNOWN ) 00534 { 00535 goodEntry = NULL; 00536 } 00537 dictEntry->Unregister(); 00538 } 00539 00540 // Create a new virtual DictEntry if necessary 00541 if (!goodEntry) 00542 { 00543 if (dictEntry) 00544 { 00545 goodEntry = DictEntry::New(group, elem, goodVR, "FIXME", 00546 dictEntry->GetName() ); 00547 } 00548 else 00549 { 00550 goodEntry = DictEntry::New(group, elem, goodVR); 00551 } 00552 } 00553 else 00554 { 00555 goodEntry->Register(); 00556 } 00557 return goodEntry; 00558 }
|
|
Searches [both] the public [and the shadow dictionary (when they exist)] for the presence of the DictEntry with given group and element. The public dictionary has precedence on the shadow one(s), if any.
Definition at line 493 of file gdcmDocEntrySet.cxx. References gdcmWarningMacro, gdcm::DictSet::GetDefaultPubDict(), gdcm::Global::GetDicts(), gdcm::Dict::GetEntry(), and gdcm::RefCounter::Register(). Referenced by gdcm::DocEntrySet::GetDictEntry(), gdcm::DocEntrySet::NewDataEntry(), gdcm::DocEntrySet::NewSeqEntry(), and gdcm::Document::ReadNextDocEntry(). 00494 { 00495 DictEntry *found = 0; 00496 Dict *pubDict = Global::GetDicts()->GetDefaultPubDict(); 00497 if (!pubDict) 00498 { 00499 gdcmWarningMacro( "We SHOULD have a default dictionary"); 00500 } 00501 else 00502 { 00503 found = pubDict->GetEntry(group, elem); 00504 if( found ) 00505 found->Register(); 00506 } 00507 return found; 00508 }
|
|
retrieves a Dicom Element using (group, element)
Implements gdcm::DocEntrySet. Definition at line 163 of file gdcmElementSet.cxx. References gdcm::ElementSet::TagHT, and gdcm::DicomEntry::TranslateToKey(). Referenced by AnonymizeFile(), AnonymizeNoLoad(), gdcm::FileHelper::CopyDataEntry(), gdcm::DicomDir::CreateDicomDir(), gdcm::Document::DoTheLoadingDocumentJob(), DoTheLoadingJob(), gdcm::DicomDir::DoTheLoadingJob(), GetPixelAreaLength(), GetPixelOffset(), gdcm::Document::GetTransferSyntax(), HasLUT(), gdcm::Document::IsDicomV3(), gdcm::Document::IsPapyrus(), IsReadable(), gdcm::Document::LoadEntryBinArea(), gdcm::DocEntryArchive::Push(), and gdcm::DocEntryArchive::Restore(). 00164 { 00165 TagKey key = DictEntry::TranslateToKey(group, elem); 00166 TagDocEntryHT::iterator it = TagHT.find(key); 00167 00168 if ( it!=TagHT.end() ) 00169 return it->second; 00170 return NULL; 00171 }
|
|
Gets (from Header) a 'non string' element value.
Definition at line 69 of file gdcmDocEntrySet.cxx. References gdcm::DataEntry::GetBinArea(), and gdcm::DocEntrySet::GetDataEntry(). Referenced by gdcm::PixelReadConvert::GrabInformationsFromFile(). 00070 { 00071 DataEntry *entry = GetDataEntry(group, elem); 00072 if ( entry ) 00073 return entry->GetBinArea(); 00074 return 0; 00075 }
|
|
Return the value of the DataEntry if it's "std::string representable".
Definition at line 84 of file gdcmDocEntrySet.cxx. References gdcm::Util::CreateCleanString(), gdcm::GDCM_NOTASCII, gdcm::GDCM_NOTLOADED, gdcm::GDCM_UNFOUND, gdcm::GDCM_UNREAD, gdcm::DataEntry::GetBinArea(), gdcm::DocEntrySet::GetDocEntry(), gdcm::DocEntry::GetLength(), gdcm::DataEntry::GetString(), gdcm::DocEntry::GetVR(), gdcm::Global::GetVR(), gdcm::Util::IsCleanArea(), gdcm::DataEntry::IsNotLoaded(), gdcm::DataEntry::IsUnfound(), gdcm::DataEntry::IsUnread(), and gdcm::VR::IsVROfStringRepresentable(). 00085 { 00086 DocEntry *d = GetDocEntry(group,elem); 00087 if ( !d ) 00088 return GDCM_UNFOUND; 00089 00090 DataEntry *de = dynamic_cast<DataEntry *>(d); 00091 if ( de ) 00092 { 00093 if( de->IsNotLoaded() ) 00094 return GDCM_NOTLOADED; 00095 if( de->IsUnfound() ) 00096 return GDCM_UNFOUND; 00097 if( de->IsUnread() ) 00098 return GDCM_UNREAD; 00099 } 00100 00101 if( Global::GetVR()->IsVROfStringRepresentable( de->GetVR() ) ) 00102 return de->GetString(); 00103 else 00104 { 00105 uint8_t *a = de->GetBinArea(); 00106 if( Util::IsCleanArea(a, de->GetLength()) ) 00107 return Util::CreateCleanString(a, de->GetLength()); 00108 } 00109 return GDCM_NOTASCII; 00110 }
|
|
Searches within Header Entries (Dicom Elements) parsed with the public and private dictionaries for the value length of a given tag..
Definition at line 120 of file gdcmDocEntrySet.cxx. References gdcm::DocEntrySet::GetDocEntry(), and gdcm::DocEntry::GetLength(). Referenced by gdcm::DicomDir::SetElement(), and Write(). 00121 { 00122 DocEntry *entry = GetDocEntry(group, elem); 00123 if ( entry ) 00124 return entry->GetLength(); 00125 return -1; 00126 }
|
|
Get the "std::string representable" value of the Dicom entry.
Definition at line 47 of file gdcmDocEntrySet.cxx. References gdcm::GDCM_NOTLOADED, gdcm::GDCM_UNFOUND, gdcm::GDCM_UNREAD, gdcm::DocEntrySet::GetDocEntry(), gdcm::DataEntry::GetString(), gdcm::DataEntry::IsNotLoaded(), gdcm::DataEntry::IsUnfound(), and gdcm::DataEntry::IsUnread(). Referenced by gdcm::SerieHelper::AddFileName(), AnonymizeFile(), gdcm::FileHelper::CheckMandatoryElements(), gdcm::Document::DoTheLoadingDocumentJob(), DoTheLoadingJob(), GetImageNumber(), GetImageOrientationPatient(), GetLUTNbits(), GetModality(), GetNumberOfScalarComponents(), GetNumberOfScalarComponentsRaw(), GetPixelSize(), GetPixelType(), gdcm::Document::GetTransferSyntaxName(), gdcm::PixelReadConvert::GrabInformationsFromFile(), IsMonochrome(), IsMonochrome1(), IsPaletteColor(), IsReadable(), IsYBRFull(), gdcm::Document::operator<(), and gdcm::DicomDir::SetElement(). 00048 { 00049 DataEntry *entry = dynamic_cast<DataEntry *>(GetDocEntry(group,elem)); 00050 if ( entry ) 00051 { 00052 if( entry->IsNotLoaded() ) 00053 return GDCM_NOTLOADED; 00054 if( entry->IsUnfound() ) 00055 return GDCM_UNFOUND; 00056 if( entry->IsUnread() ) 00057 return GDCM_UNREAD; 00058 return entry->GetString(); 00059 } 00060 return GDCM_UNFOUND; 00061 }
|
|
Accessor to Filename.
Definition at line 74 of file gdcmDocument.h. Referenced by gdcm::DicomDir::DoTheLoadingJob(), gdcm::SerieHelper::FileNameGreaterThan(), gdcm::SerieHelper::FileNameLessThan(), gdcm::Document::IsParsable(), gdcm::DicomDir::IsReadable(), gdcm::Document::Load(), gdcm::DicomDir::ParseDirectory(), and gdcm::DicomDir::SetElement(). 00074 { return Filename; }
|
|
returns the File Type (ACR, ACR_LIBIDO, ExplicitVR, ImplicitVR, Unknown)
Definition at line 403 of file gdcmDocument.cxx. References gdcm::Document::Filetype. 00404 { 00405 return Filetype; 00406 }
|
|
Get the first entry while visiting *the* 'zero level' DocEntrySet (DocEntries out of any Sequence).
Implements gdcm::DocEntrySet. Definition at line 133 of file gdcmElementSet.cxx. References gdcm::ElementSet::ItTagHT, and gdcm::ElementSet::TagHT. Referenced by gdcm::Document::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 }
|
|
Accessor to File::GrPixel.
Definition at line 154 of file gdcmFile.h. 00154 { return GrPixel; }
|
|
Retrieve the high bit position.
Definition at line 835 of file gdcmFile.cxx. References gdcmWarningMacro, gdcm::DocEntrySet::GetDataEntry(), and gdcm::DataEntry::GetValue(). Referenced by gdcm::FileHelper::CheckMandatoryElements(), and gdcm::PixelReadConvert::GrabInformationsFromFile(). 00836 { 00837 DataEntry *entry = GetDataEntry(0x0028,0x0102); 00838 if( !entry ) 00839 { 00840 gdcmWarningMacro("HighBitPosition (0028,0102) is supposed to be mandatory"); 00841 return 0; 00842 } 00843 return (int)entry->GetValue(0); 00844 }
|
|
gets the info from 0020,0013 : Image Number else 0.
Definition at line 319 of file gdcmFile.cxx. References gdcm::GDCM_UNFOUND, and gdcm::DocEntrySet::GetEntryString(). Referenced by gdcm::SerieHelper::ImageNumberGreaterThan(), and gdcm::SerieHelper::ImageNumberLessThan(). 00320 { 00321 //0020 0013 : Image Number 00322 std::string strImNumber = GetEntryString(0x0020,0x0013); 00323 if ( strImNumber != GDCM_UNFOUND ) 00324 { 00325 return atoi( strImNumber.c_str() ); 00326 } 00327 return 0; //Hopeless 00328 }
|
|
gets the info from 0020,0037 : Image Orientation Patient or from 0020 0035 : Image Orientation (RET) (needed to organize DICOM files based on their x,y,z position)
Definition at line 763 of file gdcmFile.cxx. References gdcm::GDCM_UNFOUND, gdcmWarningMacro, and gdcm::DocEntrySet::GetEntryString(). Referenced by gdcm::Orientation::GetOrientation(), and gdcm::Orientation::GetOrientationType(). 00764 { 00765 std::string strImOriPat; 00766 //iop is supposed to be float[6] 00767 iop[0] = iop[1] = iop[2] = iop[3] = iop[4] = iop[5] = 0.; 00768 00769 // 0020 0037 DS REL Image Orientation (Patient) 00770 if ( (strImOriPat = GetEntryString(0x0020,0x0037)) != GDCM_UNFOUND ) 00771 { 00772 if ( sscanf( strImOriPat.c_str(), "%f \\ %f \\%f \\%f \\%f \\%f ", 00773 &iop[0], &iop[1], &iop[2], &iop[3], &iop[4], &iop[5]) != 6 ) 00774 { 00775 gdcmWarningMacro( "Wrong Image Orientation Patient (0020,0037)." 00776 << " Less than 6 values were found." ); 00777 return false; 00778 } 00779 } 00780 //For ACR-NEMA 00781 // 0020 0035 DS REL Image Orientation (RET) 00782 else if ( (strImOriPat = GetEntryString(0x0020,0x0035)) != GDCM_UNFOUND ) 00783 { 00784 if ( sscanf( strImOriPat.c_str(), "%f \\ %f \\%f \\%f \\%f \\%f ", 00785 &iop[0], &iop[1], &iop[2], &iop[3], &iop[4], &iop[5]) != 6 ) 00786 { 00787 gdcmWarningMacro( "wrong Image Orientation Patient (0020,0035). " 00788 << "Less than 6 values were found." ); 00789 return false; 00790 } 00791 } 00792 return true; 00793 }
|
|
Returns the JPEG Fragments info.
Definition at line 164 of file gdcmFile.h. Referenced by gdcm::PixelReadConvert::GrabInformationsFromFile(). 00164 { return JPEGInfo; }
|
|
gets the info from 0028,1101 : Lookup Table Desc-Red else 0
Definition at line 1115 of file gdcmFile.cxx. References gdcm::GDCM_UNFOUND, gdcm::DocEntrySet::GetEntryString(), and gdcm::Util::Tokenize(). 01116 { 01117 std::vector<std::string> tokens; 01118 int lutNbits; 01119 01120 //Just hope Lookup Table Desc-Red = Lookup Table Desc-Red 01121 // = Lookup Table Desc-Blue 01122 // Consistency already checked in GetLUTLength 01123 std::string lutDescription = GetEntryString(0x0028,0x1101); 01124 if ( lutDescription == GDCM_UNFOUND ) 01125 { 01126 return 0; 01127 } 01128 01129 tokens.clear(); // clean any previous value 01130 Util::Tokenize ( lutDescription, tokens, "\\" ); 01131 //LutLength=atoi(tokens[0].c_str()); 01132 //LutDepth=atoi(tokens[1].c_str()); 01133 01134 lutNbits = atoi( tokens[2].c_str() ); 01135 tokens.clear(); 01136 01137 return lutNbits; 01138 }
|
|
gets the info from 0008,0060 : Modality
Definition at line 334 of file gdcmFile.cxx. References gdcm::AS, gdcm::AU, gdcm::BI, gdcm::CF, gdcm::CP, gdcm::CR, gdcm::CS, gdcm::CT, gdcm::DD, gdcm::DF, gdcm::DG, gdcm::DM, gdcm::DS, gdcm::DX, gdcm::ECG, gdcm::EPS, gdcm::FA, gdcm::FS, gdcm::GDCM_UNFOUND, gdcm::DocEntrySet::GetEntryString(), gdcm::HC, gdcm::HD, gdcm::LP, gdcm::LS, gdcm::MA, gdcm::MR, gdcm::NM, gdcm::OT, gdcm::PT, gdcm::RF, gdcm::RG, gdcm::RTDOSE, gdcm::RTIMAGE, gdcm::RTPLAN, gdcm::RTSTRUCT, gdcm::SM, gdcm::ST, gdcm::TG, gdcm::Unknow, gdcm::US, gdcm::VF, gdcm::XA, and gdcm::XC. 00335 { 00336 // 0008 0060 : Modality 00337 std::string strModality = GetEntryString(0x0008,0x0060); 00338 if ( strModality != GDCM_UNFOUND ) 00339 { 00340 if ( strModality.find("AU") < strModality.length()) return AU; 00341 else if ( strModality.find("AS") < strModality.length()) return AS; 00342 else if ( strModality.find("BI") < strModality.length()) return BI; 00343 else if ( strModality.find("CF") < strModality.length()) return CF; 00344 else if ( strModality.find("CP") < strModality.length()) return CP; 00345 else if ( strModality.find("CR") < strModality.length()) return CR; 00346 else if ( strModality.find("CT") < strModality.length()) return CT; 00347 else if ( strModality.find("CS") < strModality.length()) return CS; 00348 else if ( strModality.find("DD") < strModality.length()) return DD; 00349 else if ( strModality.find("DF") < strModality.length()) return DF; 00350 else if ( strModality.find("DG") < strModality.length()) return DG; 00351 else if ( strModality.find("DM") < strModality.length()) return DM; 00352 else if ( strModality.find("DS") < strModality.length()) return DS; 00353 else if ( strModality.find("DX") < strModality.length()) return DX; 00354 else if ( strModality.find("ECG") < strModality.length()) return ECG; 00355 else if ( strModality.find("EPS") < strModality.length()) return EPS; 00356 else if ( strModality.find("FA") < strModality.length()) return FA; 00357 else if ( strModality.find("FS") < strModality.length()) return FS; 00358 else if ( strModality.find("HC") < strModality.length()) return HC; 00359 else if ( strModality.find("HD") < strModality.length()) return HD; 00360 else if ( strModality.find("LP") < strModality.length()) return LP; 00361 else if ( strModality.find("LS") < strModality.length()) return LS; 00362 else if ( strModality.find("MA") < strModality.length()) return MA; 00363 else if ( strModality.find("MR") < strModality.length()) return MR; 00364 else if ( strModality.find("NM") < strModality.length()) return NM; 00365 else if ( strModality.find("OT") < strModality.length()) return OT; 00366 else if ( strModality.find("PT") < strModality.length()) return PT; 00367 else if ( strModality.find("RF") < strModality.length()) return RF; 00368 else if ( strModality.find("RG") < strModality.length()) return RG; 00369 else if ( strModality.find("RTDOSE") 00370 < strModality.length()) return RTDOSE; 00371 else if ( strModality.find("RTIMAGE") 00372 < strModality.length()) return RTIMAGE; 00373 else if ( strModality.find("RTPLAN") 00374 < strModality.length()) return RTPLAN; 00375 else if ( strModality.find("RTSTRUCT") 00376 < strModality.length()) return RTSTRUCT; 00377 else if ( strModality.find("SM") < strModality.length()) return SM; 00378 else if ( strModality.find("ST") < strModality.length()) return ST; 00379 else if ( strModality.find("TG") < strModality.length()) return TG; 00380 else if ( strModality.find("US") < strModality.length()) return US; 00381 else if ( strModality.find("VF") < strModality.length()) return VF; 00382 else if ( strModality.find("XA") < strModality.length()) return XA; 00383 else if ( strModality.find("XC") < strModality.length()) return XC; 00384 00385 else 00386 { 00389 return Unknow; 00390 } 00391 } 00392 return Unknow; 00393 }
|
|
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 gdcm::Document::ComputeGroup0002Length(), and gdcm::Validator::SetInput(). 00148 { 00149 gdcmAssertMacro (ItTagHT != TagHT.end()); 00150 00151 ++ItTagHT; 00152 if (ItTagHT != TagHT.end()) 00153 return ItTagHT->second; 00154 return NULL; 00155 }
|
|
This function is intended to user who doesn't want to have to manage a LUT and expects to get an RBG Pixel image (or a monochrome one ...).
Definition at line 1180 of file gdcmFile.cxx. References gdcm::Util::DicomStringEqual(), gdcm::GDCM_UNFOUND, gdcm::DocEntrySet::GetEntryString(), GetSamplesPerPixel(), and HasLUT(). Referenced by gdcm::FileHelper::SetWriteToRaw(), and gdcm::FileHelper::SetWriteToRGB(). 01181 { 01182 if ( GetSamplesPerPixel() == 3 ) 01183 { 01184 return 3; 01185 } 01186 01187 // 0028 0100 US IMG Bits Allocated 01188 // (in order no to be messed up by old RGB images) 01189 if ( GetEntryString(0x0028,0x0100) == "24" ) 01190 { 01191 return 3; 01192 } 01193 01194 std::string strPhotometricInterpretation = GetEntryString(0x0028,0x0004); 01195 01196 if ( ( strPhotometricInterpretation == "PALETTE COLOR ") ) 01197 { 01198 if ( HasLUT() )// PALETTE COLOR is NOT enough 01199 { 01200 return 3; 01201 } 01202 else 01203 { 01204 return 1; 01205 } 01206 } 01207 01208 // beware of trailing space at end of string 01209 // DICOM tags are never of odd length 01210 if ( strPhotometricInterpretation == GDCM_UNFOUND || 01211 Util::DicomStringEqual(strPhotometricInterpretation, "MONOCHROME1") || 01212 Util::DicomStringEqual(strPhotometricInterpretation, "MONOCHROME2") ) 01213 { 01214 return 1; 01215 } 01216 else 01217 { 01218 // we assume that *all* kinds of YBR are dealt with 01219 return 3; 01220 } 01221 }
|
|
This function is intended to user that DOESN'T want to get RGB pixels image when it's stored as a PALETTE COLOR image
Definition at line 1230 of file gdcmFile.cxx. References gdcm::DocEntrySet::GetEntryString(), and GetSamplesPerPixel(). 01231 { 01232 // 0028 0100 US IMG Bits Allocated 01233 // (in order no to be messed up by old RGB images) 01234 if ( File::GetEntryString(0x0028,0x0100) == "24" ) 01235 { 01236 return 3; 01237 } 01238 01239 // we assume that *all* kinds of YBR are dealt with 01240 return GetSamplesPerPixel(); 01241 }
|
|
Accessor to File::NumPixel.
Definition at line 156 of file gdcmFile.h. 00156 { return NumPixel; }
|
|
Recover the pixel area length (in Bytes).
Definition at line 1270 of file gdcmFile.cxx. References gdcmWarningMacro, gdcm::ElementSet::GetDocEntry(), gdcm::DocEntry::GetLength(), GrPixel, and NumPixel. Referenced by gdcm::PixelReadConvert::GrabInformationsFromFile(). 01271 { 01272 DocEntry *pxlElement = GetDocEntry(GrPixel, NumPixel); 01273 if ( pxlElement ) 01274 { 01275 return pxlElement->GetLength(); 01276 } 01277 else 01278 { 01279 gdcmWarningMacro( "Big trouble : Pixel Element (" 01280 << std::hex << GrPixel<<","<< NumPixel<< ") NOT found" ); 01281 return 0; 01282 } 01283 }
|
|
Recover the offset (from the beginning of the file) of *image* pixels (not *icone image* pixels, if any !).
Definition at line 1248 of file gdcmFile.cxx. References gdcmWarningMacro, gdcm::ElementSet::GetDocEntry(), gdcm::DocEntry::GetOffset(), GrPixel, and NumPixel. Referenced by gdcm::PixelReadConvert::GrabInformationsFromFile(). 01249 { 01250 DocEntry *pxlElement = GetDocEntry(GrPixel, NumPixel); 01251 if ( pxlElement ) 01252 { 01253 return pxlElement->GetOffset(); 01254 } 01255 else 01256 { 01257 gdcmWarningMacro( "Big trouble : Pixel Element (" 01258 << std::hex << GrPixel<<","<< NumPixel<< ") NOT found" ); 01259 return 0; 01260 } 01261 }
|
|
Return the size (in bytes) of a single pixel of data.
Definition at line 884 of file gdcmFile.cxx. References gdcmWarningMacro, gdcm::DocEntrySet::GetEntryString(), and GetPixelType(). 00885 { 00886 // 0028 0100 US IMG Bits Allocated 00887 // (in order no to be messed up by old ACR-NEMA RGB images) 00888 assert( !(GetEntryString(0x0028,0x0100) == "24") ); 00889 00890 std::string pixelType = GetPixelType(); 00891 if ( pixelType == "8U" || pixelType == "8S" ) 00892 { 00893 return 1; 00894 } 00895 if ( pixelType == "16U" || pixelType == "16S") 00896 { 00897 return 2; 00898 } 00899 if ( pixelType == "32U" || pixelType == "32S") 00900 { 00901 return 4; 00902 } 00903 if ( pixelType == "FD" ) 00904 { 00905 return 8; 00906 } 00907 gdcmWarningMacro( "Unknown pixel type: " << pixelType); 00908 return 0; 00909 }
|
|
Build the Pixel Type of the image. Possible values are:
Definition at line 926 of file gdcmFile.cxx. References gdcm::GDCM_UNFOUND, gdcmWarningMacro, gdcm::DocEntrySet::GetEntryString(), and IsSignedPixelData(). Referenced by GetPixelSize(). 00927 { 00928 std::string bitsAlloc = GetEntryString(0x0028, 0x0100); // Bits Allocated 00929 if ( bitsAlloc == GDCM_UNFOUND ) 00930 { 00931 gdcmWarningMacro( "Bits Allocated (0028,0100) supposed to be mandatory"); 00932 bitsAlloc = "16"; // default and arbitrary value, not to polute the output 00933 } 00934 00935 if ( bitsAlloc == "64" ) 00936 { 00937 return "FD"; 00938 } 00939 else if ( bitsAlloc == "12" ) 00940 { 00941 // It will be unpacked 00942 bitsAlloc = "16"; 00943 } 00944 else if ( bitsAlloc == "24" ) 00945 { 00946 // (in order no to be messed up by old RGB images) 00947 bitsAlloc = "8"; 00948 } 00949 00950 std::string sign; 00951 if( IsSignedPixelData() ) 00952 { 00953 sign = "S"; 00954 } 00955 else 00956 { 00957 sign = "U"; 00958 } 00959 return bitsAlloc + sign; 00960 }
|
|
Retrieve the Planar Configuration for RGB images (0 : RGB Pixels , 1 : R Plane + G Plane + B Plane).
Definition at line 869 of file gdcmFile.cxx. References gdcm::DocEntrySet::GetDataEntry(), and gdcm::DataEntry::GetValue(). Referenced by gdcm::PixelReadConvert::GrabInformationsFromFile(). 00870 { 00871 DataEntry *entry = GetDataEntry(0x0028,0x0006); 00872 if( !entry ) 00873 { 00874 return 0; 00875 } 00876 return (int)entry->GetValue(0); 00877 }
|
|
Gets the print level for the Dicom Entries.
Definition at line 50 of file gdcmBase.h. 00050 { return PrintLevel; }
|
|
Get the public dictionary used.
Definition at line 300 of file gdcmDocument.cxx. References gdcm::Document::RefPubDict. Referenced by gdcm::DicomDir::SetElement(). 00301 { 00302 return RefPubDict; 00303 }
|
|
Get the reference counting.
Definition at line 57 of file gdcmRefCounter.h. 00058 { 00059 return RefCount; 00060 }
|
|
gets the info from 0028,1052 : Rescale Intercept
Definition at line 1144 of file gdcmFile.cxx. References gdcmWarningMacro, gdcm::DocEntrySet::GetDataEntry(), and gdcm::DataEntry::GetValue(). 01145 { 01146 // 0028 1052 DS IMG Rescale Intercept 01147 DataEntry *entry = GetDataEntry(0x0028, 0x1052); 01148 if( !entry ) 01149 { 01150 gdcmWarningMacro( "Missing Rescale Intercept (0028,1052)"); 01151 return 0.0f; 01152 } 01153 return (float)entry->GetValue(0); 01154 01155 }
|
|
gets the info from 0028,1053 : Rescale Slope
Definition at line 1161 of file gdcmFile.cxx. References gdcmDebugMacro, gdcm::DocEntrySet::GetDataEntry(), and gdcm::DataEntry::GetValue(). 01162 { 01163 // 0028 1053 DS IMG Rescale Slope 01164 DataEntry *entry = GetDataEntry(0x0028, 0x1053); 01165 if( !entry ) 01166 { 01167 gdcmDebugMacro( "Missing Rescale Slope (0028,1053)"); 01168 return 1.0f; 01169 } 01170 return (float)entry->GetValue(0); 01171 }
|
|
returns the RLE info
Definition at line 162 of file gdcmFile.h. Referenced by gdcm::PixelReadConvert::GrabInformationsFromFile(). 00162 { return RLEInfo; }
|
|
Retrieve the number of Samples Per Pixel (1 : gray level, 3 : RGB/YBR -1 or 3 Planes-).
Definition at line 852 of file gdcmFile.cxx. References gdcmWarningMacro, gdcm::DocEntrySet::GetDataEntry(), and gdcm::DataEntry::GetValue(). Referenced by gdcm::FileHelper::CheckWriteIntegrity(), GetNumberOfScalarComponents(), GetNumberOfScalarComponentsRaw(), and gdcm::PixelReadConvert::GrabInformationsFromFile(). 00853 { 00854 DataEntry *entry = GetDataEntry(0x0028,0x0002); 00855 if( !entry ) 00856 { 00857 gdcmWarningMacro("SamplesPerPixel (0028,0002) is supposed to be mandatory"); 00858 return 1; // Well, it's supposed to be mandatory ... 00859 // but sometimes it's missing : *we* assume Gray pixels 00860 } 00861 return (int)entry->GetValue(0); 00862 }
|
|
Same as Document::GetDocEntry except it only returns a result when the corresponding entry is of type SeqEntry.
Definition at line 153 of file gdcmDocEntrySet.cxx. References gdcm::DocEntrySet::GetDocEntry(). Referenced by gdcm::Document::DoTheLoadingDocumentJob(). 00154 { 00155 DocEntry *currentEntry = GetDocEntry(group, elem); 00156 if ( !currentEntry ) 00157 return NULL; 00158 00159 return dynamic_cast<SeqEntry*>(currentEntry); 00160 }
|
|
Get the shadow dictionary used.
Definition at line 308 of file gdcmDocument.cxx. References gdcm::Document::RefShaDict. 00309 { 00310 return RefShaDict; 00311 }
|
|
'Swap code' accessor (see SwapCode )
Definition at line 70 of file gdcmDocument.h. Referenced by gdcm::PixelReadConvert::GrabInformationsFromFile(). 00070 { return SwapCode; }
|
|
Accessor to the Transfer Syntax (when present) of the current document (it internally handles reading the value from disk when only parsing occured).
Definition at line 415 of file gdcmDocument.cxx. References gdcm::GDCM_UNKNOWN, gdcmWarningMacro, gdcm::ElementSet::GetDocEntry(), and gdcm::Document::LoadDocEntrySafe(). Referenced by ComputeJPEGFragmentInfo(), ComputeRLEInfo(), DoTheLoadingJob(), gdcm::PixelReadConvert::GrabInformationsFromFile(), and gdcm::Document::HandleOutOfGroup0002(). 00416 { 00417 DocEntry *entry = GetDocEntry(0x0002, 0x0010); 00418 if ( !entry ) 00419 { 00420 return GDCM_UNKNOWN; 00421 } 00422 00423 // The entry might be present but not loaded (parsing and loading 00424 // happen at different stages): try loading and proceed with check... 00425 LoadDocEntrySafe(entry); 00426 if (DataEntry *dataEntry = dynamic_cast<DataEntry *>(entry) ) 00427 { 00428 std::string transfer = dataEntry->GetString(); 00429 // The actual transfer (as read from disk) might be padded. We 00430 // first need to remove the potential padding. We can make the 00431 // weak assumption that padding was not executed with digits... 00432 if ( transfer.length() == 0 ) 00433 { 00434 // for brain damaged headers 00435 gdcmWarningMacro( "Transfer Syntax has length = 0."); 00436 return GDCM_UNKNOWN; 00437 } 00438 while ( !isdigit((unsigned char)transfer[transfer.length()-1]) ) 00439 { 00440 transfer.erase(transfer.length()-1, 1); 00441 if ( transfer.length() == 0 ) 00442 { 00443 // for brain damaged headers 00444 gdcmWarningMacro( "Transfer Syntax contains no valid character."); 00445 return GDCM_UNKNOWN; 00446 } 00447 } 00448 return transfer; 00449 } 00450 return GDCM_UNKNOWN; 00451 }
|
|
Accesses the info from 0002,0010 : Transfer Syntax and TS.
Definition at line 457 of file gdcmDocument.cxx. References gdcm::GDCM_NOTLOADED, gdcm::GDCM_UNFOUND, gdcmDebugMacro, gdcmErrorMacro, gdcm::DocEntrySet::GetEntryString(), and gdcm::Global::GetTS(). Referenced by gdcm::Document::HandleOutOfGroup0002(). 00458 { 00459 // use the TS (TS : Transfer Syntax) 00460 std::string transferSyntax = GetEntryString(0x0002,0x0010); 00461 00462 if ( (transferSyntax.find(GDCM_NOTLOADED) < transferSyntax.length()) ) 00463 { 00464 gdcmErrorMacro( "Transfer Syntax not loaded. " << std::endl 00465 << "Better you increase MAX_SIZE_LOAD_ELEMENT_VALUE" ); 00466 return "Uncompressed ACR-NEMA"; 00467 } 00468 if ( transferSyntax == GDCM_UNFOUND ) 00469 { 00470 gdcmDebugMacro( "Unfound Transfer Syntax (0002,0010)"); 00471 return "Uncompressed ACR-NEMA"; 00472 } 00473 00474 // we do it only when we need it 00475 const TSKey &tsName = Global::GetTS()->GetValue( transferSyntax ); 00476 00477 // Global::GetTS() is a global static you shall never try to delete it! 00478 return tsName; 00479 }
|
|
gets the info from 0020,0032 : Image Position Patient else from 0020,0030 : Image Position (RET) else 0.
Definition at line 626 of file gdcmFile.cxx. References gdcmErrorMacro, gdcmWarningMacro, gdcm::DocEntrySet::GetDataEntry(), gdcm::DataEntry::GetValue(), gdcm::DataEntry::GetValueCount(), and gdcm::DataEntry::IsValueCountValid(). 00627 { 00628 DataEntry *entry = GetDataEntry(0x0020,0x0032); 00629 if( !entry ) 00630 { 00631 gdcmWarningMacro( "Unfound Image Position Patient (0020,0032)"); 00632 entry = GetDataEntry(0x0020,0x0030); 00633 if( !entry ) 00634 { 00635 gdcmWarningMacro( "Unfound Image Position (RET) (0020,0030)"); 00636 return 0.0f; 00637 } 00638 } 00639 00640 if( entry->GetValueCount() == 3 ) 00641 { 00642 if (!entry->IsValueCountValid() ) 00643 { 00644 gdcmErrorMacro( "Invalid Value Count" ); 00645 } 00646 return (float)entry->GetValue(0); 00647 } 00648 return 0.0f; 00649 }
|
|
Retrieve the number of columns of image.
Definition at line 400 of file gdcmFile.cxx. References gdcm::DocEntrySet::GetDataEntry(), and gdcm::DataEntry::GetValue(). Referenced by gdcm::FileHelper::CheckWriteIntegrity(), and gdcm::PixelReadConvert::GrabInformationsFromFile(). 00401 { 00402 DataEntry *entry = GetDataEntry(0x0028,0x0011); 00403 if( entry ) 00404 return (int)entry->GetValue(0); 00405 return 0; 00406 }
|
|
gets the info from 0018,1164 : ImagerPixelSpacing then 0028,0030 : Pixel Spacing else 1.0
Definition at line 460 of file gdcmFile.cxx. References gdcmWarningMacro, gdcm::DocEntrySet::GetDataEntry(), gdcm::DataEntry::GetValue(), and gdcm::DataEntry::GetValueCount(). 00461 { 00462 float xspacing = 1.0; 00463 uint32_t nbValue; 00464 00465 // To follow David Clunie's advice, we first check ImagerPixelSpacing 00466 00467 DataEntry *entry = GetDataEntry(0x0018,0x1164); 00468 if( entry ) 00469 { 00470 nbValue = entry->GetValueCount(); 00471 // Can't use IsValueCountValid because of the complex heuristic. 00472 if( nbValue !=2 ) 00473 gdcmWarningMacro("ImagerPixelSpacing (0x0018,0x1164) " 00474 << "has a wrong number of values :" << nbValue); 00475 00476 if( nbValue >= 3 ) 00477 xspacing = (float)entry->GetValue(2); 00478 else if( nbValue >= 2 ) 00479 xspacing = (float)entry->GetValue(1); 00480 else 00481 xspacing = (float)entry->GetValue(0); 00482 00483 if ( xspacing == 0.0 ) 00484 xspacing = 1.0; 00485 return xspacing; 00486 } 00487 else 00488 { 00489 gdcmWarningMacro( "Unfound Imager Pixel Spacing (0018,1164)" ); 00490 } 00491 00492 entry = GetDataEntry(0x0028,0x0030); 00493 if( entry ) 00494 { 00495 nbValue = entry->GetValueCount(); 00496 if( nbValue !=2 ) 00497 gdcmWarningMacro("PixelSpacing (0x0018,0x0030) " 00498 << "has a wrong number of values :" << nbValue); 00499 00500 if( nbValue >= 3 ) 00501 xspacing = (float)entry->GetValue(2); 00502 else if( nbValue >= 2 ) 00503 xspacing = (float)entry->GetValue(1); 00504 else 00505 xspacing = (float)entry->GetValue(0); 00506 00507 if ( xspacing == 0.0 ) 00508 xspacing = 1.0; 00509 return xspacing; 00510 } 00511 else 00512 { 00513 gdcmWarningMacro( "Unfound Pixel Spacing (0028,0030)" ); 00514 } 00515 00516 return xspacing; 00517 }
|
|
gets the info from 0020,0032 : Image Position Patient else from 0020,0030 : Image Position (RET) else 0.
Definition at line 657 of file gdcmFile.cxx. References gdcmErrorMacro, gdcmWarningMacro, gdcm::DocEntrySet::GetDataEntry(), gdcm::DataEntry::GetValue(), gdcm::DataEntry::GetValueCount(), and gdcm::DataEntry::IsValueCountValid(). 00658 { 00659 DataEntry *entry = GetDataEntry(0x0020,0x0032); 00660 if( !entry ) 00661 { 00662 gdcmWarningMacro( "Unfound Image Position Patient (0020,0032)"); 00663 entry = GetDataEntry(0x0020,0x0030); 00664 if( !entry ) 00665 { 00666 gdcmWarningMacro( "Unfound Image Position (RET) (0020,0030)"); 00667 return 0.0f; 00668 } 00669 } 00670 00671 if( entry->GetValueCount() == 3 ) 00672 { 00673 if (!entry->IsValueCountValid() ) 00674 { 00675 gdcmErrorMacro( "Invalid Value Count" ); 00676 } 00677 return (float)entry->GetValue(1); 00678 } 00679 return 0.0f; 00680 }
|
|
Retrieve the number of lines of image.
Definition at line 414 of file gdcmFile.cxx. References gdcm::DocEntrySet::GetDataEntry(), gdcm::DataEntry::GetValue(), and gdcm::Document::IsDicomV3(). Referenced by gdcm::FileHelper::CheckWriteIntegrity(), and gdcm::PixelReadConvert::GrabInformationsFromFile(). 00415 { 00416 DataEntry *entry = GetDataEntry(0x0028,0x0010); 00417 if( entry ) 00418 return (int)entry->GetValue(0); 00419 00420 if ( IsDicomV3() ) 00421 { 00422 return 0; 00423 } 00424 00425 // The Rows (0028,0010) entry was optional for ACR/NEMA. 00426 // (at least some images didn't have it.) 00427 // It might hence be a signal (1D image). So we default to 1: 00428 return 1; 00429 }
|
|
gets the info from 0018,1164 : ImagerPixelSpacing then from 0028,0030 : Pixel Spacing else 1.0
Definition at line 525 of file gdcmFile.cxx. References gdcmWarningMacro, gdcm::DocEntrySet::GetDataEntry(), and gdcm::DataEntry::GetValue(). 00526 { 00527 float yspacing = 1.0; 00528 // To follow David Clunie's advice, we first check ImagerPixelSpacing 00529 00530 DataEntry *entry = GetDataEntry(0x0018,0x1164); 00531 if( entry ) 00532 { 00533 yspacing = (float)entry->GetValue(0); 00534 00535 if ( yspacing == 0.0 ) 00536 yspacing = 1.0; 00537 return yspacing; 00538 } 00539 else 00540 { 00541 gdcmWarningMacro( "Unfound Imager Pixel Spacing (0018,1164)" ); 00542 } 00543 00544 entry = GetDataEntry(0x0028,0x0030); 00545 if( entry ) 00546 { 00547 yspacing = (float)entry->GetValue(0); 00548 00549 if ( yspacing == 0.0 ) 00550 yspacing = 1.0; 00551 return yspacing; 00552 } 00553 else 00554 { 00555 gdcmWarningMacro( "Unfound Pixel Spacing (0028,0030)" ); 00556 } 00557 00558 return yspacing; 00559 }
|
|
gets the info from 0020,0032 : Image Position Patient else from 0020,0030 : Image Position (RET) else from 0020,1041 : Slice Location else from 0020,0050 : Location else 0.
Definition at line 690 of file gdcmFile.cxx. References gdcmErrorMacro, gdcmWarningMacro, gdcm::DocEntrySet::GetDataEntry(), gdcm::DataEntry::GetValue(), gdcm::DataEntry::GetValueCount(), and gdcm::DataEntry::IsValueCountValid(). 00691 { 00692 DataEntry *entry = GetDataEntry(0x0020,0x0032); 00693 if( entry ) 00694 { 00695 if( entry->GetValueCount() == 3 ) 00696 { 00697 if (!entry->IsValueCountValid() ) 00698 { 00699 gdcmErrorMacro( "Invalid Value Count" ); 00700 } 00701 return (float)entry->GetValue(2); 00702 } 00703 gdcmWarningMacro( "Wrong Image Position Patient (0020,0032)"); 00704 return 0.0f; 00705 } 00706 00707 entry = GetDataEntry(0x0020,0x0030); 00708 if( entry ) 00709 { 00710 if( entry->GetValueCount() == 3 ) 00711 { 00712 if (!entry->IsValueCountValid() ) 00713 { 00714 gdcmErrorMacro( "Invalid Value Count" ); 00715 } 00716 return (float)entry->GetValue(2); 00717 } 00718 gdcmWarningMacro( "Wrong Image Position (RET) (0020,0030)"); 00719 return 0.0f; 00720 } 00721 00722 // for *very* old ACR-NEMA images 00723 entry = GetDataEntry(0x0020,0x1041); 00724 if( entry ) 00725 { 00726 if( entry->GetValueCount() == 1 ) 00727 { 00728 if (!entry->IsValueCountValid() ) 00729 { 00730 gdcmErrorMacro( "Invalid Value Count" ); 00731 } 00732 return (float)entry->GetValue(0); // VM=1 ! 00733 } 00734 gdcmWarningMacro( "Wrong Slice Location (0020,1041)"); 00735 return 0.0f; 00736 } 00737 00738 entry = GetDataEntry(0x0020,0x0050); 00739 if( entry ) 00740 { 00741 if( entry->GetValueCount() == 1 ) 00742 { 00743 if (!entry->IsValueCountValid() ) 00744 { 00745 gdcmErrorMacro( "Invalid Value Count" ); 00746 } 00747 return (float)entry->GetValue(0); 00748 } 00749 gdcmWarningMacro( "Wrong Location (0020,0050)"); 00750 return 0.0f; 00751 } 00752 return 0.; // Hopeless 00753 }
|
|
Retrieve the number of planes of volume or the number of frames of a multiframe.
Definition at line 439 of file gdcmFile.cxx. References gdcm::DocEntrySet::GetDataEntry(), and gdcm::DataEntry::GetValue(). Referenced by gdcm::FileHelper::CheckWriteIntegrity(), and gdcm::PixelReadConvert::GrabInformationsFromFile(). 00440 { 00441 // Both DicomV3 and ACR/Nema consider the "Number of Frames" 00442 // as the third dimension. 00443 DataEntry *entry = GetDataEntry(0x0028,0x0008); 00444 if( entry ) 00445 return (int)entry->GetValue(0); 00446 00447 // We then consider the "Planes" entry as the third dimension 00448 entry = GetDataEntry(0x0028,0x0012); 00449 if( entry ) 00450 return (int)entry->GetValue(0); 00451 return 1; 00452 }
|
|
gets the info from 0018,0088 : Space Between Slices else from 0018,0050 : Slice Thickness else 1.0
Definition at line 567 of file gdcmFile.cxx. References gdcmWarningMacro, gdcm::DocEntrySet::GetDataEntry(), and gdcm::DataEntry::GetValue(). 00568 { 00569 // ---> 00570 // ---> Warning : 00571 // ---> 00572 // For *Dicom* images, ZSpacing should be calculated using 00573 // XOrigin, YOrigin, ZOrigin (of the top left image corner) 00574 // of 2 consecutive images, and the Orientation 00575 // 00576 // Computing ZSpacing on a single image is not really meaningfull ! 00577 00578 float zspacing = 1.0f; 00579 00580 // Spacing Between Slices : distance between the middle of 2 slices 00581 // Slices may be : 00582 // jointives (Spacing between Slices = Slice Thickness) 00583 // overlapping (Spacing between Slices < Slice Thickness) 00584 // disjointes (Spacing between Slices > Slice Thickness) 00585 // Slice Thickness : epaisseur de tissus sur laquelle est acquis le signal 00586 // It only concerns the MRI guys, not people wanting to visualize volumes 00587 // If Spacing Between Slices is missing, 00588 // we suppose slices joint together 00589 DataEntry *entry = GetDataEntry(0x0018,0x0088); 00590 if( entry ) 00591 { 00592 zspacing = (float)entry->GetValue(0); 00593 00594 if ( zspacing == 0.0 ) 00595 zspacing = 1.0; 00596 return zspacing; 00597 } 00598 else 00599 gdcmWarningMacro("Unfound Spacing Between Slices (0018,0088)"); 00600 00601 // if no 'Spacing Between Slices' is found, 00602 // we assume slices join together 00603 // (no overlapping, no interslice gap) 00604 // if they don't, we're fucked up 00605 entry = GetDataEntry(0x0018,0x0050); 00606 if( entry ) 00607 { 00608 zspacing = (float)entry->GetValue(0); 00609 00610 if ( zspacing == 0.0 ) 00611 zspacing = 1.0; 00612 return zspacing; 00613 } 00614 else 00615 gdcmWarningMacro("Unfound Slice Thickness (0018,0050)"); 00616 00617 return zspacing; 00618 }
|
|
tells us if LUT are used
Definition at line 1069 of file gdcmFile.cxx. References gdcm::ElementSet::GetDocEntry(). Referenced by gdcm::FileHelper::CheckWriteIntegrity(), gdcm::FileHelper::GetImageData(), GetNumberOfScalarComponents(), gdcm::PixelReadConvert::GrabInformationsFromFile(), and gdcm::FileHelper::SetWriteToRaw(). 01070 { 01071 // Check the presence of the LUT Descriptors, and LUT Tables 01072 // LutDescriptorRed 01073 if ( !GetDocEntry(0x0028,0x1101) ) 01074 { 01075 return false; 01076 } 01077 // LutDescriptorGreen 01078 if ( !GetDocEntry(0x0028,0x1102) ) 01079 { 01080 return false; 01081 } 01082 // LutDescriptorBlue 01083 if ( !GetDocEntry(0x0028,0x1103) ) 01084 { 01085 return false; 01086 } 01087 // Red Palette Color Lookup Table Data 01088 if ( !GetDocEntry(0x0028,0x1201) ) 01089 { 01090 return false; 01091 } 01092 // Green Palette Color Lookup Table Data 01093 if ( !GetDocEntry(0x0028,0x1202) ) 01094 { 01095 return false; 01096 } 01097 // Blue Palette Color Lookup Table Data 01098 if ( !GetDocEntry(0x0028,0x1203) ) 01099 { 01100 return false; 01101 } 01102 01103 // FIXME : (0x0028,0x3006) : LUT Data (CTX dependent) 01104 // NOT taken into account, but we don't know how to use it ... 01105 return true; 01106 }
|
|
Modifies the value of a given Header Entry (Dicom Element) when it exists. Create it with the given value when unexistant. A copy of the binArea is made to be kept in the Document.
Definition at line 308 of file gdcmDocEntrySet.cxx. References gdcm::DocEntrySet::AddEntry(), gdcm::RefCounter::Delete(), gdcmWarningMacro, gdcm::DocEntrySet::GetDocEntry(), gdcm::DocEntry::GetVR(), gdcm::DocEntrySet::NewDataEntry(), gdcm::DocEntrySet::RemoveEntry(), and gdcm::DocEntrySet::SetEntryBinArea(). Referenced by gdcm::FileHelper::InsertEntryBinArea(). 00311 { 00312 DataEntry *dataEntry = 0; 00313 DocEntry *currentEntry = GetDocEntry( group, elem ); 00314 00315 // Verify the currentEntry 00316 if (currentEntry) 00317 { 00318 dataEntry = dynamic_cast<DataEntry *>(currentEntry); 00319 00320 // Verify the VR 00321 if ( dataEntry ) 00322 if ( dataEntry->GetVR()!=vr ) 00323 dataEntry = NULL; 00324 00325 // if currentEntry doesn't correspond to the requested dataEntry 00326 if ( !dataEntry) 00327 { 00328 if ( !RemoveEntry(currentEntry) ) 00329 { 00330 gdcmWarningMacro( "Removal of previous DocEntry failed."); 00331 return NULL; 00332 } 00333 } 00334 } 00335 00336 // Create a new dataEntry if necessary 00337 if ( !dataEntry) 00338 { 00339 dataEntry = NewDataEntry(group, elem, vr); 00340 00341 if ( !AddEntry(dataEntry) ) 00342 { 00343 gdcmWarningMacro( "AddEntry failed although this is a creation."); 00344 dataEntry->Delete(); 00345 return NULL; 00346 } 00347 dataEntry->Delete(); 00348 } 00349 00350 // Set the dataEntry value 00351 uint8_t *tmpArea; 00352 if ( lgth>0 && binArea ) 00353 { 00354 tmpArea = new uint8_t[lgth]; 00355 memcpy(tmpArea,binArea,lgth); 00356 } 00357 else 00358 { 00359 tmpArea = 0; 00360 } 00361 if ( !SetEntryBinArea(tmpArea,lgth,dataEntry) ) 00362 { 00363 if ( tmpArea ) 00364 { 00365 delete[] tmpArea; 00366 } 00367 } 00368 00369 return dataEntry; 00370 }
|
|
Modifies the value of a given Doc Entry (Dicom Element) when it exists. Create it with the given value when unexistant.
Definition at line 250 of file gdcmDocEntrySet.cxx. References gdcm::DocEntrySet::AddEntry(), gdcm::RefCounter::Delete(), gdcmWarningMacro, gdcm::DocEntrySet::GetDocEntry(), gdcm::DocEntry::GetVR(), gdcm::DocEntrySet::NewDataEntry(), gdcm::DocEntrySet::RemoveEntry(), and gdcm::DocEntrySet::SetEntryString(). Referenced by gdcm::FileHelper::InsertEntryString(), gdcm::FileHelper::Write(), and Write(). 00253 { 00254 DataEntry *dataEntry = 0; 00255 DocEntry *currentEntry = GetDocEntry( group, elem ); 00256 00257 if (currentEntry) 00258 { 00259 dataEntry = dynamic_cast<DataEntry *>(currentEntry); 00260 00261 // Verify the VR 00262 if ( dataEntry ) 00263 if ( dataEntry->GetVR()!=vr ) 00264 dataEntry = NULL; 00265 00266 // if currentEntry doesn't correspond to the requested dataEntry 00267 if ( !dataEntry) 00268 { 00269 if ( !RemoveEntry(currentEntry) ) 00270 { 00271 gdcmWarningMacro( "Removal of previous DocEntry failed."); 00272 return NULL; 00273 } 00274 } 00275 } 00276 00277 // Create a new dataEntry if necessary 00278 if ( !dataEntry ) 00279 { 00280 dataEntry = NewDataEntry( group, elem, vr ); 00281 00282 if ( !AddEntry(dataEntry) ) 00283 { 00284 gdcmWarningMacro("AddEntry failed although this is a creation."); 00285 dataEntry->Delete(); 00286 return NULL; 00287 } 00288 dataEntry->Delete(); 00289 } 00290 00291 // Set the dataEntry value 00292 SetEntryString(value, dataEntry); // The std::string value 00293 return dataEntry; 00294 }
|
|
Modifies the value of a given Doc Entry (Dicom Element) when it exists. Creates it when unexistant.
Definition at line 380 of file gdcmDocEntrySet.cxx. References gdcm::DocEntrySet::AddEntry(), gdcm::RefCounter::Delete(), gdcmWarningMacro, gdcm::DocEntrySet::GetDocEntry(), gdcm::DocEntrySet::NewSeqEntry(), and gdcm::DocEntrySet::RemoveEntry(). Referenced by gdcm::FileHelper::InsertSeqEntry(). 00381 { 00382 SeqEntry *seqEntry = 0; 00383 DocEntry *currentEntry = GetDocEntry( group, elem ); 00384 00385 // Verify the currentEntry 00386 if ( currentEntry ) 00387 { 00388 seqEntry = dynamic_cast<SeqEntry *>(currentEntry); 00389 00390 // Verify the VR 00391 if ( seqEntry ) 00392 seqEntry = NULL; 00393 00394 // if currentEntry doesn't correspond to the requested seqEntry 00395 if ( !seqEntry ) 00396 { 00397 if (!RemoveEntry(currentEntry)) 00398 { 00399 gdcmWarningMacro( "Removal of previous DocEntry failed."); 00400 00401 return NULL; 00402 } 00403 } 00404 } 00405 // Create a new seqEntry if necessary 00406 if ( !seqEntry ) 00407 { 00408 seqEntry = NewSeqEntry(group, elem); 00409 00410 if ( !AddEntry(seqEntry) ) 00411 { 00412 gdcmWarningMacro( "AddEntry failed although this is a creation."); 00413 seqEntry->Delete(); 00414 return NULL; 00415 } 00416 seqEntry->Delete(); 00417 } 00418 00419 // TODO : Find a trick to insert a SequenceDelimitationItem 00420 // in the SeqEntry, at the end. 00421 return seqEntry; 00422 }
|
|
Predicate for dicom version 3 file.
Definition at line 372 of file gdcmDocument.cxx. References gdcm::ElementSet::GetDocEntry(). Referenced by GetYSize(), and gdcm::PixelReadConvert::GrabInformationsFromFile(). 00373 { 00374 // Checking if Transfer Syntax exists is enough 00375 // Anyway, it's too late check if the 'Preamble' was found ... 00376 // And ... would it be a rich idea to check ? 00377 // (some 'no Preamble' DICOM images exist !) 00378 return GetDocEntry(0x0002, 0x0010) != NULL; 00379 }
|
|
Tells us if the ElementSet contains no entry.
Implements gdcm::DocEntrySet. Definition at line 60 of file gdcmElementSet.h. Referenced by gdcm::Document::DoTheLoadingDocumentJob(), and gdcm::Document::IsParsable(). 00060 { return TagHT.empty(); }
|
|
Check whether this a monochrome picture (gray levels) or not, using "Photometric Interpretation" tag (0x0028,0x0004).
Definition at line 987 of file gdcmFile.cxx. References gdcm::Util::DicomStringEqual(), gdcm::GDCM_UNFOUND, gdcmWarningMacro, and gdcm::DocEntrySet::GetEntryString(). Referenced by gdcm::PixelReadConvert::GrabInformationsFromFile(). 00988 { 00989 const std::string &PhotometricInterp = GetEntryString( 0x0028, 0x0004 ); 00990 if ( Util::DicomStringEqual(PhotometricInterp, "MONOCHROME1") 00991 || Util::DicomStringEqual(PhotometricInterp, "MONOCHROME2") ) 00992 { 00993 return true; 00994 } 00995 if ( PhotometricInterp == GDCM_UNFOUND ) 00996 { 00997 gdcmWarningMacro( "Photometric Interpretation (0028,0004) supposed to be " 00998 << "mandatory"); 00999 } 01000 return false; 01001 }
|
|
Check whether this a MONOCHROME1 picture (high values = dark) or not using "Photometric Interpretation" tag (0x0028,0x0004).
Definition at line 1008 of file gdcmFile.cxx. References gdcm::Util::DicomStringEqual(), gdcm::GDCM_UNFOUND, gdcmWarningMacro, and gdcm::DocEntrySet::GetEntryString(). Referenced by gdcm::PixelReadConvert::GrabInformationsFromFile(). 01009 { 01010 const std::string &PhotometricInterp = GetEntryString( 0x0028, 0x0004 ); 01011 if ( Util::DicomStringEqual(PhotometricInterp, "MONOCHROME1") ) 01012 { 01013 return true; 01014 } 01015 if ( PhotometricInterp == GDCM_UNFOUND ) 01016 { 01017 gdcmWarningMacro( "Photometric Interpretation (0028,0004) : supposed to" 01018 << " be mandatory! "); 01019 } 01020 return false; 01021 }
|
|
Check whether this a "PALETTE COLOR" picture or not by accessing the "Photometric Interpretation" tag ( 0x0028, 0x0004 ).
Definition at line 1028 of file gdcmFile.cxx. References gdcm::GDCM_UNFOUND, gdcmDebugMacro, and gdcm::DocEntrySet::GetEntryString(). Referenced by gdcm::PixelReadConvert::GrabInformationsFromFile(). 01029 { 01030 std::string PhotometricInterp = GetEntryString( 0x0028, 0x0004 ); 01031 if ( PhotometricInterp == "PALETTE COLOR " ) 01032 { 01033 return true; 01034 } 01035 if ( PhotometricInterp == GDCM_UNFOUND ) 01036 { 01037 gdcmDebugMacro( "Not found : Palette color (0028,0004)"); 01038 } 01039 return false; 01040 }
|
|
Predicate for Papyrus file Dedicated to whomsoever it may concern.
Definition at line 386 of file gdcmDocument.cxx. References gdcm::ElementSet::GetDocEntry(). 00387 { 00388 // check for Papyrus private Sequence 00389 DocEntry *e = GetDocEntry(0x0041, 0x1050); 00390 if ( !e ) 00391 return false; 00392 // check if it's actually a Sequence 00393 if ( !dynamic_cast<SeqEntry*>(e) ) 00394 return false; 00395 return true; 00396 }
|
|
This predicate tells us whether or not the current Document was properly parsed and contains at least *one* Dicom Element (and nothing more, sorry).
Definition at line 340 of file gdcmDocument.cxx. References gdcm::Document::Filetype, gdcmWarningMacro, gdcm::Document::GetFileName(), gdcm::ElementSet::IsEmpty(), and gdcm::Unknown. Referenced by gdcm::Document::IsReadable(). 00341 { 00342 if ( Filetype == Unknown ) 00343 { 00344 gdcmWarningMacro( "Wrong filetype for " << GetFileName()); 00345 return false; 00346 } 00347 00348 if ( IsEmpty() ) 00349 { 00350 gdcmWarningMacro( "No tag in internal hash table."); 00351 return false; 00352 } 00353 00354 return true; 00355 }
|
|
This predicate, based on hopefully reasonable heuristics, decides whether or not the current File was properly parsed and contains the mandatory information for being considered as a well formed and usable Dicom/Acr File.
Reimplemented from gdcm::Document. Definition at line 258 of file gdcmFile.cxx. References gdcm::GDCM_UNFOUND, gdcmWarningMacro, gdcm::ElementSet::GetDocEntry(), gdcm::DocEntrySet::GetEntryString(), GrPixel, gdcm::Document::IsReadable(), and NumPixel. Referenced by gdcm::SerieHelper::AddFileName(), gdcm::DicomDir::CreateDicomDirChainedList(), gdcm::FileHelper::FileHelper(), and gdcm::FileHelper::Print(). 00259 { 00260 if ( !Document::IsReadable() ) 00261 { 00262 return false; 00263 } 00264 00265 const std::string &res = GetEntryString(0x0028, 0x0005); 00266 if ( res != GDCM_UNFOUND && atoi(res.c_str()) > 4 ) 00267 { 00268 gdcmWarningMacro("Wrong Image Dimensions" << res); 00269 return false; // Image Dimensions 00270 } 00271 bool b0028_0100 = true; 00272 if ( !GetDocEntry(0x0028, 0x0100) ) 00273 { 00274 gdcmWarningMacro("Bits Allocated (0028|0100) not found"); 00275 //return false; // "Bits Allocated" 00276 b0028_0100 = false; 00277 } 00278 bool b0028_0101 = true; 00279 if ( !GetDocEntry(0x0028, 0x0101) ) 00280 { 00281 gdcmWarningMacro("Bits Stored (0028|0101) not found"); 00282 //return false; // "Bits Stored" 00283 b0028_0101 = false; 00284 } 00285 bool b0028_0102 = true; 00286 if ( !GetDocEntry(0x0028, 0x0102) ) 00287 { 00288 gdcmWarningMacro("Hight Bit (0028|0102) not found"); 00289 //return false; // "High Bit" 00290 b0028_0102 = false; 00291 } 00292 bool b0028_0103 = true; 00293 if ( !GetDocEntry(0x0028, 0x0103) ) 00294 { 00295 gdcmWarningMacro("Pixel Representation (0028|0103) not found"); 00296 //return false; // "Pixel Representation" i.e. 'Sign' ( 0 : unsigned, 1 : signed) 00297 b0028_0103 = false; 00298 } 00299 00300 if ( !b0028_0100 && !b0028_0101 && !b0028_0102 && !b0028_0103) 00301 { 00302 gdcmWarningMacro("Too much mandatory Tags missing !"); 00303 return false; 00304 } 00305 00306 if ( !GetDocEntry(GrPixel, NumPixel) ) 00307 { 00308 gdcmWarningMacro("Pixel Dicom Element " << std::hex << 00309 GrPixel << "|" << NumPixel << "not found"); 00310 return false; // Pixel Dicom Element not found :-( 00311 } 00312 return true; 00313 }
|
|
Check whether the pixels are signed (1) or UNsigned (0) data.
Definition at line 970 of file gdcmFile.cxx. References gdcmWarningMacro, gdcm::DocEntrySet::GetDataEntry(), and gdcm::DataEntry::GetValue(). Referenced by GetPixelType(), and gdcm::PixelReadConvert::GrabInformationsFromFile(). 00971 { 00972 DataEntry *entry = GetDataEntry(0x0028, 0x0103);//"Pixel Representation" 00973 if( !entry ) 00974 { 00975 gdcmWarningMacro( "Pixel Representation (0028,0103) supposed to be " 00976 << "mandatory"); 00977 return false; 00978 } 00979 return entry->GetValue(0) != 0; 00980 }
|
|
Check whether this a "YBR_FULL" color picture or not by accessing the "Photometric Interpretation" tag ( 0x0028, 0x0004 ).
Definition at line 1047 of file gdcmFile.cxx. References gdcm::GDCM_UNFOUND, gdcmDebugMacro, and gdcm::DocEntrySet::GetEntryString(). Referenced by gdcm::PixelReadConvert::GrabInformationsFromFile(). 01048 { 01049 std::string PhotometricInterp = GetEntryString( 0x0028, 0x0004 ); 01050 if ( PhotometricInterp == "YBR_FULL" ) 01051 { 01052 return true; 01053 } 01054 if ( PhotometricInterp == GDCM_UNFOUND ) 01055 { 01056 gdcmDebugMacro( "Not found : YBR Full (0028,0004)"); 01057 } 01058 return false; 01059 }
|
|
Loader. (DEPRECATED : not to break the API).
Definition at line 99 of file gdcmDocument.cxx. References gdcm::Document::DoTheLoadingDocumentJob(), and gdcm::Document::Filename. 00100 { 00101 Filename = fileName; 00102 return DoTheLoadingDocumentJob( ); 00103 }
|
|
Loader.
Reimplemented from gdcm::Document. Definition at line 143 of file gdcmFile.cxx. References DoTheLoadingJob(). Referenced by gdcm::SerieHelper::AddFileName(), gdcm::DicomDir::CreateDicomDirChainedList(), and gdcm::FileHelper::Load(). 00144 { 00145 if ( ! this->Document::Load( ) ) 00146 return false; 00147 00148 return DoTheLoadingJob( ); 00149 }
|
|
Loads the element while preserving the current underlying file position indicator as opposed to LoadDocEntry that modifies it.
Definition at line 822 of file gdcmDocument.cxx. References gdcm::Document::Fp, and gdcm::Document::LoadDocEntry(). Referenced by gdcm::Document::GetTransferSyntax(). 00823 { 00824 if ( Fp ) 00825 { 00826 long PositionOnEntry = Fp->tellg(); 00827 LoadDocEntry(entry); 00828 Fp->seekg(PositionOnEntry, std::ios::beg); 00829 } 00830 }
|
|
Loads (from disk) the element content when a string is not suitable.
Definition at line 741 of file gdcmDocument.cxx. References gdcm::Document::CloseFile(), gdcm::Document::Fp, gdcmWarningMacro, gdcm::VR::GetAtomicElementLength(), gdcm::DataEntry::GetBinArea(), gdcm::DocEntry::GetElement(), gdcm::DocEntry::GetGroup(), gdcm::DocEntry::GetLength(), gdcm::DocEntry::GetOffset(), gdcm::DocEntry::GetVR(), gdcm::Global::GetVR(), gdcm::Document::OpenFile(), gdcm::DataEntry::SetBinArea(), gdcm::DataEntry::SetState(), gdcm::DataEntry::STATE_UNREAD, gdcm::Document::SwapDouble(), gdcm::Document::SwapLong(), and gdcm::Document::SwapShort(). 00742 { 00743 if( entry->GetBinArea() ) 00744 return; 00745 00746 bool openFile = !Fp; 00747 if ( openFile ) 00748 OpenFile(); 00749 00750 size_t o =(size_t)entry->GetOffset(); 00751 Fp->seekg(o, std::ios::beg); 00752 00753 size_t l = entry->GetLength(); 00754 uint8_t *data = new uint8_t[l]; 00755 if ( !data ) 00756 { 00757 gdcmWarningMacro( "Cannot allocate DataEntry content for : " 00758 << std::hex << entry->GetGroup() 00759 << "|" << entry->GetElement() ); 00760 return; 00761 } 00762 00763 // Read the data 00764 Fp->read((char*)data, l); 00765 if ( Fp->fail() || Fp->eof() ) 00766 { 00767 delete[] data; 00768 entry->SetState(DataEntry::STATE_UNREAD); 00769 return; 00770 } 00771 00772 // Swap the data content if necessary 00773 uint32_t i; 00774 unsigned short vrLgth = 00775 Global::GetVR()->GetAtomicElementLength(entry->GetVR()); 00776 00777 // FIXME : trouble expected if we read an ... OW Entry (LUT, etc ..) 00778 // if( entry->GetVR() == "OW" ) 00779 // vrLgth = 1; 00780 00781 switch(vrLgth) 00782 { 00783 case 1: 00784 { 00785 break; 00786 } 00787 case 2: 00788 { 00789 uint16_t *data16 = (uint16_t *)data; 00790 for(i=0;i<l/vrLgth;i++) 00791 data16[i] = SwapShort(data16[i]); 00792 break; 00793 } 00794 case 4: 00795 { 00796 uint32_t *data32 = (uint32_t *)data; 00797 for(i=0;i<l/vrLgth;i++) 00798 data32[i] = SwapLong(data32[i]); 00799 break; 00800 } 00801 case 8: 00802 { 00803 double *data64 = (double *)data; 00804 for(i=0;i<l/vrLgth;i++) 00805 data64[i] = SwapDouble(data64[i]); 00806 break; 00807 } 00808 } 00809 00810 entry->SetBinArea(data); 00811 00812 if ( openFile ) 00813 CloseFile(); 00814 }
|
|
Loads (from disk) the element content when a string is not suitable.
Definition at line 716 of file gdcmDocument.cxx. References gdcmDebugMacro, gdcmWarningMacro, and gdcm::ElementSet::GetDocEntry(). Referenced by gdcm::Document::DoTheLoadingDocumentJob(), gdcm::PixelReadConvert::GrabInformationsFromFile(), and gdcm::Document::LoadDocEntry(). 00717 { 00718 // Search the corresponding DocEntry 00719 DocEntry *docEntry = GetDocEntry(group, elem); 00720 if ( !docEntry ) 00721 { 00722 gdcmDebugMacro(std::hex << group << "|" << elem 00723 << " doesn't exist" ); 00724 return; 00725 } 00726 DataEntry *dataEntry = dynamic_cast<DataEntry *>(docEntry); 00727 if ( !dataEntry ) 00728 { 00729 gdcmWarningMacro(std::hex << group << "|" << elem 00730 << " is NOT a DataEntry"); 00731 return; 00732 } 00733 LoadEntryBinArea(dataEntry); 00734 }
|
|
Protect the Writer from writing illegal groups.
Reimplemented from gdcm::ElementSet. Definition at line 181 of file gdcmFile.h.
|
|
Definition at line 104 of file gdcmFile.h. Referenced by gdcm::SerieHelper::AddFileName(), gdcm::DicomDir::CreateDicomDirChainedList(), and gdcm::FileHelper::FileHelper(). 00104 {return new File();}
|
|
Build a new Val Entry from all the low level arguments. Check for existence of dictionary entry, and build a default one when absent.
Definition at line 444 of file gdcmDocEntrySet.cxx. References gdcmWarningMacro, gdcm::DocEntrySet::GetDictEntry(), gdcm::DataEntry::New(), and gdcm::RefCounter::Unregister(). Referenced by gdcm::FileHelper::CopyDataEntry(), gdcm::DocEntrySet::InsertEntryBinArea(), gdcm::DocEntrySet::InsertEntryString(), and gdcm::Document::ReadNextDocEntry(). 00446 { 00447 DictEntry *dictEntry = GetDictEntry(group, elem, vr); 00448 00449 DataEntry *newEntry = DataEntry::New(dictEntry); 00450 dictEntry->Unregister(); // GetDictEntry register it 00451 if (!newEntry) 00452 { 00453 gdcmWarningMacro( "Failed to allocate DataEntry"); 00454 return 0; 00455 } 00456 return newEntry; 00457 }
|
|
Build a new Seq Entry from all the low level arguments. Check for existence of dictionary entry, and build a default one when absent.
Definition at line 467 of file gdcmDocEntrySet.cxx. References gdcmWarningMacro, gdcm::DocEntrySet::GetDictEntry(), gdcm::SeqEntry::New(), and gdcm::RefCounter::Unregister(). Referenced by gdcm::Document::Backtrack(), gdcm::DocEntrySet::InsertSeqEntry(), and gdcm::Document::ReadNextDocEntry(). 00468 { 00469 DictEntry *dictEntry = GetDictEntry(group, elem, "SQ"); 00470 00471 SeqEntry *newEntry = SeqEntry::New( dictEntry ); 00472 dictEntry->Unregister(); // GetDictEntry register it 00473 if (!newEntry) 00474 { 00475 gdcmWarningMacro( "Failed to allocate SeqEntry"); 00476 return 0; 00477 } 00478 return newEntry; 00479 }
|
|
Tries to open the file Document::Filename and checks the preamble when existing.
Definition at line 572 of file gdcmDocument.cxx. References gdcm::Document::CloseFile(), gdcm::Document::Filename, gdcm::Util::Format(), gdcm::Document::Fp, gdcmDebugMacro, gdcmWarningMacro, and gdcm::Document::HasDCMPreamble. Referenced by gdcm::Document::DoTheLoadingDocumentJob(), DoTheLoadingJob(), gdcm::FileHelper::GetRaw(), and gdcm::Document::LoadEntryBinArea(). 00573 { 00574 HasDCMPreamble = false; 00575 if (Filename.length() == 0) 00576 { 00577 return 0; 00578 } 00579 00580 if ( Fp ) 00581 { 00582 gdcmDebugMacro( "File already open: " << Filename.c_str()); 00583 CloseFile(); 00584 } 00585 00586 Fp = new std::ifstream(Filename.c_str(), std::ios::in | std::ios::binary); 00587 if ( ! *Fp ) 00588 { 00589 // Don't user gdcmErrorMacro : 00590 // a spurious message will appear when you use, for instance 00591 // gdcm::FileHelper *fh = new gdcm::FileHelper( outputFileName ); 00592 // to create outputFileName. 00593 00594 // FIXME : if the upper comment is still usefull 00595 // --> the constructor is not so good ... 00596 00597 gdcmWarningMacro( "Cannot open file: " << Filename.c_str()); 00598 delete Fp; 00599 Fp = 0; 00600 return 0; 00601 //exit(1); // No function is allowed to leave the application instead 00602 // of warning the caller 00603 } 00604 00605 uint16_t zero = 0; 00606 Fp->read((char*)&zero, (size_t)2); 00607 if ( Fp->eof() ) 00608 { 00609 CloseFile(); 00610 return 0; 00611 } 00612 00613 //-- Broken ACR or DICOM with no Preamble; may start with a Shadow Group -- 00614 00615 // FIXME : We cannot be sure the preable is only zeroes.. 00616 // (see ACUSON-24-YBR_FULL-RLE.dcm ) 00617 if ( 00618 zero == 0x0001 || zero == 0x0100 || zero == 0x0002 || zero == 0x0200 || 00619 zero == 0x0003 || zero == 0x0300 || zero == 0x0004 || zero == 0x0400 || 00620 zero == 0x0005 || zero == 0x0500 || zero == 0x0006 || zero == 0x0600 || 00621 zero == 0x0007 || zero == 0x0700 || zero == 0x0008 || zero == 0x0800 ) 00622 { 00623 std::string msg = Util::Format( 00624 "ACR/DICOM starting by 0x(%04x) at the beginning of the file\n", zero); 00625 // FIXME : is it a Warning message, or a Debug message? 00626 gdcmWarningMacro( msg.c_str() ); 00627 return Fp; 00628 } 00629 00630 //-- DICOM -- 00631 Fp->seekg(126L, std::ios::cur); 00632 char dicm[4]; // = {' ',' ',' ',' '}; 00633 Fp->read(dicm, (size_t)4); 00634 if ( Fp->eof() ) 00635 { 00636 CloseFile(); 00637 return 0; 00638 } 00639 if ( memcmp(dicm, "DICM", 4) == 0 ) 00640 { 00641 HasDCMPreamble = true; 00642 return Fp; 00643 } 00644 00645 // -- Neither ACR/No Preamble Dicom nor DICOMV3 file 00646 CloseFile(); 00647 // Don't user Warning nor Error, not to polute the output 00648 // while directory recursive parsing ... 00649 gdcmDebugMacro( "Neither ACR/No Preamble Dicom nor DICOMV3 file: " 00650 << Filename.c_str()); 00651 return 0; 00652 }
|
|
Compares two documents, according to DicomDir rules.
Definition at line 839 of file gdcmDocument.cxx. References gdcm::DocEntrySet::GetEntryString(). 00840 { 00841 // Patient Name 00842 std::string s1 = GetEntryString(0x0010,0x0010); 00843 std::string s2 = document.GetEntryString(0x0010,0x0010); 00844 if (s1 < s2) 00845 { 00846 return true; 00847 } 00848 else if ( s1 > s2 ) 00849 { 00850 return false; 00851 } 00852 else 00853 { 00854 // Patient ID 00855 s1 = GetEntryString(0x0010,0x0020); 00856 s2 = document.GetEntryString(0x0010,0x0020); 00857 if ( s1 < s2 ) 00858 { 00859 return true; 00860 } 00861 else if ( s1 > s2 ) 00862 { 00863 return false; 00864 } 00865 else 00866 { 00867 // Study Instance UID 00868 s1 = GetEntryString(0x0020,0x000d); 00869 s2 = document.GetEntryString(0x0020,0x000d); 00870 if ( s1 < s2 ) 00871 { 00872 return true; 00873 } 00874 else if ( s1 > s2 ) 00875 { 00876 return false; 00877 } 00878 else 00879 { 00880 // Serie Instance UID 00881 s1 = GetEntryString(0x0020,0x000e); 00882 s2 = document.GetEntryString(0x0020,0x000e); 00883 if ( s1 < s2 ) 00884 { 00885 return true; 00886 } 00887 else if ( s1 > s2 ) 00888 { 00889 return false; 00890 } 00891 } 00892 } 00893 } 00894 return false; 00895 }
|
|
Prints the Header Entries (Dicom Elements) from the H Table.
Reimplemented from gdcm::Base. Reimplemented in gdcm::DicomDir. Definition at line 186 of file gdcmElementSet.cxx. References gdcm::DataEntry::FLAG_PIXELDATA, gdcm::DocEntrySet::GetDataEntry(), gdcm::DocEntry::Print(), gdcm::Base::PrintLevel, gdcm::DataEntry::SetFlag(), gdcm::Base::SetPrintLevel(), and gdcm::ElementSet::TagHT. Referenced by gdcm::FileHelper::Print(). 00187 { 00188 // Let's change the 'warning value' for Pixel Data, 00189 // to avoid human reader to be confused by 'gdcm::NotLoaded'. 00190 DataEntry *pixelElement = GetDataEntry(0x7fe0,0x0010); 00191 if ( pixelElement != 0 ) 00192 { 00193 pixelElement->SetFlag( DataEntry::FLAG_PIXELDATA ); 00194 } 00195 00196 for( TagDocEntryHT::const_iterator i = TagHT.begin(); i != TagHT.end(); ++i) 00197 { 00198 DocEntry *entry = i->second; 00199 00200 entry->SetPrintLevel(PrintLevel); 00201 entry->Print(os); 00202 00203 if ( dynamic_cast<SeqEntry *>(entry) ) 00204 { 00205 // Avoid the newline for a sequence: 00206 continue; 00207 } 00208 os << std::endl; 00209 } 00210 }
|
|
When parsing the Pixel Data of an encapsulated file, read the basic offset table (when present, and BTW dump it).
Definition at line 1781 of file gdcmFile.cxx. References BasicOffsetTableItemValue, gdcm::Document::Fp, gdcmDebugMacro, and ReadTagLength(). Referenced by ComputeJPEGFragmentInfo(), and ComputeRLEInfo(). 01782 { 01784 uint32_t itemLength = ReadTagLength(0xfffe, 0xe000); 01785 01786 // When present, read the basic offset table itself. 01787 // Notes: - since the presence of this basic offset table is optional 01788 // we can't rely on it for the implementation, and we will simply 01789 // trash it's content (when present). 01790 // - still, when present, we could add some further checks on the 01791 // lengths, but we won't bother with such fuses for the time being. 01792 if ( itemLength != 0 ) 01793 { 01794 char *charBasicOffsetTableItemValue = new char[itemLength]; 01795 Fp->read(charBasicOffsetTableItemValue, itemLength); 01796 unsigned int nbEntries = itemLength/4; 01797 assert( nbEntries*4 == itemLength); // Make sure this is a multiple 01798 BasicOffsetTableItemValue = new uint32_t[nbEntries]; 01799 01800 for (unsigned int i=0; i < nbEntries; i++ ) 01801 { 01802 BasicOffsetTableItemValue[i] = *((uint32_t*)(&charBasicOffsetTableItemValue[4*i])); 01803 #if defined(GDCM_WORDS_BIGENDIAN) || defined(GDCM_FORCE_BIGENDIAN_EMULATION) 01804 uint32_t val = BasicOffsetTableItemValue[i]; 01805 BasicOffsetTableItemValue[i] 01806 = ( (val<<24) | ((val<<8) & 0x00ff0000) | 01807 ( (val>>8) & 0x0000ff00) | (val>>24) ); 01808 #endif 01809 gdcmDebugMacro( "Read one length for: " << 01810 std::hex << BasicOffsetTableItemValue[i] ); 01811 } 01812 01813 delete[] charBasicOffsetTableItemValue; 01814 } 01815 }
|
|
Reads a supposed to be 16 Bits integer (swaps it depending on processor endianness).
Definition at line 904 of file gdcmDocument.cxx. References gdcm::Document::Fp, and gdcm::Document::SwapShort(). Referenced by gdcm::Document::FindDocEntryLengthOBOrOW(), gdcm::Document::ReadNextDocEntry(), and ReadTag(). 00906 { 00907 uint16_t g; 00908 Fp->read ((char*)&g, (size_t)2); 00909 if ( Fp->fail() ) 00910 { 00911 throw FormatError( "Document::ReadInt16()", " file error." ); 00912 } 00913 if ( Fp->eof() ) 00914 { 00915 throw FormatError( "Document::ReadInt16()", "EOF." ); 00916 } 00917 g = SwapShort(g); 00918 return g; 00919 }
|
|
Reads a supposed to be 32 Bits integer (swaps it depending on processor endianness).
Definition at line 926 of file gdcmDocument.cxx. References gdcm::Document::Fp, and gdcm::Document::SwapLong(). Referenced by ComputeRLEInfo(), gdcm::Document::FindDocEntryLengthOBOrOW(), and ReadTagLength(). 00928 { 00929 uint32_t g; 00930 Fp->read ((char*)&g, (size_t)4); 00931 if ( Fp->fail() ) 00932 { 00933 throw FormatError( "Document::ReadInt32()", " file error." ); 00934 } 00935 if ( Fp->eof() ) 00936 { 00937 throw FormatError( "Document::ReadInt32()", "EOF." ); 00938 } 00939 g = SwapLong(g); 00940 return g; 00941 }
|
|
Assuming the internal file pointer Document::Fp is placed at the beginning of a tag, check whether this tag is (TestGroup, TestElem).
Definition at line 1700 of file gdcmFile.cxx. References gdcm::Document::Fp, gdcmErrorMacro, gdcmWarningMacro, gdcm::Document::ReadInt16(), and gdcm::DicomEntry::TranslateToKey(). Referenced by ComputeJPEGFragmentInfo(), ComputeRLEInfo(), and ReadTagLength(). 01701 { 01702 long positionOnEntry = Fp->tellg(); 01703 long currentPosition = Fp->tellg(); // On debugging purposes 01704 01705 // Read the Item Tag group and element, and make 01706 // sure they are what we expected: 01707 uint16_t itemTagGroup; 01708 uint16_t itemTagElem; 01709 try 01710 { 01711 itemTagGroup = ReadInt16(); 01712 itemTagElem = ReadInt16(); 01713 } 01714 catch ( FormatError ) 01715 { 01716 gdcmErrorMacro( "Can not read tag for " 01717 << " We should have found tag (" 01718 << DictEntry::TranslateToKey(testGroup,testElem) << ")" 01719 ) ; 01720 01721 return false; 01722 } 01723 if ( itemTagGroup != testGroup || itemTagElem != testElem ) 01724 { 01725 // in order not to pollute output we don't warn on 'delimitors' 01726 if (itemTagGroup != 0xfffe || testGroup != 0xfffe ) 01727 gdcmWarningMacro( "Wrong Item Tag found:" 01728 << " We should have found tag (" 01729 << DictEntry::TranslateToKey(testGroup,testElem) << ")" << std::endl 01730 << " but instead we encountered tag (" 01731 << DictEntry::TranslateToKey(itemTagGroup,itemTagElem) << ")" 01732 << " at address: " << " 0x(" << std::hex 01733 << (unsigned int)currentPosition << std::dec << ")" 01734 ) ; 01735 Fp->seekg(positionOnEntry, std::ios::beg); 01736 01737 return false; 01738 } 01739 return true; 01740 }
|
|
Assuming the internal file pointer Document::Fp is placed at the beginning of a tag (TestGroup, TestElement), read the length associated to the Tag.
Definition at line 1756 of file gdcmFile.cxx. References gdcm::Document::Fp, gdcmDebugMacro, gdcmErrorMacro, gdcm::Document::ReadInt32(), ReadTag(), and gdcm::DicomEntry::TranslateToKey(). Referenced by ComputeJPEGFragmentInfo(), ComputeRLEInfo(), and ReadEncapsulatedBasicOffsetTable(). 01757 { 01758 01759 if ( !ReadTag(testGroup, testElem) ) 01760 { 01761 // Avoid polutting output 01762 if ( testGroup != 0xfffe ) 01763 gdcmErrorMacro( "ReadTag did not succeed for (" 01764 << DictEntry::TranslateToKey(testGroup,testElem) 01765 << ")..." ); 01766 return 0; 01767 } 01768 01770 long currentPosition = Fp->tellg(); 01771 uint32_t itemLength = ReadInt32(); 01772 gdcmDebugMacro( "Basic Item Length is: " << itemLength 01773 << " at address: " << std::hex << (unsigned int)currentPosition); 01774 return itemLength; 01775 }
|
|
Register the object.
Definition at line 45 of file gdcmRefCounter.h. Referenced by gdcm::SQItem::AddEntry(), gdcm::ElementSet::AddEntry(), gdcm::Dict::AddEntry(), gdcm::SeqEntry::AddSQItem(), gdcm::DocEntry::DocEntry(), gdcm::FileHelper::FileHelper(), gdcm::DocEntrySet::GetDictEntry(), gdcm::DocEntryArchive::Push(), gdcm::Dict::ReplaceEntry(), and gdcm::SeqEntry::SetDelimitationItem(). 00045 { RefCount++; }
|
|
Clear the hash table from given entry AND delete the entry.
Implements gdcm::DocEntrySet. Definition at line 99 of file gdcmElementSet.cxx. References gdcmWarningMacro, gdcm::DocEntry::GetKey(), gdcm::ElementSet::TagHT, and gdcm::RefCounter::Unregister(). Referenced by gdcm::Document::Backtrack(), DoTheLoadingJob(), gdcm::DicomDir::NewMeta(), gdcm::Document::ParseDES(), gdcm::DocEntryArchive::Push(), and gdcm::DocEntryArchive::Restore(). 00100 { 00101 const TagKey &key = entryToRemove->GetKey(); 00102 if ( TagHT.count(key) == 1 ) 00103 { 00104 TagHT.erase(key); 00105 entryToRemove->Unregister(); 00106 return true; 00107 } 00108 00109 gdcmWarningMacro( "Key not present : " << key); 00110 return false ; 00111 }
|
|
Accesses an existing DataEntry (i.e. a Dicom Element) and modifies it's content with the given value.
Definition at line 229 of file gdcmDocEntrySet.cxx. References gdcm::DataEntry::SetBinArea(), and gdcm::DocEntry::SetLength(). 00230 { 00231 if (entry) 00232 { 00233 entry->SetLength(lgth); 00234 entry->SetBinArea(content); 00235 return true; 00236 } 00237 return false; 00238 }
|
|
Accesses an existing DocEntry (i.e. a Dicom Element) through it's (group, element) and modifies it's content with the given value.
Definition at line 192 of file gdcmDocEntrySet.cxx. References gdcmWarningMacro, and gdcm::DocEntrySet::GetDataEntry(). Referenced by gdcm::DocEntrySet::InsertEntryBinArea(), and gdcm::FileHelper::SetEntryBinArea(). 00194 { 00195 DataEntry *entry = GetDataEntry(group, elem); 00196 if (!entry ) 00197 { 00198 gdcmWarningMacro( "No corresponding DataEntry " << std::hex << group << 00199 "," << elem << " element (try promotion first)."); 00200 return false; 00201 } 00202 00203 return SetEntryBinArea(content,lgth,entry); 00204 }
|
|
Accesses an existing DocEntry (i.e. a Dicom Element) and modifies it's content with the given value.
Definition at line 212 of file gdcmDocEntrySet.cxx. References gdcm::DataEntry::SetString(). 00213 { 00214 if (entry) 00215 { 00216 entry->SetString(content); 00217 return true; 00218 } 00219 return false; 00220 }
|
|
Accesses an existing DocEntry (i.e. a Dicom Element) through it's (group, element) and modifies it's content with the given value.
Definition at line 170 of file gdcmDocEntrySet.cxx. References gdcmWarningMacro, and gdcm::DocEntrySet::GetDataEntry(). Referenced by AnonymizeFile(), gdcm::Document::DoTheLoadingDocumentJob(), gdcm::DocEntrySet::InsertEntryString(), and gdcm::FileHelper::SetEntryString(). 00172 { 00173 DataEntry *entry = GetDataEntry(group, elem); 00174 if (!entry ) 00175 { 00176 gdcmWarningMacro( "No corresponding DataEntry " << std::hex << group << 00177 "," << elem << " element (try promotion first)."); 00178 return false; 00179 } 00180 return SetEntryString(content,entry); 00181 }
|
|
Accessor to Filename.
Reimplemented in gdcm::DicomDir. Definition at line 76 of file gdcmDocument.h. Referenced by gdcm::SerieHelper::AddFileName(), gdcm::DicomDir::CreateDicomDirChainedList(), gdcm::Document::Document(), and gdcm::FileHelper::SetFileName(). 00077 { if (Filename != fileName) 00078 Filename = fileName, IsDocumentModified = true; }
|
|
Sets the LoadMode as a boolean string. LD_NOSEQ, LD_NOSHADOW, LD_NOSHADOWSEQ ... (nothing more, right now) WARNING : before using NO_SHADOW, be sure *all* your files contain accurate values in the 0x0000 element (if any) of *each* Shadow Group. The parser will fail if the size is wrong !
Definition at line 103 of file gdcmDocument.h. Referenced by gdcm::SerieHelper::AddFileName(), gdcm::DicomDir::CreateDicomDirChainedList(), and gdcm::FileHelper::SetLoadMode(). 00103 { if (LoadMode != mode) 00104 LoadMode=mode, IsDocumentModified = true; }
|
|
Sets the print level for the Dicom Header Elements.
Definition at line 47 of file gdcmBase.h. Referenced by gdcm::SQItem::Print(), gdcm::SeqEntry::Print(), gdcm::FileHelper::Print(), gdcm::ElementSet::Print(), and gdcm::DicomDir::Print(). 00047 { PrintLevel = level; }
|
|
Set the shadow dictionary used.
Definition at line 327 of file gdcmDocument.cxx. References gdcm::DictSet::GetDict(), gdcm::Global::GetDicts(), and gdcm::Document::RefShaDict. 00328 { 00329 RefShaDict = Global::GetDicts()->GetDict(dictName); 00330 return !RefShaDict; 00331 }
|
|
Set the shadow dictionary used.
Definition at line 317 of file gdcmDocument.cxx. References gdcm::Document::RefShaDict. 00318 { 00319 RefShaDict = dict; 00320 return !RefShaDict; 00321 }
|
|
skips bytes inside the source file
Definition at line 947 of file gdcmDocument.cxx. References gdcm::Document::Fp. Referenced by ComputeJPEGFragmentInfo(), ComputeRLEInfo(), gdcm::Document::FindDocEntryLengthOBOrOW(), and gdcm::Document::SkipDocEntry(). 00948 { 00949 //FIXME don't dump the returned value 00950 Fp->seekg((long)nBytes, std::ios::cur); 00951 }
|
|
Unregister the object.
Definition at line 49 of file gdcmRefCounter.h. Referenced by gdcm::SeqEntry::ClearSQItem(), gdcm::DocEntrySet::GetDictEntry(), gdcm::DocEntrySet::NewDataEntry(), gdcm::DocEntrySet::NewSeqEntry(), gdcm::Document::ReadNextDocEntry(), gdcm::SQItem::RemoveEntry(), gdcm::ElementSet::RemoveEntry(), gdcm::SeqEntry::SetDelimitationItem(), gdcm::DocEntry::~DocEntry(), and gdcm::FileHelper::~FileHelper().
|
|
Performs some consistency checking on various 'File related' (as opposed to 'DicomDir related') entries then writes in a file all the (Dicom Elements) included the Pixels.
Definition at line 1466 of file gdcmFile.cxx. References gdcm::Document::ComputeGroup0002Length(), gdcm::Util::DicomString(), gdcm::Util::Format(), gdcmWarningMacro, gdcm::DocEntrySet::GetDataEntry(), gdcm::DocEntrySet::GetEntryLength(), GrPixel, gdcm::DocEntrySet::InsertEntryString(), gdcm::JPEG, NumPixel, gdcm::DataEntry::SetString(), and gdcm::Document::WriteContent(). Referenced by gdcm::FileHelper::Write(). 01467 { 01468 std::ofstream *fp = new std::ofstream(fileName.c_str(), 01469 std::ios::out | std::ios::binary); 01470 if (*fp == NULL) 01471 { 01472 gdcmWarningMacro("Failed to open (write) File: " << fileName.c_str()); 01473 return false; 01474 } 01475 01476 // Entry : 0002|0000 = group length -> recalculated 01477 DataEntry *e0000 = GetDataEntry(0x0002,0x0000); 01478 if ( e0000 ) 01479 { 01480 std::ostringstream sLen; 01481 sLen << ComputeGroup0002Length( ); 01482 e0000->SetString(sLen.str()); 01483 } 01484 01485 // FIXME : Derma?.dcm does not have it...let's remove it ?!? JPRx 01486 if( writetype != JPEG ) 01487 { 01488 int i_lgPix = GetEntryLength(GrPixel, NumPixel); 01489 if (i_lgPix != -2) 01490 { 01491 // no (GrPixel, NumPixel) element 01492 std::string s_lgPix = Util::Format("%d", i_lgPix+12); 01493 s_lgPix = Util::DicomString( s_lgPix.c_str() ); 01494 InsertEntryString(s_lgPix,GrPixel, 0x0000); 01495 } 01496 } 01497 Document::WriteContent(fp, writetype); 01498 01499 fp->close(); 01500 delete fp; 01501 01502 return true; 01503 }
|
|
Writes in a file all the Entries (Dicom Elements).
Reimplemented from gdcm::ElementSet. Definition at line 675 of file gdcmDocument.cxx. References gdcm::ExplicitVR, gdcm::ImplicitVR, gdcm::JPEG, and gdcm::ElementSet::WriteContent(). Referenced by Write(). 00676 { 00677 // Skip if user wants to write an ACR-NEMA file 00678 00679 if ( filetype == ImplicitVR || filetype == ExplicitVR || 00680 filetype == JPEG ) 00681 { 00682 // writing Dicom File Preamble 00683 char filePreamble[128]; 00684 memset(filePreamble, 0, 128); 00685 fp->write(filePreamble, 128); 00686 fp->write("DICM", 4); 00687 } 00688 00689 /* 00690 * \todo rewrite later, if really usefull 00691 * - 'Group Length' element is optional in DICOM 00692 * - but un-updated odd groups lengthes can causes pb 00693 * (xmedcon breaker) 00694 * 00695 * if ( (filetype == ImplicitVR) || (filetype == ExplicitVR) ) 00696 * UpdateGroupLength(false,filetype); 00697 * if ( filetype == ACR) 00698 * UpdateGroupLength(true,ACR); 00699 * 00700 * --> Computing group length for groups with embeded Sequences 00701 * --> was too much tricky / we were [in a hurry / too lazy] 00702 * --> We don't write the element 0x0000 (group length) 00703 */ 00704 00705 ElementSet::WriteContent(fp, filetype); // This one is recursive 00706 }
|
|
Definition at line 207 of file gdcmFile.h. Referenced by ComputeJPEGFragmentInfo(), ComputeRLEInfo(), File(), ReadEncapsulatedBasicOffsetTable(), and ~File(). |
|
Refering underlying filename.
Definition at line 121 of file gdcmDocument.h. Referenced by AnonymizeNoLoad(), gdcm::Document::DoTheLoadingDocumentJob(), gdcm::Document::Load(), and gdcm::Document::OpenFile(). |
|
ACR, ACR_LIBIDO, ExplicitVR, ImplicitVR, Unknown.
Definition at line 147 of file gdcmDocument.h. Referenced by gdcm::Document::CheckSwap(), gdcm::Document::Document(), gdcm::Document::DoTheLoadingDocumentJob(), gdcm::Document::FindDocEntryVR(), gdcm::Document::GetFileType(), gdcm::Document::HandleOutOfGroup0002(), gdcm::Document::Initialize(), gdcm::Document::IsParsable(), gdcm::DicomDir::IsReadable(), and gdcm::Document::ReadNextDocEntry(). |
|
File Pointer, opened during Document parsing.
Definition at line 144 of file gdcmDocument.h. Referenced by gdcm::Document::Backtrack(), gdcm::Document::CheckSwap(), gdcm::Document::CloseFile(), ComputeJPEGFragmentInfo(), ComputeRLEInfo(), gdcm::Document::Document(), gdcm::Document::DoTheLoadingDocumentJob(), DoTheLoadingJob(), gdcm::DicomDir::DoTheLoadingJob(), gdcm::Document::FindDocEntryLengthOBOrOW(), gdcm::Document::FindDocEntryVR(), gdcm::Document::IsDocEntryAnInteger(), gdcm::Document::LoadDocEntry(), gdcm::Document::LoadDocEntrySafe(), gdcm::Document::LoadEntryBinArea(), gdcm::Document::OpenFile(), gdcm::Document::ParseDES(), gdcm::Document::ParseSQ(), ReadEncapsulatedBasicOffsetTable(), gdcm::Document::ReadInt16(), gdcm::Document::ReadInt32(), gdcm::Document::ReadNextDocEntry(), ReadTag(), ReadTagLength(), gdcm::Document::SkipBytes(), gdcm::Document::SkipToNextDocEntry(), and gdcm::Document::SwitchByteSwapCode(). |
|
whether we already parsed group 0002 (Meta Elements)
Definition at line 138 of file gdcmDocument.h. Referenced by gdcm::Document::Document(), gdcm::Document::DoTheLoadingDocumentJob(), and gdcm::Document::HandleOutOfGroup0002(). |
|
In some cases (e.g. for some ACR-NEMA images) the header entry for the group of pixels is *not* found at 0x7fe0. In order to make things easier the parser shall store the proper value in GrPixel to provide a unique access facility.
Definition at line 198 of file gdcmFile.h. Referenced by DoTheLoadingJob(), File(), GetPixelAreaLength(), GetPixelOffset(), IsReadable(), and Write(). |
|
whether file has a DCM Preamble
Definition at line 141 of file gdcmDocument.h. Referenced by gdcm::Document::OpenFile(), and gdcm::Document::ReadNextDocEntry(). |
|
After opening the file, we read HEADER_LENGTH_TO_READ bytes.
Definition at line 150 of file gdcmDocument.h. |
|
Whether the gdcm::Document is already parsed/loaded : False from the creation of the gdcm::Document untill gdcm::Document:Load().
Definition at line 170 of file gdcmDocument.h. Referenced by gdcm::Document::Document(), and gdcm::Document::DoTheLoadingDocumentJob(). |
|
Whether the gdcm::Document was modified since the last Load().
Definition at line 173 of file gdcmDocument.h. Referenced by gdcm::Document::Document(), and gdcm::Document::DoTheLoadingDocumentJob(). |
|
Store the JPEG fragments info obtained during parsing of pixels.
Definition at line 187 of file gdcmFile.h. Referenced by ComputeJPEGFragmentInfo(), File(), and ~File(). |
|
Bit string integer (each one considered as a boolean) Bit 0 : Skip Sequences, if possible Bit 1 : Skip Shadow Groups if possible Probabely, some more to add.
Definition at line 165 of file gdcmDocument.h. Referenced by gdcm::DicomDir::CreateDicomDirChainedList(), gdcm::Document::Document(), and gdcm::Document::ParseDES(). |
|
Elements whose value is longer than MAX_SIZE_LOAD_ELEMENT_VALUE are NOT loaded.
Definition at line 153 of file gdcmDocument.h. Referenced by gdcm::Document::Document(). |
|
In some cases (e.g. for some ACR-NEMA images) the Entry Element Number of the 'Pixel Element' is *not* found at 0x0010. In order to make things easier the parser shall store the proper value in NumPixel to provide a unique access facility.
Definition at line 193 of file gdcmFile.h. Referenced by DoTheLoadingJob(), File(), GetPixelAreaLength(), GetPixelOffset(), IsReadable(), and Write(). |
|
To be able to backtrack (Private Sequence, Implicit VR related pb).
Definition at line 124 of file gdcmDocEntrySet.h. Referenced by gdcm::Document::Backtrack(), gdcm::DocEntrySet::DocEntrySet(), and gdcm::Document::ParseDES(). |
|
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(). |
|
Store the RLE frames info obtained during parsing of pixels.
Definition at line 185 of file gdcmFile.h. Referenced by ComputeRLEInfo(), File(), and ~File(). |
|
Swap code gives an information on the byte order of a supposed to be an int32, as it's read on disc (depending on the image Transfer Syntax *and* on the processor endianess) as opposed as it should in memory to be dealt as an int32. For instance :
Definition at line 135 of file gdcmDocument.h. Referenced by gdcm::Document::CheckSwap(), gdcm::Document::Document(), gdcm::Document::SwapDouble(), gdcm::Document::SwapLong(), gdcm::Document::SwapShort(), and gdcm::Document::SwitchByteSwapCode(). |
|
User supplied list of elements to Anonymize.
Definition at line 156 of file gdcmDocument.h. Referenced by AddAnonymizeElement(), AnonymizeFile(), and AnonymizeNoLoad(). |
|
User supplied list of elements to force Load.
Definition at line 159 of file gdcmDocument.h. Referenced by gdcm::Document::AddForceLoadElement(), and gdcm::Document::DoTheLoadingDocumentJob(). |