From 9aa702d6397e3e490263a0791dd6c8ed2f3d1e83 Mon Sep 17 00:00:00 2001 From: regrain Date: Wed, 19 Oct 2005 13:17:04 +0000 Subject: [PATCH] * Remove the Key information in Entry * Create a DicomEntry parent of DictEntry * Remap correctly the TagKey -- BeNours --- src/CMakeLists.txt | 3 +- src/gdcmCommon.h | 49 +---------------- src/gdcmDicomEntry.cxx | 94 ++++++++++++++++++++++++++++++++ src/gdcmDicomEntry.h | 86 +++++++++++++++++++++++++++++ src/gdcmDictEntry.cxx | 50 +++-------------- src/gdcmDictEntry.h | 119 ++++------------------------------------- src/gdcmDocEntry.cxx | 5 +- src/gdcmDocEntry.h | 13 ++--- src/gdcmDocEntrySet.h | 7 ++- src/gdcmSQItem.h | 15 +----- src/gdcmSerieHelper.h | 5 +- src/gdcmTagKey.h | 97 +++++++++++++++++++++++++++++++++ src/gdcmVRKey.h | 5 +- 13 files changed, 313 insertions(+), 235 deletions(-) create mode 100644 src/gdcmDicomEntry.cxx create mode 100644 src/gdcmDicomEntry.h create mode 100644 src/gdcmTagKey.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 84d3df6e..3b1710f7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -33,6 +33,7 @@ SET(libgdcm_la_SOURCES gdcmDicomDirVisit.cxx gdcmDicomDirSerie.cxx gdcmDicomDirStudy.cxx + gdcmDicomEntry.cxx gdcmDict.cxx gdcmDictEntry.cxx gdcmDictGroupName.cxx @@ -44,9 +45,9 @@ SET(libgdcm_la_SOURCES gdcmDocument.cxx gdcmElementSet.cxx gdcmException.cxx + gdcmFile.cxx gdcmFileHelper.cxx gdcmGlobal.cxx - gdcmFile.cxx gdcmJPEGFragment.cxx gdcmJPEGFragmentsInfo.cxx gdcmJpeg8.cxx diff --git a/src/gdcmCommon.h b/src/gdcmCommon.h index 85c63a55..e7875ede 100644 --- a/src/gdcmCommon.h +++ b/src/gdcmCommon.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmCommon.h,v $ Language: C++ - Date: $Date: 2005/10/19 12:01:50 $ - Version: $Revision: 1.98 $ + Date: $Date: 2005/10/19 13:17:04 $ + Version: $Revision: 1.99 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -24,20 +24,6 @@ #include -//----------------------------------------------------------------------------- -// TagKey definition -#define FASTTAGKEY 0 - -// FIXME: Should rewrite this: -#if FASTTAGKEY - #include - #include -#endif - #if defined(_MSC_VER) && (_MSC_VER == 1200) - /* ostream operator for std::string since VS6 does not provide it*/ - #include -#endif - //----------------------------------------------------------------------------- #if defined(_WIN32) && defined(BUILD_SHARED_LIBS) #ifdef gdcm_EXPORTS @@ -83,37 +69,6 @@ GDCM_EXPORT extern const std::string GDCM_VRUNKNOWN; /// We'll fix the mess up -without any change in the API- as soon as the bench /// marks are fully performed. -#if FASTTAGKEY -typedef union { - uint16_t tab[2]; - uint32_t tagkey; - } TagKey; -/* ostream operator for TagKey */ -inline std::ostream& operator<<(std::ostream& _O, TagKey _val) -{ - _O.setf( std::ios::right); - return (_O << std::hex << std::setw( 4 ) << std::setfill( '0' ) - << _val.tab[0] << '|' << std::setw( 4 ) << std::setfill( '0' ) - << _val.tab[1] << std::setfill( ' ' ) << std::dec); -} -inline bool operator==(TagKey _self, TagKey _val) -{ - return _self.tagkey == _val.tagkey; -} -inline bool operator<(TagKey _self, TagKey _val) -{ - // This expression is a tad faster but PrintFile output - // is more difficult to read - //return _self.tagkey < _val.tagkey; - - // More usal order of dicom tags: - if( _self.tab[0] == _val.tab[0] ) - return _self.tab[1] < _val.tab[1]; - return _self.tab[0] < _val.tab[0]; -} -#else -typedef std::string TagKey; -#endif #if defined(_MSC_VER) && (_MSC_VER == 1200) // Doing everything within gdcm namespace to avoid polluting 3d party software inline std::ostream& operator<<(std::ostream& _O, std::string _val) diff --git a/src/gdcmDicomEntry.cxx b/src/gdcmDicomEntry.cxx new file mode 100644 index 00000000..785b941c --- /dev/null +++ b/src/gdcmDicomEntry.cxx @@ -0,0 +1,94 @@ +/*========================================================================= + + Program: gdcm + Module: $RCSfile: gdcmDicomEntry.cxx,v $ + Language: C++ + Date: $Date: 2005/10/19 13:17:05 $ + Version: $Revision: 1.1 $ + + Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de + l'Image). All rights reserved. See Doc/License.txt or + http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "gdcmDicomEntry.h" +#include "gdcmDebug.h" +#include "gdcmUtil.h" + +#include // for std::ios::left, ... +#include +#include // for sprintf + +namespace gdcm +{ +//----------------------------------------------------------------------------- +// Constructor / Destructor +/** + * \brief Constructor + * @param group DICOM-Group Number + * @param elem DICOM-Element Number + * @param vr Value Representation + * @param vm Value Multiplicity + * @param name description of the element +*/ +DicomEntry::DicomEntry(const uint16_t &group,const uint16_t &elt, + const VRKey &vr) +{ + Tag.SetGroup(group); + Tag.SetElement(elt); + VR = vr; +} + +/** + * \brief Destructor + */ +DicomEntry::~DicomEntry() +{ +} + +//----------------------------------------------------------------------------- +// Public +/** + * \brief concatenates 2 uint16_t (supposed to be a Dicom group number + * and a Dicom element number) + * @param group the Dicom group number used to build the tag + * @param elem the Dicom element number used to build the tag + * @return the built tag + */ +TagKey DicomEntry::TranslateToKey(uint16_t group, uint16_t elem) +{ + // according to 'Purify', TranslateToKey is one of the most + // time consuming methods. + // Let's try to shorten it ! + return TagKey(group,elem); +} + +//----------------------------------------------------------------------------- +// Protected + +//----------------------------------------------------------------------------- +// Private + +//----------------------------------------------------------------------------- +// Print +/** + * \brief Prints an entry of the Dicom DictionaryEntry + * @param os ostream we want to print in + * @param indent Indentation string to be prepended during printing + */ +void DicomEntry::Print(std::ostream &os, std::string const & ) +{ + std::ostringstream s; + + s << GetKey(); + s << " [" << VR << "] "; +} + +//----------------------------------------------------------------------------- +} // end namespace gdcm + diff --git a/src/gdcmDicomEntry.h b/src/gdcmDicomEntry.h new file mode 100644 index 00000000..d74dca86 --- /dev/null +++ b/src/gdcmDicomEntry.h @@ -0,0 +1,86 @@ +/*========================================================================= + + Program: gdcm + Module: $RCSfile: gdcmDicomEntry.h,v $ + Language: C++ + Date: $Date: 2005/10/19 13:17:05 $ + Version: $Revision: 1.1 $ + + Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de + l'Image). All rights reserved. See Doc/License.txt or + http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#ifndef GDCMDICOMENTRY_H +#define GDCMDICOMENTRY_H + +#include "gdcmCommon.h" +#include "gdcmBase.h" +#include "gdcmVRKey.h" +#include "gdcmTagKey.h" + +namespace gdcm +{ +//----------------------------------------------------------------------------- +/** + * \brief + * the DicomEntry in an element contained by the Dict. + * It contains : + * - the key referenced by the DICOM norm or the constructor (for private keys) + * i.e. the Group number + * the Element number + * - the VR (Value Representation) + * - the VM (Value Multplicity) + * - the corresponding name in english + */ +class GDCM_EXPORT DicomEntry : public Base +{ +public: + DicomEntry(const uint16_t &group,const uint16_t &elt, + const VRKey &vr = GDCM_VRUNKNOWN); + ~DicomEntry(); + +// Print + void Print(std::ostream &os = std::cout, std::string const &indent = ""); + + /// \brief Returns the Dicom Group Number + /// @return the Dicom Group Number + const uint16_t &GetGroup() const { return Tag[0]; } + + /// \brief Returns the Dicom Element Number + /// @return the Dicom Element Number + const uint16_t &GetElement() const { return Tag[1]; } + + /// \brief Set the Dicom Value Representation + /// \param vr the Dicom Value Representation + virtual void SetVR(VRKey const &vr) { VR = vr; } + /// \brief Returns the Dicom Value Representation + /// @return the Dicom Value Representation + const VRKey &GetVR() const { return VR; } + /// \brief tells if the V(alue) R(epresentation) is known (?!) + /// @return + bool IsVRUnknown() const { return VR == GDCM_VRUNKNOWN; } + + const TagKey &GetKey() const { return Tag; } + +// Key creation + static TagKey TranslateToKey(uint16_t group, uint16_t elem); + +private: + /// Dicom \ref TagKey. Contains DicomGroup number and DicomElement number + TagKey Tag; + + /// \brief Value Representation i.e. some clue about the nature + /// of the data represented e.g. + /// "FD" short for "Floating Point Double"(see \ref VR) + /// "PN" short for "Person Name" + VRKey VR; +}; +} // end namespace gdcm +//----------------------------------------------------------------------------- +#endif diff --git a/src/gdcmDictEntry.cxx b/src/gdcmDictEntry.cxx index ed1052af..cfe420d8 100644 --- a/src/gdcmDictEntry.cxx +++ b/src/gdcmDictEntry.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDictEntry.cxx,v $ Language: C++ - Date: $Date: 2005/10/18 12:58:27 $ - Version: $Revision: 1.52 $ + Date: $Date: 2005/10/19 13:17:04 $ + Version: $Revision: 1.53 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -40,14 +40,11 @@ namespace gdcm DictEntry::DictEntry(uint16_t group, uint16_t elem, VRKey const &vr, TagName const &vm, - TagName const &name) + TagName const &name): + DicomEntry(group,elem,vr) { - Group = group; - Element = elem; - VR = vr; VM = vm; Name = name; - Key = TranslateToKey(group, elem); } //----------------------------------------------------------------------------- @@ -61,7 +58,7 @@ void DictEntry::SetVR(VRKey const &vr) { if ( IsVRUnknown() ) { - VR = vr; + DicomEntry::SetVR(vr); } else { @@ -86,32 +83,6 @@ void DictEntry::SetVM(TagName const &vm) } } -/** - * \brief concatenates 2 uint16_t (supposed to be a Dicom group number - * and a Dicom element number) - * @param group the Dicom group number used to build the tag - * @param elem the Dicom element number used to build the tag - * @return the built tag - */ -TagKey DictEntry::TranslateToKey(uint16_t group, uint16_t elem) -{ - // according to 'Purify', TranslateToKey is one of the most - // time consuming methods. - // Let's try to shorten it ! - - //return Util::Format("%04x|%04x", group, elem); // too much time ! -#if FASTTAGKEY - TagKey r; - r.tab[0] = group; - r.tab[1] = elem; - return r; -#else - char res[10]; - sprintf(res,"%04x|%04x", group, elem); - return res; -#endif -} - //----------------------------------------------------------------------------- // Protected @@ -125,18 +96,13 @@ TagKey DictEntry::TranslateToKey(uint16_t group, uint16_t elem) * @param os ostream we want to print in * @param indent Indentation string to be prepended during printing */ -void DictEntry::Print(std::ostream &os, std::string const & ) +void DictEntry::Print(std::ostream &os, std::string const &indent ) { + DicomEntry::Print(os,indent); + VRKey vr; std::ostringstream s; - vr = GetVR(); - if ( IsVRUnknown() ) - vr=" "; - - s << DictEntry::TranslateToKey(GetGroup(),GetElement()); - s << " [" << vr << "] "; - if ( PrintLevel >= 1 ) { s.setf(std::ios::left); diff --git a/src/gdcmDictEntry.h b/src/gdcmDictEntry.h index 2b651f2b..2be34877 100644 --- a/src/gdcmDictEntry.h +++ b/src/gdcmDictEntry.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDictEntry.h,v $ Language: C++ - Date: $Date: 2005/10/18 12:58:27 $ - Version: $Revision: 1.37 $ + Date: $Date: 2005/10/19 13:17:04 $ + Version: $Revision: 1.38 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -19,8 +19,7 @@ #ifndef GDCMDICTENTRY_H #define GDCMDICTENTRY_H -#include "gdcmBase.h" -#include "gdcmVRKey.h" +#include "gdcmDicomEntry.h" namespace gdcm { @@ -36,7 +35,7 @@ namespace gdcm * - the VM (Value Multplicity) * - the corresponding name in english */ -class GDCM_EXPORT DictEntry : public Base +class GDCM_EXPORT DictEntry : public DicomEntry { public: DictEntry(uint16_t group, @@ -49,127 +48,27 @@ public: void Print(std::ostream &os = std::cout, std::string const &indent = ""); // Content of DictEntry - void SetVR(VRKey const &vr); - void SetVM(TagName const &vm); - - /// \brief tells if the V(alue) R(epresentation) is known (?!) - /// @return - bool IsVRUnknown() const { return VR == GDCM_VRUNKNOWN; } + virtual void SetVR(VRKey const &vr); + virtual void SetVM(TagName const &vm); + /// \brief returns the VM field of the current DictEntry + /// @return The 'Value Multiplicity' field + const TagName &GetVM() const { return VM; } /// \brief tells if the V(alue) M(ultiplicity) is known (?!) /// @return bool IsVMUnknown() const { return VM == GDCM_UNKNOWN; } - /// \brief Returns the Dicom Group Number of the current DictEntry - /// @return the Dicom Group Number - const uint16_t &GetGroup() const { return Group; } - - /// \brief Returns the Dicom Element Number of the current DictEntry - /// @return the Dicom Element Number - const uint16_t &GetElement() const { return Element; } - - /// \brief Returns the Dicom Value Representation of the current - /// DictEntry - /// @return the Dicom Value Representation - const VRKey &GetVR() const { return VR; } - - /// \brief sets the key of the current DictEntry - /// @param k New key to be set. - void SetKey(TagKey const &k) { Key = k; } - - /// \brief returns the VM field of the current DictEntry - /// @return The 'Value Multiplicity' field - const TagName &GetVM() const { return VM; } - /// \brief Returns the Dicom Name of the current DictEntry /// e.g. "Patient Name" for Dicom Tag (0x0010, 0x0010) /// @return the Dicom Name const TagName &GetName() const { return Name; } - /// \brief Gets the key of the current DictEntry - /// @return the key. - const TagKey &GetKey() const { return Key; } - -// Key creation - static TagKey TranslateToKey(uint16_t group, uint16_t elem); - private: - /// \todo FIXME - /// where are the group and elem used except from building up - /// a TagKey. If the answer is nowhere then there is no need - /// to store the group and elem independently. - /// - /// --> EVERYWHERE ! The alternate question would be : - /// What's TagKey used for ? - - /// DicomGroup number - uint16_t Group; // e.g. 0x0010 - - /// DicomElement number - uint16_t Element; // e.g. 0x0103 - - /// \brief Value Representation i.e. some clue about the nature - /// of the data represented e.g. - /// "FD" short for "Floating Point Double"(see \ref VR) - /// "PN" short for "Person Name" - VRKey VR; - - /* - * . - * Formerly 'Group name abbreviations' - * Here is a small dictionary we encountered in "nature": - * - CMD Command - * - META Meta Information - * - DIR Directory - * - ID ??? - * - PAT Patient - * - ACQ Acquisition - * - REL Related - * - IMG Image - * - SDY Study - * - VIS Visit - * - WAV Waveform - * - PRC ??? - * - DEV Device - * - NMI Nuclear Medicine - * - MED ??? - * - BFS Basic Film Session - * - BFB Basic Film Box - * - BIB Basic Image Box - * - BAB - * - IOB - * - PJ - * - PRINTER - * - RT Radio Therapy - * - DVH - * - SSET - * - RES Results - * - CRV Curve - * - OLY Overlays - * - PXL Pixels - * - DL Delimiters - * . - * - * Other usefull abreviations used for Radiographic view associated with - * Patient Position (0018,5100): - * - AP = Anterior/Posterior - * - PA = Posterior/Anterior - * - LL = Left Lateral - * - RL = Right Lateral - * - RLD = Right Lateral Decubitus - * - LLD = Left Lateral Decubitus - * - RLO = Right Lateral Oblique - * - LLO = Left Lateral Oblique - * . - */ /// \brief Value Multiplicity (e.g. "1", "1-n", "6") TagName VM; /// e.g. "Patient's Name" TagName Name; - - /// Redundant with (group, elem) but we add it for efficiency purpose. - TagKey Key; }; } // end namespace gdcm //----------------------------------------------------------------------------- diff --git a/src/gdcmDocEntry.cxx b/src/gdcmDocEntry.cxx index a4011aa7..2c250b5a 100644 --- a/src/gdcmDocEntry.cxx +++ b/src/gdcmDocEntry.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocEntry.cxx,v $ Language: C++ - Date: $Date: 2005/10/18 19:54:26 $ - Version: $Revision: 1.72 $ + Date: $Date: 2005/10/19 13:17:04 $ + Version: $Revision: 1.73 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -39,7 +39,6 @@ DocEntry::DocEntry(DictEntry *in) { ImplicitVR = false; DicomDict = in; - SetKey( in->GetKey( ) ); Offset = 0 ; // To avoid further missprinting // init some variables diff --git a/src/gdcmDocEntry.h b/src/gdcmDocEntry.h index 2310a70b..cf12bdfa 100644 --- a/src/gdcmDocEntry.h +++ b/src/gdcmDocEntry.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocEntry.h,v $ Language: C++ - Date: $Date: 2005/10/18 12:58:28 $ - Version: $Revision: 1.51 $ + Date: $Date: 2005/10/19 13:17:04 $ + Version: $Revision: 1.52 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -55,11 +55,8 @@ public: /// Returns the Dicom Element number of the current Dicom entry const uint16_t &GetElement() const { return DicomDict->GetElement();} - /// Set the 'key' of the current Dicom entry - void SetKey( TagKey const &key ) { Key = key; } - /// Returns the 'key' of the current Dicom entry - TagKey const &GetKey() const { return Key; } + TagKey GetKey() const { return DicomDict->GetKey(); } /// \brief Returns the 'Name' '(e.g. "Patient's Name") found in the Dicom /// Dictionnary of the current Dicom Header Entry @@ -148,10 +145,6 @@ protected: /// Offset from the beginning of file for direct user access size_t Offset; - /// \brief Generalized key of this DocEntry (for details on - /// the generalized key refer to \ref TagKey documentation). - TagKey Key; - private: }; } // end namespace gdcm diff --git a/src/gdcmDocEntrySet.h b/src/gdcmDocEntrySet.h index 99ce356a..bcf22dd3 100644 --- a/src/gdcmDocEntrySet.h +++ b/src/gdcmDocEntrySet.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocEntrySet.h,v $ Language: C++ - Date: $Date: 2005/10/18 12:58:28 $ - Version: $Revision: 1.58 $ + Date: $Date: 2005/10/19 13:17:05 $ + Version: $Revision: 1.59 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -21,6 +21,7 @@ #include "gdcmBase.h" #include "gdcmVRKey.h" +#include "gdcmTagKey.h" #include @@ -32,8 +33,6 @@ class DataEntry; class SeqEntry; class DictEntry; -typedef TagKey BaseTagKey; - //----------------------------------------------------------------------------- /** * \brief diff --git a/src/gdcmSQItem.h b/src/gdcmSQItem.h index 586d650c..4dca0cff 100644 --- a/src/gdcmSQItem.h +++ b/src/gdcmSQItem.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmSQItem.h,v $ Language: C++ - Date: $Date: 2005/09/02 07:10:03 $ - Version: $Revision: 1.44 $ + Date: $Date: 2005/10/19 13:17:05 $ + Version: $Revision: 1.45 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -72,12 +72,6 @@ public: /// \brief Accessor on \ref SQDepthLevel. void SetDepthLevel(int depth) { SQDepthLevel = depth; } - // waste time hunting - // / \brief Accessor on \ref BaseTagKey. - //void SetBaseTagKey( BaseTagKey const &key ) { BaseTagKeyNested = key; } - // / \brief Accessor on \ref BaseTagKey. - //BaseTagKey const &GetBaseTagKey() const { return BaseTagKeyNested; } - protected: // Variables that need to be accessed in subclasses /// \brief Chained list of Doc Entries @@ -95,11 +89,6 @@ private: /// (see \ref Print). int SQDepthLevel; - // waste time hunting - // / \brief A TagKey of a DocEntry nested in a sequence is prepended - // / with this BaseTagKey. - //BaseTagKey BaseTagKeyNested; - /// \brief SQ Item ordinal number int SQItemNumber; }; diff --git a/src/gdcmSerieHelper.h b/src/gdcmSerieHelper.h index 312da40c..693b82a6 100644 --- a/src/gdcmSerieHelper.h +++ b/src/gdcmSerieHelper.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmSerieHelper.h,v $ Language: C++ - Date: $Date: 2005/10/17 09:52:41 $ - Version: $Revision: 1.23 $ + Date: $Date: 2005/10/19 13:17:05 $ + Version: $Revision: 1.24 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -20,6 +20,7 @@ #define GDCMSERIEHELPER_H #include "gdcmCommon.h" +#include "gdcmTagKey.h" #include "gdcmDebug.h" // for LEGACY #include diff --git a/src/gdcmTagKey.h b/src/gdcmTagKey.h new file mode 100644 index 00000000..01b35d2b --- /dev/null +++ b/src/gdcmTagKey.h @@ -0,0 +1,97 @@ +/*========================================================================= + + Program: gdcm + Module: $RCSfile: gdcmTagKey.h,v $ + Language: C++ + Date: $Date: 2005/10/19 13:17:05 $ + Version: $Revision: 1.1 $ + + Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de + l'Image). All rights reserved. See Doc/License.txt or + http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#ifndef GDCMTAGKEY_H +#define GDCMTAGKEY_H + +#include "gdcmCommon.h" + +#include +#include +#include // for std::ios::left, ... + +namespace gdcm +{ +//----------------------------------------------------------------------------- +class TagKey +{ +public : + inline TagKey(const uint16_t &gr, const uint16_t &elt) { tag[0] = gr;tag[1] = elt;} + inline TagKey() { tag[0] = tag[1] = 0x0000;} + + friend std::ostream& operator<<(std::ostream& _os, const TagKey &_val); + + inline void SetGroup(const uint16_t &val) { tag[0] = val; } + inline const uint16_t &GetGroup(void) { return tag[0]; } + + inline void SetElement(const uint16_t &val) { tag[1] = val; } + inline const uint16_t &GetElement(void) { return tag[1]; } + + inline TagKey &operator=(const TagKey &_val) + { + tag[0] = _val.tag[0]; + tag[1] = _val.tag[1]; + return *this; + } + + inline const uint16_t &operator[](const unsigned int &_id) const + { + assert(_id<2); + return tag[_id]; + } + inline const uint16_t &operator[](const unsigned int &_id) + { + assert(_id<2); + return tag[_id]; + } + + inline bool operator==(const TagKey &_val) const + { + return tag[0] == _val.tag[0] && tag[1] == _val.tag[1]; + } + + inline bool operator!=(const TagKey &_val) const + { + return tag[0] != _val.tag[0] || tag[1] != _val.tag[1]; + } + + inline bool operator<(const TagKey &_val) const + { + return tag[0] < _val.tag[0] || (tag[0] == _val.tag[0] && tag[1] < _val.tag[1]); + } + +private : + uint16_t tag[2]; +}; + +//----------------------------------------------------------------------------- +inline std::ostream& operator<<(std::ostream& _os, const TagKey &_val) +{ + _os.setf( std::ios::right); + _os << std::hex << std::setw( 4 ) << std::setfill( '0' ) + << _val.tag[0] << '|' << std::setw( 4 ) << std::setfill( '0' ) + << _val.tag[1] << std::setfill( ' ' ) << std::dec; + return _os; +} + +//----------------------------------------------------------------------------- + +} // end namespace gdcm + +//----------------------------------------------------------------------------- +#endif diff --git a/src/gdcmVRKey.h b/src/gdcmVRKey.h index 71449375..a594abbc 100644 --- a/src/gdcmVRKey.h +++ b/src/gdcmVRKey.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmVRKey.h,v $ Language: C++ - Date: $Date: 2005/10/18 12:58:29 $ - Version: $Revision: 1.1 $ + Date: $Date: 2005/10/19 13:17:05 $ + Version: $Revision: 1.2 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -20,7 +20,6 @@ #define GDCMVRKEY_H #include "gdcmCommon.h" -#include "gdcmDebug.h" #include -- 2.45.2