1 #-----------------------------------------------------------------------------
2 # DICOM dictionary stuff
4 #-----------------------------------------------------------------------------
5 # Generate our own 'DICOM' dictionary, based on the following dictionaries:
9 NIH.dic #the forbidden one...
15 FOREACH(dict ${ALL_DICTS})
16 FILE(READ "${GDCM_SOURCE_DIR}/Dicts/${dict}" dict_append)
17 SET(TEST_DICT_BODY "${TEST_DICT_BODY}\n${dict_append}")
19 CONFIGURE_FILE("${GDCM_SOURCE_DIR}/Dicts/gdcm.dic.in"
20 "${GDCM_BINARY_DIR}/Dicts/gdcm.dic" @ONLY IMMEDIATE)
22 #-----------------------------------------------------------------------------
23 # Nice trick to avoid creating a .h file each time we compile gdcm
24 # Since CONFIGURE_FILE do a 'copy if different'
25 # We have to write the file here since is contains 'DICOM_DICTIONARY'
26 # Which is a variable afterward...
28 # Following code contributing by Andy Cedilnik (Kitware)
29 FILE(READ "${GDCM_BINARY_DIR}/Dicts/gdcm.dic" ENT)
30 STRING(REGEX REPLACE "\r?\n" ";" ENT "${ENT}")
31 SET(DICOM_DATA_DICTIONARY "")
35 "^([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-]+) (.*)$"
36 " {0x\\1, 0x\\2, \"\\3\" , \"\\4\" , \"\\5\"}, " nline "${line}")
37 SET(DICOM_DATA_DICTIONARY "${DICOM_DATA_DICTIONARY}\n${nline}")
40 SET(DICOM_DATA_DICTIONARY "${DICOM_DATA_DICTIONARY} \n {0,0,0,0,0}")
42 #-----------------------------------------------------------------------------
43 # ... for DicomTS file
44 FILE(READ "dicomTS.dic" ENT_TS)
45 STRING(REGEX REPLACE "\r?\n" ";" ENT_TS "${ENT_TS}")
46 SET(DICOM_TS_DICTIONARY "")
48 FOREACH(line ${ENT_TS})
51 " ts[\"\\1\"] = \"\\2\"; " nline "${line}")
52 SET(DICOM_TS_DICTIONARY "${DICOM_TS_DICTIONARY}\n${nline}")
55 #-----------------------------------------------------------------------------
56 # ... for DicomVR file
57 FILE(READ "dicomVR.dic" ENT_VR)
58 STRING(REGEX REPLACE ";" "/" ENT_VR "${ENT_VR}") # CMake doesn't like ';'
59 STRING(REGEX REPLACE "\r?\n" ";" ENT_VR "${ENT_VR}")
60 SET(DICOM_VR_DICTIONARY "")
62 FOREACH(line ${ENT_VR})
64 "^([A-Z][A-Z]) (.*)/ +//.*$"
65 " vr[\"\\1\"] = \"\\2\"; " nline "${line}")
66 SET(DICOM_VR_DICTIONARY "${DICOM_VR_DICTIONARY}\n${nline}")
69 #-----------------------------------------------------------------------------
70 # ... for DictGroupName file
71 FILE(READ "DictGroupName.dic" ENT_TS)
72 STRING(REGEX REPLACE "\r?\n" ";" ENT_TS "${ENT_TS}")
73 SET(DICT_GROUP_NAME_DICTIONARY "")
75 FOREACH(line ${ENT_TS})
78 " groupName[0x\\1] = \\2; " nline "${line}")
79 SET(DICT_GROUP_NAME_DICTIONARY "${DICT_GROUP_NAME_DICTIONARY}\n${nline}")
82 #-----------------------------------------------------------------------------
83 # ... for DicomDir file
84 FILE(READ "DicomDir.dic" ENT_DIR)
85 STRING(REGEX REPLACE "\\\\" "\\\\\\\\" ENT_DIR "${ENT_DIR}")
86 STRING(REGEX REPLACE ";" "/" ENT_DIR "${ENT_DIR}") # CMake doesn't like ';'
87 STRING(REGEX REPLACE "\r?\n" ";" ENT_DIR "${ENT_DIR}")
88 SET(DICOM_DIR_DICTIONARY "")
90 FOREACH(line ${ENT_DIR})
92 "^(metaElem|patientElem|studyElem|serieElem|imageElem) *([a-f0-9]+) ([a-f0-9]+) [\"](.*)[\"](.*)$"
93 " {\"\\1\" , 0x\\2 , 0x\\3 , \"\\4\"}, \\5" nline "${line}")
94 SET(DICOM_DIR_DICTIONARY "${DICOM_DIR_DICTIONARY}\n${nline}")
97 #-----------------------------------------------------------------------------
98 # ... Set the dictionnary
99 SET(DICOM_DIR_DICTIONARY "${DICOM_DIR_DICTIONARY} \n {0,0,0,0}")
101 CONFIGURE_FILE("${GDCM_SOURCE_DIR}/src/gdcmDefaultDicts.cxx.in"
102 "${GDCM_BINARY_DIR}/src/gdcmDefaultDicts.cxx" IMMEDIATE)
104 #-----------------------------------------------------------------------------
105 INSTALL_FILES(${GDCM_DATA_DIR} .dic