1 #-----------------------------------------------------------------------------
2 # DICOM dictionary stuff
5 INSTALL_FILES(${GDCM_DATA_DIR} .dic
13 # Nice trick to avoid creating a .h file each time we compile gdcm
14 # Since CONFIGURE_FILE do a 'copy if different'
15 # We have to write the file here since is contains 'DICOM_DICTIONARY'
16 # Which is a variable afterward...
18 # Following code contributing by Andy Cedilnik (Kitware)
19 FILE(READ "dicomV3.dic" ENT)
20 STRING(REGEX REPLACE "\r?\n" ";" ENT "${ENT}")
21 SET(DICOM_DATA_DICTIONARY "")
25 "^([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-]+) (.*)$"
26 " {0x\\1, 0x\\2, \"\\3\" , \"\\4\" , \"\\5\"}, " nline "${line}")
27 SET(DICOM_DATA_DICTIONARY "${DICOM_DATA_DICTIONARY}\n${nline}")
30 SET(DICOM_DATA_DICTIONARY "${DICOM_DATA_DICTIONARY} \n {0,0,0,0,0}")
32 #-----------------------------------------------------------------------------
33 # ... for DicomTS file
34 FILE(READ "dicomTS.dic" ENT_TS)
35 STRING(REGEX REPLACE "\r?\n" ";" ENT_TS "${ENT_TS}")
36 SET(DICOM_TS_DICTIONARY "")
38 FOREACH(line ${ENT_TS})
41 " ts[\"\\1\"] = \"\\2\"; " nline "${line}")
42 SET(DICOM_TS_DICTIONARY "${DICOM_TS_DICTIONARY}\n${nline}")
45 #-----------------------------------------------------------------------------
46 # ... for DicomVR file
47 FILE(READ "dicomVR.dic" ENT_VR)
48 STRING(REGEX REPLACE ";" "/" ENT_VR "${ENT_VR}") # CMake doesn't like ';'
49 STRING(REGEX REPLACE "\r?\n" ";" ENT_VR "${ENT_VR}")
50 SET(DICOM_VR_DICTIONARY "")
52 FOREACH(line ${ENT_VR})
54 "^([A-Z][A-Z]) (.*)/ +//.*$"
55 " vr[\"\\1\"] = \"\\2\"; " nline "${line}")
56 SET(DICOM_VR_DICTIONARY "${DICOM_VR_DICTIONARY}\n${nline}")
59 #-----------------------------------------------------------------------------
60 # ... for DictGroupName file
61 FILE(READ "DictGroupName.dic" ENT_TS)
62 STRING(REGEX REPLACE "\r?\n" ";" ENT_TS "${ENT_TS}")
63 SET(DICT_GROUP_NAME_DICTIONARY "")
65 FOREACH(line ${ENT_TS})
68 " groupName[0x\\1] = \\2; " nline "${line}")
69 SET(DICT_GROUP_NAME_DICTIONARY "${DICT_GROUP_NAME_DICTIONARY}\n${nline}")
72 #-----------------------------------------------------------------------------
73 # ... for DicomDir file
74 FILE(READ "DicomDir.dic" ENT_DIR)
75 STRING(REGEX REPLACE "\\\\" "\\\\\\\\" ENT_DIR "${ENT_DIR}")
76 STRING(REGEX REPLACE ";" "/" ENT_DIR "${ENT_DIR}") # CMake doesn't like ';'
77 STRING(REGEX REPLACE "\r?\n" ";" ENT_DIR "${ENT_DIR}")
78 SET(DICOM_DIR_DICTIONARY "")
80 FOREACH(line ${ENT_DIR})
82 "^(metaElem|patientElem|studyElem|serieElem|imageElem) *([a-f0-9]+) ([a-f0-9]+) [\"](.*)[\"](.*)$"
83 " {\"\\1\" , 0x\\2 , 0x\\3 , \"\\4\"}, \\5" nline "${line}")
84 SET(DICOM_DIR_DICTIONARY "${DICOM_DIR_DICTIONARY}\n${nline}")
87 #-----------------------------------------------------------------------------
88 # ... Set the dictionnary
89 SET(DICOM_DIR_DICTIONARY "${DICOM_DIR_DICTIONARY} \n {0,0,0,0}")
91 FOREACH(file dicomV3.dic dicomTS.dic dicomVR.dic DicomDir.dic DictGroupName.dic)
92 CONFIGURE_FILE("${GDCM_SOURCE_DIR}/Dicts/${file}"
93 "${GDCM_BINARY_DIR}/Dicts/${file}.out")
95 CONFIGURE_FILE("${GDCM_SOURCE_DIR}/src/gdcmDefaultDicts.cxx.in"
96 "${GDCM_BINARY_DIR}/src/gdcmDefaultDicts.cxx" IMMEDIATE)
98 #-----------------------------------------------------------------------------
99 # Now generate our own 'DICOM' dictionary, based on the following dictionaries:
103 NIH.dic #the forbidden one...
106 FOREACH(dict ${ALL_DICTS})
107 FILE(READ "${GDCM_SOURCE_DIR}/Dicts/${dict}" dict_append)
108 FILE(APPEND "${GDCM_BINARY_DIR}/Dicts/gdcm.dic" ${dict_append})