From 54ce6e928bccc91bb12601c782b92c833678de40 Mon Sep 17 00:00:00 2001 From: regrain Date: Wed, 14 Jan 2004 09:58:37 +0000 Subject: [PATCH] * src/gdcmHeaderEntry.[h|cxx] : gdcmElValue -> gdcmHeaderEntry * src/gdcmHeaderEntrySet.[h|cxx] : gdcmElValSet -> gdcmHeaderEntrySet * src/*.[h|cxx] : make changes due to class name changes -- BeNours --- ChangeLog | 5 + gdcmPython/gdcm.i | 16 +- gdcmPython/testSuite.py | 2 +- gdcmPython/win32/_vtkGdcm.dsp | 12 +- gdcmPython/win32/gdcmpyembedded.dsp | 12 +- src/CMakeLists.txt | 4 +- src/Makefile.am | 64 +- src/gdcmElValSet.h | 73 -- src/gdcmFile.cxx | 42 +- src/gdcmHeader.cxx | 670 +++++++++--------- src/gdcmHeader.h | 96 +-- src/{gdcmElValue.cxx => gdcmHeaderEntry.cxx} | 10 +- src/{gdcmElValue.h => gdcmHeaderEntry.h} | 38 +- ...dcmElValSet.cxx => gdcmHeaderEntrySet.cxx} | 156 ++-- src/gdcmHeaderEntrySet.h | 73 ++ src/gdcmHeaderHelper.cxx | 56 +- src/gdcmParse.cxx | 2 +- src/win32/gdcmdll.dsp | 24 +- vtk/win32/vtkgdcm.dsp | 10 +- 19 files changed, 686 insertions(+), 679 deletions(-) delete mode 100644 src/gdcmElValSet.h rename src/{gdcmElValue.cxx => gdcmHeaderEntry.cxx} (81%) rename src/{gdcmElValue.h => gdcmHeaderEntry.h} (82%) rename src/{gdcmElValSet.cxx => gdcmHeaderEntrySet.cxx} (79%) create mode 100644 src/gdcmHeaderEntrySet.h diff --git a/ChangeLog b/ChangeLog index 9b180ef0..de94800a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2004-01-14 Benoit Regrain + * src/gdcmHeaderEntry.[h|cxx] : gdcmElValue -> gdcmHeaderEntry + * src/gdcmHeaderEntrySet.[h|cxx] : gdcmElValSet -> gdcmHeaderEntrySet + * src/*.[h|cxx] : make changes due to class name changes + 2004-01-13 Benoit Regrain * src/*.[h|cxx] : coding style * vtk/*.[h|cxx] : coding style diff --git a/gdcmPython/gdcm.i b/gdcmPython/gdcm.i index 8683251f..7e7f40f5 100644 --- a/gdcmPython/gdcm.i +++ b/gdcmPython/gdcm.i @@ -4,12 +4,12 @@ #include "gdcmDictEntry.h" #include "gdcmDict.h" #include "gdcmDictSet.h" -#include "gdcmElValue.h" -#include "gdcmElValSet.h" -#include "gdcmUtil.h" +#include "gdcmHeaderEntry.h" +#include "gdcmHeaderEntrySet.h" #include "gdcmHeader.h" #include "gdcmHeaderHelper.h" #include "gdcmFile.h" +#include "gdcmUtil.h" using namespace std; // Utility functions on strings for removing leading and trailing spaces @@ -68,14 +68,14 @@ extern gdcmGlobal gdcmGlob; //////////////////////////////////////////////////////////////////////////// // Convert a c++ hash table in a python native dictionary -%typemap(out) TagElValueHT & { +%typemap(out) TagHeaderEntryHT & { PyObject* NewDict = PyDict_New(); // The result of this typemap string RawName; // Element name as gotten from gdcm PyObject* NewKey = (PyObject*)0; // Associated name as python object string RawValue; // Element value as gotten from gdcm PyObject* NewVal = (PyObject*)0; // Associated value as python object - for (TagElValueHT::iterator tag = $1->begin(); tag != $1->end(); ++tag) { + for (TagHeaderEntryHT::iterator tag = $1->begin(); tag != $1->end(); ++tag) { // The element name shall be the key: RawName = tag->second->GetName(); @@ -110,9 +110,9 @@ extern gdcmGlobal gdcmGlob; %include "gdcmDictEntry.h" %include "gdcmDict.h" %include "gdcmDictSet.h" -%include "gdcmElValue.h" -%include "gdcmElValSet.h" -%include "gdcmUtil.h" +%include "gdcmHeaderEntry.h" +%include "gdcmHeaderEntrySet.h" %include "gdcmHeader.h" %include "gdcmHeaderHelper.h" %include "gdcmFile.h" +%include "gdcmUtil.h" diff --git a/gdcmPython/testSuite.py b/gdcmPython/testSuite.py index 32627872..2d9057b7 100644 --- a/gdcmPython/testSuite.py +++ b/gdcmPython/testSuite.py @@ -540,7 +540,7 @@ class gdcmTestCase(unittest.TestCase): assert reader.IsReadable(),\ "File '%s' is not readable by gdcmHeader" % fileName - valDict = reader.GetPubElVal() + valDict = reader.GetPubEntry() for subEntry in entry[1]: element = subEntry[0] value = subEntry[1] diff --git a/gdcmPython/win32/_vtkGdcm.dsp b/gdcmPython/win32/_vtkGdcm.dsp index 4b434b6c..f6236770 100644 --- a/gdcmPython/win32/_vtkGdcm.dsp +++ b/gdcmPython/win32/_vtkGdcm.dsp @@ -70,23 +70,23 @@ SOURCE=..\..\src\gdcmDictSet.cxx # End Source File # Begin Source File -SOURCE=..\..\src\gdcmElValSet.cxx +SOURCE=..\..\src\gdcmException.cxx # End Source File # Begin Source File -SOURCE=..\..\src\gdcmElValue.cxx +SOURCE=..\..\src\gdcmFile.cxx # End Source File # Begin Source File -SOURCE=..\..\src\gdcmException.cxx +SOURCE=..\..\src\gdcmHeader.cxx # End Source File # Begin Source File -SOURCE=..\..\src\gdcmFile.cxx +SOURCE=..\..\src\gdcmHeaderEntry.cxx # End Source File # Begin Source File -SOURCE=..\..\src\gdcmHeader.cxx +SOURCE=..\..\src\gdcmHeaderEntrySet.cxx # End Source File # Begin Source File @@ -156,7 +156,7 @@ InputPath=.\init.h SOURCE=..\..\vtk\vtkGdcmReader.h # Begin Custom Build - Performing Custom Build Step on $(VTKPATH)\bin\vtkwrappython "$(InputDir)\$(InputName).h" $(VTKPATH)\Examples\Build\vtkMy\Wrapping\hints 1 $(ProjDir)\..\$(InputName)Python.cxx -InputDir=\Projects\gdcm\vtk +InputDir=\Projects\gdcm\VTK ProjDir=. InputPath=..\..\vtk\vtkGdcmReader.h InputName=vtkGdcmReader diff --git a/gdcmPython/win32/gdcmpyembedded.dsp b/gdcmPython/win32/gdcmpyembedded.dsp index 1b652b88..29e42f31 100644 --- a/gdcmPython/win32/gdcmpyembedded.dsp +++ b/gdcmPython/win32/gdcmpyembedded.dsp @@ -53,7 +53,7 @@ LINK32=link.exe # Begin Special Build Tool ProjDir=. SOURCE="$(InputPath)" -PostBuild_Cmds=move $(ProjDir)\gdcm.py $(ProjDir)\..\ +PostBuild_Cmds=move $(ProjDir)\gdcm.py $(ProjDir)\..\ # End Special Build Tool # Begin Target @@ -92,23 +92,23 @@ SOURCE=..\..\src\gdcmDictSet.cxx # End Source File # Begin Source File -SOURCE=..\..\src\gdcmElValSet.cxx +SOURCE=..\..\src\gdcmException.cxx # End Source File # Begin Source File -SOURCE=..\..\src\gdcmElValue.cxx +SOURCE=..\..\src\gdcmFile.cxx # End Source File # Begin Source File -SOURCE=..\..\src\gdcmException.cxx +SOURCE=..\..\src\gdcmHeader.cxx # End Source File # Begin Source File -SOURCE=..\..\src\gdcmFile.cxx +SOURCE=..\..\src\gdcmHeaderEntry.cxx # End Source File # Begin Source File -SOURCE=..\..\src\gdcmHeader.cxx +SOURCE=..\..\src\gdcmHeaderEntrySet.cxx # End Source File # Begin Source File diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d7ad2795..5000f8c6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -14,11 +14,11 @@ SET(libgdcm_la_SOURCES gdcmUtil.cxx gdcmHeader.cxx gdcmHeaderHelper.cxx - gdcmElValue.cxx + gdcmHeaderEntry.cxx + gdcmHeaderEntrySet.cxx gdcmDictEntry.cxx gdcmDict.cxx gdcmDictSet.cxx - gdcmElValSet.cxx gdcmFile.cxx gdcmVR.cxx gdcmTS.cxx diff --git a/src/Makefile.am b/src/Makefile.am index d252f51b..68883906 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -12,41 +12,41 @@ libgdcm_la_LIBADD = \ $(top_builddir)/src/jpeg/libijg8/libgdcmijpeg8.la \ $(top_builddir)/src/jpeg/ljpg/libgdcmjpg.la -libgdcm_la_SOURCES= \ - gdcmException.cxx \ - gdcmUtil.cxx \ - gdcmHeader.cxx \ - gdcmHeaderHelper.cxx \ - gdcmElValue.cxx \ - gdcmDictEntry.cxx \ - gdcmDict.cxx \ - gdcmDictSet.cxx \ - gdcmElValSet.cxx \ - gdcmFile.cxx \ - gdcmVR.cxx \ - gdcmTS.cxx \ - gdcmJpeg.cxx \ - gdcmJpeg12.cxx \ - gdcmJpeg2000.cxx \ - gdcmRLE.cxx \ - gdcmParse.cxx +libgdcm_la_SOURCES= \ + gdcmException.cxx \ + gdcmUtil.cxx \ + gdcmHeader.cxx \ + gdcmHeaderHelper.cxx \ + gdcmHeaderEntry.cxx \ + gdcmHeaderEntrySet.cxx \ + gdcmDictEntry.cxx \ + gdcmDict.cxx \ + gdcmDictSet.cxx \ + gdcmFile.cxx \ + gdcmVR.cxx \ + gdcmTS.cxx \ + gdcmJpeg.cxx \ + gdcmJpeg12.cxx \ + gdcmJpeg2000.cxx \ + gdcmRLE.cxx \ + gdcmParse.cxx libgdcmincludedir = $(includedir) -libgdcminclude_HEADERS = \ - gdcmException.h \ - gdcmHeader.h \ - gdcmHeaderHelper.h \ - gdcmCommon.h \ - gdcm.h \ - gdcmDictSet.h \ - gdcmDict.h \ - gdcmDictEntry.h \ - gdcmElValue.h \ - gdcmElValSet.h \ - gdcmVR.h \ - gdcmTS.h \ +libgdcminclude_HEADERS = \ + gdcmException.h \ + gdcmHeader.h \ + gdcmHeaderHelper.h \ + gdcmCommon.h \ + gdcm.h \ + gdcmDictSet.h \ + gdcmDict.h \ + gdcmDictEntry.h \ + gdcmElValue.h \ + gdcmElValSet.h \ + gdcmVR.h \ + gdcmTS.h \ gdcmFile.h -EXTRA_DIST = \ +EXTRA_DIST = \ gdcmUtil.h diff --git a/src/gdcmElValSet.h b/src/gdcmElValSet.h deleted file mode 100644 index 07bea3ca..00000000 --- a/src/gdcmElValSet.h +++ /dev/null @@ -1,73 +0,0 @@ -// gdcmElValSet.h -//----------------------------------------------------------------------------- -#ifndef GDCMELVALSET_H -#define GDCMELVALSET_H - -#include "gdcmCommon.h" -#include "gdcmElValue.h" - -#include -#include -#include // for linking together *all* the Dicom Elements - -//----------------------------------------------------------------------------- -typedef std::multimap TagElValueHT; -typedef std::pair PairHT; -typedef std::pair IterHT; - -typedef std::list ListTag; // for linking together the Elements - -// TODO : to be removed after re-writting gdcmElValSet::UpdateGroupLength -// using the chained list instead of the H table -typedef std::string GroupKey; -typedef std::map GroupHT; - -//----------------------------------------------------------------------------- -/* - * Container for a set of successfully parsed ElValues (i.e. Dicom Elements). - */ -class GDCM_EXPORT gdcmElValSet { -public: - ~gdcmElValSet(); - - void Print(std::ostream &); - - void Add(gdcmElValue*); - - gdcmElValue* GetElementByNumber(guint16 group, guint16 element); - std::string GetElValueByNumber(guint16 group, guint16 element); - - bool SetElValueByNumber(std::string content, guint16 group, guint16 element); - bool SetElValueLengthByNumber(guint32 l, guint16 group, guint16 element); - bool SetVoidAreaByNumber(void *a, guint16 Group, guint16 Elem ); - - guint32 GenerateFreeTagKeyInGroup(guint16 group); - int CheckIfExistByNumber(guint16 Group, guint16 Elem ); // int ! - - /** - * \ingroup gdcmElValSet - * \brief returns a ref to the Dicom Header H table (multimap) - * return the Dicom Header H table - */ - inline TagElValueHT & gdcmElValSet::GetTagHt(void) { return tagHt; }; - - /** - * \ingroup gdcmElValSet - * \brief returns a ref to the Dicom Header chained list - * return the Dicom Header chained list - */ - inline ListTag & gdcmElValSet::GetListElem(void) { return listElem; }; - - bool Write(FILE *fp, FileType type); - -private: - void UpdateGroupLength(bool SkipSequence = false, FileType type = ImplicitVR); - void WriteElements(FileType type, FILE *); - -// Variables - TagElValueHT tagHt; // H Table (multimap), to provide fast access - ListTag listElem; // chained list, to keep the 'spacial' ordering -}; - -//----------------------------------------------------------------------------- -#endif diff --git a/src/gdcmFile.cxx b/src/gdcmFile.cxx index fb042163..ffb3d848 100644 --- a/src/gdcmFile.cxx +++ b/src/gdcmFile.cxx @@ -137,7 +137,7 @@ void gdcmFile::SetPixelDataSizeFromHeader(void) { int nb; std::string str_nb; - str_nb=Header->GetPubElValByNumber(0x0028,0x0100); + str_nb=Header->GetPubEntryByNumber(0x0028,0x0100); if (str_nb == GDCM_UNFOUND ) { nb = 16; } else { @@ -147,7 +147,7 @@ void gdcmFile::SetPixelDataSizeFromHeader(void) { lgrTotale = lgrTotaleRaw = Header->GetXSize() * Header->GetYSize() * Header->GetZSize() * (nb/8)* Header->GetSamplesPerPixel(); std::string str_PhotometricInterpretation = - Header->GetPubElValByNumber(0x0028,0x0004); + Header->GetPubEntryByNumber(0x0028,0x0004); /*if ( str_PhotometricInterpretation == "PALETTE COLOR " )*/ // pb when undealt Segmented Palette Color @@ -246,11 +246,11 @@ size_t gdcmFile::GetImageDataIntoVector (void* destination, size_t MaxSize) { // CreateOrReplaceIfExist ? std::string spp = "3"; // Samples Per Pixel - Header->SetPubElValByNumber(spp,0x0028,0x0002); + Header->SetPubEntryByNumber(spp,0x0028,0x0002); std::string rgb= "RGB "; // Photometric Interpretation - Header->SetPubElValByNumber(rgb,0x0028,0x0004); + Header->SetPubEntryByNumber(rgb,0x0028,0x0004); std::string planConfig = "0"; // Planar Configuration - Header->SetPubElValByNumber(planConfig,0x0028,0x0006); + Header->SetPubEntryByNumber(planConfig,0x0028,0x0006); } else { // need to make RGB Pixels (?) @@ -266,7 +266,7 @@ size_t gdcmFile::GetImageDataIntoVector (void* destination, size_t MaxSize) { // Segmented xxx Palette Color are *more* than 65535 long ?!? std::string rgb= "MONOCHROME1 "; // Photometric Interpretation - Header->SetPubElValByNumber(rgb,0x0028,0x0004); + Header->SetPubEntryByNumber(rgb,0x0028,0x0004); } @@ -333,7 +333,7 @@ size_t gdcmFile::GetImageDataIntoVectorRaw (void* destination, size_t MaxSize) { (void)ReadPixelData(destination); // Nombre de Bits Alloues pour le stockage d'un Pixel - str_nb = Header->GetPubElValByNumber(0x0028,0x0100); + str_nb = Header->GetPubEntryByNumber(0x0028,0x0100); if (str_nb == GDCM_UNFOUND ) { nb = 16; } else { @@ -341,7 +341,7 @@ size_t gdcmFile::GetImageDataIntoVectorRaw (void* destination, size_t MaxSize) { } // Nombre de Bits Utilises - str_nbu=Header->GetPubElValByNumber(0x0028,0x0101); + str_nbu=Header->GetPubEntryByNumber(0x0028,0x0101); if (str_nbu == GDCM_UNFOUND ) { nbu = nb; } else { @@ -349,7 +349,7 @@ size_t gdcmFile::GetImageDataIntoVectorRaw (void* destination, size_t MaxSize) { } // Position du Bit de Poids Fort - str_highBit=Header->GetPubElValByNumber(0x0028,0x0102); + str_highBit=Header->GetPubEntryByNumber(0x0028,0x0102); if (str_highBit == GDCM_UNFOUND ) { highBit = nb - 1; } else { @@ -358,7 +358,7 @@ size_t gdcmFile::GetImageDataIntoVectorRaw (void* destination, size_t MaxSize) { // Pixel sign // 0 = Unsigned // 1 = Signed - str_signe=Header->GetPubElValByNumber(0x0028,0x0103); + str_signe=Header->GetPubEntryByNumber(0x0028,0x0103); if (str_signe == GDCM_UNFOUND ) { signe = 0; // default is unsigned } else { @@ -416,7 +416,7 @@ size_t gdcmFile::GetImageDataIntoVectorRaw (void* destination, size_t MaxSize) { // ------------------- std::string str_PhotometricInterpretation = - Header->GetPubElValByNumber(0x0028,0x0004); + Header->GetPubEntryByNumber(0x0028,0x0004); if ( (str_PhotometricInterpretation == "MONOCHROME1 ") || (str_PhotometricInterpretation == "MONOCHROME2 ") ) { @@ -531,12 +531,12 @@ size_t gdcmFile::GetImageDataIntoVectorRaw (void* destination, size_t MaxSize) { // CreateOrReplaceIfExist ? std::string spp = "3"; // Samples Per Pixel - Header->SetPubElValByNumber(spp,0x0028,0x0002); + Header->SetPubEntryByNumber(spp,0x0028,0x0002); std::string rgb="RGB "; // Photometric Interpretation - Header->SetPubElValByNumber(rgb,0x0028,0x0004); + Header->SetPubEntryByNumber(rgb,0x0028,0x0004); std::string planConfig = "0"; // Planar Configuration - Header->SetPubElValByNumber(planConfig,0x0028,0x0006); + Header->SetPubEntryByNumber(planConfig,0x0028,0x0006); // TODO : Drop Palette Color out of the Header? return lgrTotale; @@ -675,10 +675,10 @@ bool gdcmFile::WriteBase (std::string FileName, FileType type) { std::string rows, columns; if ( Header->GetFileType() == ACR_LIBIDO){ - rows = Header->GetPubElValByNumber(0x0028, 0x0010); - columns = Header->GetPubElValByNumber(0x0028, 0x0011); - Header->SetPubElValByNumber(columns, 0x0028, 0x0010); - Header->SetPubElValByNumber(rows , 0x0028, 0x0011); + rows = Header->GetPubEntryByNumber(0x0028, 0x0010); + columns = Header->GetPubEntryByNumber(0x0028, 0x0011); + Header->SetPubEntryByNumber(columns, 0x0028, 0x0010); + Header->SetPubEntryByNumber(rows , 0x0028, 0x0011); } // ----------------- End of Special Patch ---------------- @@ -691,8 +691,8 @@ bool gdcmFile::WriteBase (std::string FileName, FileType type) { // just after writting if (Header->GetFileType() == ACR_LIBIDO){ - Header->SetPubElValByNumber(rows , 0x0028, 0x0010); - Header->SetPubElValByNumber(columns, 0x0028, 0x0011); + Header->SetPubEntryByNumber(rows , 0x0028, 0x0010); + Header->SetPubEntryByNumber(columns, 0x0028, 0x0011); } // ----------------- End of Special Patch ---------------- @@ -851,7 +851,7 @@ bool gdcmFile::ReadPixelData(void* destination) { // --------------- SingleFrame/Multiframe JPEG Lossless/Lossy/2000 int nb; - std::string str_nb=Header->GetPubElValByNumber(0x0028,0x0100); + std::string str_nb=Header->GetPubEntryByNumber(0x0028,0x0100); if (str_nb == GDCM_UNFOUND ) { nb = 16; } else { diff --git a/src/gdcmHeader.cxx b/src/gdcmHeader.cxx index eb927e3c..4c39aada 100644 --- a/src/gdcmHeader.cxx +++ b/src/gdcmHeader.cxx @@ -54,7 +54,7 @@ gdcmHeader::gdcmHeader(const char *InFilename, if ( !OpenFile(exception_on_error)) return; ParseHeader(); - LoadElements(); + LoadHeaderEntries(); CloseFile(); } @@ -88,8 +88,8 @@ gdcmHeader::~gdcmHeader (void) { * \brief * @return */ -void gdcmHeader::PrintPubElVal(std::ostream & os) { - PubElValSet.Print(os); +void gdcmHeader::PrintPubEntry(std::ostream & os) { + PubEntrySet.Print(os); } /** @@ -113,18 +113,18 @@ void gdcmHeader::PrintPubDict(std::ostream & os) { * false otherwise. */ bool gdcmHeader::IsReadable(void) { - std::string res = GetPubElValByNumber(0x0028, 0x0005); - if ( res != GDCM_UNFOUND - && atoi(res.c_str()) > 4 ) { + std::string res = GetEntryByNumber(0x0028, 0x0005); + if ( res != GDCM_UNFOUND && atoi(res.c_str()) > 4 ) { return false; // Image Dimensions } - if ( GetPubElValByNumber(0x0028, 0x0100) == GDCM_UNFOUND ) + + if ( !GetHeaderEntryByNumber(0x0028, 0x0100) ) return false; // "Bits Allocated" - if ( GetPubElValByNumber(0x0028, 0x0101) == GDCM_UNFOUND ) + if ( !GetHeaderEntryByNumber(0x0028, 0x0101) ) return false; // "Bits Stored" - if ( GetPubElValByNumber(0x0028, 0x0102) == GDCM_UNFOUND ) + if ( !GetHeaderEntryByNumber(0x0028, 0x0102) ) return false; // "High Bit" - if ( GetPubElValByNumber(0x0028, 0x0103) == GDCM_UNFOUND ) + if ( !GetHeaderEntryByNumber(0x0028, 0x0103) ) return false; // "Pixel Representation" return true; } @@ -137,10 +137,11 @@ bool gdcmHeader::IsReadable(void) { * @return True when ImplicitVRLittleEndian found. False in all other cases. */ bool gdcmHeader::IsImplicitVRLittleEndianTransferSyntax(void) { - gdcmElValue* Element = PubElValSet.GetElementByNumber(0x0002, 0x0010); + gdcmHeaderEntry *Element = GetHeaderEntryByNumber(0x0002, 0x0010); if ( !Element ) return false; - LoadElementValueSafe(Element); + LoadHeaderEntrySafe(Element); + std::string Transfer = Element->GetValue(); if ( Transfer == "1.2.840.10008.1.2" ) return true; @@ -155,10 +156,11 @@ bool gdcmHeader::IsImplicitVRLittleEndianTransferSyntax(void) { * @return True when ExplicitVRLittleEndian found. False in all other cases. */ bool gdcmHeader::IsExplicitVRLittleEndianTransferSyntax(void) { - gdcmElValue* Element = PubElValSet.GetElementByNumber(0x0002, 0x0010); + gdcmHeaderEntry* Element = GetHeaderEntryByNumber(0x0002, 0x0010); if ( !Element ) return false; - LoadElementValueSafe(Element); + LoadHeaderEntrySafe(Element); + std::string Transfer = Element->GetValue(); if ( Transfer == "1.2.840.10008.1.2.1" ) return true; @@ -173,10 +175,11 @@ bool gdcmHeader::IsExplicitVRLittleEndianTransferSyntax(void) { * @return True when DeflatedExplicitVRLittleEndian found. False in all other cases. */ bool gdcmHeader::IsDeflatedExplicitVRLittleEndianTransferSyntax(void) { - gdcmElValue* Element = PubElValSet.GetElementByNumber(0x0002, 0x0010); + gdcmHeaderEntry* Element = GetHeaderEntryByNumber(0x0002, 0x0010); if ( !Element ) return false; - LoadElementValueSafe(Element); + LoadHeaderEntrySafe(Element); + std::string Transfer = Element->GetValue(); if ( Transfer == "1.2.840.10008.1.2.1.99" ) return true; @@ -191,10 +194,11 @@ bool gdcmHeader::IsDeflatedExplicitVRLittleEndianTransferSyntax(void) { * @return True when big endian found. False in all other cases. */ bool gdcmHeader::IsExplicitVRBigEndianTransferSyntax(void) { - gdcmElValue* Element = PubElValSet.GetElementByNumber(0x0002, 0x0010); + gdcmHeaderEntry* Element = GetHeaderEntryByNumber(0x0002, 0x0010); if ( !Element ) return false; - LoadElementValueSafe(Element); + LoadHeaderEntrySafe(Element); + std::string Transfer = Element->GetValue(); if ( Transfer == "1.2.840.10008.1.2.2" ) //1.2.2 ??? A verifier ! return true; @@ -209,10 +213,11 @@ bool gdcmHeader::IsExplicitVRBigEndianTransferSyntax(void) { * @return True when JPEGBaseLineProcess1found. False in all other cases. */ bool gdcmHeader::IsJPEGBaseLineProcess1TransferSyntax(void) { - gdcmElValue* Element = PubElValSet.GetElementByNumber(0x0002, 0x0010); + gdcmHeaderEntry* Element = GetHeaderEntryByNumber(0x0002, 0x0010); if ( !Element ) return false; - LoadElementValueSafe(Element); + LoadHeaderEntrySafe(Element); + std::string Transfer = Element->GetValue(); if ( Transfer == "1.2.840.10008.1.2.4.50" ) return true; @@ -227,10 +232,11 @@ bool gdcmHeader::IsJPEGBaseLineProcess1TransferSyntax(void) { * @return True when JPEGExtendedProcess2-4 found. False in all other cases. */ bool gdcmHeader::IsJPEGExtendedProcess2_4TransferSyntax(void) { - gdcmElValue* Element = PubElValSet.GetElementByNumber(0x0002, 0x0010); + gdcmHeaderEntry* Element = GetHeaderEntryByNumber(0x0002, 0x0010); if ( !Element ) return false; - LoadElementValueSafe(Element); + LoadHeaderEntrySafe(Element); + std::string Transfer = Element->GetValue(); if ( Transfer == "1.2.840.10008.1.2.4.51" ) return true; @@ -245,10 +251,11 @@ bool gdcmHeader::IsJPEGExtendedProcess2_4TransferSyntax(void) { * @return True when JPEGExtendedProcess3-5 found. False in all other cases. */ bool gdcmHeader::IsJPEGExtendedProcess3_5TransferSyntax(void) { - gdcmElValue* Element = PubElValSet.GetElementByNumber(0x0002, 0x0010); + gdcmHeaderEntry* Element = GetHeaderEntryByNumber(0x0002, 0x0010); if ( !Element ) return false; - LoadElementValueSafe(Element); + LoadHeaderEntrySafe(Element); + std::string Transfer = Element->GetValue(); if ( Transfer == "1.2.840.10008.1.2.4.52" ) return true; @@ -264,10 +271,11 @@ bool gdcmHeader::IsJPEGExtendedProcess3_5TransferSyntax(void) { * other cases. */ bool gdcmHeader::IsJPEGSpectralSelectionProcess6_8TransferSyntax(void) { - gdcmElValue* Element = PubElValSet.GetElementByNumber(0x0002, 0x0010); + gdcmHeaderEntry* Element = GetHeaderEntryByNumber(0x0002, 0x0010); if ( !Element ) return false; - LoadElementValueSafe(Element); + LoadHeaderEntrySafe(Element); + std::string Transfer = Element->GetValue(); if ( Transfer == "1.2.840.10008.1.2.4.53" ) return true; @@ -283,10 +291,11 @@ bool gdcmHeader::IsJPEGSpectralSelectionProcess6_8TransferSyntax(void) { * other cases. */ bool gdcmHeader::IsRLELossLessTransferSyntax(void) { - gdcmElValue* Element = PubElValSet.GetElementByNumber(0x0002, 0x0010); + gdcmHeaderEntry* Element = GetHeaderEntryByNumber(0x0002, 0x0010); if ( !Element ) return false; - LoadElementValueSafe(Element); + LoadHeaderEntrySafe(Element); + std::string Transfer = Element->GetValue(); if ( Transfer == "1.2.840.10008.1.2.5" ) return true; @@ -300,11 +309,12 @@ bool gdcmHeader::IsRLELossLessTransferSyntax(void) { * @return */ bool gdcmHeader::IsJPEGLossless(void) { - gdcmElValue* Element = PubElValSet.GetElementByNumber(0x0002, 0x0010); + gdcmHeaderEntry* Element = GetHeaderEntryByNumber(0x0002, 0x0010); // faire qq chose d'intelligent a la place de ça if ( !Element ) return false; - LoadElementValueSafe(Element); + LoadHeaderEntrySafe(Element); + const char * Transfert = Element->GetValue().c_str(); if ( memcmp(Transfert+strlen(Transfert)-2 ,"70",2)==0) return true; if ( memcmp(Transfert+strlen(Transfert)-2 ,"55",2)==0) return true; @@ -322,10 +332,11 @@ bool gdcmHeader::IsJPEGLossless(void) { * other cases. */ bool gdcmHeader::IsJPEG2000(void) { - gdcmElValue* Element = PubElValSet.GetElementByNumber(0x0002, 0x0010); + gdcmHeaderEntry* Element = GetHeaderEntryByNumber(0x0002, 0x0010); if ( !Element ) return false; - LoadElementValueSafe(Element); + LoadHeaderEntrySafe(Element); + std::string Transfer = Element->GetValue(); if ( (Transfer == "1.2.840.10008.1.2.4.90") || (Transfer == "1.2.840.10008.1.2.4.91") ) @@ -363,7 +374,7 @@ FileType gdcmHeader::GetFileType(void) int gdcmHeader::GetXSize(void) { // We cannot check for "Columns" because the "Columns" tag is present // both in IMG (0028,0011) and OLY (6000,0011) sections of the dictionary. - std::string StrSize = GetPubElValByNumber(0x0028,0x0011); + std::string StrSize = GetEntryByNumber(0x0028,0x0011); if (StrSize == GDCM_UNFOUND) return 0; return atoi(StrSize.c_str()); @@ -378,7 +389,7 @@ int gdcmHeader::GetXSize(void) { int gdcmHeader::GetYSize(void) { // We cannot check for "Rows" because the "Rows" tag is present // both in IMG (0028,0010) and OLY (6000,0010) sections of the dictionary. - std::string StrSize = GetPubElValByNumber(0x0028,0x0010); + std::string StrSize = GetEntryByNumber(0x0028,0x0010); if (StrSize != GDCM_UNFOUND) return atoi(StrSize.c_str()); if ( IsDicomV3() ) @@ -401,14 +412,14 @@ int gdcmHeader::GetYSize(void) { int gdcmHeader::GetZSize(void) { // Both DicomV3 and ACR/Nema consider the "Number of Frames" // as the third dimension. - std::string StrSize = GetPubElValByNumber(0x0028,0x0008); + std::string StrSize = GetEntryByNumber(0x0028,0x0008); if (StrSize != GDCM_UNFOUND) return atoi(StrSize.c_str()); // We then consider the "Planes" entry as the third dimension [we // cannot retrieve by name since "Planes tag is present both in // IMG (0028,0012) and OLY (6000,0012) sections of the dictionary]. - StrSize = GetPubElValByNumber(0x0028,0x0012); + StrSize = GetEntryByNumber(0x0028,0x0012); if (StrSize != GDCM_UNFOUND) return atoi(StrSize.c_str()); return 1; @@ -422,7 +433,7 @@ int gdcmHeader::GetZSize(void) { * @return The encountered number of Bits Stored, 0 by default. */ int gdcmHeader::GetBitsStored(void) { - std::string StrSize = GetPubElValByNumber(0x0028,0x0101); + std::string StrSize = GetEntryByNumber(0x0028,0x0101); if (StrSize == GDCM_UNFOUND) return 1; return atoi(StrSize.c_str()); @@ -436,7 +447,7 @@ int gdcmHeader::GetBitsStored(void) { * @return The encountered number of Bits Allocated, 0 by default. */ int gdcmHeader::GetBitsAllocated(void) { - std::string StrSize = GetPubElValByNumber(0x0028,0x0100); + std::string StrSize = GetEntryByNumber(0x0028,0x0100); if (StrSize == GDCM_UNFOUND) return 1; return atoi(StrSize.c_str()); @@ -450,7 +461,7 @@ int gdcmHeader::GetBitsAllocated(void) { * @return The encountered number of Samples Per Pixel, 1 by default. */ int gdcmHeader::GetSamplesPerPixel(void) { - std::string StrSize = GetPubElValByNumber(0x0028,0x0002); + std::string StrSize = GetEntryByNumber(0x0028,0x0002); if (StrSize == GDCM_UNFOUND) return 1; // Well, it's supposed to be mandatory ... return atoi(StrSize.c_str()); @@ -464,7 +475,7 @@ int gdcmHeader::GetSamplesPerPixel(void) { * @return The encountered Planar Configuration, 0 by default. */ int gdcmHeader::GetPlanarConfiguration(void) { - std::string StrSize = GetPubElValByNumber(0x0028,0x0006); + std::string StrSize = GetEntryByNumber(0x0028,0x0006); if (StrSize == GDCM_UNFOUND) return 0; return atoi(StrSize.c_str()); @@ -503,8 +514,7 @@ int gdcmHeader::GetPixelSize(void) { * @return */ std::string gdcmHeader::GetPixelType(void) { - std::string BitsAlloc; - BitsAlloc = GetPubElValByNumber(0x0028, 0x0100); // Bits Allocated + std::string BitsAlloc = GetEntryByNumber(0x0028, 0x0100); // Bits Allocated if (BitsAlloc == GDCM_UNFOUND) { dbg.Verbose(0, "gdcmHeader::GetPixelType: unfound Bits Allocated"); BitsAlloc = std::string("16"); @@ -514,8 +524,7 @@ std::string gdcmHeader::GetPixelType(void) { else if (BitsAlloc == "24") // (in order no to be messed up BitsAlloc = std::string("8"); // by old RGB images) - std::string Signed; - Signed = GetPubElValByNumber(0x0028, 0x0103); // "Pixel Representation" + std::string Signed = GetEntryByNumber(0x0028, 0x0103); // "Pixel Representation" if (Signed == GDCM_UNFOUND) { dbg.Verbose(0, "gdcmHeader::GetPixelType: unfound Pixel Representation"); BitsAlloc = std::string("0"); @@ -542,7 +551,8 @@ size_t gdcmHeader::GetPixelOffset(void) { // When the "Image Location" is absent we default to group 0x7fe0. guint16 grPixel; guint16 numPixel; - std::string ImageLocation = GetPubElValByNumber(0x0028, 0x0200); + std::string ImageLocation = GetEntryByNumber(0x0028, 0x0200); + if ( ImageLocation == GDCM_UNFOUND ) { // Image Location grPixel = 0x7fe0; } else { @@ -554,8 +564,7 @@ size_t gdcmHeader::GetPixelOffset(void) { else numPixel = 0x0010; - gdcmElValue* PixelElement = PubElValSet.GetElementByNumber(grPixel, - numPixel); + gdcmHeaderEntry* PixelElement = GetHeaderEntryByNumber(grPixel,numPixel); if (PixelElement) return PixelElement->GetOffset(); else @@ -576,7 +585,7 @@ size_t gdcmHeader::GetPixelAreaLength(void) { // When the "Image Location" is absent we default to group 0x7fe0. guint16 grPixel; guint16 numPixel; - std::string ImageLocation = GetPubElValByNumber(0x0028, 0x0200); + std::string ImageLocation = GetEntryByNumber(0x0028, 0x0200); if ( ImageLocation == GDCM_UNFOUND ) { grPixel = 0x7fe0; } else { @@ -588,8 +597,7 @@ size_t gdcmHeader::GetPixelAreaLength(void) { else numPixel = 0x0010; - gdcmElValue* PixelElement = PubElValSet.GetElementByNumber(grPixel, - numPixel); + gdcmHeaderEntry* PixelElement = GetHeaderEntryByNumber(grPixel,numPixel); if (PixelElement) return PixelElement->GetLength(); else @@ -607,21 +615,21 @@ size_t gdcmHeader::GetPixelAreaLength(void) { bool gdcmHeader::HasLUT(void) { // Check the presence of the LUT Descriptors - if (GetPubElValByNumber(0x0028,0x1101) == GDCM_UNFOUND) + if ( !GetHeaderEntryByNumber(0x0028,0x1101) ) return false; // LutDescriptorGreen - if (GetPubElValByNumber(0x0028,0x1102) == GDCM_UNFOUND) + if ( !GetHeaderEntryByNumber(0x0028,0x1102) ) return false; // LutDescriptorBlue - if (GetPubElValByNumber(0x0028,0x1103) == GDCM_UNFOUND) + if ( !GetHeaderEntryByNumber(0x0028,0x1103) ) return false; // It is not enough // we check also - if (GetPubElValByNumber(0x0028,0x1201) == GDCM_UNFOUND) + if ( !GetHeaderEntryByNumber(0x0028,0x1201) ) return false; - if (GetPubElValByNumber(0x0028,0x1202) == GDCM_UNFOUND) + if ( !GetHeaderEntryByNumber(0x0028,0x1202) ) return false; - if (GetPubElValByNumber(0x0028,0x1203) == GDCM_UNFOUND) + if ( !GetHeaderEntryByNumber(0x0028,0x1203) ) return false; return true; } @@ -640,7 +648,7 @@ int gdcmHeader::GetLUTNbits(void) { int LutNbits; //Just hope Lookup Table Desc-Red = Lookup Table Desc-Red = Lookup Table Desc-Blue // Consistency already checked in GetLUTLength - std::string LutDescription = GetPubElValByNumber(0x0028,0x1101); + std::string LutDescription = GetEntryByNumber(0x0028,0x1101); if (LutDescription == GDCM_UNFOUND) return 0; tokens.erase(tokens.begin(),tokens.end()); // clean any previous value @@ -674,7 +682,7 @@ unsigned char * gdcmHeader::GetLUTRGBA(void) { // and OT-PAL-8-face.dcm // if Photometric Interpretation # PALETTE COLOR, no LUT to be done - if (gdcmHeader::GetPubElValByNumber(0x0028,0x0004) != "PALETTE COLOR ") { + if (gdcmHeader::GetEntryByNumber(0x0028,0x0004) != "PALETTE COLOR ") { return NULL; } @@ -684,13 +692,13 @@ unsigned char * gdcmHeader::GetLUTRGBA(void) { // Get info from Lut Descriptors // (the 3 LUT descriptors may be different) - std::string LutDescriptionR = GetPubElValByNumber(0x0028,0x1101); + std::string LutDescriptionR = GetEntryByNumber(0x0028,0x1101); if (LutDescriptionR == GDCM_UNFOUND) return NULL; - std::string LutDescriptionG = GetPubElValByNumber(0x0028,0x1102); + std::string LutDescriptionG = GetEntryByNumber(0x0028,0x1102); if (LutDescriptionG == GDCM_UNFOUND) return NULL; - std::string LutDescriptionB = GetPubElValByNumber(0x0028,0x1103); + std::string LutDescriptionB = GetEntryByNumber(0x0028,0x1103); if (LutDescriptionB == GDCM_UNFOUND) return NULL; @@ -719,11 +727,11 @@ unsigned char * gdcmHeader::GetLUTRGBA(void) { // Load LUTs into memory, (as they were stored on disk) unsigned char *lutR = (unsigned char *) - GetPubElValVoidAreaByNumber(0x0028,0x1201); + GetPubEntryVoidAreaByNumber(0x0028,0x1201); unsigned char *lutG = (unsigned char *) - GetPubElValVoidAreaByNumber(0x0028,0x1202); + GetPubEntryVoidAreaByNumber(0x0028,0x1202); unsigned char *lutB = (unsigned char *) - GetPubElValVoidAreaByNumber(0x0028,0x1203); + GetPubEntryVoidAreaByNumber(0x0028,0x1203); if (!lutR || !lutG || !lutB ) { return NULL; @@ -737,7 +745,7 @@ unsigned char * gdcmHeader::GetLUTRGBA(void) { memset(LUTRGBA, 0, 1024); // Bits Allocated int nb; - std::string str_nb = GetPubElValByNumber(0x0028,0x0100); + std::string str_nb = GetEntryByNumber(0x0028,0x0100); if (str_nb == GDCM_UNFOUND ) { nb = 16; } else { @@ -794,7 +802,7 @@ unsigned char * gdcmHeader::GetLUTRGBA(void) { */ std::string gdcmHeader::GetTransfertSyntaxName(void) { // use the gdcmTS (TS : Transfert Syntax) - std::string TransfertSyntax = GetPubElValByNumber(0x0002,0x0010); + std::string TransfertSyntax = GetEntryByNumber(0x0002,0x0010); if (TransfertSyntax == GDCM_UNFOUND) { dbg.Verbose(0, "gdcmHeader::GetTransfertSyntaxName: unfound Transfert Syntax (0002,0010)"); return "Uncompressed ACR-NEMA"; @@ -814,12 +822,12 @@ std::string gdcmHeader::GetTransfertSyntaxName(void) { * @return Corresponding element value when it exists, and the string * GDCM_UNFOUND ("gdcm::Unfound") otherwise. */ -std::string gdcmHeader::GetPubElValByName(std::string tagName) { +std::string gdcmHeader::GetPubEntryByName(std::string tagName) { gdcmDictEntry *dictEntry = RefPubDict->GetTagByName(tagName); if( dictEntry == NULL) return GDCM_UNFOUND; - return(PubElValSet.GetElValueByNumber(dictEntry->GetGroup(), - dictEntry->GetElement())); + + return(GetEntryByNumber(dictEntry->GetGroup(),dictEntry->GetElement())); } /** @@ -835,13 +843,13 @@ std::string gdcmHeader::GetPubElValByName(std::string tagName) { * @return Corresponding element value representation when it exists, * and the string GDCM_UNFOUND ("gdcm::Unfound") otherwise. */ -std::string gdcmHeader::GetPubElValRepByName(std::string tagName) { +std::string gdcmHeader::GetPubEntryVRByName(std::string tagName) { gdcmDictEntry *dictEntry = RefPubDict->GetTagByName(tagName); if( dictEntry == NULL) - return GDCM_UNFOUND; - gdcmElValue* elem = PubElValSet.GetElementByNumber( - dictEntry->GetGroup(), - dictEntry->GetElement()); + return GDCM_UNFOUND; + + gdcmHeaderEntry* elem = GetHeaderEntryByNumber(dictEntry->GetGroup(), + dictEntry->GetElement()); return elem->GetVR(); } @@ -854,8 +862,8 @@ std::string gdcmHeader::GetPubElValRepByName(std::string tagName) { * @return Corresponding element value when it exists, and the string * GDCM_UNFOUND ("gdcm::Unfound") otherwise. */ -std::string gdcmHeader::GetPubElValByNumber(guint16 group, guint16 element) { - return PubElValSet.GetElValueByNumber(group, element); +std::string gdcmHeader::GetPubEntryByNumber(guint16 group, guint16 element) { + return PubEntrySet.GetEntryByNumber(group, element); } /** @@ -872,8 +880,8 @@ std::string gdcmHeader::GetPubElValByNumber(guint16 group, guint16 element) { * @return Corresponding element value representation when it exists, * and the string GDCM_UNFOUND ("gdcm::Unfound") otherwise. */ -std::string gdcmHeader::GetPubElValRepByNumber(guint16 group, guint16 element) { - gdcmElValue* elem = PubElValSet.GetElementByNumber(group, element); +std::string gdcmHeader::GetPubEntryVRByNumber(guint16 group, guint16 element) { + gdcmHeaderEntry* elem = GetHeaderEntryByNumber(group, element); if ( !elem ) return GDCM_UNFOUND; return elem->GetVR(); @@ -881,44 +889,44 @@ std::string gdcmHeader::GetPubElValRepByNumber(guint16 group, guint16 element) { /** * \ingroup gdcmHeader - * \brief Accesses an existing gdcmElValue in the PubElValSet of this instance + * \brief Accesses an existing gdcmHeaderEntry in the PubHeaderEntrySet of this instance * through tag name and modifies it's content with the given value. * @param content new value to substitute with * @param tagName name of the tag to be modified */ -bool gdcmHeader::SetPubElValByName(std::string content, std::string tagName) { - //return ( PubElValSet.SetElValueByName (content, tagName) ); +bool gdcmHeader::SetPubEntryByName(std::string content, std::string tagName) { + //return ( PubHeaderEntrySet.SetHeaderEntryByName (content, tagName) ); gdcmDictEntry *dictEntry = RefPubDict->GetTagByName(tagName); if( dictEntry == NULL) - return false; - return(PubElValSet.SetElValueByNumber(content, - dictEntry->GetGroup(), - dictEntry->GetElement())); + return false; + return(PubEntrySet.SetEntryByNumber(content, + dictEntry->GetGroup(), + dictEntry->GetElement())); } /** * \ingroup gdcmHeader - * \brief Accesses an existing gdcmElValue (i.e. a Dicom Element) - * in the PubElValSet of this instance + * \brief Accesses an existing gdcmHeaderEntry (i.e. a Dicom Element) + * in the PubHeaderEntrySet of this instance * through it's (group, element) and modifies it's content with * the given value. * @param content new value to substitute with * @param group group of the Dicom Element to modify * @param element element of the Dicom Element to modify */ -bool gdcmHeader::SetPubElValByNumber(std::string content, guint16 group, +bool gdcmHeader::SetPubEntryByNumber(std::string content, guint16 group, guint16 element) //TODO : homogeneiser les noms : SetPubElValByNumber -// qui appelle PubElValSet.SetElValueByNumber -// pourquoi pas SetPubElValueByNumber ?? +// qui appelle PubHeaderEntrySet.SetHeaderEntryByNumber +// pourquoi pas SetPubHeaderEntryByNumber ?? { - return ( PubElValSet.SetElValueByNumber (content, group, element) ); + return ( PubEntrySet.SetEntryByNumber (content, group, element) ); } /** * \ingroup gdcmHeader - * \brief Accesses an existing gdcmElValue in the PubElValSet of this instance + * \brief Accesses an existing gdcmHeaderEntry in the PubHeaderEntrySet of this instance * through it's (group, element) and modifies it's length with * the given value. * \warning Use with extreme caution. @@ -928,9 +936,9 @@ bool gdcmHeader::SetPubElValByNumber(std::string content, guint16 group, * @return 1 on success, 0 otherwise. */ -bool gdcmHeader::SetPubElValLengthByNumber(guint32 length, guint16 group, +bool gdcmHeader::SetPubEntryLengthByNumber(guint32 length, guint16 group, guint16 element) { - return ( PubElValSet.SetElValueLengthByNumber (length, group, element) ); + return ( PubEntrySet.SetEntryLengthByNumber (length, group, element) ); } /** @@ -942,9 +950,8 @@ bool gdcmHeader::SetPubElValLengthByNumber(guint32 length, guint16 group, * @return Corresponding element value when it exists, * and the string GDCM_UNFOUND ("gdcm::Unfound") otherwise. */ -std::string gdcmHeader::GetElValByName(std::string tagName) { - std::string pub = GetPubElValByName(tagName); - return pub; +std::string gdcmHeader::GetEntryByName(std::string tagName) { + return GetPubEntryByName(tagName); } /** @@ -961,9 +968,8 @@ std::string gdcmHeader::GetElValByName(std::string tagName) { * @return Corresponding element value representation when it exists, * and the string GDCM_UNFOUND ("gdcm::Unfound") otherwise. */ -std::string gdcmHeader::GetElValRepByName(std::string tagName) { - std::string pub = GetPubElValRepByName(tagName); - return pub; +std::string gdcmHeader::GetEntryVRByName(std::string tagName) { + return GetPubEntryVRByName(tagName); } /** @@ -976,9 +982,8 @@ std::string gdcmHeader::GetElValRepByName(std::string tagName) { * @return Corresponding element value representation when it exists, * and the string GDCM_UNFOUND ("gdcm::Unfound") otherwise. */ -std::string gdcmHeader::GetElValByNumber(guint16 group, guint16 element) { - std::string pub = GetPubElValByNumber(group, element); - return pub; +std::string gdcmHeader::GetEntryByNumber(guint16 group, guint16 element) { + return GetPubEntryByNumber(group, element); } /** @@ -996,21 +1001,18 @@ std::string gdcmHeader::GetElValByNumber(guint16 group, guint16 element) { * @return Corresponding element value representation when it exists, * and the string GDCM_UNFOUND ("gdcm::Unfound") otherwise. */ -std::string gdcmHeader::GetElValRepByNumber(guint16 group, guint16 element) { - std::string pub = GetPubElValRepByNumber(group, element); - return pub; +std::string gdcmHeader::GetEntryVRByNumber(guint16 group, guint16 element) { + return GetPubEntryVRByNumber(group, element); } /** - * \ingroup gdcmElValSet + * \ingroup gdcmHeader * \brief Sets the value (string) of the target Dicom Element * @param content string value of the Dicom Element * @param tagName name of the searched Dicom Element. * @return true when found */ -bool gdcmHeader::SetElValueByName(std::string content, - std::string tagName) { - +bool gdcmHeader::SetEntryByName(std::string content,std::string tagName) { gdcmDictEntry *dictEntry = RefPubDict->GetTagByName(tagName); if( dictEntry == NULL) return false; @@ -1018,7 +1020,7 @@ bool gdcmHeader::SetElValueByName(std::string content, TagKey key = gdcmDictEntry::TranslateToKey(dictEntry->GetGroup(), dictEntry->GetElement()); - if ( ! PubElValSet.GetTagHt().count(key)) + if ( PubEntrySet.GetTagHT().count(key) == 0 ) return false; int l = content.length(); if(l%2) { // Odd length are padded with a space (020H). @@ -1027,16 +1029,16 @@ bool gdcmHeader::SetElValueByName(std::string content, } //tagHt[key]->SetValue(content); - gdcmElValue * a; + gdcmHeaderEntry * a; IterHT p; - TagElValueHT::iterator p2; + TagHeaderEntryHT::iterator p2; // DO NOT remove the following lines : they explain the stuff //p= tagHt.equal_range(key); // get a pair of iterators first-last synonym //p2=p.first; // iterator on the first synonym //a=p2->second; // H Table target column (2-nd col) // or, easier : - a = ((PubElValSet.GetTagHt().equal_range(key)).first)->second; + a = ((PubEntrySet.GetTagHT().equal_range(key)).first)->second; a-> SetValue(content); @@ -1111,13 +1113,13 @@ bool gdcmHeader::CloseFile(void) { * \brief Parses the header of the file but WITHOUT loading element values. */ void gdcmHeader::ParseHeader(bool exception_on_error) throw(gdcmFormatError) { - gdcmElValue * newElValue = (gdcmElValue *)0; + gdcmHeaderEntry * newHeaderEntry = (gdcmHeaderEntry *)0; rewind(fp); CheckSwap(); - while ( (newElValue = ReadNextElement()) ) { - SkipElementValue(newElValue); - PubElValSet.Add(newElValue); + while ( (newHeaderEntry = ReadNextHeaderEntry()) ) { + SkipHeaderEntry(newHeaderEntry); + PubEntrySet.Add(newHeaderEntry); } } @@ -1139,7 +1141,7 @@ bool gdcmHeader::Write(FILE * fp, FileType type) { // values with a VR of UI shall be padded with a single trailing null // Dans le cas suivant on doit pader manuellement avec un 0 - PubElValSet.SetElValueLengthByNumber(18, 0x0002, 0x0010); + PubEntrySet.SetEntryLengthByNumber(18, 0x0002, 0x0010); } if (type == ExplicitVR) { @@ -1150,10 +1152,10 @@ bool gdcmHeader::Write(FILE * fp, FileType type) { // values with a VR of UI shall be padded with a single trailing null // Dans le cas suivant on doit pader manuellement avec un 0 - PubElValSet.SetElValueLengthByNumber(20, 0x0002, 0x0010); + PubEntrySet.SetEntryLengthByNumber(20, 0x0002, 0x0010); } - return PubElValSet.Write(fp, type); + return PubEntrySet.Write(fp, type); } /** @@ -1170,18 +1172,80 @@ bool gdcmHeader::Write(FILE * fp, FileType type) { void gdcmHeader::SetImageDataSize(size_t ImageDataSize) { std::string content1; char car[20]; - // Assumes ElValue (0x7fe0, 0x0010) exists ... + // Assumes HeaderEntry (0x7fe0, 0x0010) exists ... sprintf(car,"%d",ImageDataSize); - gdcmElValue *a = GetElValueByNumber(0x7fe0, 0x0010); + gdcmHeaderEntry *a = GetHeaderEntryByNumber(0x7fe0, 0x0010); a->SetLength(ImageDataSize); ImageDataSize+=8; sprintf(car,"%d",ImageDataSize); content1=car; - SetPubElValByNumber(content1, 0x7fe0, 0x0000); + SetPubEntryByNumber(content1, 0x7fe0, 0x0000); } +/** + * \ingroup gdcmHeader + * \brief TODO + * @param Value + * @param Group + * @param Elem + * \return integer acts as a boolean + */ +bool gdcmHeader::ReplaceOrCreateByNumber(std::string Value, + guint16 Group, guint16 Elem ) { + // TODO : FIXME JPRx + // curieux, non ? + // on (je) cree une HeaderEntry ne contenant pas de valeur + // on l'ajoute au HeaderEntrySet + // on affecte une valeur a cette HeaderEntry a l'interieur du HeaderEntrySet + // --> devrait pouvoir etre fait + simplement ??? + if (CheckIfExistByNumber(Group, Elem) == 0) { + gdcmHeaderEntry* a =NewHeaderEntryByNumber(Group, Elem); + if (a == NULL) + return false; + PubEntrySet.Add(a); + } + PubEntrySet.SetEntryByNumber(Value, Group, Elem); + return(true); +} + +/** + * \ingroup gdcmHeader + * \brief Modify (or Creates if not found) an element + * @param Value new value + * @param Group + * @param Elem + * \return integer acts as a boolean + * + */ +bool gdcmHeader::ReplaceOrCreateByNumber(char* Value, guint16 Group, guint16 Elem ) { + + gdcmHeaderEntry* nvHeaderEntry=NewHeaderEntryByNumber(Group, Elem); + // TODO : check if fails + PubEntrySet.Add(nvHeaderEntry); + std::string v = Value; + PubEntrySet.SetEntryByNumber(v, Group, Elem); + return(true); +} + +/** + * \ingroup gdcmHeader + * \brief Set a new value if the invoked element exists + * Seems to be useless !!! + * @param Value + * @param Group + * @param Elem + * \return integer acts as a boolean + */ +bool gdcmHeader::ReplaceIfExistByNumber(char* Value, guint16 Group, guint16 Elem ) { + + //gdcmHeaderEntry* HeaderEntry = PubHeaderEntrySet.GetElementByNumber(Group, Elem); + std::string v = Value; + PubEntrySet.SetEntryByNumber(v, Group, Elem); + return true; +} + /** * \ingroup gdcmHeader * \brief Swaps back the bytes of 4-byte long integer accordingly to @@ -1230,27 +1294,42 @@ guint16 gdcmHeader::SwapShort(guint16 a) { * * @return */ -gdcmElValue* gdcmHeader::GetElValueByNumber(guint16 Group, guint16 Elem) { - - gdcmElValue* elValue = PubElValSet.GetElementByNumber(Group, Elem); - if (!elValue) { - dbg.Verbose(1, "gdcmHeader::GetElValueByNumber", - "failed to Locate gdcmElValue"); - return (gdcmElValue*)0; +gdcmHeaderEntry *gdcmHeader::GetHeaderEntryByNumber(guint16 Group, guint16 Elem) { + gdcmHeaderEntry *HeaderEntry = PubEntrySet.GetHeaderEntryByNumber(Group, Elem); + if (!HeaderEntry) { + dbg.Verbose(1, "gdcmHeader::GetHeaderEntryByNumber", + "failed to Locate gdcmHeaderEntry"); + return NULL; } - return elValue; + return HeaderEntry; } /** * \ingroup gdcmHeader - * \brief Checks if a given ElValue (group,number) - * \ exists in the Public ElValSet + * \brief Searches within the public dictionary for a Dicom Element of + * a given tag. + * @param tagName name of the searched Dicom Element. + * @return Corresponding Dicom Element when it exists, and NULL + * otherwise. + */ + gdcmHeaderEntry *gdcmHeader::GetHeaderEntryByName(std::string tagName) { + gdcmDictEntry *dictEntry = RefPubDict->GetTagByName(tagName); + if( dictEntry == NULL) + return NULL; + + return(GetHeaderEntryByNumber(dictEntry->GetGroup(),dictEntry->GetElement())); +} + +/** + * \ingroup gdcmHeader + * \brief Checks if a given HeaderEntry (group,number) + * \ exists in the Public HeaderEntrySet * @param Group * @param Elem * @return integer acts as a boolean */ bool gdcmHeader::CheckIfExistByNumber(guint16 Group, guint16 Elem ) { - return (PubElValSet.CheckIfExistByNumber(Group, Elem)>0); + return (PubEntrySet.CheckIfExistByNumber(Group, Elem)>0); } /** @@ -1261,14 +1340,14 @@ bool gdcmHeader::CheckIfExistByNumber(guint16 Group, guint16 Elem ) { * @param Elem * @return File Offset of the Element Value */ -size_t gdcmHeader::GetPubElValOffsetByNumber(guint16 Group, guint16 Elem) { - gdcmElValue* elValue = PubElValSet.GetElementByNumber(Group, Elem); - if (!elValue) { - dbg.Verbose(1, "gdcmHeader::GetElValueByNumber", - "failed to Locate gdcmElValue"); +size_t gdcmHeader::GetPubEntryOffsetByNumber(guint16 Group, guint16 Elem) { + gdcmHeaderEntry* Entry = GetHeaderEntryByNumber(Group, Elem); + if (!Entry) { + dbg.Verbose(1, "gdcmHeader::GetHeaderEntryByNumber", + "failed to Locate gdcmHeaderEntry"); return (size_t)0; } - return elValue->GetOffset(); + return Entry->GetOffset(); } /** @@ -1279,14 +1358,14 @@ size_t gdcmHeader::GetPubElValOffsetByNumber(guint16 Group, guint16 Elem) { * @param Elem * @return Pointer to the 'non string' area */ -void * gdcmHeader::GetPubElValVoidAreaByNumber(guint16 Group, guint16 Elem) { - gdcmElValue* elValue = PubElValSet.GetElementByNumber(Group, Elem); - if (!elValue) { - dbg.Verbose(1, "gdcmHeader::GetElValueByNumber", - "failed to Locate gdcmElValue"); +void * gdcmHeader::GetPubEntryVoidAreaByNumber(guint16 Group, guint16 Elem) { + gdcmHeaderEntry* Entry = GetHeaderEntryByNumber(Group, Elem); + if (!Entry) { + dbg.Verbose(1, "gdcmHeader::GetHeaderEntryByNumber", + "failed to Locate gdcmHeaderEntry"); return (NULL); } - return elValue->GetVoidArea(); + return Entry->GetVoidArea(); } /** @@ -1294,8 +1373,8 @@ void * gdcmHeader::GetPubElValVoidAreaByNumber(guint16 Group, guint16 Elem) { * \brief Loads (from disk) the element content * when a string is not suitable */ -void * gdcmHeader::LoadElementVoidArea(guint16 Group, guint16 Elem) { - gdcmElValue * Element= PubElValSet.GetElementByNumber(Group, Elem); +void * gdcmHeader::LoadEntryVoidArea(guint16 Group, guint16 Elem) { + gdcmHeaderEntry * Element= GetHeaderEntryByNumber(Group, Elem); if ( !Element ) return NULL; size_t o =(size_t)Element->GetOffset(); @@ -1305,7 +1384,8 @@ void * gdcmHeader::LoadElementVoidArea(guint16 Group, guint16 Elem) { if(!a) { return NULL; } - /* int res = */ PubElValSet.SetVoidAreaByNumber(a, Group, Elem); + + PubEntrySet.SetVoidAreaByNumber(a, Group, Elem); // TODO check the result size_t l2 = fread(a, 1, l ,fp); if(l != l2) { @@ -1315,68 +1395,6 @@ void * gdcmHeader::LoadElementVoidArea(guint16 Group, guint16 Elem) { return a; } -/** - * \ingroup gdcmHeader - * \brief TODO - * @param Value - * @param Group - * @param Elem - * \return integer acts as a boolean - */ -bool gdcmHeader::ReplaceOrCreateByNumber(std::string Value, - guint16 Group, guint16 Elem ) { - // TODO : FIXME JPRx - // curieux, non ? - // on (je) cree une Elvalue ne contenant pas de valeur - // on l'ajoute au ElValSet - // on affecte une valeur a cette ElValue a l'interieur du ElValSet - // --> devrait pouvoir etre fait + simplement ??? - if (CheckIfExistByNumber(Group, Elem) == 0) { - gdcmElValue* a =NewElValueByNumber(Group, Elem); - if (a == NULL) - return false; - PubElValSet.Add(a); - } - PubElValSet.SetElValueByNumber(Value, Group, Elem); - return(true); -} - -/** - * \ingroup gdcmHeader - * \brief Modify (or Creates if not found) an element - * @param Value new value - * @param Group - * @param Elem - * \return integer acts as a boolean - * - */ -bool gdcmHeader::ReplaceOrCreateByNumber(char* Value, guint16 Group, guint16 Elem ) { - - gdcmElValue* nvElValue=NewElValueByNumber(Group, Elem); - // TODO : check if fails - PubElValSet.Add(nvElValue); - std::string v = Value; - PubElValSet.SetElValueByNumber(v, Group, Elem); - return(true); -} - -/** - * \ingroup gdcmHeader - * \brief Set a new value if the invoked element exists - * Seems to be useless !!! - * @param Value - * @param Group - * @param Elem - * \return integer acts as a boolean - */ -bool gdcmHeader::ReplaceIfExistByNumber(char* Value, guint16 Group, guint16 Elem ) { - - //gdcmElValue* elValue = PubElValSet.GetElementByNumber(Group, Elem); - std::string v = Value; - PubElValSet.SetElValueByNumber(v, Group, Elem); - return true; -} - //----------------------------------------------------------------------------- // Private /** @@ -1384,36 +1402,36 @@ bool gdcmHeader::ReplaceIfExistByNumber(char* Value, guint16 Group, guint16 Elem * \brief Loads the element values of all the elements present in the * public tag based hash table. */ -void gdcmHeader::LoadElements(void) { +void gdcmHeader::LoadHeaderEntries(void) { rewind(fp); // We don't use any longer the HashTable, since a lot a stuff is missing // when SeQuences were encountered // - //TagElValueHT ht = PubElValSet.GetTagHt(); - //for (TagElValueHT::iterator tag = ht.begin(); tag != ht.end(); ++tag) { + //TagHeaderEntryHT ht = PubHeaderEntrySet.GetTagHT(); + //for (TagHeaderEntryHT::iterator tag = ht.begin(); tag != ht.end(); ++tag) { // LoadElementValue(tag->second); //} - for (ListTag::iterator i = GetPubListElem().begin(); - i != GetPubListElem().end(); + for (ListTag::iterator i = GetPubListEntry().begin(); + i != GetPubListEntry().end(); ++i){ - LoadElementValue(*i); + LoadHeaderEntry(*i); } rewind(fp); // Load 'non string' values - std::string PhotometricInterpretation = GetPubElValByNumber(0x0028,0x0004); + std::string PhotometricInterpretation = GetPubEntryByNumber(0x0028,0x0004); if( PhotometricInterpretation == "PALETTE COLOR " ){ - LoadElementVoidArea(0x0028,0x1200); // gray LUT - LoadElementVoidArea(0x0028,0x1201); // R LUT - LoadElementVoidArea(0x0028,0x1202); // G LUT - LoadElementVoidArea(0x0028,0x1203); // B LUT + LoadEntryVoidArea(0x0028,0x1200); // gray LUT + LoadEntryVoidArea(0x0028,0x1201); // R LUT + LoadEntryVoidArea(0x0028,0x1202); // G LUT + LoadEntryVoidArea(0x0028,0x1203); // B LUT - LoadElementVoidArea(0x0028,0x1221); // Segmented Red Palette Color LUT Data - LoadElementVoidArea(0x0028,0x1222); // Segmented Green Palette Color LUT Data - LoadElementVoidArea(0x0028,0x1223); // Segmented Blue Palette Color LUT Data + LoadEntryVoidArea(0x0028,0x1221); // Segmented Red Palette Color LUT Data + LoadEntryVoidArea(0x0028,0x1222); // Segmented Green Palette Color LUT Data + LoadEntryVoidArea(0x0028,0x1223); // Segmented Blue Palette Color LUT Data } // -------------------------------------------------------------- @@ -1423,14 +1441,14 @@ void gdcmHeader::LoadElements(void) { // we switch lineNumber and columnNumber // std::string RecCode; - RecCode = GetPubElValByNumber(0x0008, 0x0010); + RecCode = GetPubEntryByNumber(0x0008, 0x0010); if (RecCode == "ACRNEMA_LIBIDO_1.1" || RecCode == "CANRME_AILIBOD1_1." ) { filetype = ACR_LIBIDO; - std::string rows = GetPubElValByNumber(0x0028, 0x0010); - std::string columns = GetPubElValByNumber(0x0028, 0x0011); - SetPubElValByNumber(columns, 0x0028, 0x0010); - SetPubElValByNumber(rows , 0x0028, 0x0011); + std::string rows = GetPubEntryByNumber(0x0028, 0x0010); + std::string columns = GetPubEntryByNumber(0x0028, 0x0011); + SetPubEntryByNumber(columns, 0x0028, 0x0010); + SetPubEntryByNumber(rows , 0x0028, 0x0011); } // ----------------- End of Special Patch ---------------- } @@ -1442,7 +1460,7 @@ void gdcmHeader::LoadElements(void) { * gdcmHeader::SetMaxSizeLoadElementValue() * @param ElVal string value of the Dicom Element */ -void gdcmHeader::LoadElementValue(gdcmElValue * ElVal) { +void gdcmHeader::LoadHeaderEntry(gdcmHeaderEntry * ElVal) { size_t item_read; guint16 group = ElVal->GetGroup(); std::string vr= ElVal->GetVR(); @@ -1495,7 +1513,7 @@ void gdcmHeader::LoadElementValue(gdcmElValue * ElVal) { // Actually, elements with Value Multiplicity > 1 // contain a set of integers (not a single one) // Any compacter code suggested (?) - if ( IsAnInteger(ElVal) ) { + if ( IsHeaderEntryAnInteger(ElVal) ) { guint32 NewInt; std::ostringstream s; int nbInt; @@ -1557,9 +1575,9 @@ void gdcmHeader::LoadElementValue(gdcmElValue * ElVal) { * @param ElVal Element whose value shall be loaded. * @return */ -void gdcmHeader::LoadElementValueSafe(gdcmElValue * ElVal) { +void gdcmHeader::LoadHeaderEntrySafe(gdcmHeaderEntry * ElVal) { long PositionOnEntry = ftell(fp); - LoadElementValue(ElVal); + LoadHeaderEntry(ElVal); fseek(fp, PositionOnEntry, SEEK_SET); } @@ -1569,7 +1587,7 @@ void gdcmHeader::LoadElementValueSafe(gdcmElValue * ElVal) { * * @return */ - void gdcmHeader::FindLength (gdcmElValue * ElVal) { + void gdcmHeader::FindHeaderEntryLength (gdcmHeaderEntry * ElVal) { guint16 element = ElVal->GetElement(); guint16 group = ElVal->GetGroup(); std::string vr = ElVal->GetVR(); @@ -1591,10 +1609,10 @@ void gdcmHeader::LoadElementValueSafe(gdcmElValue * ElVal) { guint32 length32 = ReadInt32(); if ( (vr == "OB") && (length32 == 0xffffffff) ) { - ElVal->SetLength(FindLengthOB()); + ElVal->SetLength(FindHeaderEntryLengthOB()); return; } - FixFoundLength(ElVal, length32); + FixHeaderEntryFoundLength(ElVal, length32); return; } @@ -1660,7 +1678,7 @@ void gdcmHeader::LoadElementValueSafe(gdcmElValue * ElVal) { // Unknown Sequence Length } - FixFoundLength(ElVal, (guint32)length16); + FixHeaderEntryFoundLength(ElVal, (guint32)length16); return; } @@ -1670,7 +1688,7 @@ void gdcmHeader::LoadElementValueSafe(gdcmElValue * ElVal) { // on Data elements "Implicit and Explicit VR Data Elements shall // not coexist in a Data Set and Data Sets nested within it".] // Length is on 4 bytes. - FixFoundLength(ElVal, ReadInt32()); + FixHeaderEntryFoundLength(ElVal, ReadInt32()); return; } @@ -1679,7 +1697,7 @@ void gdcmHeader::LoadElementValueSafe(gdcmElValue * ElVal) { * \brief Find the value representation of the current tag. * @param ElVal */ -void gdcmHeader::FindVR( gdcmElValue *ElVal) { +void gdcmHeader::FindHeaderEntryVR( gdcmHeaderEntry *ElVal) { if (filetype != ExplicitVR) return; @@ -1761,61 +1779,13 @@ void gdcmHeader::FindVR( gdcmElValue *ElVal) { ElVal->SetImplicitVr(); } -/** - * \ingroup gdcmHeader - * \brief - * - * @return - */ - guint32 gdcmHeader::FindLengthOB(void) { - // See PS 3.5-2001, section A.4 p. 49 on encapsulation of encoded pixel data. - guint16 g; - guint16 n; - long PositionOnEntry = ftell(fp); - bool FoundSequenceDelimiter = false; - guint32 TotalLength = 0; - guint32 ItemLength; - - while ( ! FoundSequenceDelimiter) { - g = ReadInt16(); - n = ReadInt16(); - if (errno == 1) - return 0; - TotalLength += 4; // We even have to decount the group and element - - if ( g != 0xfffe && g!=0xb00c ) /*for bogus header */ { - char msg[100]; // for sprintf. Sorry - sprintf(msg,"wrong group (%04x) for an item sequence (%04x,%04x)\n",g, g,n); - dbg.Verbose(1, "gdcmHeader::FindLengthOB: ",msg); - errno = 1; - return 0; - } - if ( n == 0xe0dd || ( g==0xb00c && n==0x0eb6 ) ) /* for bogus header */ - FoundSequenceDelimiter = true; - else if ( n != 0xe000 ){ - char msg[100]; // for sprintf. Sorry - sprintf(msg,"wrong element (%04x) for an item sequence (%04x,%04x)\n", - n, g,n); - dbg.Verbose(1, "gdcmHeader::FindLengthOB: ",msg); - errno = 1; - return 0; - } - ItemLength = ReadInt32(); - TotalLength += ItemLength + 4; // We add 4 bytes since we just read - // the ItemLength with ReadInt32 - SkipBytes(ItemLength); - } - fseek(fp, PositionOnEntry, SEEK_SET); - return TotalLength; -} - /** * \ingroup gdcmHeader * \brief * @param ElVal * @return */ -void gdcmHeader::SkipElementValue(gdcmElValue * ElVal) { +void gdcmHeader::SkipHeaderEntry(gdcmHeaderEntry * ElVal) { SkipBytes(ElVal->GetLength()); } @@ -1825,7 +1795,7 @@ void gdcmHeader::SkipElementValue(gdcmElValue * ElVal) { * the parser went Jabberwocky) one can hope improving things by * applying this heuristic. */ -void gdcmHeader::FixFoundLength(gdcmElValue * ElVal, guint32 FoundLength) { +void gdcmHeader::FixHeaderEntryFoundLength(gdcmHeaderEntry * ElVal, guint32 FoundLength) { ElVal->SetReadLength(FoundLength); // will be updated only if a bug is found @@ -1870,7 +1840,7 @@ void gdcmHeader::FixFoundLength(gdcmElValue * ElVal, guint32 FoundLength) { * @param ElVal The element value on which to apply the predicate. * @return The result of the heuristical predicate. */ -bool gdcmHeader::IsAnInteger(gdcmElValue * ElVal) { +bool gdcmHeader::IsHeaderEntryAnInteger(gdcmHeaderEntry * ElVal) { guint16 element = ElVal->GetElement(); guint16 group = ElVal->GetGroup(); std::string vr = ElVal->GetVR(); @@ -1896,6 +1866,54 @@ bool gdcmHeader::IsAnInteger(gdcmElValue * ElVal) { return false; } +/** + * \ingroup gdcmHeader + * \brief + * + * @return + */ + guint32 gdcmHeader::FindHeaderEntryLengthOB(void) { + // See PS 3.5-2001, section A.4 p. 49 on encapsulation of encoded pixel data. + guint16 g; + guint16 n; + long PositionOnEntry = ftell(fp); + bool FoundSequenceDelimiter = false; + guint32 TotalLength = 0; + guint32 ItemLength; + + while ( ! FoundSequenceDelimiter) { + g = ReadInt16(); + n = ReadInt16(); + if (errno == 1) + return 0; + TotalLength += 4; // We even have to decount the group and element + + if ( g != 0xfffe && g!=0xb00c ) /*for bogus header */ { + char msg[100]; // for sprintf. Sorry + sprintf(msg,"wrong group (%04x) for an item sequence (%04x,%04x)\n",g, g,n); + dbg.Verbose(1, "gdcmHeader::FindLengthOB: ",msg); + errno = 1; + return 0; + } + if ( n == 0xe0dd || ( g==0xb00c && n==0x0eb6 ) ) /* for bogus header */ + FoundSequenceDelimiter = true; + else if ( n != 0xe000 ){ + char msg[100]; // for sprintf. Sorry + sprintf(msg,"wrong element (%04x) for an item sequence (%04x,%04x)\n", + n, g,n); + dbg.Verbose(1, "gdcmHeader::FindLengthOB: ",msg); + errno = 1; + return 0; + } + ItemLength = ReadInt32(); + TotalLength += ItemLength + 4; // We add 4 bytes since we just read + // the ItemLength with ReadInt32 + SkipBytes(ItemLength); + } + fseek(fp, PositionOnEntry, SEEK_SET); + return TotalLength; +} + /** * \ingroup gdcmHeader * \brief Reads a supposed to be 16 Bits integer @@ -2242,12 +2260,12 @@ gdcmDictEntry * gdcmHeader::GetDictEntryByName(std::string Name) { /** * \ingroup gdcmHeader * \brief Read the next tag but WITHOUT loading it's value - * @return On succes the newly created ElValue, NULL on failure. + * @return On succes the newly created HeaderEntry, NULL on failure. */ -gdcmElValue * gdcmHeader::ReadNextElement(void) { +gdcmHeaderEntry * gdcmHeader::ReadNextHeaderEntry(void) { guint16 g,n; - gdcmElValue * NewElVal; + gdcmHeaderEntry * NewElVal; g = ReadInt16(); n = ReadInt16(); @@ -2255,15 +2273,15 @@ gdcmElValue * gdcmHeader::ReadNextElement(void) { if (errno == 1) // We reached the EOF (or an error occured) and header parsing // has to be considered as finished. - return (gdcmElValue *)0; + return (gdcmHeaderEntry *)0; - NewElVal = NewElValueByNumber(g, n); - FindVR(NewElVal); - FindLength(NewElVal); + NewElVal = NewHeaderEntryByNumber(g, n); + FindHeaderEntryVR(NewElVal); + FindHeaderEntryLength(NewElVal); if (errno == 1) { // Call it quits - return (gdcmElValue *)0; + return (gdcmHeaderEntry *)0; } NewElVal->SetOffset(ftell(fp)); //if ( (g==0x7fe0) && (n==0x0010) ) @@ -2277,17 +2295,17 @@ gdcmElValue * gdcmHeader::ReadNextElement(void) { * a default one when absent. * @param Name Name of the underlying DictEntry */ -gdcmElValue* gdcmHeader::NewElValueByName(std::string Name) { +gdcmHeaderEntry* gdcmHeader::NewHeaderEntryByName(std::string Name) { gdcmDictEntry * NewTag = GetDictEntryByName(Name); if (!NewTag) NewTag = new gdcmDictEntry(0xffff, 0xffff, "LO", "Unknown", Name); - gdcmElValue* NewElVal = new gdcmElValue(NewTag); + gdcmHeaderEntry* NewElVal = new gdcmHeaderEntry(NewTag); if (!NewElVal) { - dbg.Verbose(1, "gdcmHeader::ObtainElValueByName", - "failed to allocate gdcmElValue"); - return (gdcmElValue*)0; + dbg.Verbose(1, "gdcmHeader::ObtainHeaderEntryByName", + "failed to allocate gdcmHeaderEntry"); + return (gdcmHeaderEntry*)0; } return NewElVal; } @@ -2300,64 +2318,48 @@ gdcmElValue* gdcmHeader::NewElValueByName(std::string Name) { * @param Group group of the underlying DictEntry * @param Elem element of the underlying DictEntry */ -gdcmElValue* gdcmHeader::NewElValueByNumber(guint16 Group, guint16 Elem) { +gdcmHeaderEntry* gdcmHeader::NewHeaderEntryByNumber(guint16 Group, guint16 Elem) { // Find out if the tag we encountered is in the dictionaries: gdcmDictEntry * NewTag = GetDictEntryByNumber(Group, Elem); if (!NewTag) NewTag = new gdcmDictEntry(Group, Elem); - gdcmElValue* NewElVal = new gdcmElValue(NewTag); + gdcmHeaderEntry* NewElVal = new gdcmHeaderEntry(NewTag); if (!NewElVal) { - dbg.Verbose(1, "gdcmHeader::NewElValueByNumber", - "failed to allocate gdcmElValue"); - return (gdcmElValue*)0; + dbg.Verbose(1, "gdcmHeader::NewHeaderEntryByNumber", + "failed to allocate gdcmHeaderEntry"); + return (gdcmHeaderEntry*)0; } return NewElVal; } -/** - * \ingroup gdcmHeader - * \brief Searches within the public dictionary for a Dicom Element of - * a given tag. - * @param tagName name of the searched Dicom Element. - * @return Corresponding Dicom Element when it exists, and NULL - * otherwise. - */ - gdcmElValue* gdcmHeader::GetElementByName(std::string tagName) { - gdcmDictEntry *dictEntry = RefPubDict->GetTagByName(tagName); - if( dictEntry == NULL) - return (gdcmElValue*)NULL; - return(PubElValSet.GetElementByNumber(dictEntry->GetGroup(), - dictEntry->GetElement())); -} - /** * \ingroup gdcmHeader * \brief Small utility function that creates a new manually crafted - * (as opposed as read from the file) gdcmElValue with user + * (as opposed as read from the file) gdcmHeaderEntry with user * specified name and adds it to the public tag hash table. * \note A fake TagKey is generated so the PubDict can keep it's coherence. * @param NewTagName The name to be given to this new tag. * @param VR The Value Representation to be given to this new tag. * @ return The newly hand crafted Element Value. */ -gdcmElValue* gdcmHeader::NewManualElValToPubDict(std::string NewTagName, - std::string VR) { - gdcmElValue* NewElVal = (gdcmElValue*)0; +gdcmHeaderEntry* gdcmHeader::NewManualHeaderEntryToPubDict(std::string NewTagName, + std::string VR) { + gdcmHeaderEntry* NewElVal = (gdcmHeaderEntry*)0; guint32 StuffGroup = 0xffff; // Group to be stuffed with additional info guint32 FreeElem = 0; gdcmDictEntry* NewEntry = (gdcmDictEntry*)0; - FreeElem = PubElValSet.GenerateFreeTagKeyInGroup(StuffGroup); + FreeElem = PubEntrySet.GenerateFreeTagKeyInGroup(StuffGroup); if (FreeElem == UINT32_MAX) { dbg.Verbose(1, "gdcmHeader::NewManualElValToPubDict", "Group 0xffff in Public Dict is full"); - return (gdcmElValue*)0; + return (gdcmHeaderEntry*)0; } NewEntry = new gdcmDictEntry(StuffGroup, FreeElem, VR, "GDCM", NewTagName); - NewElVal = new gdcmElValue(NewEntry); - PubElValSet.Add(NewElVal); + NewElVal = new gdcmHeaderEntry(NewEntry); + PubEntrySet.Add(NewElVal); return NewElVal; } diff --git a/src/gdcmHeader.h b/src/gdcmHeader.h index 31d98776..9f3603e9 100644 --- a/src/gdcmHeader.h +++ b/src/gdcmHeader.h @@ -8,8 +8,8 @@ #include "gdcmTS.h" #include "gdcmException.h" #include "gdcmDictSet.h" -#include "gdcmElValue.h" -#include "gdcmElValSet.h" +#include "gdcmHeaderEntry.h" +#include "gdcmHeaderEntrySet.h" #include //----------------------------------------------------------------------------- @@ -87,7 +87,7 @@ public: // When some proprietary shadow groups are disclosed, we can set up // an additional specific dictionary to access extra information. - // OK : we still have *ONE* ElValSet, + // OK : we still have *ONE* HeaderEntrySet, // with both Public and Shadow Elements // parsed against THE Public Dictionary and A (single) Shadow Dictionary @@ -95,32 +95,32 @@ public: // TODO Swig int SetPubDict(std::string filename); // Public element value - std::string GetPubElValByName (std::string tagName); - std::string GetPubElValRepByName (std::string tagName); - std::string GetPubElValByNumber (guint16 group, guint16 element); - std::string GetPubElValRepByNumber(guint16 group, guint16 element); + std::string GetPubEntryByName (std::string tagName); + std::string GetPubEntryVRByName (std::string tagName); + std::string GetPubEntryByNumber (guint16 group, guint16 element); + std::string GetPubEntryVRByNumber(guint16 group, guint16 element); - bool SetPubElValByName (std::string content, std::string tagName); - bool SetPubElValByNumber(std::string content, guint16 group, guint16 element); - bool SetPubElValLengthByNumber(guint32 lgr, guint16 group, guint16 element); + bool SetPubEntryByName (std::string content, std::string tagName); + bool SetPubEntryByNumber(std::string content, guint16 group, guint16 element); + bool SetPubEntryLengthByNumber(guint32 lgr, guint16 group, guint16 element); - inline ListTag & GetPubListElem(void) { return PubElValSet.GetListElem();}; - inline TagElValueHT & GetPubElVal(void) { return PubElValSet.GetTagHt(); }; + inline ListTag & GetPubListEntry(void) { return PubEntrySet.GetListEntry();}; + inline TagHeaderEntryHT & GetPubEntry(void) { return PubEntrySet.GetTagHT(); }; - void PrintPubElVal(std::ostream & os = std::cout); + void PrintPubEntry(std::ostream & os = std::cout); void PrintPubDict (std::ostream & os = std::cout); // Element value - std::string GetElValByName (std::string tagName); - std::string GetElValRepByName (std::string tagName); - std::string GetElValByNumber (guint16 group, guint16 element); - std::string GetElValRepByNumber(guint16 group, guint16 element); + std::string GetEntryByName (std::string tagName); + std::string GetEntryVRByName (std::string tagName); + std::string GetEntryByNumber (guint16 group, guint16 element); + std::string GetEntryVRByNumber(guint16 group, guint16 element); - bool SetElValueByName(std::string content,std::string tagName); -// bool SetElValueByNumber(std::string content,guint16 group, guint16 element); + bool SetEntryByName(std::string content,std::string tagName); +// bool SetEntryByNumber(std::string content,guint16 group, guint16 element); -// inline ListTag & GetListElem(void) { return PubElValSet.GetListElem();}; -// inline TagElValueHT & GetElVal(void) { return PubElValSet.GetTagHt(); }; +// inline ListTag & GetListElem(void) { return PubHeaderEntrySet.GetListElem();}; +// inline TagHeaderEntryHT & GetElVal(void) { return PubHeaderEntrySet.GetTagHt(); }; // Read (used in gdcmFile) FILE *OpenFile(bool exception_on_error = false) throw(gdcmFileError); @@ -131,26 +131,27 @@ public: bool Write(FILE *, FileType); void SetImageDataSize(size_t ExpectedSize); + bool ReplaceOrCreateByNumber(std::string Value, guint16 Group, guint16 Elem); + bool ReplaceOrCreateByNumber( char * Value, guint16 Group, guint16 Elem); + bool ReplaceIfExistByNumber ( char * Value, guint16 Group, guint16 Elem); + // System access inline int GetSwapCode(void) { return sw; } guint16 SwapShort(guint16); // needed by gdcmFile guint32 SwapLong(guint32); // for JPEG Files - // was protected - bool ReplaceOrCreateByNumber(std::string Value, guint16 Group, guint16 Elem); - bool ReplaceOrCreateByNumber( char * Value, guint16 Group, guint16 Elem); - bool ReplaceIfExistByNumber ( char * Value, guint16 Group, guint16 Elem); - protected: bool CheckIfExistByNumber(guint16 Group, guint16 Elem ); - gdcmElValue * GetElValueByNumber(guint16 group, guint16 element); + + gdcmHeaderEntry *GetHeaderEntryByName (std::string Name); + gdcmHeaderEntry *GetHeaderEntryByNumber(guint16 group, guint16 element); int write(std::ostream&); int anonymize(std::ostream&); // FIXME : anonymize should be a friend ? - size_t GetPubElValOffsetByNumber (guint16 Group, guint16 Elem); - void * GetPubElValVoidAreaByNumber(guint16 Group, guint16 Elem); - void * LoadElementVoidArea (guint16 Group, guint16 Element); + size_t GetPubEntryOffsetByNumber (guint16 Group, guint16 Elem); + void * GetPubEntryVoidAreaByNumber(guint16 Group, guint16 Elem); + void * LoadEntryVoidArea (guint16 Group, guint16 Element); // Variables @@ -159,17 +160,17 @@ protected: private: // Read - void LoadElements (void); - void LoadElementValue (gdcmElValue *); - void LoadElementValueSafe(gdcmElValue *); - void FindLength (gdcmElValue *); - void FindVR (gdcmElValue *); + void LoadHeaderEntries (void); + void LoadHeaderEntry (gdcmHeaderEntry *); + void LoadHeaderEntrySafe (gdcmHeaderEntry *); + void FindHeaderEntryLength(gdcmHeaderEntry *); + void FindHeaderEntryVR (gdcmHeaderEntry *); - guint32 FindLengthOB(void); + void SkipHeaderEntry (gdcmHeaderEntry *); + void FixHeaderEntryFoundLength(gdcmHeaderEntry *, guint32); + bool IsHeaderEntryAnInteger (gdcmHeaderEntry *); - void SkipElementValue (gdcmElValue *); - void FixFoundLength (gdcmElValue *, guint32); - bool IsAnInteger (gdcmElValue *); + guint32 FindHeaderEntryLengthOB(void); guint16 ReadInt16(void); guint32 ReadInt32(void); @@ -184,15 +185,14 @@ private: gdcmDictEntry *GetDictEntryByName (std::string Name); gdcmDictEntry *GetDictEntryByNumber(guint16, guint16); - // ElValue related utilities - gdcmElValue *ReadNextElement (void); - gdcmElValue *NewElValueByNumber(guint16 group, guint16 element); - gdcmElValue *NewElValueByName (std::string Name); - gdcmElValue* GetElementByName (std::string Name); + // HeaderEntry related utilities + gdcmHeaderEntry *ReadNextHeaderEntry (void); + gdcmHeaderEntry *NewHeaderEntryByNumber(guint16 group, guint16 element); + gdcmHeaderEntry *NewHeaderEntryByName (std::string Name); - // Deprecated - gdcmElValue *NewManualElValToPubDict(std::string NewTagName, - std::string VR); + // Deprecated (Not used) + gdcmHeaderEntry *NewManualHeaderEntryToPubDict(std::string NewTagName, + std::string VR); // Variables // Pointer to the Value Representation Hash Table which contains all @@ -214,7 +214,7 @@ private: gdcmDict *RefShaDict; /// ELement VALueS parsed with the PUBlic dictionary. - gdcmElValSet PubElValSet; + gdcmHeaderEntrySet PubEntrySet; // Refering underlying filename. std::string filename; diff --git a/src/gdcmElValue.cxx b/src/gdcmHeaderEntry.cxx similarity index 81% rename from src/gdcmElValue.cxx rename to src/gdcmHeaderEntry.cxx index 64e3e247..aed66bd8 100644 --- a/src/gdcmElValue.cxx +++ b/src/gdcmHeaderEntry.cxx @@ -1,19 +1,19 @@ -// gdcmElValue.cxx +// gdcmHeaderEntry.cxx //----------------------------------------------------------------------------- // TODO -// A 'gdcmElValue' is actually a 'Dicom Element'. +// A 'gdcmHeaderEntry' is actually a 'Dicom Element'. // WHY such a confusing name??? // -#include "gdcmElValue.h" +#include "gdcmHeaderEntry.h" //----------------------------------------------------------------------------- // Constructor / Destructor /** - * \ingroup gdcmElValue + * \ingroup gdcmHeaderEntry * \brief Constructor from a given gdcmDictEntry * @param in Pointer to existing dictionary entry */ -gdcmElValue::gdcmElValue(gdcmDictEntry* in) { +gdcmHeaderEntry::gdcmHeaderEntry(gdcmDictEntry* in) { ImplicitVr = false; entry = in; } diff --git a/src/gdcmElValue.h b/src/gdcmHeaderEntry.h similarity index 82% rename from src/gdcmElValue.h rename to src/gdcmHeaderEntry.h index 7b4600a4..1c8520ae 100644 --- a/src/gdcmElValue.h +++ b/src/gdcmHeaderEntry.h @@ -1,7 +1,7 @@ -// gdcmElValue.h +// gdcmHeaderEntry.h //----------------------------------------------------------------------------- -#ifndef GDCMELVALUE_H -#define GDCMELVALUE_H +#ifndef GDCMHeaderEntry_H +#define GDCMHeaderEntry_H #include "gdcmDictEntry.h" class gdcmHeader; @@ -10,12 +10,12 @@ class gdcmHeader; //----------------------------------------------------------------------------- /* - * The dicom header of a Dicom file contains a set of such ELement VALUES + * The dicom header of a Dicom file contains a set of such entries * (when successfuly parsed against a given Dicom dictionary) */ -class GDCM_EXPORT gdcmElValue { +class GDCM_EXPORT gdcmHeaderEntry { public: - gdcmElValue(gdcmDictEntry*); + gdcmHeaderEntry(gdcmDictEntry*); inline guint16 GetGroup(void) { return entry->GetGroup(); }; inline guint16 GetElement(void) { return entry->GetElement();}; @@ -38,60 +38,60 @@ public: inline void SetVoidArea(void * area) { voidArea = area; }; /** - * \ingroup gdcmElValue + * \ingroup gdcmHeaderEntry * \brief Sets the offset of the Dicom Element * \warning : use with caution ! * @param of offset to be set */ - inline void gdcmElValue::SetOffset(size_t of) { Offset = of; }; + inline void gdcmHeaderEntry::SetOffset(size_t of) { Offset = of; }; /** - * \ingroup gdcmElValue + * \ingroup gdcmHeaderEntry * \brief Sets the DicEntry of the current Dicom Element * @param NewEntry pointer to the DictEntry */ - inline void gdcmElValue::SetDictEntry(gdcmDictEntry *NewEntry) { + inline void gdcmHeaderEntry::SetDictEntry(gdcmDictEntry *NewEntry) { entry = NewEntry; }; /** - * \ingroup gdcmElValue + * \ingroup gdcmHeaderEntry * \brief Sets to TRUE the ImplicitVr flag of the current Dicom Element */ - inline void gdcmElValue::SetImplicitVr(void) { + inline void gdcmHeaderEntry::SetImplicitVr(void) { ImplicitVr = true; }; /** - * \ingroup gdcmElValue + * \ingroup gdcmHeaderEntry * \brief tells us if the current Dicom Element was checked as ImplicitVr * @return true if the current Dicom Element was checked as ImplicitVr */ - inline bool gdcmElValue::IsImplicitVr(void) { + inline bool gdcmHeaderEntry::IsImplicitVr(void) { return ImplicitVr; }; /** - * \ingroup gdcmElValue + * \ingroup gdcmHeaderEntry * \brief Gets the DicEntry of the current Dicom Element * @return the DicEntry of the current Dicom Element */ - gdcmDictEntry * gdcmElValue::GetDictEntry(void) { + gdcmDictEntry * gdcmHeaderEntry::GetDictEntry(void) { return entry; }; /** - * \ingroup gdcmElValue + * \ingroup gdcmHeaderEntry * \brief tells us if the VR of the current Dicom Element is Unkonwn * @return true if the VR is unkonwn */ - inline bool gdcmElValue::IsVRUnknown(void) { + inline bool gdcmHeaderEntry::IsVRUnknown(void) { return entry->IsVRUnknown(); }; private: // FIXME: In fact we should be more specific and use : - // friend gdcmElValue * gdcmHeader::ReadNextElement(void); + // friend gdcmHeaderEntry * gdcmHeader::ReadNextElement(void); friend class gdcmHeader; // Variables diff --git a/src/gdcmElValSet.cxx b/src/gdcmHeaderEntrySet.cxx similarity index 79% rename from src/gdcmElValSet.cxx rename to src/gdcmHeaderEntrySet.cxx index 58f87458..b49582d2 100644 --- a/src/gdcmElValSet.cxx +++ b/src/gdcmHeaderEntrySet.cxx @@ -1,7 +1,7 @@ -// gdcmElValSet.cxx +// gdcmHeaderEntrySet.cxx //----------------------------------------------------------------------------- #include "gdcmUtil.h" -#include "gdcmElValSet.h" +#include "gdcmHeaderEntrySet.h" #include "gdcmTS.h" #ifdef GDCM_NO_ANSI_STRING_STREAM # include @@ -13,29 +13,29 @@ //----------------------------------------------------------------------------- // Constructor / Destructor /** - * \ingroup gdcmElValSet + * \ingroup gdcmHeaderEntrySet * \brief Destructor */ -gdcmElValSet::~gdcmElValSet() { - for (TagElValueHT::iterator tag = tagHt.begin(); tag != tagHt.end(); ++tag) { - gdcmElValue* EntryToDelete = tag->second; +gdcmHeaderEntrySet::~gdcmHeaderEntrySet() { + for (TagHeaderEntryHT::iterator tag = tagHT.begin(); tag != tagHT.end(); ++tag) { + gdcmHeaderEntry* EntryToDelete = tag->second; if ( EntryToDelete ) delete EntryToDelete; tag->second=NULL; } - tagHt.clear(); + tagHT.clear(); } //----------------------------------------------------------------------------- // Print /** - * \ingroup gdcmElValSet + * \ingroup gdcmHeaderEntrySet * \brief prints the Dicom Elements of the gdcmHeader * using both H table and Chained List * @param os The output stream to be written to. */ -void gdcmElValSet::Print(std::ostream & os) { +void gdcmHeaderEntrySet::Print(std::ostream & os) { size_t o; unsigned short int g, e; @@ -45,12 +45,12 @@ void gdcmElValSet::Print(std::ostream & os) { std::ostringstream s; - s << "------------- using tagHt ---------------------" << std::endl; + s << "------------- using tagHT ---------------------" << std::endl; // Tag HT - s << "------------- using tagHt ---------------------" << std::endl; - for (TagElValueHT::iterator tag = tagHt.begin(); - tag != tagHt.end(); + s << "------------- using tagHT ---------------------" << std::endl; + for (TagHeaderEntryHT::iterator tag = tagHT.begin(); + tag != tagHT.end(); ++tag){ g = tag->second->GetGroup(); e = tag->second->GetElement(); @@ -84,10 +84,10 @@ void gdcmElValSet::Print(std::ostream & os) { char greltag[10]; //group element tag - s << "------------ using listElem -------------------" << std::endl; + s << "------------ using listEntries -------------------" << std::endl; - for (ListTag::iterator i = listElem.begin(); - i != listElem.end(); + for (ListTag::iterator i = listEntries.begin(); + i != listEntries.end(); ++i){ g = (*i)->GetGroup(); e = (*i)->GetElement(); @@ -125,25 +125,25 @@ void gdcmElValSet::Print(std::ostream & os) { //----------------------------------------------------------------------------- // Public /** - * \ingroup gdcmElValSet + * \ingroup gdcmHeaderEntrySet * \brief add a new Dicom Element pointer to * the H Table and to the chained List - * @param newElValue + * @param newHeaderEntry */ -void gdcmElValSet::Add(gdcmElValue * newElValue) { +void gdcmHeaderEntrySet::Add(gdcmHeaderEntry * newHeaderEntry) { -// tagHt [newElValue->GetKey()] = newElValue; +// tagHT [newHeaderEntry->GetKey()] = newHeaderEntry; - tagHt.insert( PairHT( newElValue->GetKey(),newElValue) ); + tagHT.insert( PairHT( newHeaderEntry->GetKey(),newHeaderEntry) ); -// WARNING : push_bash in listElem ONLY during ParseHeader +// WARNING : push_bash in listEntries ONLY during ParseHeader // TODO : something to allow further Elements addition // position to be taken care of ! - listElem.push_back(newElValue); + listEntries.push_back(newHeaderEntry); } /** - * \ingroup gdcmElValSet + * \ingroup gdcmHeaderEntrySet * \brief retrieves a Dicom Element (the first one) using (group, element) * \ warning (group, element) IS NOT an identifier inside the Dicom Header * if you think it's NOT UNIQUE, check the count number @@ -153,39 +153,39 @@ void gdcmElValSet::Add(gdcmElValue * newElValue) { * @param element Element number of the searched Dicom Element * @return */ -gdcmElValue* gdcmElValSet::GetElementByNumber(guint16 group, guint16 element) { +gdcmHeaderEntry* gdcmHeaderEntrySet::GetHeaderEntryByNumber(guint16 group, guint16 element) { TagKey key = gdcmDictEntry::TranslateToKey(group, element); - if ( ! tagHt.count(key)) - return (gdcmElValue*)0; - return tagHt.find(key)->second; + if ( ! tagHT.count(key)) + return NULL; + return tagHT.find(key)->second; } /** - * \ingroup gdcmElValSet + * \ingroup gdcmHeaderEntrySet * \brief Gets the value (string) of the target Dicom Element * @param group Group number of the searched Dicom Element * @param element Element number of the searched Dicom Element * @return */ -std::string gdcmElValSet::GetElValueByNumber(guint16 group, guint16 element) { +std::string gdcmHeaderEntrySet::GetEntryByNumber(guint16 group, guint16 element) { TagKey key = gdcmDictEntry::TranslateToKey(group, element); - if ( ! tagHt.count(key)) + if ( ! tagHT.count(key)) return GDCM_UNFOUND; - return tagHt.find(key)->second->GetValue(); + return tagHT.find(key)->second->GetValue(); } /** - * \ingroup gdcmElValSet + * \ingroup gdcmHeaderEntrySet * \brief Sets the value (string) of the target Dicom Element * @param content string value of the Dicom Element * @param group Group number of the searched Dicom Element * @param element Element number of the searched Dicom Element * @return */ -bool gdcmElValSet::SetElValueByNumber(std::string content, - guint16 group, guint16 element) { +bool gdcmHeaderEntrySet::SetEntryByNumber(std::string content, + guint16 group, guint16 element) { TagKey key = gdcmDictEntry::TranslateToKey(group, element); - if ( ! tagHt.count(key)) + if ( ! tagHT.count(key)) return false; int l = content.length(); if(l%2) { // Odd length are padded with a space (020H). @@ -193,21 +193,21 @@ bool gdcmElValSet::SetElValueByNumber(std::string content, content = content + '\0'; } - //tagHt[key]->SetValue(content); - gdcmElValue * a; + //tagHT[key]->SetValue(content); + gdcmHeaderEntry * a; IterHT p; - TagElValueHT::iterator p2; + TagHeaderEntryHT::iterator p2; // DO NOT remove the following lines : they explain the stuff - //p= tagHt.equal_range(key); // get a pair of iterators first-last synonym + //p= tagHT.equal_range(key); // get a pair of iterators first-last synonym //p2=p.first; // iterator on the first synonym //a=p2->second; // H Table target column (2-nd col) // or, easier : - a = ((tagHt.equal_range(key)).first)->second; + a = ((tagHT.equal_range(key)).first)->second; a-> SetValue(content); - //std::string vr = tagHt[key]->GetVR(); + //std::string vr = tagHT[key]->GetVR(); std::string vr = a->GetVR(); guint32 lgr; @@ -217,13 +217,13 @@ bool gdcmElValSet::SetElValueByNumber(std::string content, lgr = 4; else lgr = l; - //tagHt[key]->SetLength(lgr); + //tagHT[key]->SetLength(lgr); a->SetLength(lgr); return true; } /** - * \ingroup gdcmElValSet + * \ingroup gdcmHeaderEntrySet * \brief Sets the value length of the Dicom Element * \warning : use with caution ! * @param length @@ -231,62 +231,62 @@ bool gdcmElValSet::SetElValueByNumber(std::string content, * @param element Element number of the searched Dicom Element * @return boolean */ -bool gdcmElValSet::SetElValueLengthByNumber(guint32 length, - guint16 group, guint16 element) { +bool gdcmHeaderEntrySet::SetEntryLengthByNumber(guint32 length, + guint16 group, guint16 element) { TagKey key = gdcmDictEntry::TranslateToKey(group, element); - if ( ! tagHt.count(key)) + if ( ! tagHT.count(key)) return false; if (length%2) length++; // length must be even - //tagHt[key]->SetLength(length); - ( ((tagHt.equal_range(key)).first)->second )->SetLength(length); + //tagHT[key]->SetLength(length); + ( ((tagHT.equal_range(key)).first)->second )->SetLength(length); return true ; } /** - * \ingroup gdcmElValSet + * \ingroup gdcmHeaderEntrySet * \brief Sets a 'non string' value to a given Dicom Element * @param area * @param group Group number of the searched Dicom Element * @param element Element number of the searched Dicom Element * @return */ -bool gdcmElValSet::SetVoidAreaByNumber(void * area, +bool gdcmHeaderEntrySet::SetVoidAreaByNumber(void * area, guint16 group, guint16 element) { TagKey key = gdcmDictEntry::TranslateToKey(group, element); - if ( ! tagHt.count(key)) + if ( ! tagHT.count(key)) return false; - //tagHt[key]->SetVoidArea(area); - ( ((tagHt.equal_range(key)).first)->second )->SetVoidArea(area); + //tagHT[key]->SetVoidArea(area); + ( ((tagHT.equal_range(key)).first)->second )->SetVoidArea(area); return true ; } /** - * \ingroup gdcmElValSet + * \ingroup gdcmHeaderEntrySet * \brief Generate a free TagKey i.e. a TagKey that is not present * in the TagHt dictionary. * @param group The generated tag must belong to this group. * @return The element of tag with given group which is fee. */ -guint32 gdcmElValSet::GenerateFreeTagKeyInGroup(guint16 group) { +guint32 gdcmHeaderEntrySet::GenerateFreeTagKeyInGroup(guint16 group) { for (guint32 elem = 0; elem < UINT32_MAX; elem++) { TagKey key = gdcmDictEntry::TranslateToKey(group, elem); - if (tagHt.count(key) == 0) + if (tagHT.count(key) == 0) return elem; } return UINT32_MAX; } /** - * \ingroup gdcmElValSet + * \ingroup gdcmHeaderEntrySet * \brief Checks if a given Dicom Element exists * \ within the H table * @param group Group number of the searched Dicom Element * @param element Element number of the searched Dicom Element * @return number of occurences */ -int gdcmElValSet::CheckIfExistByNumber(guint16 group, guint16 element ) { +int gdcmHeaderEntrySet::CheckIfExistByNumber(guint16 group, guint16 element ) { std::string key = gdcmDictEntry::TranslateToKey(group, element ); - return (tagHt.count(key)); + return (tagHT.count(key)); } // ============== @@ -294,14 +294,14 @@ int gdcmElValSet::CheckIfExistByNumber(guint16 group, guint16 element ) { // so we can remove the GroupHT from the gdcmHeader // ============= /** - * \ingroup gdcmElValSet + * \ingroup gdcmHeaderEntrySet * \brief * @param _fp already open file pointer * @param type type of the File to be written * (ACR-NEMA, ExplicitVR, ImplicitVR) * @return always "True" ?! */ -bool gdcmElValSet::Write(FILE * _fp, FileType type) { +bool gdcmHeaderEntrySet::Write(FILE * _fp, FileType type) { // Question : // Comment pourrait-on savoir si le DcmHeader vient d'un fichier DicomV3 ou non @@ -316,7 +316,7 @@ bool gdcmElValSet::Write(FILE * _fp, FileType type) { if ( type == ACR) UpdateGroupLength(true,ACR); - WriteElements(type, _fp); + WriteEntries(type, _fp); return(true); } @@ -326,18 +326,18 @@ bool gdcmElValSet::Write(FILE * _fp, FileType type) { //----------------------------------------------------------------------------- // Private /** - * \ingroup gdcmElValSet + * \ingroup gdcmHeaderEntrySet * \brief Re-computes the length of a ACR-NEMA/Dicom group from a DcmHeader * \warning : to be re-written using the chained list instead of the H table. * \todo : to be re-written using the chained list instead of the H table * @param SkipSequence TRUE if we don't want to write Sequences (ACR-NEMA Files) * @param type Type of the File (ExplicitVR,ImplicitVR, ACR, ...) */ -void gdcmElValSet::UpdateGroupLength(bool SkipSequence, FileType type) { +void gdcmHeaderEntrySet::UpdateGroupLength(bool SkipSequence, FileType type) { guint16 gr, el; std::string vr; - gdcmElValue *elem; + gdcmHeaderEntry *elem; char trash[10]; std::string str_trash; @@ -347,12 +347,12 @@ void gdcmElValSet::UpdateGroupLength(bool SkipSequence, FileType type) { // remember : // typedef std::map GroupHT; - gdcmElValue *elemZ; + gdcmHeaderEntry *elemZ; // for each Tag in the DCM Header - for (TagElValueHT::iterator tag2 = tagHt.begin(); - tag2 != tagHt.end(); + for (TagHeaderEntryHT::iterator tag2 = tagHT.begin(); + tag2 != tagHT.end(); ++tag2){ elem = tag2->second; @@ -404,13 +404,13 @@ void gdcmElValSet::UpdateGroupLength(bool SkipSequence, FileType type) { sscanf(g->first.c_str(),"%x",&gr_bid); tk = g->first + "|0000"; // generate the element full tag - if ( tagHt.count(tk) == 0) { // if element 0x0000 not found + if ( tagHT.count(tk) == 0) { // if element 0x0000 not found gdcmDictEntry * tagZ = new gdcmDictEntry(gr_bid, 0x0000, "UL"); - elemZ = new gdcmElValue(tagZ); + elemZ = new gdcmHeaderEntry(tagZ); elemZ->SetLength(4); Add(elemZ); // create it } else { - elemZ=GetElementByNumber(gr_bid, 0x0000); + elemZ=GetHeaderEntryByNumber(gr_bid, 0x0000); } sprintf(trash ,"%d",g->second); str_trash=trash; @@ -419,7 +419,7 @@ void gdcmElValSet::UpdateGroupLength(bool SkipSequence, FileType type) { } /** - * \ingroup gdcmElValSet + * \ingroup gdcmHeaderEntrySet * \brief writes on disc according to the requested format * \ (ACR-NEMA, ExplicitVR, ImplicitVR) the image * \ warning does NOT add the missing elements in the header : @@ -430,7 +430,7 @@ void gdcmElValSet::UpdateGroupLength(bool SkipSequence, FileType type) { * @param _fp already open file pointer * @return */ -void gdcmElValSet::WriteElements(FileType type, FILE * _fp) { +void gdcmHeaderEntrySet::WriteEntries(FileType type, FILE * _fp) { guint16 gr, el; guint32 lgr; const char * val; @@ -440,8 +440,8 @@ void gdcmElValSet::WriteElements(FileType type, FILE * _fp) { std::vector tokens; - // TODO : use listElem to iterate, not TagHt! - // pb : gdcmElValSet.Add does NOT update listElem + // TODO : use listEntries to iterate, not TagHt! + // pb : gdcmHeaderEntrySet.Add does NOT update listEntries // find a trick in STL to do it, at low cost ! void *ptr; @@ -449,8 +449,8 @@ void gdcmElValSet::WriteElements(FileType type, FILE * _fp) { // Tout ceci ne marche QUE parce qu'on est sur un proc Little Endian // restent a tester les echecs en ecriture (apres chaque fwrite) - for (TagElValueHT::iterator tag2=tagHt.begin(); - tag2 != tagHt.end(); + for (TagHeaderEntryHT::iterator tag2=tagHT.begin(); + tag2 != tagHT.end(); ++tag2){ gr = tag2->second->GetGroup(); diff --git a/src/gdcmHeaderEntrySet.h b/src/gdcmHeaderEntrySet.h new file mode 100644 index 00000000..e21e5050 --- /dev/null +++ b/src/gdcmHeaderEntrySet.h @@ -0,0 +1,73 @@ +// gdcmHeaderEntrySet.h +//----------------------------------------------------------------------------- +#ifndef GDCMHeaderEntrySet_H +#define GDCMHeaderEntrySet_H + +#include "gdcmCommon.h" +#include "gdcmHeaderEntry.h" + +#include +#include +#include // for linking together *all* the Dicom Elements + +//----------------------------------------------------------------------------- +typedef std::multimap TagHeaderEntryHT; +typedef std::pair PairHT; +typedef std::pair IterHT; + +typedef std::list ListTag; // for linking together the Elements + +// TODO : to be removed after re-writting gdcmHeaderEntrySet::UpdateGroupLength +// using the chained list instead of the H table +typedef std::string GroupKey; +typedef std::map GroupHT; + +//----------------------------------------------------------------------------- +/* + * Container for a set of successfully parsed HeaderEntrys (i.e. Dicom Elements). + */ +class GDCM_EXPORT gdcmHeaderEntrySet { +public: + ~gdcmHeaderEntrySet(); + + void Print(std::ostream &); + + void Add(gdcmHeaderEntry*); + + gdcmHeaderEntry* GetHeaderEntryByNumber(guint16 group, guint16 element); + std::string GetEntryByNumber(guint16 group, guint16 element); + + bool SetEntryByNumber(std::string content, guint16 group, guint16 element); + bool SetEntryLengthByNumber(guint32 l, guint16 group, guint16 element); + bool SetVoidAreaByNumber(void *a, guint16 Group, guint16 Elem ); + + guint32 GenerateFreeTagKeyInGroup(guint16 group); + int CheckIfExistByNumber(guint16 Group, guint16 Elem ); // int ! + + /** + * \ingroup gdcmHeaderEntrySet + * \brief returns a ref to the Dicom Header H table (multimap) + * return the Dicom Header H table + */ + inline TagHeaderEntryHT & gdcmHeaderEntrySet::GetTagHT(void) { return tagHT; }; + + /** + * \ingroup gdcmHeaderEntrySet + * \brief returns a ref to the Dicom Header chained list + * return the Dicom Header chained list + */ + inline ListTag & gdcmHeaderEntrySet::GetListEntry(void) { return listEntries; }; + + bool Write(FILE *fp, FileType type); + +private: + void UpdateGroupLength(bool SkipSequence = false, FileType type = ImplicitVR); + void WriteEntries(FileType type, FILE *); + +// Variables + TagHeaderEntryHT tagHT; // H Table (multimap), to provide fast access + ListTag listEntries; // chained list, to keep the 'spacial' ordering +}; + +//----------------------------------------------------------------------------- +#endif diff --git a/src/gdcmHeaderHelper.cxx b/src/gdcmHeaderHelper.cxx index 1f38148f..abfdf381 100644 --- a/src/gdcmHeaderHelper.cxx +++ b/src/gdcmHeaderHelper.cxx @@ -88,7 +88,7 @@ int gdcmHeaderHelper::GetPixelSize() { // 0028 0100 US IMG Bits Allocated // (in order no to be messed up by old RGB images) - if (gdcmHeader::GetPubElValByNumber(0x0028,0x0100) == "24") + if (gdcmHeader::GetPubEntryByNumber(0x0028,0x0100) == "24") return 3; std::string PixelType = GetPixelType(); @@ -118,7 +118,7 @@ int gdcmHeaderHelper::GetPixelSize() { */ std::string gdcmHeaderHelper::GetPixelType() { std::string BitsAlloc; - BitsAlloc = GetPubElValByNumber(0x0028, 0x0100); + BitsAlloc = GetPubEntryByNumber(0x0028, 0x0100); if (BitsAlloc == GDCM_UNFOUND) { // Bits Allocated dbg.Verbose(0, "gdcmHeader::GetPixelType: unfound Bits Allocated"); BitsAlloc = std::string("16"); @@ -129,7 +129,7 @@ std::string gdcmHeaderHelper::GetPixelType() { BitsAlloc = std::string("8"); // by old RGB images) std::string Signed; - Signed = GetPubElValByNumber(0x0028, 0x0103); + Signed = GetPubEntryByNumber(0x0028, 0x0103); if (Signed == GDCM_UNFOUND) { // "Pixel Representation" dbg.Verbose(0, "gdcmHeader::GetPixelType: unfound Pixel Representation"); BitsAlloc = std::string("0"); @@ -150,7 +150,7 @@ std::string gdcmHeaderHelper::GetPixelType() { */ float gdcmHeaderHelper::GetXSpacing() { float xspacing, yspacing; - std::string StrSpacing = GetPubElValByNumber(0x0028,0x0030); + std::string StrSpacing = GetPubEntryByNumber(0x0028,0x0030); if (StrSpacing == GDCM_UNFOUND) { dbg.Verbose(0, "gdcmHeader::GetXSpacing: unfound Pixel Spacing (0028,0030)"); @@ -174,7 +174,7 @@ float gdcmHeaderHelper::GetXSpacing() { */ float gdcmHeaderHelper::GetYSpacing() { float xspacing, yspacing; - std::string StrSpacing = GetPubElValByNumber(0x0028,0x0030); + std::string StrSpacing = GetPubEntryByNumber(0x0028,0x0030); if (StrSpacing == GDCM_UNFOUND) { dbg.Verbose(0, "gdcmHeader::GetYSpacing: unfound Pixel Spacing (0028,0030)"); @@ -208,11 +208,11 @@ float gdcmHeaderHelper::GetZSpacing() { // Si le Spacing Between Slices est absent, // on suppose que les coupes sont jointives - std::string StrSpacingBSlices = GetPubElValByNumber(0x0018,0x0088); + std::string StrSpacingBSlices = GetPubEntryByNumber(0x0018,0x0088); if (StrSpacingBSlices == GDCM_UNFOUND) { dbg.Verbose(0, "gdcmHeader::GetZSpacing: unfound StrSpacingBSlices"); - std::string StrSliceThickness = GetPubElValByNumber(0x0018,0x0050); + std::string StrSliceThickness = GetPubEntryByNumber(0x0018,0x0050); if (StrSliceThickness == GDCM_UNFOUND) return 1.; else @@ -229,7 +229,7 @@ float gdcmHeaderHelper::GetZSpacing() { float gdcmHeaderHelper::GetRescaleIntercept() { float resInter = 0.; - std::string StrRescInter = GetPubElValByNumber(0x0028,0x1052); //0028 1052 DS IMG Rescale Intercept + std::string StrRescInter = GetPubEntryByNumber(0x0028,0x1052); //0028 1052 DS IMG Rescale Intercept if (StrRescInter != GDCM_UNFOUND) { if( sscanf( StrRescInter.c_str(), "%f", &resInter) != 1) { dbg.Verbose(0, "gdcmHeader::GetRescaleIntercept: Rescale Slope is empty"); @@ -242,7 +242,7 @@ float gdcmHeaderHelper::GetRescaleIntercept() float gdcmHeaderHelper::GetRescaleSlope() { float resSlope = 1.; - std::string StrRescSlope = GetPubElValByNumber(0x0028,0x1053); //0028 1053 DS IMG Rescale Slope + std::string StrRescSlope = GetPubEntryByNumber(0x0028,0x1053); //0028 1053 DS IMG Rescale Slope if (StrRescSlope != GDCM_UNFOUND) { if( sscanf( StrRescSlope.c_str(), "%f", &resSlope) != 1) { dbg.Verbose(0, "gdcmHeader::GetRescaleSlope: Rescale Slope is empty"); @@ -267,11 +267,11 @@ int gdcmHeaderHelper::GetNumberOfScalarComponents() { // 0028 0100 US IMG Bits Allocated // (in order no to be messed up by old RGB images) - if (gdcmHeader::GetPubElValByNumber(0x0028,0x0100) == "24") + if (gdcmHeader::GetPubEntryByNumber(0x0028,0x0100) == "24") return 3; std::string PhotometricInterpretation = - gdcmHeader::GetPubElValByNumber(0x0028,0x0004); + gdcmHeader::GetPubEntryByNumber(0x0028,0x0004); if ( ( PhotometricInterpretation == "PALETTE COLOR ") ) { if (HasLUT()) // PALETTE COLOR is NOT enough @@ -305,7 +305,7 @@ int gdcmHeaderHelper::GetNumberOfScalarComponentsRaw() { // 0028 0100 US IMG Bits Allocated // (in order no to be messed up by old RGB images) - if (gdcmHeader::GetPubElValByNumber(0x0028,0x0100) == "24") + if (gdcmHeader::GetPubEntryByNumber(0x0028,0x0100) == "24") return 3; // we assume that *all* kinds of YBR are dealt with @@ -314,22 +314,22 @@ int gdcmHeaderHelper::GetNumberOfScalarComponentsRaw() { std::string gdcmHeaderHelper::GetStudyUID() { - return GetPubElValByNumber(0x0020,0x000d); //0020 000d UI REL Study Instance UID + return GetPubEntryByNumber(0x0020,0x000d); //0020 000d UI REL Study Instance UID } std::string gdcmHeaderHelper::GetSeriesUID() { - return GetPubElValByNumber(0x0020,0x000e); //0020 000e UI REL Series Instance UID + return GetPubEntryByNumber(0x0020,0x000e); //0020 000e UI REL Series Instance UID } std::string gdcmHeaderHelper::GetClassUID() { - return GetPubElValByNumber(0x0008,0x0016); //0008 0016 UI ID SOP Class UID + return GetPubEntryByNumber(0x0008,0x0016); //0008 0016 UI ID SOP Class UID } std::string gdcmHeaderHelper::GetInstanceUID() { - return GetPubElValByNumber(0x0008,0x0018); //0008 0018 UI ID SOP Instance UID + return GetPubEntryByNumber(0x0008,0x0018); //0008 0018 UI ID SOP Instance UID } // Image Position Patient (0020,0032): @@ -350,11 +350,11 @@ std::string gdcmHeaderHelper::GetInstanceUID() */ float gdcmHeaderHelper::GetXOrigin() { float xImPos, yImPos, zImPos; - std::string StrImPos = GetPubElValByNumber(0x0020,0x0032); + std::string StrImPos = GetPubEntryByNumber(0x0020,0x0032); if (StrImPos == GDCM_UNFOUND) { dbg.Verbose(0, "gdcmHeader::GetXImagePosition: unfound Image Position Patient (0020,0032)"); - StrImPos = GetPubElValByNumber(0x0020,0x0030); // For ACR-NEMA images + StrImPos = GetPubEntryByNumber(0x0020,0x0030); // For ACR-NEMA images if (StrImPos == GDCM_UNFOUND) { dbg.Verbose(0, "gdcmHeader::GetXImagePosition: unfound Image Position (RET) (0020,0030)"); // How to tell the caller nothing was found ? @@ -375,11 +375,11 @@ float gdcmHeaderHelper::GetXOrigin() { */ float gdcmHeaderHelper::GetYOrigin() { float xImPos, yImPos, zImPos; - std::string StrImPos = GetPubElValByNumber(0x0020,0x0032); + std::string StrImPos = GetPubEntryByNumber(0x0020,0x0032); if (StrImPos == GDCM_UNFOUND) { dbg.Verbose(0, "gdcmHeader::GetYImagePosition: unfound Image Position Patient (0020,0032)"); - StrImPos = GetPubElValByNumber(0x0020,0x0030); // For ACR-NEMA images + StrImPos = GetPubEntryByNumber(0x0020,0x0030); // For ACR-NEMA images if (StrImPos == GDCM_UNFOUND) { dbg.Verbose(0, "gdcmHeader::GetYImagePosition: unfound Image Position (RET) (0020,0030)"); // How to tell the caller nothing was found ? @@ -402,7 +402,7 @@ float gdcmHeaderHelper::GetYOrigin() { */ float gdcmHeaderHelper::GetZOrigin() { float xImPos, yImPos, zImPos; - std::string StrImPos = GetPubElValByNumber(0x0020,0x0032); + std::string StrImPos = GetPubEntryByNumber(0x0020,0x0032); if (StrImPos != GDCM_UNFOUND) { if( sscanf( StrImPos.c_str(), "%f\\%f\\%f", &xImPos, &yImPos, &zImPos) != 3) { dbg.Verbose(0, "gdcmHeader::GetZImagePosition: wrong Image Position Patient (0020,0032)"); @@ -411,7 +411,7 @@ float gdcmHeaderHelper::GetZOrigin() { return zImPos; } } - StrImPos = GetPubElValByNumber(0x0020,0x0030); // For ACR-NEMA images + StrImPos = GetPubEntryByNumber(0x0020,0x0030); // For ACR-NEMA images if (StrImPos != GDCM_UNFOUND) { if( sscanf( StrImPos.c_str(), "%f\\%f\\%f", &xImPos, &yImPos, &zImPos) != 3) { dbg.Verbose(0, "gdcmHeader::GetZImagePosition: wrong Image Position (RET) (0020,0030)"); @@ -420,7 +420,7 @@ float gdcmHeaderHelper::GetZOrigin() { return zImPos; } } - std::string StrSliceLocation = GetPubElValByNumber(0x0020,0x1041);// for *very* old ACR-NEMA images + std::string StrSliceLocation = GetPubEntryByNumber(0x0020,0x1041);// for *very* old ACR-NEMA images if (StrSliceLocation != GDCM_UNFOUND) { if( sscanf( StrSliceLocation.c_str(), "%f", &zImPos) !=1) { dbg.Verbose(0, "gdcmHeader::GetZImagePosition: wrong Slice Location (0020,1041)"); @@ -430,7 +430,7 @@ float gdcmHeaderHelper::GetZOrigin() { } } dbg.Verbose(0, "gdcmHeader::GetZImagePosition: unfound Slice Location (0020,1041)"); - std::string StrLocation = GetPubElValByNumber(0x0020,0x0050); + std::string StrLocation = GetPubEntryByNumber(0x0020,0x0050); if (StrLocation != GDCM_UNFOUND) { if( sscanf( StrLocation.c_str(), "%f", &zImPos) !=1) { dbg.Verbose(0, "gdcmHeader::GetZImagePosition: wrong Location (0020,0050)"); @@ -455,7 +455,7 @@ int gdcmHeaderHelper::GetImageNumber() { //binary conversion rules. This may be preferable to sscanf() since atoi() is a much smaller, // simpler and faster function. sscanf() can do all possible conversions whereas atoi() can //only do single decimal integer conversions. - std::string StrImNumber = GetPubElValByNumber(0x0020,0x0013); //0020 0013 IS REL Image Number + std::string StrImNumber = GetPubEntryByNumber(0x0020,0x0013); //0020 0013 IS REL Image Number if (StrImNumber != GDCM_UNFOUND) { return atoi( StrImNumber.c_str() ); } @@ -468,7 +468,7 @@ int gdcmHeaderHelper::GetImageNumber() { * @return ModalityType */ ModalityType gdcmHeaderHelper::GetModality(void) { - std::string StrModality = GetPubElValByNumber(0x0008,0x0060); //0008 0060 CS ID Modality + std::string StrModality = GetPubEntryByNumber(0x0008,0x0060); //0008 0060 CS ID Modality if (StrModality != GDCM_UNFOUND) { if ( StrModality.find("AU") < StrModality.length()) return AU; else if ( StrModality.find("AS") < StrModality.length()) return AS; @@ -531,7 +531,7 @@ void gdcmHeaderHelper::GetImageOrientationPatient( float* iop ) { //iop is supposed to be float[6] iop[0] = iop[1] = iop[2] = iop[3] = iop[4] = iop[5] = 0; - std::string StrImOriPat = GetPubElValByNumber(0x0020,0x0037); // 0020 0037 DS REL Image Orientation (Patient) + std::string StrImOriPat = GetPubEntryByNumber(0x0020,0x0037); // 0020 0037 DS REL Image Orientation (Patient) if (StrImOriPat != GDCM_UNFOUND) { if( sscanf( StrImOriPat.c_str(), "%f\\%f\\%f\\%f\\%f\\%f", &iop[0], &iop[1], &iop[2], &iop[3], &iop[4], &iop[5]) != 6) { @@ -543,7 +543,7 @@ void gdcmHeaderHelper::GetImageOrientationPatient( float* iop ) { } //For ACR-NEMA - StrImOriPat = GetPubElValByNumber(0x0020,0x0035); //0020 0035 DS REL Image Orientation (RET) + StrImOriPat = GetPubEntryByNumber(0x0020,0x0035); //0020 0035 DS REL Image Orientation (RET) if (StrImOriPat != GDCM_UNFOUND) { if( sscanf( StrImOriPat.c_str(), "%f\\%f\\%f\\%f\\%f\\%f", &iop[0], &iop[1], &iop[2], &iop[3], &iop[4], &iop[5]) != 6) { diff --git a/src/gdcmParse.cxx b/src/gdcmParse.cxx index b79efb72..7936e69a 100644 --- a/src/gdcmParse.cxx +++ b/src/gdcmParse.cxx @@ -51,7 +51,7 @@ bool gdcmFile::ParsePixelData(void) { } int nb; - std::string str_nb=Header->GetPubElValByNumber(0x0028,0x0100); + std::string str_nb=Header->GetPubEntryByNumber(0x0028,0x0100); if (str_nb == GDCM_UNFOUND ) { nb = 16; } else { diff --git a/src/win32/gdcmdll.dsp b/src/win32/gdcmdll.dsp index f1e959b2..be1f6b45 100644 --- a/src/win32/gdcmdll.dsp +++ b/src/win32/gdcmdll.dsp @@ -58,7 +58,7 @@ LINK32=link.exe # Begin Special Build Tool SOURCE="$(InputPath)" PostBuild_Desc=Copy for test -PostBuild_Cmds=copy ..\..\lib\gdcmdll.dll ..\..\gdcmPython\ copy ..\..\lib\gdcmdll.dll ..\..\test\ copy Release\gdcmdll.lib ..\..\lib\ +PostBuild_Cmds=copy ..\..\lib\gdcmdll.dll ..\..\gdcmPython\ copy ..\..\lib\gdcmdll.dll ..\..\test\ copy Release\gdcmdll.lib ..\..\lib\ # End Special Build Tool !ELSEIF "$(CFG)" == "gdcmdll - Win32 Debug" @@ -90,7 +90,7 @@ LINK32=link.exe # Begin Special Build Tool SOURCE="$(InputPath)" PostBuild_Desc=Copy for test -PostBuild_Cmds=copy ..\..\lib\gdcmdll.dll ..\..\gdcmPython\ copy ..\..\lib\gdcmdll.dll ..\..\test\ copy Debug\gdcmdll.lib ..\..\lib\ +PostBuild_Cmds=copy ..\..\lib\gdcmdll.dll ..\..\gdcmPython\ copy ..\..\lib\gdcmdll.dll ..\..\test\ copy Debug\gdcmdll.lib ..\..\lib\ # End Special Build Tool !ENDIF @@ -116,23 +116,23 @@ SOURCE=..\gdcmDictSet.cxx # End Source File # Begin Source File -SOURCE=..\gdcmElValSet.cxx +SOURCE=..\gdcmException.cxx # End Source File # Begin Source File -SOURCE=..\gdcmElValue.cxx +SOURCE=..\gdcmFile.cxx # End Source File # Begin Source File -SOURCE=..\gdcmException.cxx +SOURCE=..\gdcmHeader.cxx # End Source File # Begin Source File -SOURCE=..\gdcmFile.cxx +SOURCE=..\gdcmHeaderEntry.cxx # End Source File # Begin Source File -SOURCE=..\gdcmHeader.cxx +SOURCE=..\gdcmHeaderEntrySet.cxx # End Source File # Begin Source File @@ -196,23 +196,23 @@ SOURCE=..\gdcmDictSet.h # End Source File # Begin Source File -SOURCE=..\gdcmElValSet.h +SOURCE=..\gdcmException.h # End Source File # Begin Source File -SOURCE=..\gdcmElValue.h +SOURCE=..\gdcmFile.h # End Source File # Begin Source File -SOURCE=..\gdcmException.h +SOURCE=..\gdcmHeader.h # End Source File # Begin Source File -SOURCE=..\gdcmFile.h +SOURCE=..\gdcmHeaderEntry.h # End Source File # Begin Source File -SOURCE=..\gdcmHeader.h +SOURCE=..\gdcmHeaderEntrySet.h # End Source File # Begin Source File diff --git a/vtk/win32/vtkgdcm.dsp b/vtk/win32/vtkgdcm.dsp index b6676e4a..17907c60 100644 --- a/vtk/win32/vtkgdcm.dsp +++ b/vtk/win32/vtkgdcm.dsp @@ -112,23 +112,23 @@ SOURCE=..\..\src\gdcmDictSet.cxx # End Source File # Begin Source File -SOURCE=..\..\src\gdcmElValSet.cxx +SOURCE=..\..\src\gdcmException.cxx # End Source File # Begin Source File -SOURCE=..\..\src\gdcmElValue.cxx +SOURCE=..\..\src\gdcmFile.cxx # End Source File # Begin Source File -SOURCE=..\..\src\gdcmException.cxx +SOURCE=..\..\src\gdcmHeader.cxx # End Source File # Begin Source File -SOURCE=..\..\src\gdcmFile.cxx +SOURCE=..\..\src\gdcmHeaderEntry.cxx # End Source File # Begin Source File -SOURCE=..\..\src\gdcmHeader.cxx +SOURCE=..\..\src\gdcmHeaderEntrySet.cxx # End Source File # Begin Source File -- 2.46.1