+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
#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
////////////////////////////////////////////////////////////////////////////
// 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();
%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"
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]
# End Source File\r
# Begin Source File\r
\r
-SOURCE=..\..\src\gdcmElValSet.cxx\r
+SOURCE=..\..\src\gdcmException.cxx\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=..\..\src\gdcmElValue.cxx\r
+SOURCE=..\..\src\gdcmFile.cxx\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=..\..\src\gdcmException.cxx\r
+SOURCE=..\..\src\gdcmHeader.cxx\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=..\..\src\gdcmFile.cxx\r
+SOURCE=..\..\src\gdcmHeaderEntry.cxx\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=..\..\src\gdcmHeader.cxx\r
+SOURCE=..\..\src\gdcmHeaderEntrySet.cxx\r
# End Source File\r
# Begin Source File\r
\r
\r
SOURCE=..\..\vtk\vtkGdcmReader.h\r
# 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\r
-InputDir=\Projects\gdcm\vtk\r
+InputDir=\Projects\gdcm\VTK\r
ProjDir=.\r
InputPath=..\..\vtk\vtkGdcmReader.h\r
InputName=vtkGdcmReader\r
# Begin Special Build Tool\r
ProjDir=.\r
SOURCE="$(InputPath)"\r
-PostBuild_Cmds=move $(ProjDir)\gdcm.py $(ProjDir)\..\ \r
+PostBuild_Cmds=move $(ProjDir)\gdcm.py $(ProjDir)\..\ \r
# End Special Build Tool\r
# Begin Target\r
\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=..\..\src\gdcmElValSet.cxx\r
+SOURCE=..\..\src\gdcmException.cxx\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=..\..\src\gdcmElValue.cxx\r
+SOURCE=..\..\src\gdcmFile.cxx\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=..\..\src\gdcmException.cxx\r
+SOURCE=..\..\src\gdcmHeader.cxx\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=..\..\src\gdcmFile.cxx\r
+SOURCE=..\..\src\gdcmHeaderEntry.cxx\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=..\..\src\gdcmHeader.cxx\r
+SOURCE=..\..\src\gdcmHeaderEntrySet.cxx\r
# End Source File\r
# Begin Source File\r
\r
gdcmUtil.cxx\r
gdcmHeader.cxx\r
gdcmHeaderHelper.cxx\r
- gdcmElValue.cxx\r
+ gdcmHeaderEntry.cxx\r
+ gdcmHeaderEntrySet.cxx\r
gdcmDictEntry.cxx\r
gdcmDict.cxx\r
gdcmDictSet.cxx\r
- gdcmElValSet.cxx\r
gdcmFile.cxx\r
gdcmVR.cxx\r
gdcmTS.cxx\r
$(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
+++ /dev/null
-// gdcmElValSet.h
-//-----------------------------------------------------------------------------
-#ifndef GDCMELVALSET_H
-#define GDCMELVALSET_H
-
-#include "gdcmCommon.h"
-#include "gdcmElValue.h"
-
-#include <stdio.h>
-#include <map>
-#include <list> // for linking together *all* the Dicom Elements
-
-//-----------------------------------------------------------------------------
-typedef std::multimap<TagKey, gdcmElValue*> TagElValueHT;
-typedef std::pair<TagKey, gdcmElValue*> PairHT;
-typedef std::pair<TagElValueHT::iterator,TagElValueHT::iterator> IterHT;
-
-typedef std::list<gdcmElValue*> 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<GroupKey, int> 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
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 {
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
// 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 (?)
// 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);
}
(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 {
}
// Nombre de Bits Utilises
- str_nbu=Header->GetPubElValByNumber(0x0028,0x0101);
+ str_nbu=Header->GetPubEntryByNumber(0x0028,0x0101);
if (str_nbu == GDCM_UNFOUND ) {
nbu = nb;
} else {
}
// 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 {
// 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 {
// -------------------
std::string str_PhotometricInterpretation =
- Header->GetPubElValByNumber(0x0028,0x0004);
+ Header->GetPubEntryByNumber(0x0028,0x0004);
if ( (str_PhotometricInterpretation == "MONOCHROME1 ")
|| (str_PhotometricInterpretation == "MONOCHROME2 ") ) {
// 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;
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 ----------------
// 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 ----------------
// --------------- 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 {
if ( !OpenFile(exception_on_error))
return;
ParseHeader();
- LoadElements();
+ LoadHeaderEntries();
CloseFile();
}
* \brief
* @return
*/
-void gdcmHeader::PrintPubElVal(std::ostream & os) {
- PubElValSet.Print(os);
+void gdcmHeader::PrintPubEntry(std::ostream & os) {
+ PubEntrySet.Print(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;
}
* @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;
* @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;
* @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;
* @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;
* @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;
* @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;
* @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;
* 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;
* 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;
* @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;
* 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") )
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());
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() )
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;
* @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());
* @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());
* @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());
* @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());
* @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");
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");
// 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 {
else
numPixel = 0x0010;
- gdcmElValue* PixelElement = PubElValSet.GetElementByNumber(grPixel,
- numPixel);
+ gdcmHeaderEntry* PixelElement = GetHeaderEntryByNumber(grPixel,numPixel);
if (PixelElement)
return PixelElement->GetOffset();
else
// 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 {
else
numPixel = 0x0010;
- gdcmElValue* PixelElement = PubElValSet.GetElementByNumber(grPixel,
- numPixel);
+ gdcmHeaderEntry* PixelElement = GetHeaderEntryByNumber(grPixel,numPixel);
if (PixelElement)
return PixelElement->GetLength();
else
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;
}
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
// 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;
}
// 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;
// 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;
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 {
*/
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";
* @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()));
}
/**
* @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();
}
* @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);
}
/**
* @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();
/**
* \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.
* @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) );
}
/**
* @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);
}
/**
* @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);
}
/**
* @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);
}
/**
* @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;
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).
}
//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);
* \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);
}
}
// 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) {
// 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);
}
/**
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
*
* @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);
}
/**
* @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();
}
/**
* @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();
}
/**
* \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();
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) {
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
/**
* \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
}
// --------------------------------------------------------------
// 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 ----------------
}
* 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();
// 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;
* @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);
}
*
* @return
*/
- void gdcmHeader::FindLength (gdcmElValue * ElVal) {
+ void gdcmHeader::FindHeaderEntryLength (gdcmHeaderEntry * ElVal) {
guint16 element = ElVal->GetElement();
guint16 group = ElVal->GetGroup();
std::string vr = ElVal->GetVR();
guint32 length32 = ReadInt32();
if ( (vr == "OB") && (length32 == 0xffffffff) ) {
- ElVal->SetLength(FindLengthOB());
+ ElVal->SetLength(FindHeaderEntryLengthOB());
return;
}
- FixFoundLength(ElVal, length32);
+ FixHeaderEntryFoundLength(ElVal, length32);
return;
}
// Unknown Sequence Length
}
- FixFoundLength(ElVal, (guint32)length16);
+ FixHeaderEntryFoundLength(ElVal, (guint32)length16);
return;
}
// 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;
}
* \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;
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());
}
* 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
* @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();
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
/**
* \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();
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) )
* 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;
}
* @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;
}
#include "gdcmTS.h"
#include "gdcmException.h"
#include "gdcmDictSet.h"
-#include "gdcmElValue.h"
-#include "gdcmElValSet.h"
+#include "gdcmHeaderEntry.h"
+#include "gdcmHeaderEntrySet.h"
#include <map>
//-----------------------------------------------------------------------------
// 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
// 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);
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
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);
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
gdcmDict *RefShaDict;
/// ELement VALueS parsed with the PUBlic dictionary.
- gdcmElValSet PubElValSet;
+ gdcmHeaderEntrySet PubEntrySet;
// Refering underlying filename.
std::string filename;
-// 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;
}
-// gdcmElValue.h
+// gdcmHeaderEntry.h
//-----------------------------------------------------------------------------
-#ifndef GDCMELVALUE_H
-#define GDCMELVALUE_H
+#ifndef GDCMHeaderEntry_H
+#define GDCMHeaderEntry_H
#include "gdcmDictEntry.h"
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();};
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
-// gdcmElValSet.cxx
+// gdcmHeaderEntrySet.cxx
//-----------------------------------------------------------------------------
#include "gdcmUtil.h"
-#include "gdcmElValSet.h"
+#include "gdcmHeaderEntrySet.h"
#include "gdcmTS.h"
#ifdef GDCM_NO_ANSI_STRING_STREAM
# include <strstream>
//-----------------------------------------------------------------------------
// 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;
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();
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();
//-----------------------------------------------------------------------------
// 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
* @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).
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;
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
* @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));
}
// ==============
// 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
if ( type == ACR)
UpdateGroupLength(true,ACR);
- WriteElements(type, _fp);
+ WriteEntries(type, _fp);
return(true);
}
//-----------------------------------------------------------------------------
// 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;
// remember :
// typedef std::map<GroupKey, int> 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;
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;
}
/**
- * \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 :
* @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;
std::vector<std::string> 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;
// 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();
--- /dev/null
+// gdcmHeaderEntrySet.h
+//-----------------------------------------------------------------------------
+#ifndef GDCMHeaderEntrySet_H
+#define GDCMHeaderEntrySet_H
+
+#include "gdcmCommon.h"
+#include "gdcmHeaderEntry.h"
+
+#include <stdio.h>
+#include <map>
+#include <list> // for linking together *all* the Dicom Elements
+
+//-----------------------------------------------------------------------------
+typedef std::multimap<TagKey, gdcmHeaderEntry*> TagHeaderEntryHT;
+typedef std::pair<TagKey, gdcmHeaderEntry*> PairHT;
+typedef std::pair<TagHeaderEntryHT::iterator,TagHeaderEntryHT::iterator> IterHT;
+
+typedef std::list<gdcmHeaderEntry*> ListTag; // for linking together the Elements
+
+// 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<GroupKey, int> 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
// 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();
*/
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");
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");
*/
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)");
*/
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)");
// 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
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");
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");
// 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
// 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
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):
*/
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 ?
*/
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 ?
*/
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)");
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)");
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)");
}
}
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)");
//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() );
}
* @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;
//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) {
}
//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) {
}
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 {
# Begin Special Build Tool\r
SOURCE="$(InputPath)"\r
PostBuild_Desc=Copy for test\r
-PostBuild_Cmds=copy ..\..\lib\gdcmdll.dll ..\..\gdcmPython\ copy ..\..\lib\gdcmdll.dll ..\..\test\ copy Release\gdcmdll.lib ..\..\lib\ \r
+PostBuild_Cmds=copy ..\..\lib\gdcmdll.dll ..\..\gdcmPython\ copy ..\..\lib\gdcmdll.dll ..\..\test\ copy Release\gdcmdll.lib ..\..\lib\ \r
# End Special Build Tool\r
\r
!ELSEIF "$(CFG)" == "gdcmdll - Win32 Debug"\r
# Begin Special Build Tool\r
SOURCE="$(InputPath)"\r
PostBuild_Desc=Copy for test\r
-PostBuild_Cmds=copy ..\..\lib\gdcmdll.dll ..\..\gdcmPython\ copy ..\..\lib\gdcmdll.dll ..\..\test\ copy Debug\gdcmdll.lib ..\..\lib\ \r
+PostBuild_Cmds=copy ..\..\lib\gdcmdll.dll ..\..\gdcmPython\ copy ..\..\lib\gdcmdll.dll ..\..\test\ copy Debug\gdcmdll.lib ..\..\lib\ \r
# End Special Build Tool\r
\r
!ENDIF \r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=..\gdcmElValSet.cxx\r
+SOURCE=..\gdcmException.cxx\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=..\gdcmElValue.cxx\r
+SOURCE=..\gdcmFile.cxx\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=..\gdcmException.cxx\r
+SOURCE=..\gdcmHeader.cxx\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=..\gdcmFile.cxx\r
+SOURCE=..\gdcmHeaderEntry.cxx\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=..\gdcmHeader.cxx\r
+SOURCE=..\gdcmHeaderEntrySet.cxx\r
# End Source File\r
# Begin Source File\r
\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=..\gdcmElValSet.h\r
+SOURCE=..\gdcmException.h\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=..\gdcmElValue.h\r
+SOURCE=..\gdcmFile.h\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=..\gdcmException.h\r
+SOURCE=..\gdcmHeader.h\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=..\gdcmFile.h\r
+SOURCE=..\gdcmHeaderEntry.h\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=..\gdcmHeader.h\r
+SOURCE=..\gdcmHeaderEntrySet.h\r
# End Source File\r
# Begin Source File\r
\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=..\..\src\gdcmElValSet.cxx\r
+SOURCE=..\..\src\gdcmException.cxx\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=..\..\src\gdcmElValue.cxx\r
+SOURCE=..\..\src\gdcmFile.cxx\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=..\..\src\gdcmException.cxx\r
+SOURCE=..\..\src\gdcmHeader.cxx\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=..\..\src\gdcmFile.cxx\r
+SOURCE=..\..\src\gdcmHeaderEntry.cxx\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=..\..\src\gdcmHeader.cxx\r
+SOURCE=..\..\src\gdcmHeaderEntrySet.cxx\r
# End Source File\r
# Begin Source File\r
\r