#-----------------------------------------------------------------------------
# Build directory on which many applications depend
SUBDIRS(
- src
Dicts
+ src
)
#-----------------------------------------------------------------------------
# Example subdir:
# Since CONFIGURE_FILE do a 'copy if different'
# We have to write the file here since is contains 'DICOM_DICTIONARY'
# Which is a variable afterward...
-#FILE(WRITE "/tmp/output.h.in" "@DICOM_DICTIONARY@" )
-
-# Following code contributing by Andy Cedilnik
-SET(INFILE "dicomV3.dic")
-
-FILE(READ "${INFILE}" ENT)
+# Following code contributing by Andy Cedilnik (Kitware)
+FILE(READ "dicomV3.dic" ENT)
STRING(REGEX REPLACE "\n" ";" ENT "${ENT}")
-SET(DICOM_DICTIONARY
- "void FillDefault()\n{"
-)
+SET(DICOM_DATA_DICTIONARY "")
FOREACH(line ${ENT})
STRING(REGEX REPLACE
-# "^([0-9a-f][0-9a-f][0-9a-f][0-9a-f]) ([0-9a-f][0-9a-f][0-9a-f][0-9a-f]) ([A-Z]+) ([A-Z]+) (.*)([ \(RET\)]*)$"
- # FIXME ? is not properly used, just luck
"^([0-9a-f][0-9a-f][0-9a-f][0-9a-f]) ([0-9a-f][0-9a-f][0-9a-f][0-9a-f]) ([A-Z]+) ([A-Z?]+) (.*)$"
-# " { \\1, \\2, \"\\3\" , \"\\4\" , \"\\5\", \"\\6\"}," nline "${line}")
-# " { \\1, \\2, \"\\3\" , \"\\4\" , \"\\5\"}," nline "${line}")
- " AddNewEntry( DictEntry ( 0x\\1, 0x\\2, \"\\3\" , \"\\4\" , \"\\5\"));" nline "${line}")
- SET(DICOM_DICTIONARY "${DICOM_DICTIONARY}\n${nline}")
+ " 0x\\1, 0x\\2, \"\\3\" , \"\\4\" , \"\\5\", " nline "${line}")
+ SET(DICOM_DATA_DICTIONARY "${DICOM_DATA_DICTIONARY}\n${nline}")
+ENDFOREACH(line)
+
+SET(DICOM_DATA_DICTIONARY "${DICOM_DATA_DICTIONARY} \n 0,0,0,0,0")
+
+FILE(READ "dicomTS.dic" ENT_TS)
+STRING(REGEX REPLACE "\n" ";" ENT_TS "${ENT_TS}")
+SET(DICOM_TS_DICTIONARY "")
+
+FOREACH(line ${ENT_TS})
+ STRING(REGEX REPLACE
+ "^([0-9.]+) +(.*)$"
+ " ts[\"\\1\"] = \"\\2\"; " nline "${line}")
+ SET(DICOM_TS_DICTIONARY "${DICOM_TS_DICTIONARY}\n${nline}")
+ENDFOREACH(line)
+
+FILE(READ "dicomVR.dic" ENT_VR)
+STRING(REGEX REPLACE ";" "/" ENT_VR "${ENT_VR}") # CMake doesn't like ';'
+STRING(REGEX REPLACE "\n" ";" ENT_VR "${ENT_VR}")
+SET(DICOM_VR_DICTIONARY "")
+
+FOREACH(line ${ENT_VR})
+ STRING(REGEX REPLACE
+ "^([A-Z][A-Z]) (.*)/ +//.*$"
+ " vr[\"\\1\"] = \"\\2\"; " nline "${line}")
+ SET(DICOM_VR_DICTIONARY "${DICOM_VR_DICTIONARY}\n${nline}")
ENDFOREACH(line)
-SET(DICOM_DICTIONARY "${DICOM_DICTIONARY} \n }")
+FILE(READ "DicomDir.dic" ENT_DIR)
+STRING(REGEX REPLACE "\\\\" "\\\\\\\\" ENT_DIR "${ENT_DIR}")
+STRING(REGEX REPLACE ";" "/" ENT_DIR "${ENT_DIR}") # CMake doesn't like ';'
+STRING(REGEX REPLACE "\n" ";" ENT_DIR "${ENT_DIR}")
+SET(DICOM_DIR_DICTIONARY "")
+
+FOREACH(line ${ENT_DIR})
+ STRING(REGEX REPLACE
+ "^(metaElem|patientElem|studyElem|serieElem|imageElem) *([a-f0-9]+) ([a-f0-9]+) [\"](.*)[\"](.*)$"
+ " \"\\1\" , 0x\\2 , 0x\\3 , \"\\4\", \\5" nline "${line}")
+ SET(DICOM_DIR_DICTIONARY "${DICOM_DIR_DICTIONARY}\n${nline}")
+ENDFOREACH(line)
+
+SET(DICOM_DIR_DICTIONARY "${DICOM_DIR_DICTIONARY} \n 0,0,0,0")
# See above
-CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/gdcmDefaultDict.h.in" "${GDCM_BINARY_DIR}/gdcmDefaultDict.h")
+CONFIGURE_FILE("${GDCM_SOURCE_DIR}/src/gdcmDefaultDicts.cxx.in" "${GDCM_BINARY_DIR}/src/gdcmDefaultDicts.cxx" IMMEDIATE)
-#MESSAGE("${DICOM_DICTIONARY}")
-FILE(READ "dicomV3VM2004.dic" ENT)
-STRING(REGEX REPLACE "\n" ";" ENT "${ENT}")
+FILE(READ "dicomV3VM2004.dic" ENT2)
+STRING(REGEX REPLACE "\n" ";" ENT2 "${ENT2}")
SET(DICOM_DICTIONARY2 "")
-FOREACH(line ${ENT})
+FOREACH(line ${ENT2})
STRING(REGEX REPLACE
# "^([0-9a-f][0-9a-f][0-9a-f][0-9a-f]) ([0-9a-f][0-9a-f][0-9a-f][0-9a-f]) ([A-Z]+) ([A-Z]+) (.*)([ \(RET\)]*)$"
"^([0-9a-f][0-9a-f][0-9a-f][0-9a-f]) ([0-9a-f][0-9a-f][0-9a-f][0-9a-f]) ([A-Z]+) ([0-9]|[1]-[0-9n]|[2]-[2][n]|[3]-[3][n]) (.*)$"
SET(DICOM_DICTIONARY2 "${DICOM_DICTIONARY2}\n${nline}")
ENDFOREACH(line)
-#MESSAGE("${DICOM_DICTIONARY2}")
+
+#FILE(READ "04_06PU.txt" ENT3)
+FILE(READ "extract.txt" ENT3)
+
+STRING(REGEX REPLACE "\n" ";" ENT3 "${ENT3}")
+SET(DICOM_DICTIONARY3 "")
+
+FOREACH(line ${ENT3})
+ STRING(REGEX REPLACE
+# "^[(]([0-9a-fA-F]+),([0-9a-fA-F]+)[)] (.*) ([A-ZA-Z]*) ([[0-3][-][1-3n]*|[1-]*[0-9]+]*) ?([RET|Retired]*)$"
+ "^[(]([0-9a-fA-F]+),([0-9a-fA-F]+)[)] +(.*) +([A-ZA-Z [[0-3][-][1-3n]*|[1-]*[0-9]+]]*)([ RET]*)$"
+ " { \\1 , \\2, \\3, \\4, \\5 }," nline "${line}")
+ STRING(COMPARE NOTEQUAL "${line}" "${nline}" add)
+ IF(add)
+ #SET(DICOM_DICTIONARY3 "${DICOM_DICTIONARY3}\n${nline}")
+ MESSAGE("${nline}")
+ ELSE(add)
+ MESSAGE("WRONG:${nline}")
+ ENDIF(add)
+ENDFOREACH(line)
+
+
+# Txt generation:
+# ~/Software/xpdf-3.00-linux/pdftotext -f 9 -l 81 -raw -nopgbrk 04_06PU.PDF 04_06PU-3.txt
+++ /dev/null
-@DICOM_DICTIONARY@
# "jpeglib.h" is defined here:
INCLUDE_DIRECTORIES(
- ${GDCM_SOURCE_DIR}/
+ ${GDCM_SOURCE_DIR}/src
${GDCM_BINARY_DIR}/ #for gdcmConfigure.h
)
gdcmUtil.cxx
gdcmValEntry.cxx
gdcmVR.cxx
+ ${GDCM_BINARY_DIR}/src/gdcmDefaultDicts.cxx
)
ADD_LIBRARY(gdcm ${libgdcm_la_SOURCES} )
--- /dev/null
+/*=========================================================================
+
+ Program: gdcm
+ Module: $RCSfile: gdcmDefaultDicts.cxx.in,v $
+ Language: C++
+ Date: $Date: 2004/11/03 18:08:56 $
+ Version: $Revision: 1.1 $
+
+ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
+ l'Image). All rights reserved. See Doc/License.txt or
+ http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*/
+
+#ifndef GDCMDEFAULTDICTS_H
+#define GDCMDEFAULTDICTS_H
+
+#include "gdcmDict.h"
+#include "gdcmDictEntry.h"
+#include "gdcmTS.h"
+#include "gdcmVR.h"
+#include "gdcmDicomDirElement.h"
+
+namespace gdcm
+{
+
+typedef struct
+{
+ uint16_t group;
+ uint16_t element;
+ char *vr;
+ char *fourth;
+ char *name;
+} DICT_ENTRY;
+
+static DICT_ENTRY datadir[] = {
+@DICOM_DATA_DICTIONARY@
+};
+
+void FillDefaultDataDict(Dict *d)
+{
+ unsigned int i = 0;
+ DICT_ENTRY n = datadir[i];
+ while( n.name != 0 )
+ {
+ const DictEntry e( n.group, n.element, n.vr, n.fourth, n.name);
+ d->AddNewEntry( e );
+ n = datadir[++i];
+ }
+}
+
+void FillDefaultTSDict(TSHT & ts)
+{
+@DICOM_TS_DICTIONARY@
+}
+
+void FillDefaultVRDict(VRHT & vr)
+{
+@DICOM_VR_DICTIONARY@
+}
+
+typedef struct
+{
+ char *type;
+ unsigned short group;
+ unsigned short element;
+ char *value;
+} ELEMENT;
+
+static ELEMENT dataelement[] = {
+@DICOM_DIR_DICTIONARY@
+};
+
+void FillDefaultDIRDict(DicomDirElement *dde)
+{
+ unsigned int i = 0;
+ ELEMENT e = dataelement[i];
+ Element elem;
+ while( e.type != 0 )
+ {
+ elem.Group = e.group;
+ elem.Elem = e.element;
+ elem.Value = e.value;
+ if( strcmp(e.type, "metaElem" ) == 0 )
+ {
+ dde->GetDicomDirMetaElements().push_back(elem);
+ }
+ else if( strcmp(e.type, "patientElem" ) == 0 )
+ {
+ dde->GetDicomDirPatientElements().push_back(elem);
+ }
+ else if( strcmp(e.type, "studyElem" ) == 0 )
+ {
+ dde->GetDicomDirStudyElements().push_back(elem);
+ }
+ else if( strcmp(e.type, "serieElem" ) == 0 )
+ {
+ dde->GetDicomDirSerieElements().push_back(elem);
+ }
+ else if( strcmp(e.type, "imageElem" ) == 0 )
+ {
+ dde->GetDicomDirImageElements().push_back(elem);
+ }
+ e = dataelement[++i];
+ }
+}
+
+} //end gdcm namespace
+#endif
+
Program: gdcm
Module: $RCSfile: gdcmDicomDirElement.cxx,v $
Language: C++
- Date: $Date: 2004/10/12 04:35:44 $
- Version: $Revision: 1.20 $
+ Date: $Date: 2004/11/03 18:08:56 $
+ Version: $Revision: 1.21 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#include <fstream>
#include <iostream>
+
namespace gdcm
{
-
+void FillDefaultDIRDict(DicomDirElement *dde);
//-----------------------------------------------------------------------------
// Constructor / Destructor
*/
DicomDirElement::DicomDirElement()
{
- std::string filename = DictSet::BuildDictPath() + std::string(DICT_ELEM);
+ std::string filename = DictSet::BuildDictPath() + DICT_ELEM;
std::ifstream from(filename.c_str());
- dbg.Error(!from, "DicomDirElement::DicomDirElement: can't open dictionary",
- filename.c_str());
-
- char buff[1024];
- std::string type;
- Element elem;
-
- while (!from.eof())
+ if(!from)
{
- from >> std::ws;
- from.getline(buff, 1024, ' ');
- type = buff;
+ dbg.Verbose(2,
+ "DicomDirElement::DicomDirElement: can't open dictionary",
+ filename.c_str());
+ FillDefaultDIRDict( this );
+ }
+ else
+ {
+ char buff[1024];
+ std::string type;
+ Element elem;
- if( (type=="metaElem") || (type=="patientElem") ||
- (type=="studyElem") || (type=="serieElem") ||
- (type=="imageElem") )
+ while (!from.eof())
{
- from >> std::hex >> elem.Group >> elem.Elem;
-
- from >> std::ws;
- from.getline(buff, 1024, '"');
from >> std::ws;
- from.getline(buff, 1024, '"');
- elem.Value = buff;
+ from.getline(buff, 1024, ' ');
+ type = buff;
- if( type == "metaElem" )
+ if( (type=="metaElem") || (type=="patientElem") ||
+ (type=="studyElem") || (type=="serieElem") ||
+ (type=="imageElem") )
{
- DicomDirMetaList.push_back(elem);
+ from >> std::hex >> elem.Group >> elem.Elem;
+
+ from >> std::ws;
+ from.getline(buff, 1024, '"');
+ from >> std::ws;
+ from.getline(buff, 1024, '"');
+ elem.Value = buff;
+
+ AddNewEntry(type, elem);
}
- else if( type == "patientElem" )
+ else
{
- DicomDirPatientList.push_back(elem);
- }
- else if( type == "studyElem" )
- {
- DicomDirStudyList.push_back(elem);
- }
- else if( type == "serieElem" )
- {
- DicomDirSerieList.push_back(elem);
- }
- else if( type == "imageElem" )
- {
- DicomDirImageList.push_back(elem);
+ dbg.Error("DicomDirElement::DicomDirElement: Error parsing file",
+ filename.c_str());
+ dbg.Error("Type", type.c_str(), " is not registered as valid" );
}
+ from.getline(buff, 1024, '\n');
}
- from.getline(buff, 1024, '\n');
- }
from.close();
+ }
}
/**
//-----------------------------------------------------------------------------
// Public
+bool DicomDirElement::AddNewEntry(std::string const & type,
+ Element const & elem)
+{
+ if( type == "metaElem" )
+ {
+ DicomDirMetaList.push_back(elem);
+ }
+ else if( type == "patientElem" )
+ {
+ DicomDirPatientList.push_back(elem);
+ }
+ else if( type == "studyElem" )
+ {
+ DicomDirStudyList.push_back(elem);
+ }
+ else if( type == "serieElem" )
+ {
+ DicomDirSerieList.push_back(elem);
+ }
+ else if( type == "imageElem" )
+ {
+ DicomDirImageList.push_back(elem);
+ }
+ else
+ {
+ return false;
+ }
+ return true;
+}
//-----------------------------------------------------------------------------
// Protected
Program: gdcm
Module: $RCSfile: gdcmDicomDirElement.h,v $
Language: C++
- Date: $Date: 2004/10/25 04:08:20 $
- Version: $Revision: 1.14 $
+ Date: $Date: 2004/11/03 18:08:56 $
+ Version: $Revision: 1.15 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
ListDicomDirImageElem const & GetDicomDirImageElements() const
{ return DicomDirImageList; };
+ /**
+ * Public method to add an element
+ */
+ bool AddNewEntry(std::string const & type, Element const & elem);
+
private:
/// Elements chained list, related to the MetaElements of DICOMDIR
ListDicomDirMetaElem DicomDirMetaList;
Program: gdcm
Module: $RCSfile: gdcmDict.cxx,v $
Language: C++
- Date: $Date: 2004/10/28 19:53:28 $
- Version: $Revision: 1.50 $
+ Date: $Date: 2004/11/03 18:08:56 $
+ Version: $Revision: 1.51 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
namespace gdcm
{
-
+void FillDefaultDataDict(Dict *d);
//-----------------------------------------------------------------------------
// Constructor / Destructor
/**
TagName name;
std::ifstream from( filename.c_str() );
- dbg.Error(!from, "Dict::Dict: can't open dictionary",
- filename.c_str());
-
- while (!from.eof())
+ if( !from )
{
- from >> std::hex;
- from >> group;
- from >> element;
- from >> vr;
- from >> fourth;
- from >> std::ws; //remove white space
- std::getline(from, name);
-
- DictEntry newEntry(group, element, vr, fourth, name);
- AddNewEntry(newEntry);
+ dbg.Verbose(2,"Dict::Dict: can't open dictionary", filename.c_str());
+ // Using default embeded one:
+ FillDefaultDataDict( this );
}
- from.close();
+ else
+ {
+ while (!from.eof())
+ {
+ from >> std::hex;
+ from >> group;
+ from >> element;
+ from >> vr;
+ from >> fourth;
+ from >> std::ws; //remove white space
+ std::getline(from, name);
+
+ const DictEntry newEntry(group, element, vr, fourth, name);
+ AddNewEntry(newEntry);
+ }
+ from.close();
- Filename = filename;
+ Filename = filename;
+ }
}
/**
Program: gdcm
Module: $RCSfile: gdcmTS.cxx,v $
Language: C++
- Date: $Date: 2004/10/27 01:32:15 $
- Version: $Revision: 1.27 $
+ Date: $Date: 2004/11/03 18:08:56 $
+ Version: $Revision: 1.28 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
namespace gdcm
{
+void FillDefaultTSDict(TSHT & ts);
//-----------------------------------------------------------------------------
// Constructor / Destructor
TS::TS()
{
std::string filename = DictSet::BuildDictPath() + DICT_TS;
std::ifstream from(filename.c_str());
- dbg.Error(!from, "TS::TS: can't open dictionary", filename.c_str());
-
- TSKey key;
- TSAtr name;
-
- while (!from.eof())
+ if( !from )
{
- from >> key;
- from >> std::ws;
- std::getline(from, name);
-
- if(key != "")
+ dbg.Verbose(2, "TS::TS: can't open dictionary", filename.c_str());
+ FillDefaultTSDict( TsMap );
+ }
+ else
+ {
+ TSKey key;
+ TSAtr name;
+
+ while (!from.eof())
{
- TsMap[key] = name;
+ from >> key;
+ from >> std::ws;
+ std::getline(from, name);
+
+ if(key != "")
+ {
+ TsMap[key] = name;
+ }
}
+ from.close();
}
- from.close();
}
//-----------------------------------------------------------------------------
Program: gdcm
Module: $RCSfile: gdcmVR.cxx,v $
Language: C++
- Date: $Date: 2004/10/27 22:31:12 $
- Version: $Revision: 1.21 $
+ Date: $Date: 2004/11/03 18:08:56 $
+ Version: $Revision: 1.22 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
namespace gdcm
{
+void FillDefaultVRDict(VRHT & vr);
//-----------------------------------------------------------------------------
/**
* \brief Constructor
{
std::string filename = DictSet::BuildDictPath() + DICT_VR;
std::ifstream from(filename.c_str());
- dbg.Error(!from, "VR::VR: can't open dictionary", filename.c_str());
-
- char buff[1024];
- VRKey key;
- VRAtr name;
-
- while (!from.eof())
+ if(!from)
{
- from >> std::ws;
- from.getline(buff, 1024, ' ');
- key = buff;
- from >> std::ws;
- from.getline(buff, 1024, ';');
- name = buff;
-
- from >> std::ws;
- from.getline(buff, 1024, '\n');
-
- if(key != "")
+ dbg.Verbose(2, "VR::VR: can't open dictionary", filename.c_str());
+ FillDefaultVRDict(vr);
+ }
+ else
+ {
+ char buff[1024];
+ VRKey key;
+ VRAtr name;
+
+ while (!from.eof())
{
- vr[key] = name;
+ from >> std::ws;
+ from.getline(buff, 1024, ' ');
+ key = buff;
+ from >> std::ws;
+ from.getline(buff, 1024, ';');
+ name = buff;
+
+ from >> std::ws;
+ from.getline(buff, 1024, '\n');
+
+ if(key != "")
+ {
+ vr[key] = name;
+ }
}
+ from.close();
}
- from.close();
}
//-----------------------------------------------------------------------------