]> Creatis software - gdcm.git/blob - gdcmPython/gdcm.i
* Fix compilation errors
[gdcm.git] / gdcmPython / gdcm.i
1 %module gdcm
2 #pragma SWIG nowarn=504,510
3 %{
4 #include <iostream>
5
6 #include "gdcmCommon.h"
7 #include "gdcmBase.h"
8 #include "gdcmRefCounter.h"
9 #include "gdcmCommand.h"
10 #include "gdcmCommandPy.h"
11 #include "gdcmDebug.h"
12 #include "gdcmCommandManager.h"
13 #include "gdcmTagKey.h"
14 #include "gdcmVRKey.h"
15 #include "gdcmDict.h"
16 #include "gdcmDicomEntry.h"
17 #include "gdcmDictEntry.h"
18 #include "gdcmDictSet.h"
19 #include "gdcmDicomDir.h"
20 #include "gdcmDicomDirElement.h"
21 #include "gdcmDicomDirImage.h"
22 #include "gdcmDicomDirMeta.h"
23 #include "gdcmDicomDirObject.h"
24 #include "gdcmDicomDirPatient.h"
25 #include "gdcmDicomDirStudy.h"
26 #include "gdcmDicomDirSerie.h"
27 #include "gdcmDocEntrySet.h"
28 #include "gdcmDocument.h"
29 #include "gdcmElementSet.h"
30 #include "gdcmFileHelper.h"
31 #include "gdcmGlobal.h"
32 #include "gdcmFile.h"
33 #include "gdcmSerieHelper.h"
34 #include "gdcmRLEFramesInfo.h"
35 #include "gdcmJPEGFragmentsInfo.h"
36 #include "gdcmSQItem.h"
37 #include "gdcmUtil.h"
38 #include "gdcmDocEntry.h"
39 #include "gdcmDataEntry.h"
40 #include "gdcmSeqEntry.h"
41 #include "gdcmVR.h"
42 #include "gdcmTS.h"
43 #include "gdcmDictGroupName.h"
44
45 /// This is required in order to avoid %including all the gdcm include files.
46 using namespace gdcm;
47 %}
48
49
50 ///////////////////////  typemap section  ////////////////////////////////////
51
52 ////////////////////////////////////////////////
53 // Redefine all types used
54 typedef char               int8_t;
55 typedef unsigned char      uint8_t;
56 typedef short              int16_t;
57 typedef unsigned short     uint16_t;
58 typedef int                int32_t;
59 typedef unsigned int       uint32_t;
60 typedef long long          int64_t;
61 typedef unsigned long long uint64_t;
62
63 ////////////////////////////////////////////////
64 // Convert a DocEntry * to the real derived class
65 %typemap(out) gdcm::DocEntry * 
66 {
67    PyObject *newEntry;
68
69    if($1)
70    {
71       if(dynamic_cast<SeqEntry *>($1)) // SeqEntry *
72          newEntry = SWIG_NewPointerObj($1,SWIGTYPE_p_gdcm__SeqEntry,0);
73       else if(dynamic_cast<DataEntry *>($1)) // DataEntry *
74          newEntry = SWIG_NewPointerObj($1,SWIGTYPE_p_gdcm__DataEntry,0);
75       else
76          newEntry = NULL;
77    }
78    else
79    {
80       newEntry = Py_BuildValue("");
81    }
82    $result = newEntry;
83 }
84
85 ////////////////////  STL string versus Python str  ////////////////////////
86 // Convertion returning a C++ string.
87 %typemap(out) std::string
88 {
89     $result = PyString_FromString(($1).c_str());
90 }
91
92 %typemap(out) string
93 {
94     $result = PyString_FromString(($1).c_str());
95 }
96
97 %typemap(out) std::string const &
98 {
99     $result = PyString_FromString(($1)->c_str());
100 }
101
102 // Convertion of incoming Python str to STL string
103 %typemap(python, in) const std::string, std::string
104 {
105   $1 = PyString_AsString($input);
106 }
107
108 // Same convertion as above but references (since swig converts C++
109 // refererences to pointers)
110 %typemap(python, in) std::string const &
111 {
112    $1 = new std::string( PyString_AsString( $input ) );
113 }
114
115 ////////////////////  gdcm.TagName versus Python str  //////////////////////
116 %typemap(out) gdcm::TagName, const gdcm::TagName &
117 {
118     $result = PyString_FromString(($1)->c_str());
119 }
120
121 // Convertion of incoming Python str to STL string
122 %typemap(python, in) const gdcm::TagName, gdcm::TagName
123 {
124   $1 = PyString_AsString($input);
125 }
126
127 // Same convertion as above but references (since swig converts C++
128 // refererences to pointers)
129 %typemap(python, in) gdcm::TagName const &
130 {
131    $1 = new std::string( PyString_AsString( $input ) );
132 }
133
134 ////////////////////////////////////////////////////////////////////////////
135 // Because overloading and %rename don't work together (see below Note 1)
136 // we need to ignore some methods (e.g. the overloaded default constructor).
137 // The gdcm::File class doesn't have any SetFilename method anyhow, and
138 // this constructor is only used internaly (not from the API) so this is
139 // not a big loss.
140 %ignore gdcm::binary_write(std::ostream &,uint32_t const &);
141 %ignore gdcm::binary_write(std::ostream &,uint16_t const &);
142
143 %ignore gdcm::VRKey::operator=(const VRKey &_val);
144 %ignore gdcm::VRKey::operator=(const std::string &_val);
145 %ignore gdcm::VRKey::operator=(const char *_val);
146 %ignore gdcm::VRKey::operator[](const unsigned int &_id) const;
147 %ignore gdcm::VRKey::operator[](const unsigned int &_id);
148
149 %ignore gdcm::TagKey::operator=(const TagKey &_val);
150 %ignore gdcm::TagKey::operator[](const unsigned int &_id) const;
151 %ignore gdcm::TagKey::operator[](const unsigned int &_id);
152
153 %ignore gdcm::DicomDir::SetStartMethod(DicomDir::Method *method,void *arg = NULL);
154 %ignore gdcm::DicomDir::SetProgressMethod(DicomDir::Method *method,void *arg = NULL);
155 %ignore gdcm::DicomDir::SetEndMethod(DicomDir::Method *method,void *arg = NULL);
156
157 // Ignore all placed in gdcmCommon.h
158 %ignore GDCM_UNKNOWN;
159 %ignore GDCM_UNFOUND;
160 %ignore GDCM_BINLOADED;
161 %ignore GDCM_NOTLOADED;
162 %ignore GDCM_UNREAD;
163 %ignore GDCM_NOTASCII;
164 %ignore GDCM_PIXELDATA;
165 %ignore GDCM_LEGACY;
166 %ignore GDCM_VRUNKNOWN;
167
168 %constant const char *UNKNOWN        = "gdcm::Unknown";
169 %constant const char *UNFOUND        = "gdcm::Unfound";
170 %constant const char *BINLOADED      = "gdcm::Binary data loaded";
171 %constant const char *NOTLOADED      = "gdcm::NotLoaded";
172 %constant const char *UNREAD         = "gdcm::UnRead";
173 %constant const char *GDCM_NOTASCII  = "gdcm::NotAscii";
174 %constant const char *GDCM_PIXELDATA = "gdcm::Pixel Data to be loaded";
175 %constant const char *VRUNKNOWN      = "  ";
176
177 ////////////////////////////////////////////////////////////////////////////
178 // Warning: Order matters !
179 %include "gdcmCommon.h"
180 %include "gdcmBase.h"
181 %include "gdcmRefCounter.h"
182 %include "gdcmCommand.h"
183 %include "gdcmCommandPy.h"
184 %include "gdcmDebug.h"
185 %include "gdcmCommandManager.h"
186 %include "gdcmTagKey.h"
187 %include "gdcmVRKey.h"
188 %include "gdcmDicomEntry.h"
189 %include "gdcmDictEntry.h"
190 %include "gdcmDict.h"
191 %include "gdcmDictSet.h"
192 %include "gdcmDocEntrySet.h"
193 %include "gdcmElementSet.h"
194 %include "gdcmSQItem.h"
195 %include "gdcmDicomDirElement.h"
196 %include "gdcmDicomDirObject.h"
197 %include "gdcmDicomDirImage.h"
198 %include "gdcmDicomDirSerie.h"
199 %include "gdcmDicomDirStudy.h"
200 %include "gdcmDicomDirPatient.h"
201 %include "gdcmDicomDirMeta.h"
202 %include "gdcmDocument.h"
203 %include "gdcmFile.h"
204 %include "gdcmSerieHelper.h"
205 %include "gdcmFileHelper.h"
206 %include "gdcmUtil.h"
207 %include "gdcmGlobal.h"
208 %include "gdcmDicomDir.h"
209 %include "gdcmDocEntry.h"
210 %include "gdcmDataEntry.h"
211 %include "gdcmSeqEntry.h"
212 %include "gdcmVR.h"
213 %include "gdcmTS.h"
214 %include "gdcmDictGroupName.h"