comparison src/of-dicom-1-fixes.patch @ 3908:5863c4ed08b1

of-dicom: patch to compile in octave 4.0.0 (Bug #44624) * src/of-dicom-1-fixes.patch: new file * dist-files.mk: add of-dicom-1-fixes.patch * src/of-dicom.mk: allow cross compile
author John Donoghue <john.donoghue@ieee.org>
date Wed, 15 Apr 2015 21:52:37 -0400
parents
children
comparison
equal deleted inserted replaced
3907:d8a7730284ba 3908:5863c4ed08b1
1 diff -ur dicom.orig/src/dicominfo.cpp dicom/src/dicominfo.cpp
2 --- dicom.orig/src/dicominfo.cpp 2015-04-15 21:36:10.000000000 -0400
3 +++ dicom/src/dicominfo.cpp 2015-04-15 21:41:21.000000000 -0400
4 @@ -76,10 +76,10 @@
5 char* byteval2string(char * d, int d_len_p, const gdcm::ByteValue *bv);
6 char* name2Keyword(char *d, int *d_len_p, const char* s);
7 Matrix str2DoubleVec(const char*);
8 -Octave_map dump(const char filename[], int chatty);
9 -void dumpDataSet(Octave_map *om, const gdcm::DataSet *ds, int chatty, int sequenceDepth);
10 +octave_map dump(const char filename[], int chatty);
11 +void dumpDataSet(octave_map *om, const gdcm::DataSet *ds, int chatty, int sequenceDepth);
12 void getFileModTime(char *timeStr, const char *filename);
13 -void dumpElement(Octave_map *om, const gdcm::DataElement * elem, int chatty, int sequenceDepth);
14 +void dumpElement(octave_map *om, const gdcm::DataElement * elem, int chatty, int sequenceDepth);
15 void dumpSequence(octave_value *ov, gdcm::SequenceOfItems *seq, int chatty, int sequenceDepth);
16 int element2value(std::string & varname, octave_value *ov, const gdcm::DataElement * elem, int chatty, int sequenceDepth) ;
17
18 @@ -163,7 +163,7 @@
19 }
20 }
21
22 - Octave_map om=dump(filename.c_str(),chatty);
23 + octave_map om=dump(filename.c_str(),chatty);
24 retval(0)=om;
25
26 load_dicom_dict(current_dict.c_str()); // reset dictionary to initial value
27 @@ -172,9 +172,9 @@
28 #endif
29
30
31 -Octave_map dump(const char filename[], int chatty) {
32 +octave_map dump(const char filename[], int chatty) {
33 // output struct
34 - Octave_map om;
35 + octave_map om;
36 // Instantiate the reader:
37 gdcm::Reader reader;
38 reader.SetFileName( filename );
39 @@ -202,7 +202,7 @@
40 return om;
41 }
42
43 -void dumpDataSet(Octave_map *om, const gdcm::DataSet *ds, int chatty, int sequenceDepth) {
44 +void dumpDataSet(octave_map *om, const gdcm::DataSet *ds, int chatty, int sequenceDepth) {
45
46 const gdcm::DataSet::DataElementSet DES=ds->GetDES(); // gdcm::DataSet::DataElementSet is a std::set
47 gdcm::DataSet::Iterator it;
48 @@ -212,7 +212,7 @@
49 }
50 }
51
52 -void dumpElement(Octave_map *om, const gdcm::DataElement * elem,
53 +void dumpElement(octave_map *om, const gdcm::DataElement * elem,
54 int chatty, int sequenceDepth) {
55 std::string varname;
56 octave_value ov;
57 @@ -453,10 +453,10 @@
58 const octave_idx_type nDataSet=seq->GetNumberOfItems(); // objects in sequence
59 if (chatty) octave_stdout << nDataSet << " object" << ((nDataSet==1)?"":"s") << std::endl;
60 char item_name_buf[16];
61 - Octave_map om;
62 + octave_map om;
63 for (octave_idx_type j=1; j<=nDataSet; j++ ) {
64 const gdcm::DataSet::DataElementSet des=seq->GetItem(j).GetNestedDataSet().GetDES() ;
65 - Octave_map subom;
66 + octave_map subom;
67 for (gdcm::DataSet::Iterator it=des.begin(); it != des.end(); it++) {
68 std::string key("");
69 octave_value subov;
70 diff -ur dicom.orig/src/dicomwrite.cpp dicom/src/dicomwrite.cpp
71 --- dicom.orig/src/dicomwrite.cpp 2015-04-15 21:36:10.000000000 -0400
72 +++ dicom/src/dicomwrite.cpp 2015-04-15 21:41:49.000000000 -0400
73 @@ -43,7 +43,7 @@
74 // TODO all fns here should throw exceptions, not use this "std::string & err" arg
75
76 void struct2metadata(gdcm::ImageWriter *w, gdcm::File *file, const octave_value & ov, bool trial, int sequenceDepth) ;
77 -void structarray2sequence(gdcm::SequenceOfItems & sq, Octave_map * om, bool trial, int sequenceDepth);
78 +void structarray2sequence(gdcm::SequenceOfItems & sq, octave_map * om, bool trial, int sequenceDepth);
79 void value2element (gdcm::DataElement * de, const octave_value * ov, gdcm::Tag * tag, const std::string & keyword, bool trial, bool * handled, int sequenceDepth);
80 void octaveVal2dicomImage(gdcm::ImageWriter *w, octave_value *pixval) ;
81 void genMinimalMetaData(gdcm::ImageWriter *w, gdcm::File *file);
82 @@ -132,9 +132,9 @@
83 }
84 gdcm::DataSet ds;
85 gdcm::FileMetaInformation hds;
86 - Octave_map om=ov.map_value();
87 + octave_map om=ov.map_value();
88 uint32_t skipped = 0;
89 - for (Octave_map::iterator it = om.begin(); it != om.end(); it++) {
90 + for (octave_map::iterator it = om.begin(); it != om.end(); it++) {
91 std::string keyword(om.key(it));
92 Cell cell = om.contents(it);
93 if (!dicom_is_present(keyword)) {
94 @@ -179,17 +179,17 @@
95 return ;
96 }
97
98 -void structarray2sequence(gdcm::SequenceOfItems & sq, Octave_map * om, bool trial, int sequenceDepth) {
99 - for (Octave_map::iterator it = om->begin(); it != om->end(); it++) {
100 +void structarray2sequence(gdcm::SequenceOfItems & sq, octave_map * om, bool trial, int sequenceDepth) {
101 + for (octave_map::iterator it = om->begin(); it != om->end(); it++) {
102 gdcm::Item item;
103 // item.SetVLToUndefined(); //TODO: does VL need to be set for items that contain datasets?
104 gdcm::DataSet &nds = item.GetNestedDataSet();
105 std::string itemname(om->key(it));
106 // TODO: test itemname is something like Item_n.
107 Cell cell = om->contents(it);
108 - Octave_map subom = cell(0).map_value();
109 + octave_map subom = cell(0).map_value();
110 // octave_stdout << itemname <<std::endl;
111 - for (Octave_map::iterator subit = subom.begin(); subit != subom.end(); subit++) {
112 + for (octave_map::iterator subit = subom.begin(); subit != subom.end(); subit++) {
113 std::string subkeyword(subom.key(subit));
114 gdcm::DataElement de;
115 gdcm::Tag tag;
116 @@ -289,7 +289,7 @@
117 }
118 octave_stdout << std::endl;
119 //int nObj = ov->numel() ;
120 - Octave_map subom = ov->map_value();
121 + octave_map subom = ov->map_value();
122 gdcm::SmartPointer<gdcm::SequenceOfItems> sq = new gdcm::SequenceOfItems();
123 try {
124 structarray2sequence(*sq, &subom, trial, ++sequenceDepth) ;
125 diff -ur dicom.orig/src/Makefile dicom/src/Makefile
126 --- dicom.orig/src/Makefile 2015-04-15 21:36:10.000000000 -0400
127 +++ dicom/src/Makefile 2015-04-15 21:40:04.000000000 -0400
128 @@ -15,10 +15,11 @@
129 # Please see the file, "COPYING" for further details of GNU General
130 # Public License version 3.
131
132 -
133 +MKOCTFILE ?= mkoctfile
134 +OCTAVE ?= octave
135
136 INCDIRFLAGS =
137 -LIBDIRFLAGS = -L/usr/local/lib
138 +LIBDIRFLAGS =
139 GDCMLIBFLAGS = -lgdcmcharls -lgdcmjpeg8 -lgdcmjpeg12 \
140 -lgdcmjpeg16 -lgdcmCommon \
141 -lgdcmDICT -lgdcmDSED -lgdcmIOD -lgdcmMSFF
142 @@ -29,35 +30,35 @@
143
144
145 dicomlookup.oct: dicomdict.o dicomlookup.o
146 - mkoctfile $(INCDIRFLAGS) $(LIBDIRFLAGS) $(GDCMLIBFLAGS) $(DEBUGFLAG) dicomlookup.o dicomdict.o -o dicomlookup.oct
147 + $(MKOCTFILE) $(INCDIRFLAGS) $(LIBDIRFLAGS) $(GDCMLIBFLAGS) $(DEBUGFLAG) dicomlookup.o dicomdict.o -o dicomlookup.oct
148
149 dicomdict.oct: dicomdict.o
150 - mkoctfile $(INCDIRFLAGS) $(DEBUGFLAG) dicomdict.o
151 + $(MKOCTFILE) $(INCDIRFLAGS) $(DEBUGFLAG) dicomdict.o
152
153 dicominfo.oct: dicominfo.o dicomdict.o
154 - mkoctfile $(INCDIRFLAGS) $(LIBDIRFLAGS) $(GDCMLIBFLAGS) $(DEBUGFLAG) dicominfo.o dicomdict.o -o dicominfo.oct
155 + $(MKOCTFILE) $(INCDIRFLAGS) $(LIBDIRFLAGS) $(GDCMLIBFLAGS) $(DEBUGFLAG) dicominfo.o dicomdict.o -o dicominfo.oct
156
157 dicomwrite.oct: dicomwrite.o dicomdict.o
158 - mkoctfile $(INCDIRFLAGS) $(LIBDIRFLAGS) $(GDCMLIBFLAGS) $(DEBUGFLAG) dicomwrite.o dicomdict.o -o dicomwrite.oct
159 + $(MKOCTFILE) $(INCDIRFLAGS) $(LIBDIRFLAGS) $(GDCMLIBFLAGS) $(DEBUGFLAG) dicomwrite.o dicomdict.o -o dicomwrite.oct
160
161 dicomread.oct: dicomread.cpp
162 - mkoctfile $(INCDIRFLAGS) $(LIBDIRFLAGS) $(GDCMLIBFLAGS) $(DEBUGFLAG) dicomread.cpp
163 + $(MKOCTFILE) $(INCDIRFLAGS) $(LIBDIRFLAGS) $(GDCMLIBFLAGS) $(DEBUGFLAG) dicomread.cpp
164
165 _gendicomdict.oct: _gendicomdict.cpp
166 - mkoctfile $(INCDIRFLAGS) $(LIBDIRFLAGS) $(GDCMLIBFLAGS) $(DEBUGFLAG) _gendicomdict.cpp
167 + $(MKOCTFILE) $(INCDIRFLAGS) $(LIBDIRFLAGS) $(GDCMLIBFLAGS) $(DEBUGFLAG) _gendicomdict.cpp
168
169
170 dicominfo.o: dicomdict.h dicominfo.cpp
171 - mkoctfile -c $(INCDIRFLAGS) $(DEBUGFLAG) dicominfo.cpp
172 + $(MKOCTFILE) -c $(INCDIRFLAGS) $(DEBUGFLAG) dicominfo.cpp
173
174 dicomwrite.o: dicomdict.h dicomwrite.cpp
175 - mkoctfile -c $(INCDIRFLAGS) $(DEBUGFLAG) dicomwrite.cpp
176 + $(MKOCTFILE) -c $(INCDIRFLAGS) $(DEBUGFLAG) dicomwrite.cpp
177
178 dicomdict.o: dicomdict.h dicomdict.cpp
179 - mkoctfile -c $(INCDIRFLAGS) $(DEBUGFLAG) dicomdict.cpp
180 + $(MKOCTFILE) -c $(INCDIRFLAGS) $(DEBUGFLAG) dicomdict.cpp
181
182 dicomlookup.o: dicomdict.h dicomlookup.cpp
183 - mkoctfile -c $(INCDIRFLAGS) $(DEBUGFLAG) dicomlookup.cpp
184 + $(MKOCTFILE) -c $(INCDIRFLAGS) $(DEBUGFLAG) dicomlookup.cpp
185
186 clean:
187 rm -f *.o *.oct *~
188 @@ -65,13 +66,14 @@
189 test: test_dicominfo test_dicomdict test_dicomread test_dicomlookup
190
191 test_dicominfo: dicominfo.oct
192 - octave -q --eval "test dicominfo.cpp"
193 + $(OCTAVE) -q --eval "test dicominfo.cpp"
194
195 test_dicomdict: dicomdict.oct
196 - octave -q --eval "test dicomdict.cpp"
197 + $(OCTAVE) -q --eval "test dicomdict.cpp"
198
199 test_dicomread: dicomread.oct
200 - octave -q --eval "test dicomread.cpp"
201 + $(OCTAVE) -q --eval "test dicomread.cpp"
202
203 test_dicomlookup: dicomlookup.oct
204 - octave -q --eval "test dicomlookup.cpp"
205 \ No newline at end of file
206 + $(OCTAVE) -q --eval "test dicomlookup.cpp"
207 +
208 diff -ur dicom.orig/src/dicominfo.cpp dicom/src/dicominfo.cpp
209 --- dicom.orig/src/dicominfo.cpp 2015-04-15 21:44:32.000000000 -0400
210 +++ dicom/src/dicominfo.cpp 2015-04-15 21:47:48.000000000 -0400
211 @@ -187,10 +187,10 @@
212 gdcm::DataSet &ds = file.GetDataSet();
213 gdcm::FileMetaInformation &hds=file.GetHeader();
214
215 - om.assign("Filename",filename);
216 + om.assign("Filename",octave_value(filename));
217 char dateStr[TIME_STR_LEN+1];
218 getFileModTime(dateStr, filename);
219 - om.assign("FileModDate", dateStr);
220 + om.assign("FileModDate", octave_value(dateStr));
221 if(chatty) octave_stdout << "# file info\nFilename:"
222 << filename << "\nFileModDate:" << dateStr << '\n';
223
224 @@ -220,7 +220,7 @@
225 om->assign(varname.c_str(), ov);
226 } else {
227 if (0==varname.length()) return ;
228 - om->assign(varname.c_str(), "not assigned");
229 + om->assign(varname.c_str(), octave_value("not assigned"));
230 }
231 }
232
233 @@ -464,7 +464,7 @@
234 subom.assign(key.c_str(), subov);
235 } else {
236 if (0==key.length()) continue ;
237 - subom.assign(key.c_str(), "not assigned");
238 + subom.assign(key.c_str(), octave_value("not assigned"));
239 }
240 }
241 snprintf(item_name_buf,15,"Item_%i",j);