+2004-03-30 Eric Boix <Eric.Boix@creatis.insa-lyon.fr>
+ * src/gdcmParser.[cxx|h] and gdcmHeader.[cxx.h]: gdcmHeader::Write split
+ in WriteEntryTagVRLength and WriteEntryValue. Those methods were
+ moved to base class gdcmParser and only the specialisation is kept
+ in gdcmHeader.
+ * src/gdcmParser.[cxx|h]: ReplaceOrCreateByNumber(char*, guint16, guint16)
+ trashed out (because ReplaceOrCreateByNumber(string, guint16, guint16)
+ allready does the job.
+ * src/gdcmDicomDir.[cxx|h]: WriteDicomDirEntries renamed to WriteEntries
+ (to be consistent with gdcmParser::WriteEntries).
+
2004-03-30 Benoit Regrain
* vtk/vtkGdcmReader.[h|cxx] : fix the read of 3 gdcmHeader when making an
upate of the object's instance. It's passed to 2 in the unfavorable
fwrite("DICM",4,1,fp1);
free(filePreamble);
UpdateDirectoryRecordSequenceLength();
- WriteDicomDirEntries(fp1);
+ WriteEntries(fp1);
fclose(fp1);
return true;
}
/**
- * \ingroup gdcmParser
- * \brief writes on disc according to the DICOMDIR format
- * using the tree-like structure
+ * \brief Writes in a file using the tree-like structure.
* @param _fp already open file pointer
*/
-void gdcmDicomDir::WriteDicomDirEntries(FILE *_fp)
+void gdcmDicomDir::WriteEntries(FILE *_fp)
{
// TODO (?) tester les echecs en ecriture
// (apres chaque fwrite, dans le WriteEntry)
* \brief gdcmDicomDir defines an object representing a DICOMDIR in memory.
*
*/
-
class GDCM_EXPORT gdcmDicomDir: public gdcmParser
{
public:
gdcmDicomDirPatient * NewPatient(void);
// Write
+ void WriteEntries(FILE *_fp);
bool Write(std::string fileName);
/// Types of the gdcmObject within the gdcmDicomDir
void UpdateDirectoryRecordSequenceLength(void);
static bool HeaderLessThan(gdcmHeader *header1,gdcmHeader *header2);
- void WriteDicomDirEntries(FILE *_fp);
// Variables
/**
// if Photometric Interpretation # PALETTE COLOR, no LUT to be done
if (GetEntryByNumber(0x0028,0x0004) != "PALETTE COLOR ") {
- return NULL;
+ return NULL;
}
int lengthR, debR, nbitsR;
int lengthG, debG, nbitsG;
GetEntryVoidAreaByNumber(0x0028,0x1203);
if (!lutR || !lutG || !lutB ) {
- return NULL;
+ return NULL;
}
// forge the 4 * 8 Bits Red/Green/Blue/Alpha LUT
return NULL;
}
memset(LUTRGBA, 0, 1024);
- // Bits Allocated
+ // Bits Allocated
int nb;
std::string str_nb = GetEntryByNumber(0x0028,0x0100);
if (str_nb == GDCM_UNFOUND ) {
void gdcmHeader::SetImageDataSize(size_t ImageDataSize) {
std::string content1;
char car[20];
-
+
// Assumes HeaderEntry (GrPixel, NumPixel) is unique ...
- // TODO deal with multiplicity (see gdcmData/icone.dcm)
+ // TODO deal with multiplicity (see gdcmData/icone.dcm)
sprintf(car,"%d",ImageDataSize);
gdcmHeaderEntry *a = GetHeaderEntryByNumber(GrPixel, NumPixel);
a->SetLength(ImageDataSize);
-
+
ImageDataSize+=8;
sprintf(car,"%d",ImageDataSize);
- content1=car;
+ content1=car;
SetEntryByNumber(content1, GrPixel, NumPixel);
}
s1=this->GetEntryByNumber(0x0010,0x0010);
s2=header.GetEntryByNumber(0x0010,0x0010);
if(s1 < s2)
- return(true);
+ return(true);
else if(s1 > s2)
- return(false);
+ return(false);
else
{
// Patient ID
s1=this->GetEntryByNumber(0x0010,0x0020);
s2=header.GetEntryByNumber(0x0010,0x0020);
if (s1 < s2)
- return(true);
+ return(true);
else if (s1 > s2)
return(1);
else
{
- // Study Instance UID
+ // Study Instance UID
s1=this->GetEntryByNumber(0x0020,0x000d);
s2=header.GetEntryByNumber(0x0020,0x000d);
if (s1 < s2)
- return(true);
+ return(true);
else if(s1 > s2)
- return(false);
+ return(false);
else
{
- // Serie Instance UID
+ // Serie Instance UID
s1=this->GetEntryByNumber(0x0020,0x000e);
s2=header.GetEntryByNumber(0x0020,0x000e);
if (s1 < s2)
return(false);
}
+bool gdcmHeader::WriteEntry(gdcmHeaderEntry *tag, FILE *_fp,FileType type)
+{
+ guint32 length = tag->GetLength();
+
+ // The value of a tag MUST (see the DICOM norm) be an odd number of
+ // bytes. When this is not the case, pad with an additional byte:
+ if(length%2==1)
+ {
+ tag->SetValue(tag->GetValue()+"\0");
+ tag->SetLength(tag->GetReadLength()+1);
+ }
+
+ WriteEntryTagVRLength(tag, _fp, type);
+
+ // Pixels are never loaded in the element !
+ // we stop writting when Pixel are processed
+ // FIX : we loose trailing elements (RAB, right now)
+ guint16 el = tag->GetElement();
+ guint16 group = tag->GetGroup();
+ int compte =0;
+ if ((group == GrPixel) && (el == NumPixel) ) {
+ compte++;
+ if (compte == countGrPixel) {// we passed *all* the GrPixel,NumPixel
+ return false;
+ }
+ }
+ WriteEntryValue(tag, _fp, type);
+ return true;
+}
+
//-----------------------------------------------------------------------------
// Protected
if (StudyInstanceUID !=GDCM_UNFOUND)
ReplaceOrCreateByNumber(StudyInstanceUID, 0x0010, 0x0010);
else
- ReplaceOrCreateByNumber("anonymised", 0x0010, 0x0010);
+ ReplaceOrCreateByNumber(std::string("anonymised"), 0x0010, 0x0010);
}
// Just for fun :-(
//300a 022c DA RT Air Kerma Rate Reference Date
//300e 0004 DA RT Review Date
return true;
- }
+}
//-----------------------------------------------------------------------------
// Private
*/
class GDCM_EXPORT gdcmHeader : public gdcmParser
{
+protected:
+ /// In some cases (e.g. for some ACR-NEMA images) the Header 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. See also the constructor
+ /// \ref gdcmHeader::gdcmHeader
+ guint16 NumPixel;
+ /// 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. See also the constructor
+ /// \ref gdcmHeader::gdcmHeader
+ guint16 GrPixel;
+ /// Some DICOM files may contain several images (e.g. a icon, followd by
+ /// the image itself. Hence the tag (GrPixel,NumPixel) might appear
+ /// several times. countGrPixel is the number of occurences of the
+ /// tag of pixels (i.e. (GrPixel,NumPixel)) contained in the header.
+ int countGrPixel;
public:
gdcmHeader(bool exception_on_error = false);
gdcmHeader(const char *filename,
// TODO Swig int SetShaDict(std::string filename);
// TODO Swig int SetPubDict(std::string filename);
-// System access
- /**
- * \brief the Header Entry Group Number of the 'Pixel Group'
- * is not allways 0x7fe0
- * @return GrPixel
- */
+ /// Accessor to \ref gdcmHeader::GrPixel
guint16 GetGrPixel(void) {return GrPixel;}
- /// Accessor to \ref gdcmParser::NumPixel
+ /// Accessor to \ref gdcmHeader::NumPixel
guint16 GetNumPixel(void) {return NumPixel;}
// Entry
inline virtual std::string GetEntryVRByName (std::string tagName)
{ return(gdcmParser::GetEntryVRByName(tagName)); }
- inline virtual bool SetEntryByNumber(std::string content,guint16 group, guint16 element)
+ inline virtual bool SetEntryByNumber(std::string content,
+ guint16 group, guint16 element)
{ return(gdcmParser::SetEntryByNumber(content,group,element)); }
inline virtual bool SetEntryByName(std::string content,std::string tagName)
{ return(gdcmParser::SetEntryByName(content,tagName)); }
- inline virtual bool SetEntryLengthByNumber(guint32 l,guint16 group, guint16 element)
+ inline virtual bool SetEntryLengthByNumber(guint32 l,
+ guint16 group, guint16 element)
{ return(gdcmParser::SetEntryLengthByNumber(l,group,element)); }
inline virtual void UpdateShaEntries(void)
bool operator<(gdcmHeader &header);
+ bool WriteEntry(gdcmHeaderEntry *tag,FILE *_fp,FileType type);
+
+
protected:
//CLEANME int write(std::ostream&);
//CLEANME int anonymize(std::ostream&);//FIXME: anonymize should be a friend
}
/**
- * \ingroup gdcmParser
* \brief Prints The Dict Entries of THE public Dicom Dictionnry
* @return
*/
}
/**
- * \ingroup gdcmParser
* \brief Prints The Dict Entries of THE shadow Dicom Dictionnary
* @return
*/
//-----------------------------------------------------------------------------
// Public
/**
- * \ingroup gdcmParser
* \brief Get the public dictionary used
*/
gdcmDict *gdcmParser::GetPubDict(void) {
}
/**
- * \ingroup gdcmParser
* \brief Get the shadow dictionary used
*/
gdcmDict *gdcmParser::GetShaDict(void) {
}
/**
- * \ingroup gdcmParser
* \brief Set the shadow dictionary used
* \param dict dictionary to use in shadow
*/
}
/**
- * \ingroup gdcmParser
* \brief Set the shadow dictionary used
* \param dictName name of the dictionary to use in shadow
*/
}
/**
- * \ingroup gdcmParser
* \brief This predicate, based on hopefully reasonable heuristics,
* decides whether or not the current gdcmParser was properly parsed
* and contains the mandatory information for being considered as
}
/**
- * \ingroup gdcmParser
* \brief Determines if the Transfer Syntax was already encountered
* and if it corresponds to a ImplicitVRLittleEndian one.
* @return True when ImplicitVRLittleEndian found. False in all other cases.
}
/**
- * \ingroup gdcmParser
* \brief Determines if the Transfer Syntax was already encountered
* and if it corresponds to a DeflatedExplicitVRLittleEndian one.
* @return True when DeflatedExplicitVRLittleEndian found. False in all other cases.
}
/**
- * \ingroup gdcmParser
* \brief Determines if the Transfer Syntax was already encountered
* and if it corresponds to a Explicit VR Big Endian one.
* @return True when big endian found. False in all other cases.
}
/**
- * \ingroup gdcmParser
* \brief returns the File Type
* (ACR, ACR_LIBIDO, ExplicitVR, ImplicitVR, Unknown)
* @return the FileType code
}
/**
- * \ingroup gdcmParser
* \brief opens the file
* @param exception_on_error
* @return
}
/**
- * \ingroup gdcmParser
* \brief closes the file
* @return TRUE if the close was successfull
*/
}
/**
- * \ingroup gdcmParser
- * \brief writes on disc all the Header Entries (Dicom Elements)
+ * \brief Writes in a file all the Header Entries (Dicom Elements)
* of the Chained List
* @param fp file pointer on an already open file
- * @param type type of the File to be written
+ * @param type Type of the File to be written
* (ACR-NEMA, ExplicitVR, ImplicitVR)
- * @return always "True" ?!
+ * \return Always true.
*/
bool gdcmParser::Write(FILE *fp, FileType type) {
// ==============
WriteEntries(fp,type);
return(true);
- }
+}
/**
- * \ingroup gdcmParser
* \brief Modifies the value of a given Header Entry (Dicom Element)
- * if it exists; Creates it with the given value if it doesn't
- * \warning : adds the Header Entry to the HTable, NOT to the chained List
- * @param Value passed as a std::string
- * @param Group group of the Entry
- * @param Elem element of the Entry
- * \return pointer to the created Header Entry
- * NULL if creation failed
+ * when it exists. Create it with the given value when unexistant.
+ * \warning Adds the Header Entry to the HTable, NOT to the chained List
+ * @param Value Value to be set
+ * @param Group Group of the Entry
+ * @param Elem Element of the Entry
+ * \return pointer to the modified/created Header Entry (NULL when creation
+ * failed).
*/
gdcmHeaderEntry * gdcmParser::ReplaceOrCreateByNumber(
std::string Value,
gdcmHeaderEntry* a;
a = GetHeaderEntryByNumber( Group, Elem);
if (a == NULL) {
- gdcmHeaderEntry *a =NewHeaderEntryByNumber(Group, Elem);
+ gdcmHeaderEntry *a = NewHeaderEntryByNumber(Group, Elem);
if (a == NULL)
return NULL;
AddHeaderEntry(a);
}
- //SetEntryByNumber(Value, Group, Elem);
+ //CLEANME SetEntryByNumber(Value, Group, Elem);
a->SetValue(Value);
return(a);
}
/**
- * \ingroup gdcmParser
- * \brief Modifies the value of a given Header Entry (Dicom Element)
- * if it exists; Creates it with the given value if it doesn't
- * @param Value passed as a char*
- * @param Group group of the Entry
- * @param Elem element of the Entry
- * \return pointer to the created Header Entry
- * NULL if creation failed
- *
- */
-gdcmHeaderEntry * gdcmParser::ReplaceOrCreateByNumber(
- char* Value,
- guint16 Group,
- guint16 Elem ) {
- gdcmHeaderEntry* nvHeaderEntry=NewHeaderEntryByNumber(Group, Elem);
-
- if(!nvHeaderEntry)
- return(NULL);
-
- AddHeaderEntry(nvHeaderEntry);
-
- std::string v = Value;
- SetEntryByNumber(v, Group, Elem);
- return(nvHeaderEntry);
-}
-
-/**
- * \ingroup gdcmParser
- * \brief Set a new value if the invoked element exists
- * Seems to be useless !!!
+ * \brief Set a new value if the invoked element exists
+ * Seems to be useless !!!
* @param Value new element value
* @param Group group of the Entry
* @param Elem element of the Entry
// Protected
/**
- * \ingroup gdcmParser
* \brief Checks if a given Dicom Element exists
* within the H table
* @param group Group number of the searched Dicom Element
/**
* \brief Writes in a file (according to the requested format)
* the group, the element, the value representation and the length
- of a single gdcmHeaderEntry passed as argument.
+ * of a single gdcmHeaderEntry passed as argument.
* @param tag pointer on the gdcmHeaderEntry to be written
* @param _fp already open file pointer
* @param type type of the File to be written
- * (ACR-NEMA, ExplicitVR, ImplicitVR)
*/
void gdcmParser::WriteEntryTagVRLength(gdcmHeaderEntry *tag,
FILE *_fp,
}
}
+/**
+ * \brief Writes in a file (according to the requested format)
+ * the value of a single gdcmHeaderEntry passed as argument.
+ * @param tag Pointer on the gdcmHeaderEntry to be written
+ * @param _fp Already open file pointer
+ * @param type type of the File to be written
+ */
void gdcmParser::WriteEntryValue(gdcmHeaderEntry *tag, FILE *_fp,FileType type)
{
guint16 group = tag->GetGroup();
fwrite (tag->GetValue().c_str(), (size_t)lgr ,(size_t)1, _fp); // Elem value
}
-void gdcmParser::WriteEntry(gdcmHeaderEntry *tag, FILE *_fp,FileType type)
+/**
+ * \brief Writes in a file (according to the requested format)
+ * a single gdcmHeaderEntry passed as argument.
+ * \sa WriteEntryValue, WriteEntryTagVRLength.
+ * @param tag Pointer on the gdcmHeaderEntry to be written
+ * @param _fp Already open file pointer
+ * @param type type of the File to be written
+ */
+
+bool gdcmParser::WriteEntry(gdcmHeaderEntry *tag, FILE *_fp,FileType type)
{
guint32 length = tag->GetLength();
}
WriteEntryTagVRLength(tag, _fp, type);
-
- // Pixels are never loaded in the element !
- // we stop writting when Pixel are processed
- // FIX : we loose trailing elements (RAB, right now)
- guint16 el = tag->GetElement();
- guint16 group = tag->GetGroup();
- int compte =0;
- itsTimeToWritePixels = false;
- if ((group == GrPixel) && (el == NumPixel) ) {
- compte++;
- if (compte == countGrPixel) {// we passed *all* the GrPixel,NumPixel
- itsTimeToWritePixels = true;
- return;
- }
- }
WriteEntryValue(tag, _fp, type);
+ return true;
}
/**
* @param _fp already open file pointer
*/
-void gdcmParser::WriteEntries(FILE *_fp,FileType type)
+bool gdcmParser::WriteEntries(FILE *_fp,FileType type)
{
// TODO (?) tester les echecs en ecriture (apres chaque fwrite)
// Ignore the documented delimiter
continue;
}
- WriteEntry(*tag2,_fp,type);
- if (itsTimeToWritePixels)
- break;
+ if (! WriteEntry(*tag2,_fp,type) )
+ return false;
}
+ return true;
}
/**
// --> will be done with the next organization
if ((*tag2->second).GetGroup() == 0xfffe ) continue; // ignore delimiters
}
- WriteEntry(tag2->second,_fp,type);
- if (itsTimeToWritePixels)
+ if ( ! WriteEntry(tag2->second,_fp,type))
break;
}
}
std::string vr = Entry->GetVR();
guint16 length16;
- if( (element == NumPixel) && (group == GrPixel) )
- {
- dbg.SetDebug(GDCM_DEBUG);
- dbg.Verbose(2, "gdcmParser::FindLength: ",
- "we reached (GrPixel,NumPixel)");
- }
-
if ( (filetype == ExplicitVR) && (! Entry->IsImplicitVR()) )
{
if ( (vr=="OB") || (vr=="OW") || (vr=="SQ") || (vr=="UN") )
typedef std::multimap<TagKey, gdcmHeaderEntry *> TagHeaderEntryHT;
typedef std::pair<TagKey, gdcmHeaderEntry *> PairHT;
typedef std::pair<TagHeaderEntryHT::iterator,TagHeaderEntryHT::iterator> IterHT;
-
-typedef std::list<gdcmHeaderEntry *> ListTag; // for linking together the Elements
+/// for linking together the Elements
+typedef std::list<gdcmHeaderEntry *> ListTag;
typedef std::string GroupKey;
typedef std::map<GroupKey, int> GroupHT;
*/
class GDCM_EXPORT gdcmParser
{
+private:
+ /// Public dictionary used to parse this header
+ gdcmDict *RefPubDict;
+
+ /// Optional "shadow dictionary" (private elements) used to parse
+ /// this header
+ gdcmDict *RefShaDict;
+
+ /// Equals 1 if a gdcmHeaderEntry was added post parsing
+ int wasUpdated;
+
+ /// Equals =1 if user wants to skip shadow groups while parsing
+ /// (to save space)
+ int ignoreShadow;
+
+ /// Size threshold above which an element value will NOT be loaded in
+ /// memory (to avoid loading the image/volume itself). By default,
+ /// this upper bound is fixed to 1024 bytes (which might look reasonable
+ /// when one considers the definition of the various VR contents).
+ guint32 MaxSizeLoadEntry;
+
+ /// Size threshold above which an element value will NOT be *printed* in
+ /// order no to polute the screen output. By default, this upper bound
+ /// is fixed to 64 bytes.
+ guint32 MaxSizePrintEntry;
+
+protected:
+ /// Refering underlying filename.
+ std::string filename;
+
+ /// SWap code (e.g. Big Endian, Little Endian, Bad Big Endian,
+ /// Bad Little Endian) according to the processor Endianity and
+ /// what is written on disc.
+ int sw;
+
+ /// File Pointer, opened during Header parsing.
+ FILE *fp;
+
+ /// ACR, ACR_LIBIDO, ExplicitVR, ImplicitVR, Unknown
+ FileType filetype;
+
+ /// After opening the file, we read HEADER_LENGTH_TO_READ bytes.
+ static const unsigned int HEADER_LENGTH_TO_READ;
+
+ /// Elements whose value is longer than MAX_SIZE_LOAD_ELEMENT_VALUE
+ /// are NOT loaded.
+ static const unsigned int MAX_SIZE_LOAD_ELEMENT_VALUE;
+
+ /// Elements whose value is longer than MAX_SIZE_PRINT_ELEMENT_VALUE
+ /// are NOT printed.
+ static const unsigned int MAX_SIZE_PRINT_ELEMENT_VALUE;
+
+ /// Hash Table (multimap), to provide fast access
+ TagHeaderEntryHT tagHT;
+
+ /// Chained list, to keep the 'spacial' ordering
+ ListTag listEntries;
+
+ /// will be set 1 if user asks to 'go inside' the 'sequences' (VR = "SQ")
+ int enableSequences;
+
+ /// Amount of printed details for each Header Entry (Dicom Element):
+ /// 0 : stands for the least detail level.
+ int printLevel;
+
public:
+
// Print
- /**
- * \ingroup gdcmParser
- * \brief Sets the print level for the Dicom Header
- * \note 0 for Light Print; 1 for 'medium' Print, 2 for Heavy
- */
- void SetPrintLevel(int level)
- { printLevel = level; };
- /**
- * \ingroup gdcmParser
- * \brief canonical Printer
- * \sa SetPrintLevel
- */
+ /// Canonical Printing method (see also gdcmParser::SetPrintLevel)
virtual void Print (std::ostream &os = std::cout)
{PrintEntry(os);};
virtual void PrintEntry (std::ostream &os = std::cout);
virtual void PrintPubDict (std::ostream &os = std::cout);
virtual void PrintShaDict (std::ostream &os = std::cout);
-// Standard values
- /**
- * \ingroup gdcmParser
- * \brief Gets the external File Name
- */
- inline std::string GetFileName(void)
- {return filename;}
-
// Dictionnaries
gdcmDict *GetPubDict(void);
gdcmDict *GetShaDict(void);
bool IsExplicitVRBigEndianTransferSyntax(void);
FileType GetFileType(void);
-// Entries
- /**
- * \ingroup gdcmHeader
- * \brief returns a ref to the Dicom Header H table (multimap)
- * return the Dicom Header H table
- */
- inline TagHeaderEntryHT &GetEntry(void) { return tagHT; };
-
- /**
- * \ingroup gdcmHeader
- * \brief returns a ref to the Dicom Header chained list
- * return the Dicom Header chained list
- */
- inline ListTag &GetListEntry(void) { return listEntries; };
-
// Read (used in gdcmFile, gdcmDicomDir)
FILE *OpenFile(bool exception_on_error = false) throw(gdcmFileError);
bool CloseFile(void);
// Write (used in gdcmFile, gdcmDicomDir)
virtual bool Write(FILE *, FileType);
+ virtual void WriteEntryTagVRLength(gdcmHeaderEntry *tag,
+ FILE *_fp, FileType type);
+ virtual void WriteEntryValue(gdcmHeaderEntry *tag,FILE *_fp,FileType type);
+ virtual bool WriteEntry(gdcmHeaderEntry *tag,FILE *_fp,FileType type);
+ virtual bool WriteEntries(FILE *_fp,FileType type);
+ void WriteEntriesDeprecated(FILE *_fp,FileType type); // JPR
- gdcmHeaderEntry * ReplaceOrCreateByNumber(std::string Value, guint16 Group, guint16 Elem);
- gdcmHeaderEntry * ReplaceOrCreateByNumber( char *Value, guint16 Group, guint16 Elem);
- bool ReplaceIfExistByNumber ( char *Value, guint16 Group, guint16 Elem);
+ gdcmHeaderEntry * ReplaceOrCreateByNumber(std::string Value,
+ guint16 Group, guint16 Elem);
+ bool ReplaceIfExistByNumber (char *Value, guint16 Group, guint16 Elem);
// System access
- /**
- * \ingroup gdcmHeader
- * \brief returns the 'swap code'
- * (Big Endian, Little Endian,
- * Bad Big Endian, Bad Little Endian)
- * according to the processor Endianity and what's written on disc
- * return
- */
- inline int GetSwapCode(void) { return sw; }
-
guint16 SwapShort(guint16); // needed by gdcmFile
guint32 SwapLong(guint32); // needed by gdcmFile
guint16 UnswapShort(guint16); // needed by gdcmFile
guint32 UnswapLong(guint32); // needed by gdcmFile
protected:
-// constructor and destructor are protected to forbid end user
-// to instanciate class gdcmParser
-// (only gdcmHeader and gdcmDicomDir are meaningfull)
+ // Constructor and destructor are protected to forbid end user
+ // to instanciate from this class gdcmParser (only gdcmHeader and
+ // gdcmDicomDir are meaningfull).
gdcmParser(bool exception_on_error = false);
gdcmParser(const char *inFilename,
bool exception_on_error = false,
virtual int GetEntryLengthByNumber(guint16 group, guint16 element);
virtual bool SetEntryByName (std::string content, std::string tagName);
- virtual bool SetEntryByNumber(std::string content, guint16 group, guint16 element);
- virtual bool SetEntryLengthByNumber(guint32 length, guint16 group, guint16 element);
+ virtual bool SetEntryByNumber(std::string content,
+ guint16 group, guint16 element);
+ virtual bool SetEntryLengthByNumber(guint32 length,
+ guint16 group, guint16 element);
virtual size_t GetEntryOffsetByNumber (guint16 Group, guint16 Elem);
virtual void *GetEntryVoidAreaByNumber(guint16 Group, guint16 Elem);
void LoadHeaderEntrySafe(gdcmHeaderEntry *);
- void UpdateGroupLength(bool SkipSequence = false, FileType type = ImplicitVR);
- void WriteEntryTagVRLength(gdcmHeaderEntry *tag, FILE *_fp, FileType type);
- void WriteEntryValue(gdcmHeaderEntry *tag,FILE *_fp,FileType type);
- void WriteEntry(gdcmHeaderEntry *tag,FILE *_fp,FileType type);
- void WriteEntries(FILE *_fp,FileType type);
- void WriteEntriesDeprecated(FILE *_fp,FileType type); // JPR
+ void UpdateGroupLength(bool SkipSequence = false,
+ FileType type = ImplicitVR);
void AddHeaderEntry (gdcmHeaderEntry *);
- /**
- * \ingroup gdcmParser
- * \brief Set the external File Name
- */
- inline void SetFileName(char* fileName)
- {filename = fileName;}
-
-// Variables
- /**
- * \brief File Pointer, open during Header parsing
- */
- FILE *fp;
- /**
- * \brief ACR, ACR_LIBIDO, ExplicitVR, ImplicitVR, Unknown
- */
- FileType filetype;
-
-/// after opening the file, we read HEADER_LENGTH_TO_READ bytes.
- static const unsigned int HEADER_LENGTH_TO_READ;
-/// Elements whose value is longer than MAX_SIZE_LOAD_ELEMENT_VALUE are NOT loaded
- static const unsigned int MAX_SIZE_LOAD_ELEMENT_VALUE;
-/// Elements whose value is longer than MAX_SIZE_PRINT_ELEMENT_VALUE are NOT printed
- static const unsigned int MAX_SIZE_PRINT_ELEMENT_VALUE;
-
-protected:
- /**
- * \brief H Table (multimap), to provide fast access
- */
- TagHeaderEntryHT tagHT;
- /**
- * \brief chained list, to keep the 'spacial' ordering
- */
- ListTag listEntries;
- /**
- * \brief will be set 1 if user asks to 'go inside' the 'sequences' (VR = "SQ")
- */
- int enableSequences;
- /**
- * \brief amount of printed details for each Header Entry (Dicom Element)
- * 0 : the least
- */
- int printLevel;
-
- /**
- * \brief For some ACR-NEMA images, it's *not* 7fe0 ...
- */
- guint16 GrPixel;
-
- /// In some cases (e.g. for some ACR-NEMA images) the Header 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. See also
- /// \ref gdcmHeader::gdcmHeader
- guint16 NumPixel;
- /**
- * \brief some files may contain icons; GrPixel,NumPixel appears several times
- * Let's remember how many times!
- */
- int countGrPixel;
- /**
- * \brief = true when the 'pixel Element' is reached during writting process
- */
- bool itsTimeToWritePixels;
private:
// Read
guint32 GenerateFreeTagKeyInGroup(guint16 group);
- /**
- * \brief Refering underlying filename.
- */
- std::string filename;
+public:
+// Accessors:
+ /// Accessor to \ref printLevel
+ void SetPrintLevel(int level) { printLevel = level; };
- /**
- * \brief Public dictionary used to parse this header
- */
- gdcmDict *RefPubDict;
-
- /**
- * \brief Optional "shadow dictionary" (private elements) used to parse this header
- */
- gdcmDict *RefShaDict;
+ /// Accessor to \ref filename
+ inline std::string GetFileName(void) {return filename;}
- /**
- * \brief = 1 if a gdcmHeaderEntry was added post parsing
- */
- int wasUpdated;
-
- /**
- * \brief =1 if user wants to skip shadow groups while parsing (to save space)
- */
- int ignoreShadow;
-
- /**
- * \brief Swap code e.g. little, big, bad-big, bad-little endian).
- * \warning : this code is not fixed during header parsing.
- */
- int sw;
- /**
- * \brief Size threshold above which an element value will NOT be loaded in
- * memory (to avoid loading the image/volume itself). By default,
- * this upper bound is fixed to 1024 bytes (which might look reasonable
- * when one considers the definition of the various VR contents).
- */
- guint32 MaxSizeLoadEntry;
-
- /**
- * \brief Size threshold above which an element value will NOT be *printed* in
- * order no to polute the screen output.
- * By default, this upper bound is fixed to 64 bytes.
- */
- guint32 MaxSizePrintEntry;
-
+ /// Accessor to \ref filename
+ inline void SetFileName(char* fileName) {filename = fileName;}
+
+ /// Accessor to \ref gdcmParser::tagHT
+ inline TagHeaderEntryHT &GetEntry(void) { return tagHT; };
+
+ /// Accessor to \ref gdcmParser::listEntries
+ inline ListTag &GetListEntry(void) { return listEntries; };
+
+ /// 'Swap code' accessor (see \ref sw )
+ inline int GetSwapCode(void) { return sw; }
};
//-----------------------------------------------------------------------------