gdcmDicomDirVisit.cxx
gdcmDicomDirSerie.cxx
gdcmDicomDirStudy.cxx
+ gdcmDicomEntry.cxx
gdcmDict.cxx
gdcmDictEntry.cxx
gdcmDictGroupName.cxx
gdcmDocument.cxx
gdcmElementSet.cxx
gdcmException.cxx
+ gdcmFile.cxx
gdcmFileHelper.cxx
gdcmGlobal.cxx
- gdcmFile.cxx
gdcmJPEGFragment.cxx
gdcmJPEGFragmentsInfo.cxx
gdcmJpeg8.cxx
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
#include <string>
-//-----------------------------------------------------------------------------
-// TagKey definition
-#define FASTTAGKEY 0
-
-// FIXME: Should rewrite this:
-#if FASTTAGKEY
- #include <iostream>
- #include <iomanip>
-#endif
- #if defined(_MSC_VER) && (_MSC_VER == 1200)
- /* ostream operator for std::string since VS6 does not provide it*/
- #include <iostream>
-#endif
-
//-----------------------------------------------------------------------------
#if defined(_WIN32) && defined(BUILD_SHARED_LIBS)
#ifdef gdcm_EXPORTS
/// 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)
--- /dev/null
+/*=========================================================================
+
+ 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 <iomanip> // for std::ios::left, ...
+#include <fstream>
+#include <stdio.h> // 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
+
--- /dev/null
+/*=========================================================================
+
+ 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
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
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);
}
//-----------------------------------------------------------------------------
{
if ( IsVRUnknown() )
{
- VR = vr;
+ DicomEntry::SetVR(vr);
}
else
{
}
}
-/**
- * \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
* @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);
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
#ifndef GDCMDICTENTRY_H
#define GDCMDICTENTRY_H
-#include "gdcmBase.h"
-#include "gdcmVRKey.h"
+#include "gdcmDicomEntry.h"
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,
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
//-----------------------------------------------------------------------------
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
{
ImplicitVR = false;
DicomDict = in;
- SetKey( in->GetKey( ) );
Offset = 0 ; // To avoid further missprinting
// init some variables
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
/// 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
/// 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
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
#include "gdcmBase.h"
#include "gdcmVRKey.h"
+#include "gdcmTagKey.h"
#include <fstream>
class SeqEntry;
class DictEntry;
-typedef TagKey BaseTagKey;
-
//-----------------------------------------------------------------------------
/**
* \brief
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
/// \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
/// (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;
};
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
#define GDCMSERIEHELPER_H
#include "gdcmCommon.h"
+#include "gdcmTagKey.h"
#include "gdcmDebug.h" // for LEGACY
#include <vector>
--- /dev/null
+/*=========================================================================
+
+ 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 <assert.h>
+#include <iostream>
+#include <iomanip> // 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
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
#define GDCMVRKEY_H
#include "gdcmCommon.h"
-#include "gdcmDebug.h"
#include <assert.h>