From: jpr Date: Wed, 22 Mar 2006 13:19:25 +0000 (+0000) Subject: To speed up the parsing process (avoid accessing HTable when useless): X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=a7667287c96b694d414791dd93e33e8efe0e3bc6;p=gdcm.git To speed up the parsing process (avoid accessing HTable when useless): VR and Key are now stored int the DocEntry DefaultPubDict is stored as well outsite the Htable. --- diff --git a/src/gdcmDictSet.cxx b/src/gdcmDictSet.cxx index 63c03594..891ab754 100644 --- a/src/gdcmDictSet.cxx +++ b/src/gdcmDictSet.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDictSet.cxx,v $ Language: C++ - Date: $Date: 2005/11/28 15:20:33 $ - Version: $Revision: 1.73 $ + Date: $Date: 2006/03/22 13:19:25 $ + Version: $Revision: 1.74 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -18,6 +18,7 @@ #include "gdcmDictSet.h" #include "gdcmDebug.h" +#include "gdcmGlobal.h" #include #include // For getenv #include // For sprintf @@ -37,6 +38,8 @@ DictSet::DictSet() std::string pubDictFile(DictPath); pubDictFile += PUB_DICT_FILENAME; Dicts[PUB_DICT_NAME] = Dict::New(pubDictFile); + // Stored redundantly to avoid at access HTable DictSet every time. + Global::DefaultPubDict = Dicts[PUB_DICT_NAME]; } /** diff --git a/src/gdcmDictSet.h b/src/gdcmDictSet.h index f8f0c147..0638e7b7 100644 --- a/src/gdcmDictSet.h +++ b/src/gdcmDictSet.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDictSet.h,v $ Language: C++ - Date: $Date: 2005/11/28 16:31:23 $ - Version: $Revision: 1.52 $ + Date: $Date: 2006/03/22 13:19:25 $ + 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 @@ -21,6 +21,7 @@ #include "gdcmRefCounter.h" #include "gdcmDict.h" +#include "gdcmGlobal.h" #include #include @@ -58,8 +59,9 @@ public: Dict *GetDict( DictKey const &DictName ); /// \brief Returns the default reference DICOM V3 public dictionary. - Dict* GetDefaultPubDict() { return GetDict(PUB_DICT_NAME); } - + //Dict* GetDefaultPubDict() { return GetDict(PUB_DICT_NAME); } + Dict* GetDefaultPubDict() { return Global::DefaultPubDict; } + // \ brief Returns the virtual references DICOM dictionary. // \ warning : not end user intended // Dict *GetVirtualDict() { return &VirtualEntries; } diff --git a/src/gdcmDocEntry.cxx b/src/gdcmDocEntry.cxx index 535e3bc9..c076fcc0 100644 --- a/src/gdcmDocEntry.cxx +++ b/src/gdcmDocEntry.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocEntry.cxx,v $ Language: C++ - Date: $Date: 2006/02/16 20:06:14 $ - Version: $Revision: 1.81 $ + Date: $Date: 2006/03/22 13:19:25 $ + Version: $Revision: 1.82 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -48,6 +48,9 @@ DocEntry::DocEntry(DictEntry *in) gdcmAssertMacro(DicomDict); DicomDict->Register(); + + VR = in->GetVR(); + Key = in->GetKey(); } /** diff --git a/src/gdcmDocEntry.h b/src/gdcmDocEntry.h index dc09c90a..b4133703 100644 --- a/src/gdcmDocEntry.h +++ b/src/gdcmDocEntry.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocEntry.h,v $ Language: C++ - Date: $Date: 2006/02/16 20:06:14 $ - Version: $Revision: 1.60 $ + Date: $Date: 2006/03/22 13:19:25 $ + Version: $Revision: 1.61 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -48,13 +48,16 @@ public: DictEntry * GetDictEntry() { return DicomDict; } /// Returns the Dicom Group number of the current Dicom entry - const uint16_t &GetGroup() const { return DicomDict->GetGroup(); } + const uint16_t GetGroup() const { return Key.GetGroup(); } + //const uint16_t &GetGroup() const { return DicomDict->GetGroup(); } /// Returns the Dicom Element number of the current Dicom entry - const uint16_t &GetElement() const { return DicomDict->GetElement();} + const uint16_t GetElement() const { return Key.GetElement();} + //const uint16_t &GetElement() const { return DicomDict->GetElement();} /// Returns the 'key' of the current Dicom entry - TagKey GetKey() const { return DicomDict->GetKey(); } + TagKey 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 @@ -63,7 +66,8 @@ public: /// \brief Returns the 'Value Representation' (e.g. "PN" : Person Name, /// "SL" : Signed Long), found in the Dicom header or in the Dicom /// Dictionnary, of the current Dicom entry - VRKey const &GetVR() const { return DicomDict->GetVR(); } + VRKey const &GetVR() const { return VR; } + //VRKey const &GetVR() const { return DicomDict->GetVR(); } /// \brief Returns the 'Value Multiplicity' (e.g. "1", "6", "1-n", "3-n"), /// found in the Dicom entry or in the Dicom Dictionnary @@ -83,7 +87,7 @@ public: void SetReadLength(uint32_t l) { ReadLength = l; } /// \brief Returns the 'read length' of the current Dicom entry /// \warning this value is the one stored in the Dicom header but not - /// mandatoryly the one thats's used (in case on SQ, or delimiters, + /// mandatoryly the one thats's used (in case of SQ, or delimiters, /// the usable length is set to zero) const uint32_t &GetReadLength() const { return ReadLength; } @@ -98,7 +102,8 @@ public: uint32_t GetFullLength(); virtual uint32_t ComputeFullLength() = 0; -// The following 3 members, for internal use only ! +// The following members, for internal use only ! + /// \brief Sets the offset of the Dicom entry /// \warning use with caution ! /// @param of offset to be set @@ -107,6 +112,16 @@ public: /// Sets to TRUE the ImplicitVr flag of the current Dicom entry void SetImplicitVR() { ImplicitVR = true; } + /// Sets the 'Value Representation' of the current Dicom entry + /// @param vr VR to be set + void SetVR( VRKey const &vr) { VR = vr; } + + /// Sets the 'Value Representation' of the current Dicom entry + /// @param key TagKey to be set + void SetTag( TagKey const &key) { Key = key; } + +// -----------end of members to be used with caution + /// \brief Tells us if the current Dicom entry was checked as ImplicitVr /// @return true if the current Dicom entry was checked as ImplicitVr bool IsImplicitVR() const { return ImplicitVR; } @@ -131,8 +146,8 @@ protected: /// \brief pointer to the underlying Dicom dictionary element DictEntry *DicomDict; - - /// \brief Correspond to the real length of the data + + /// \brief Corresponds to the real length of the data /// This length might always be even uint32_t Length; @@ -147,7 +162,14 @@ protected: /// Offset from the beginning of file for direct user access size_t Offset; + /// \brief Value Representation (to avoid accessing Dicom Dict every time!) + VRKey VR; // JPRx + + /// \brief Dicom \ref TagKey. Contains Dicom Group number and Dicom Element number + /// (to avoid accessing Dicom Dict every time !) // JPRx + TagKey Key; // JPRx private: + }; } // end namespace gdcm //----------------------------------------------------------------------------- diff --git a/src/gdcmDocEntrySet.cxx b/src/gdcmDocEntrySet.cxx index 18e713d8..7be85dff 100644 --- a/src/gdcmDocEntrySet.cxx +++ b/src/gdcmDocEntrySet.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocEntrySet.cxx,v $ Language: C++ - Date: $Date: 2006/02/16 20:06:14 $ - Version: $Revision: 1.70 $ + Date: $Date: 2006/03/22 13:19:25 $ + Version: $Revision: 1.71 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -442,7 +442,7 @@ SeqEntry* DocEntrySet::NewSeqEntry(uint16_t group, uint16_t elem) gdcmWarningMacro( "Failed to allocate SeqEntry for (" <GetDefaultPubDict(); if (!pubDict) { @@ -478,7 +480,7 @@ DictEntry *DocEntrySet::GetDictEntry(uint16_t group,uint16_t elem) /** * \brief 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 + * group and element, and creates a new virtual DictEntry if necessary * @param group group number of the searched DictEntry * @param elem element number of the searched DictEntry * @param vr V(alue) R(epresentation) to use, if necessary diff --git a/src/gdcmGlobal.cxx b/src/gdcmGlobal.cxx index ad98da2c..2bed9195 100644 --- a/src/gdcmGlobal.cxx +++ b/src/gdcmGlobal.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmGlobal.cxx,v $ Language: C++ - Date: $Date: 2006/01/11 10:44:24 $ - Version: $Revision: 1.31 $ + Date: $Date: 2006/03/22 13:19:25 $ + Version: $Revision: 1.32 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -58,6 +58,8 @@ TS *Global::TranSyn = (TS *)0; DictGroupName *Global::GroupName = (DictGroupName *)0; DicomDirElement *Global::ddElem = (DicomDirElement *)0; +Dict *Global::DefaultPubDict = (Dict *)0; + //----------------------------------------------------------------------------- /** * \brief Global container diff --git a/src/gdcmGlobal.h b/src/gdcmGlobal.h index 4a68c639..adffda9c 100644 --- a/src/gdcmGlobal.h +++ b/src/gdcmGlobal.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmGlobal.h,v $ Language: C++ - Date: $Date: 2005/11/30 10:58:28 $ - Version: $Revision: 1.9 $ + Date: $Date: 2006/03/22 13:19:25 $ + Version: $Revision: 1.10 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -36,6 +36,8 @@ class DicomDirElement; class Dict; class GDCM_EXPORT Global { +friend class DictSet; // to allow setting DefaultPubDict without + // providing any body an accesor ! public: Global(); ~Global(); @@ -65,6 +67,9 @@ private: /// \brief Pointer to the hash table containing the Dicom Elements necessary /// to describe each part of a DICOMDIR static DicomDirElement *ddElem; + /// pointer to the Default Public Dictionnary, redundantly store here, + /// in order not to acces the HTable every time! + static Dict *DefaultPubDict; }; } // end namespace gdcm