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
12 #GEMS.dic #Commented out to avoid polluting 'non GEMS' images
19 FOREACH(dict ${ALL_DICTS})
20 # Properly set dependencies, therefore `touch Philips-Intera.dic` does not rebuild
21 # but adding/removing a line in Philips-Intera.dic rebuild as expected
22 CONFIGURE_FILE("${GDCM_SOURCE_DIR}/Dicts/${dict}"
23 "${GDCM_BINARY_DIR}/Dicts/${dict}" COPYONLY IMMEDIATE)
24 FILE(READ "${GDCM_SOURCE_DIR}/Dicts/${dict}" dict_append)
25 SET(TEST_DICT_BODY "${TEST_DICT_BODY}\n${dict_append}")
27 CONFIGURE_FILE("${GDCM_SOURCE_DIR}/Dicts/gdcm.dic.in"
28 "${GDCM_BINARY_DIR}/Dicts/gdcm.dic" @ONLY IMMEDIATE)
30 #-----------------------------------------------------------------------------
31 # Nice trick to avoid creating a .h file each time we compile gdcm
32 # Since CONFIGURE_FILE do a 'copy if different'
33 # We have to write the file here since is contains 'DICOM_DICTIONARY'
34 # Which is a variable afterward...
36 # Following code contributing by Andy Cedilnik (Kitware)
37 FILE(READ "${GDCM_BINARY_DIR}/Dicts/gdcm.dic" ENT)
38 STRING(REGEX REPLACE "\r?\n" ";" ENT "${ENT}")
39 SET(DICOM_DATA_DICTIONARY "")
43 "^([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-]+) (.*)$"
44 " {0x\\1, 0x\\2, \"\\3\" , \"\\4\" , \"\\5\"}, " nline "${line}")
45 SET(DICOM_DATA_DICTIONARY "${DICOM_DATA_DICTIONARY}\n${nline}")
48 SET(DICOM_DATA_DICTIONARY "${DICOM_DATA_DICTIONARY} \n {0,0,0,0,0}")
50 #-----------------------------------------------------------------------------
51 # ... for DicomTS file
52 FILE(READ "dicomTS.dic" ENT_TS)
53 STRING(REGEX REPLACE "\r?\n" ";" ENT_TS "${ENT_TS}")
54 SET(DICOM_TS_DICTIONARY "")
56 FOREACH(line ${ENT_TS})
59 " ts[\"\\1\"] = \"\\2\"; " nline "${line}")
60 SET(DICOM_TS_DICTIONARY "${DICOM_TS_DICTIONARY}\n${nline}")
63 #-----------------------------------------------------------------------------
64 # ... for DicomVR file
65 FILE(READ "dicomVR.dic" ENT_VR)
66 STRING(REGEX REPLACE ";" "/" ENT_VR "${ENT_VR}") # CMake doesn't like ';'
67 STRING(REGEX REPLACE "\r?\n" ";" ENT_VR "${ENT_VR}")
68 SET(DICOM_VR_DICTIONARY "")
70 FOREACH(line ${ENT_VR})
72 "^([A-Z][A-Z]) (.*)/ +//.*$"
73 " vr[\"\\1\"] = \"\\2\"; " nline "${line}")
74 SET(DICOM_VR_DICTIONARY "${DICOM_VR_DICTIONARY}\n${nline}")
77 #-----------------------------------------------------------------------------
78 # ... for DictGroupName file
79 FILE(READ "DictGroupName.dic" ENT_TS)
80 STRING(REGEX REPLACE "\r?\n" ";" ENT_TS "${ENT_TS}")
81 SET(DICT_GROUP_NAME_DICTIONARY "")
83 FOREACH(line ${ENT_TS})
86 " groupName[0x\\1] = \\2; " nline "${line}")
87 SET(DICT_GROUP_NAME_DICTIONARY "${DICT_GROUP_NAME_DICTIONARY}\n${nline}")
90 #-----------------------------------------------------------------------------
91 # ... for DicomDir file
92 FILE(READ "DicomDir.dic" ENT_DIR)
93 STRING(REGEX REPLACE "\\\\" "\\\\\\\\" ENT_DIR "${ENT_DIR}")
94 STRING(REGEX REPLACE ";" "/" ENT_DIR "${ENT_DIR}") # CMake doesn't like ';'
95 STRING(REGEX REPLACE "\r?\n" ";" ENT_DIR "${ENT_DIR}")
96 SET(DICOM_DIR_DICTIONARY "")
98 FOREACH(line ${ENT_DIR})
100 "^(metaElem|patientElem|studyElem|serieElem|imageElem) *([a-f0-9]+) ([a-f0-9]+) [\"](.*)[\"] [\"](.*)[\"] (.*)$"
101 " {\"\\1\" , 0x\\2 , 0x\\3 , \"\\4\", \"\\5\"}, \\6" nline "${line}")
102 SET(DICOM_DIR_DICTIONARY "${DICOM_DIR_DICTIONARY}\n${nline}")
105 #-----------------------------------------------------------------------------
106 # ... Set the dictionnary
107 SET(DICOM_DIR_DICTIONARY "${DICOM_DIR_DICTIONARY} \n {0,0,0,0,0}")
109 CONFIGURE_FILE("${GDCM_SOURCE_DIR}/src/gdcmDefaultDicts.cxx.in"
110 "${GDCM_BINARY_DIR}/src/gdcmDefaultDicts.cxx" IMMEDIATE)
112 #-----------------------------------------------------------------------------
113 # For now GDCM_INSTALL_NO_DICTIONARY is a hidden variables
114 IF(NOT GDCM_INSTALL_NO_DICTIONARY)
115 INSTALL_FILES(${GDCM_INSTALL_DATA_DIR} .dic
123 ENDIF(NOT GDCM_INSTALL_NO_DICTIONARY)