1 #-----------------------------------------------------------------------------
2 # DICOM dictionary stuff
4 #-----------------------------------------------------------------------------
5 # Generate our own 'DICOM' dictionary, based on the following dictionaries:
9 NIH.dic #the forbidden one...
11 # PHILIPS-Intera.dic # uncomment me if you want
16 FOREACH(dict ${ALL_DICTS})
17 # Properly set dependencies, therefore `touch Philips-Intera.dic` does not rebuild
18 # but adding/removing a line in Philips-Intera.dic rebuild as expected
19 CONFIGURE_FILE("${GDCM_SOURCE_DIR}/Dicts/${dict}"
20 "${GDCM_BINARY_DIR}/Dicts/${dict}" COPYONLY IMMEDIATE)
21 FILE(READ "${GDCM_SOURCE_DIR}/Dicts/${dict}" dict_append)
22 SET(TEST_DICT_BODY "${TEST_DICT_BODY}\n${dict_append}")
24 CONFIGURE_FILE("${GDCM_SOURCE_DIR}/Dicts/gdcm.dic.in"
25 "${GDCM_BINARY_DIR}/Dicts/gdcm.dic" @ONLY IMMEDIATE)
27 #-----------------------------------------------------------------------------
28 # Nice trick to avoid creating a .h file each time we compile gdcm
29 # Since CONFIGURE_FILE do a 'copy if different'
30 # We have to write the file here since is contains 'DICOM_DICTIONARY'
31 # Which is a variable afterward...
33 # Following code contributing by Andy Cedilnik (Kitware)
34 FILE(READ "${GDCM_BINARY_DIR}/Dicts/gdcm.dic" ENT)
35 STRING(REGEX REPLACE "\r?\n" ";" ENT "${ENT}")
36 SET(DICOM_DATA_DICTIONARY "")
40 "^([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-]+) (.*)$"
41 " {0x\\1, 0x\\2, \"\\3\" , \"\\4\" , \"\\5\"}, " nline "${line}")
42 SET(DICOM_DATA_DICTIONARY "${DICOM_DATA_DICTIONARY}\n${nline}")
45 SET(DICOM_DATA_DICTIONARY "${DICOM_DATA_DICTIONARY} \n {0,0,0,0,0}")
47 #-----------------------------------------------------------------------------
48 # ... for DicomTS file
49 FILE(READ "dicomTS.dic" ENT_TS)
50 STRING(REGEX REPLACE "\r?\n" ";" ENT_TS "${ENT_TS}")
51 SET(DICOM_TS_DICTIONARY "")
53 FOREACH(line ${ENT_TS})
56 " ts[\"\\1\"] = \"\\2\"; " nline "${line}")
57 SET(DICOM_TS_DICTIONARY "${DICOM_TS_DICTIONARY}\n${nline}")
60 #-----------------------------------------------------------------------------
61 # ... for DicomVR file
62 FILE(READ "dicomVR.dic" ENT_VR)
63 STRING(REGEX REPLACE ";" "/" ENT_VR "${ENT_VR}") # CMake doesn't like ';'
64 STRING(REGEX REPLACE "\r?\n" ";" ENT_VR "${ENT_VR}")
65 SET(DICOM_VR_DICTIONARY "")
67 FOREACH(line ${ENT_VR})
69 "^([A-Z][A-Z]) (.*)/ +//.*$"
70 " vr[\"\\1\"] = \"\\2\"; " nline "${line}")
71 SET(DICOM_VR_DICTIONARY "${DICOM_VR_DICTIONARY}\n${nline}")
74 #-----------------------------------------------------------------------------
75 # ... for DictGroupName file
76 FILE(READ "DictGroupName.dic" ENT_TS)
77 STRING(REGEX REPLACE "\r?\n" ";" ENT_TS "${ENT_TS}")
78 SET(DICT_GROUP_NAME_DICTIONARY "")
80 FOREACH(line ${ENT_TS})
83 " groupName[0x\\1] = \\2; " nline "${line}")
84 SET(DICT_GROUP_NAME_DICTIONARY "${DICT_GROUP_NAME_DICTIONARY}\n${nline}")
87 #-----------------------------------------------------------------------------
88 # ... for DicomDir file
89 FILE(READ "DicomDir.dic" ENT_DIR)
90 STRING(REGEX REPLACE "\\\\" "\\\\\\\\" ENT_DIR "${ENT_DIR}")
91 STRING(REGEX REPLACE ";" "/" ENT_DIR "${ENT_DIR}") # CMake doesn't like ';'
92 STRING(REGEX REPLACE "\r?\n" ";" ENT_DIR "${ENT_DIR}")
93 SET(DICOM_DIR_DICTIONARY "")
95 FOREACH(line ${ENT_DIR})
97 "^(metaElem|patientElem|studyElem|serieElem|imageElem) *([a-f0-9]+) ([a-f0-9]+) [\"](.*)[\"](.*)$"
98 " {\"\\1\" , 0x\\2 , 0x\\3 , \"\\4\"}, \\5" nline "${line}")
99 SET(DICOM_DIR_DICTIONARY "${DICOM_DIR_DICTIONARY}\n${nline}")
102 #-----------------------------------------------------------------------------
103 # ... Set the dictionnary
104 SET(DICOM_DIR_DICTIONARY "${DICOM_DIR_DICTIONARY} \n {0,0,0,0}")
106 CONFIGURE_FILE("${GDCM_SOURCE_DIR}/src/gdcmDefaultDicts.cxx.in"
107 "${GDCM_BINARY_DIR}/src/gdcmDefaultDicts.cxx" IMMEDIATE)
109 #-----------------------------------------------------------------------------
110 INSTALL_FILES(${GDCM_DATA_DIR} .dic