1 #-----------------------------------------------------------------------------
2 # DICOM dictionary stuff
4 #-----------------------------------------------------------------------------
5 # Generate our own 'DICOM' dictionary, based on the following dictionaries:
9 NIH.dic #the forbidden one...
12 # The following line make sure we are not appending on an already existing file
13 FILE(WRITE "${GDCM_BINARY_DIR}/Dicts/gdcm.dic" "")
14 FOREACH(dict ${ALL_DICTS})
15 FILE(READ "${GDCM_SOURCE_DIR}/Dicts/${dict}" dict_append)
16 FILE(APPEND "${GDCM_BINARY_DIR}/Dicts/gdcm.dic" ${dict_append})
19 FOREACH(test 1.dic 2.dic 3.dic)
20 FILE(READ "${GDCM_SOURCE_DIR}/Dicts/${test}" test_append)
21 FILE(APPEND "${GDCM_BINARY_DIR}/Dicts/test.dic" ${test_append})
24 #-----------------------------------------------------------------------------
25 # Nice trick to avoid creating a .h file each time we compile gdcm
26 # Since CONFIGURE_FILE do a 'copy if different'
27 # We have to write the file here since is contains 'DICOM_DICTIONARY'
28 # Which is a variable afterward...
30 # Following code contributing by Andy Cedilnik (Kitware)
31 FILE(READ "gdcm.dic" ENT)
32 STRING(REGEX REPLACE "\r?\n" ";" ENT "${ENT}")
33 SET(DICOM_DATA_DICTIONARY "")
37 "^([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]+) ([1-9n-]+) (.*)$"
38 " {0x\\1, 0x\\2, \"\\3\" , \"\\4\" , \"\\5\"}, " nline "${line}")
39 SET(DICOM_DATA_DICTIONARY "${DICOM_DATA_DICTIONARY}\n${nline}")
42 SET(DICOM_DATA_DICTIONARY "${DICOM_DATA_DICTIONARY} \n {0,0,0,0,0}")
44 #-----------------------------------------------------------------------------
45 # ... for DicomTS file
46 FILE(READ "dicomTS.dic" ENT_TS)
47 STRING(REGEX REPLACE "\r?\n" ";" ENT_TS "${ENT_TS}")
48 SET(DICOM_TS_DICTIONARY "")
50 FOREACH(line ${ENT_TS})
53 " ts[\"\\1\"] = \"\\2\"; " nline "${line}")
54 SET(DICOM_TS_DICTIONARY "${DICOM_TS_DICTIONARY}\n${nline}")
57 #-----------------------------------------------------------------------------
58 # ... for DicomVR file
59 FILE(READ "dicomVR.dic" ENT_VR)
60 STRING(REGEX REPLACE ";" "/" ENT_VR "${ENT_VR}") # CMake doesn't like ';'
61 STRING(REGEX REPLACE "\r?\n" ";" ENT_VR "${ENT_VR}")
62 SET(DICOM_VR_DICTIONARY "")
64 FOREACH(line ${ENT_VR})
66 "^([A-Z][A-Z]) (.*)/ +//.*$"
67 " vr[\"\\1\"] = \"\\2\"; " nline "${line}")
68 SET(DICOM_VR_DICTIONARY "${DICOM_VR_DICTIONARY}\n${nline}")
71 #-----------------------------------------------------------------------------
72 # ... for DictGroupName file
73 FILE(READ "DictGroupName.dic" ENT_TS)
74 STRING(REGEX REPLACE "\r?\n" ";" ENT_TS "${ENT_TS}")
75 SET(DICT_GROUP_NAME_DICTIONARY "")
77 FOREACH(line ${ENT_TS})
80 " groupName[0x\\1] = \\2; " nline "${line}")
81 SET(DICT_GROUP_NAME_DICTIONARY "${DICT_GROUP_NAME_DICTIONARY}\n${nline}")
84 #-----------------------------------------------------------------------------
85 # ... for DicomDir file
86 FILE(READ "DicomDir.dic" ENT_DIR)
87 STRING(REGEX REPLACE "\\\\" "\\\\\\\\" ENT_DIR "${ENT_DIR}")
88 STRING(REGEX REPLACE ";" "/" ENT_DIR "${ENT_DIR}") # CMake doesn't like ';'
89 STRING(REGEX REPLACE "\r?\n" ";" ENT_DIR "${ENT_DIR}")
90 SET(DICOM_DIR_DICTIONARY "")
92 FOREACH(line ${ENT_DIR})
94 "^(metaElem|patientElem|studyElem|serieElem|imageElem) *([a-f0-9]+) ([a-f0-9]+) [\"](.*)[\"](.*)$"
95 " {\"\\1\" , 0x\\2 , 0x\\3 , \"\\4\"}, \\5" nline "${line}")
96 SET(DICOM_DIR_DICTIONARY "${DICOM_DIR_DICTIONARY}\n${nline}")
99 #-----------------------------------------------------------------------------
100 # ... Set the dictionnary
101 SET(DICOM_DIR_DICTIONARY "${DICOM_DIR_DICTIONARY} \n {0,0,0,0}")
103 #FOREACH(file dicomV3.dic dicomTS.dic dicomVR.dic DicomDir.dic DictGroupName.dic)
104 # CONFIGURE_FILE("${GDCM_SOURCE_DIR}/Dicts/${file}"
105 # "${GDCM_BINARY_DIR}/Dicts/${file}.out")
108 CONFIGURE_FILE("${GDCM_SOURCE_DIR}/src/gdcmDefaultDicts.cxx.in"
109 "${GDCM_BINARY_DIR}/src/gdcmDefaultDicts.cxx" IMMEDIATE)
111 #-----------------------------------------------------------------------------
112 INSTALL_FILES(${GDCM_DATA_DIR} .dic