1 #-----------------------------------------------------------------------------
2 # DICOM dictionary stuff
4 #-----------------------------------------------------------------------------
5 # Generate our own 'DICOM' dictionary, based on the following dictionaries:
9 NIH.dic #the forbidden one...
10 dicomV3PhilipsIntera.dic
13 # The following line make sure we are not appending on an already existing file
14 #FILE(WRITE "${GDCM_BINARY_DIR}/Dicts/gdcm.dic" "")
15 #FOREACH(dict ${ALL_DICTS})
16 # FILE(READ "${GDCM_SOURCE_DIR}/Dicts/${dict}" dict_append)
17 # FILE(APPEND "${GDCM_BINARY_DIR}/Dicts/gdcm.dic" ${dict_append})
22 FOREACH(dict ${ALL_DICTS})
23 FILE(READ "${GDCM_SOURCE_DIR}/Dicts/${dict}" dict_append)
24 SET(TEST_DICT_BODY "${TEST_DICT_BODY}\n${dict_append}")
26 CONFIGURE_FILE("${GDCM_SOURCE_DIR}/Dicts/gdcm.dic.in"
27 "${GDCM_BINARY_DIR}/Dicts/gdcm.dic" @ONLY IMMEDIATE)
29 #-----------------------------------------------------------------------------
30 # Nice trick to avoid creating a .h file each time we compile gdcm
31 # Since CONFIGURE_FILE do a 'copy if different'
32 # We have to write the file here since is contains 'DICOM_DICTIONARY'
33 # Which is a variable afterward...
35 # Following code contributing by Andy Cedilnik (Kitware)
36 FILE(READ "${GDCM_BINARY_DIR}/Dicts/gdcm.dic" ENT)
37 STRING(REGEX REPLACE "\r?\n" ";" ENT "${ENT}")
38 SET(DICOM_DATA_DICTIONARY "")
42 "^([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-]+) (.*)$"
43 " {0x\\1, 0x\\2, \"\\3\" , \"\\4\" , \"\\5\"}, " nline "${line}")
44 #MESSAGE( "${nline}" )
45 SET(DICOM_DATA_DICTIONARY "${DICOM_DATA_DICTIONARY}\n${nline}")
49 #FILE(READ "dicomV3PhilipsIntera.dic" ENT)
50 #STRING(REGEX REPLACE "\r?\n" ";" ENT "${ENT}")
51 #SET(DICOM_DATA_DICTIONARY "")
53 # STRING(REGEX REPLACE
54 # "^([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-]+) (.*)$"
55 # " {0x\\1, 0x\\2, \"\\3\" , \"\\4\" , \"\\5\"}, " nline "${line}")
56 # #SET(DICOM_DATA_DICTIONARY "${DICOM_DATA_DICTIONARY}\n${nline}")
57 # MESSAGE( "${nline}" )
61 SET(DICOM_DATA_DICTIONARY "${DICOM_DATA_DICTIONARY} \n {0,0,0,0,0}")
63 #-----------------------------------------------------------------------------
64 # ... for DicomTS file
65 FILE(READ "dicomTS.dic" ENT_TS)
66 STRING(REGEX REPLACE "\r?\n" ";" ENT_TS "${ENT_TS}")
67 SET(DICOM_TS_DICTIONARY "")
69 FOREACH(line ${ENT_TS})
72 " ts[\"\\1\"] = \"\\2\"; " nline "${line}")
73 SET(DICOM_TS_DICTIONARY "${DICOM_TS_DICTIONARY}\n${nline}")
76 #-----------------------------------------------------------------------------
77 # ... for DicomVR file
78 FILE(READ "dicomVR.dic" ENT_VR)
79 STRING(REGEX REPLACE ";" "/" ENT_VR "${ENT_VR}") # CMake doesn't like ';'
80 STRING(REGEX REPLACE "\r?\n" ";" ENT_VR "${ENT_VR}")
81 SET(DICOM_VR_DICTIONARY "")
83 FOREACH(line ${ENT_VR})
85 "^([A-Z][A-Z]) (.*)/ +//.*$"
86 " vr[\"\\1\"] = \"\\2\"; " nline "${line}")
87 SET(DICOM_VR_DICTIONARY "${DICOM_VR_DICTIONARY}\n${nline}")
90 #-----------------------------------------------------------------------------
91 # ... for DictGroupName file
92 FILE(READ "DictGroupName.dic" ENT_TS)
93 STRING(REGEX REPLACE "\r?\n" ";" ENT_TS "${ENT_TS}")
94 SET(DICT_GROUP_NAME_DICTIONARY "")
96 FOREACH(line ${ENT_TS})
99 " groupName[0x\\1] = \\2; " nline "${line}")
100 SET(DICT_GROUP_NAME_DICTIONARY "${DICT_GROUP_NAME_DICTIONARY}\n${nline}")
103 #-----------------------------------------------------------------------------
104 # ... for DicomDir file
105 FILE(READ "DicomDir.dic" ENT_DIR)
106 STRING(REGEX REPLACE "\\\\" "\\\\\\\\" ENT_DIR "${ENT_DIR}")
107 STRING(REGEX REPLACE ";" "/" ENT_DIR "${ENT_DIR}") # CMake doesn't like ';'
108 STRING(REGEX REPLACE "\r?\n" ";" ENT_DIR "${ENT_DIR}")
109 SET(DICOM_DIR_DICTIONARY "")
111 FOREACH(line ${ENT_DIR})
113 "^(metaElem|patientElem|studyElem|serieElem|imageElem) *([a-f0-9]+) ([a-f0-9]+) [\"](.*)[\"](.*)$"
114 " {\"\\1\" , 0x\\2 , 0x\\3 , \"\\4\"}, \\5" nline "${line}")
115 SET(DICOM_DIR_DICTIONARY "${DICOM_DIR_DICTIONARY}\n${nline}")
118 #-----------------------------------------------------------------------------
119 # ... Set the dictionnary
120 SET(DICOM_DIR_DICTIONARY "${DICOM_DIR_DICTIONARY} \n {0,0,0,0}")
122 #FOREACH(file dicomV3.dic dicomTS.dic dicomVR.dic DicomDir.dic DictGroupName.dic)
123 # CONFIGURE_FILE("${GDCM_SOURCE_DIR}/Dicts/${file}"
124 # "${GDCM_BINARY_DIR}/Dicts/${file}.out")
127 CONFIGURE_FILE("${GDCM_SOURCE_DIR}/src/gdcmDefaultDicts.cxx.in"
128 "${GDCM_BINARY_DIR}/src/gdcmDefaultDicts.cxx" IMMEDIATE)
130 #-----------------------------------------------------------------------------
131 INSTALL_FILES(${GDCM_DATA_DIR} .dic