2 #pragma SWIG nowarn=504,510
6 #include "gdcmCommon.h"
8 #include "gdcmRefCounter.h"
9 #include "gdcmTagKey.h"
10 #include "gdcmVRKey.h"
12 #include "gdcmDicomEntry.h"
13 #include "gdcmDictEntry.h"
14 #include "gdcmDictSet.h"
15 #include "gdcmDicomDir.h"
16 #include "gdcmDicomDirElement.h"
17 #include "gdcmDicomDirImage.h"
18 #include "gdcmDicomDirMeta.h"
19 #include "gdcmDicomDirObject.h"
20 #include "gdcmDicomDirPatient.h"
21 #include "gdcmDicomDirStudy.h"
22 #include "gdcmDicomDirSerie.h"
23 #include "gdcmDocEntrySet.h"
24 #include "gdcmDocument.h"
25 #include "gdcmElementSet.h"
26 #include "gdcmFileHelper.h"
27 #include "gdcmGlobal.h"
29 #include "gdcmSerieHelper.h"
30 #include "gdcmRLEFramesInfo.h"
31 #include "gdcmJPEGFragmentsInfo.h"
32 #include "gdcmSQItem.h"
34 #include "gdcmDocEntry.h"
35 #include "gdcmDataEntry.h"
36 #include "gdcmSeqEntry.h"
39 #include "gdcmDictGroupName.h"
41 ////////////////////////////////////////////////////////////////////////////
42 /// Refer (below) to the definition of multi-argument typemap
43 /// %typemap(python, in)
44 /// ( gdcm::DicomDir::Method*, void*, gdcm::DicomDir::Method*)
45 /// for detail on gdcmPythonVoidFunc() and gdcmPythonVoidFuncArgDelete().
46 void gdcmPythonVoidFunc(void *arg)
48 PyObject *arglist, *result;
49 PyObject *func = (PyObject *)arg;
51 arglist = Py_BuildValue("()");
53 result = PyEval_CallObject(func, arglist);
62 if (PyErr_ExceptionMatches(PyExc_KeyboardInterrupt))
64 std::cerr << "Caught a Ctrl-C within python, exiting program.\n";
71 void gdcmPythonVoidFuncArgDelete(void *arg)
73 PyObject *func = (PyObject *)arg;
80 /// This is required in order to avoid %including all the gdcm include files.
85 /////////////////////// typemap section ////////////////////////////////////
87 ////////////////////////////////////////////////
88 // Redefine all types used
90 typedef unsigned char uint8_t;
91 typedef short int16_t;
92 typedef unsigned short uint16_t;
94 typedef unsigned int uint32_t;
95 typedef long long int64_t;
96 typedef unsigned long long uint64_t;
98 ////////////////////////////////////////////////
99 // Convert a DocEntry * to the real derived class
100 %typemap(out) gdcm::DocEntry *
106 if(dynamic_cast<SeqEntry *>($1)) // SeqEntry *
107 newEntry = SWIG_NewPointerObj($1,SWIGTYPE_p_gdcm__SeqEntry,0);
108 else if(dynamic_cast<DataEntry *>($1)) // DataEntry *
109 newEntry = SWIG_NewPointerObj($1,SWIGTYPE_p_gdcm__DataEntry,0);
115 newEntry = Py_BuildValue("");
120 ////////////////////////////////////////////////////////////////////////////
121 // Multi-argument typemap designed for wrapping the progress related methods
122 // in order to control from an external application the computation of
123 // a DicomDir object (see DicomDir::SetStartMethod*,
124 // DicomDir::SetProgressMethod* and DicomDir::SetEndMethod*).
125 // Motivation: since DicomDir parsing can be quite long, a GUI application
126 // needs to display the avancement and potentially offer a
127 // cancel method to the user (when this one feels things are
128 // longer than expected).
129 // Example of usage: refer to demo/DicomDirProgressMethod.py
130 // Note: Uses gdcmPythonVoidFunc and gdcmPythonVoidFuncArgDelete defined
131 // in the Swig verbatim section of this gdcm.i i.e. in the above section
132 // enclosed within the %{ ... %} scope operator ).
133 %typemap(python, in) (void(*method)(void *),void *arg,void(*argDelete)(void *))
138 $1=gdcmPythonVoidFunc;
140 $3=gdcmPythonVoidFuncArgDelete;
150 //////////////////// STL string versus Python str ////////////////////////
151 // Convertion returning a C++ string.
152 %typemap(out) std::string
154 $result = PyString_FromString(($1).c_str());
159 $result = PyString_FromString(($1).c_str());
162 %typemap(out) std::string const &
164 $result = PyString_FromString(($1)->c_str());
167 // Convertion of incoming Python str to STL string
168 %typemap(python, in) const std::string, std::string
170 $1 = PyString_AsString($input);
173 // Same convertion as above but references (since swig converts C++
174 // refererences to pointers)
175 %typemap(python, in) std::string const &
177 $1 = new std::string( PyString_AsString( $input ) );
180 //////////////////// gdcm.TagName versus Python str //////////////////////
181 %typemap(out) gdcm::TagName, const gdcm::TagName &
183 $result = PyString_FromString(($1)->c_str());
186 // Convertion of incoming Python str to STL string
187 %typemap(python, in) const gdcm::TagName, gdcm::TagName
189 $1 = PyString_AsString($input);
192 // Same convertion as above but references (since swig converts C++
193 // refererences to pointers)
194 %typemap(python, in) gdcm::TagName const &
196 $1 = new std::string( PyString_AsString( $input ) );
199 ////////////////////////////////////////////////////////////////////////////
200 // Because overloading and %rename don't work together (see below Note 1)
201 // we need to ignore some methods (e.g. the overloaded default constructor).
202 // The gdcm::File class doesn't have any SetFilename method anyhow, and
203 // this constructor is only used internaly (not from the API) so this is
205 %ignore gdcm::binary_write(std::ostream &,uint32_t const &);
206 %ignore gdcm::binary_write(std::ostream &,uint16_t const &);
208 %ignore gdcm::VRKey::operator=(const VRKey &_val);
209 %ignore gdcm::VRKey::operator=(const std::string &_val);
210 %ignore gdcm::VRKey::operator=(const char *_val);
211 %ignore gdcm::VRKey::operator[](const unsigned int &_id) const;
212 %ignore gdcm::VRKey::operator[](const unsigned int &_id);
214 %ignore gdcm::TagKey::operator=(const TagKey &_val);
215 %ignore gdcm::TagKey::operator[](const unsigned int &_id) const;
216 %ignore gdcm::TagKey::operator[](const unsigned int &_id);
218 %ignore gdcm::DicomDir::SetStartMethod(DicomDir::Method *method,void *arg = NULL);
219 %ignore gdcm::DicomDir::SetProgressMethod(DicomDir::Method *method,void *arg = NULL);
220 %ignore gdcm::DicomDir::SetEndMethod(DicomDir::Method *method,void *arg = NULL);
222 // Ignore all placed in gdcmCommon.h
223 %ignore GDCM_UNKNOWN;
224 %ignore GDCM_UNFOUND;
225 %ignore GDCM_BINLOADED;
226 %ignore GDCM_NOTLOADED;
228 %ignore GDCM_NOTASCII;
229 %ignore GDCM_PIXELDATA;
231 %ignore GDCM_VRUNKNOWN;
233 %constant const char *UNKNOWN = "gdcm::Unknown";
234 %constant const char *UNFOUND = "gdcm::Unfound";
235 %constant const char *BINLOADED = "gdcm::Binary data loaded";
236 %constant const char *NOTLOADED = "gdcm::NotLoaded";
237 %constant const char *UNREAD = "gdcm::UnRead";
238 %constant const char *GDCM_NOTASCII = "gdcm::NotAscii";
239 %constant const char *GDCM_PIXELDATA = "gdcm::Pixel Data to be loaded";
240 %constant const char *VRUNKNOWN = " ";
242 ////////////////////////////////////////////////////////////////////////////
243 // Warning: Order matters !
244 %include "gdcmCommon.h"
245 %include "gdcmBase.h"
246 %include "gdcmRefCounter.h"
247 %include "gdcmTagKey.h"
248 %include "gdcmVRKey.h"
249 %include "gdcmDicomEntry.h"
250 %include "gdcmDictEntry.h"
251 %include "gdcmDict.h"
252 %include "gdcmDictSet.h"
253 %include "gdcmDocEntrySet.h"
254 %include "gdcmElementSet.h"
255 %include "gdcmSQItem.h"
256 %include "gdcmDicomDirElement.h"
257 %include "gdcmDicomDirObject.h"
258 %include "gdcmDicomDirImage.h"
259 %include "gdcmDicomDirSerie.h"
260 %include "gdcmDicomDirStudy.h"
261 %include "gdcmDicomDirPatient.h"
262 %include "gdcmDicomDirMeta.h"
263 %include "gdcmDocument.h"
264 %include "gdcmFile.h"
265 %include "gdcmSerieHelper.h"
266 %include "gdcmFileHelper.h"
267 %include "gdcmUtil.h"
268 %include "gdcmGlobal.h"
269 %include "gdcmDicomDir.h"
270 %include "gdcmDocEntry.h"
271 %include "gdcmDataEntry.h"
272 %include "gdcmSeqEntry.h"
275 %include "gdcmDictGroupName.h"