Xdmf.i 11.9 KB
Newer Older
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
1
2
3
4
5
/*
XdmfPython.cpp:
swig -v -c++ -python -o XdmfPython.cpp Xdmf.i
*/

6
7
%module Xdmf
%{
8

9
    // XdmfCore Includes
10
11
12
13
14
15
16
    #include <Xdmf.hpp>
    #include <XdmfArray.hpp>
    #include <XdmfArrayType.hpp>
    #include <XdmfCoreItemFactory.hpp>
    #include <XdmfCoreReader.hpp>
    #include <XdmfHDF5Controller.hpp>
    #include <XdmfHDF5Writer.hpp>
17
#ifdef XDMF_BUILD_DSM
18
19
    #include <XdmfHDF5ControllerDSM.hpp>
    #include <XdmfHDF5WriterDSM.hpp>
20
#endif
21
22
23
24
25
26
27
28
    #include <XdmfHeavyDataController.hpp>
    #include <XdmfHeavyDataWriter.hpp>
    #include <XdmfInformation.hpp>
    #include <XdmfItem.hpp>
    #include <XdmfItemProperty.hpp>
    #include <XdmfSystemUtils.hpp>
    #include <XdmfVisitor.hpp>
    #include <XdmfWriter.hpp>
29

30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
    // Xdmf Includes
    #include <XdmfAttribute.hpp>
    #include <XdmfAttributeCenter.hpp>
    #include <XdmfAttributeType.hpp>
    #include <XdmfCurvilinearGrid.hpp>
    #include <XdmfDomain.hpp>
    #include <XdmfGeometry.hpp>
    #include <XdmfGeometryType.hpp>
    #include <XdmfGrid.hpp>
    #include <XdmfGridCollection.hpp>
    #include <XdmfGridCollectionType.hpp>
    #include <XdmfItemFactory.hpp>
    #include <XdmfMap.hpp>
    #include <XdmfReader.hpp>
    #include <XdmfRectilinearGrid.hpp>
    #include <XdmfRegularGrid.hpp>
    #include <XdmfSet.hpp>
    #include <XdmfSetType.hpp>
    #include <XdmfTime.hpp>
    #include <XdmfTopology.hpp>
    #include <XdmfTopologyType.hpp>
    #include <XdmfUnstructuredGrid.hpp>
52
%}
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
53

54
55
%import XdmfCore.i

56
57
#ifdef SWIGJAVA

58
// Typemaps that work for Java
59

60
%typemap(out)  boost::shared_ptr<XdmfItem> {
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
    if(boost::shared_ptr<XdmfAttribute> value = boost::shared_dynamic_cast<XdmfAttribute>($1)) {
        *(boost::shared_ptr< XdmfAttribute > **)&($result) = value ? new boost::shared_ptr< XdmfAttribute >(value) : 0;
    }
    else if(boost::shared_ptr<XdmfCurvilinearGrid> value = boost::shared_dynamic_cast<XdmfCurvilinearGrid>($1)) {
        *(boost::shared_ptr< XdmfCurvilinearGrid > **)&($result) = value ? new boost::shared_ptr< XdmfCurvilinearGrid >(value) : 0;
    }
    else if(boost::shared_ptr<XdmfDomain> value = boost::shared_dynamic_cast<XdmfDomain>($1)) {
        *(boost::shared_ptr< XdmfDomain > **)&($result) = value ? new boost::shared_ptr< XdmfDomain >(value) : 0;
    }
    else if(boost::shared_ptr<XdmfGeometry> value = boost::shared_dynamic_cast<XdmfGeometry>($1)) {
        *(boost::shared_ptr< XdmfGeometry > **)&($result) = value ? new boost::shared_ptr< XdmfGeometry >(value) : 0;
    }
    else if(boost::shared_ptr<XdmfGridCollection> value = boost::shared_dynamic_cast<XdmfGridCollection>($1)) {
        *(boost::shared_ptr< XdmfGridCollection > **)&($result) = value ? new boost::shared_ptr< XdmfGridCollection >(value) : 0;
    }
    else if(boost::shared_ptr<XdmfInformation> value = boost::shared_dynamic_cast<XdmfInformation>($1)) {
        *(boost::shared_ptr< XdmfInformation > **)&($result) = value ? new boost::shared_ptr< XdmfInformation >(value) : 0;
    }
    else if(boost::shared_ptr<XdmfRectilinearGrid> value = boost::shared_dynamic_cast<XdmfRectilinearGrid>($1)) {
        *(boost::shared_ptr< XdmfRectilinearGrid > **)&($result) = value ? new boost::shared_ptr< XdmfRectilinearGrid >(value) : 0;
    }
    else if(boost::shared_ptr<XdmfRegularGrid> value = boost::shared_dynamic_cast<XdmfRegularGrid>($1)) {
        *(boost::shared_ptr< XdmfRegularGrid > **)&($result) = value ? new boost::shared_ptr< XdmfRegularGrid >(value) : 0;
    }
    else if(boost::shared_ptr<XdmfSet> value = boost::shared_dynamic_cast<XdmfSet>($1)) {
        *(boost::shared_ptr< XdmfSet > **)&($result) = value ? new boost::shared_ptr< XdmfSet >(value) : 0;
    }
    else if(boost::shared_ptr<XdmfTime> value = boost::shared_dynamic_cast<XdmfTime>($1)) {
        *(boost::shared_ptr< XdmfTime > **)&($result) = value ? new boost::shared_ptr< XdmfTime >(value) : 0;
    }
    else if(boost::shared_ptr<XdmfTopology> value = boost::shared_dynamic_cast<XdmfTopology>($1)) {
        *(boost::shared_ptr< XdmfTopology > **)&($result) = value ? new boost::shared_ptr< XdmfTopology >(value) : 0;
    }
    else if(boost::shared_ptr<XdmfUnstructuredGrid> value = boost::shared_dynamic_cast<XdmfUnstructuredGrid>($1)) {
        *(boost::shared_ptr< XdmfUnstructuredGrid > **)&($result) = value ? new boost::shared_ptr< XdmfUnstructuredGrid >(value) : 0;
    }
    else {
        *(boost::shared_ptr< XdmfItem > **)&($result) = &($1);
    }
100
}
101

102
// Ignore const overloaded methods
103
104
105
%ignore XdmfCurvilinearGrid::getDimensions() const;
%ignore XdmfDomain::getCurvilinearGrid(const unsigned int) const;
%ignore XdmfDomain::getCurvilinearGrid(const std::string &) const;
106
107
%ignore XdmfDomain::getGridCollection(const unsigned int) const;
%ignore XdmfDomain::getGridCollection(const std::string &) const;
108
109
110
111
112
113
%ignore XdmfDomain::getRectilinearGrid(const unsigned int) const;
%ignore XdmfDomain::getRectilinearGrid(const std::string &) const;
%ignore XdmfDomain::getRegularGrid(const unsigned int) const;
%ignore XdmfDomain::getRegularGrid(const std::string &) const;
%ignore XdmfDomain::getUnstructuredGrid(const unsigned int) const;
%ignore XdmfDomain::getUnstructuredGrid(const std::string &) const;
114
115
116
117
118
119
%ignore XdmfGrid::getAttribute(const unsigned int) const;
%ignore XdmfGrid::getAttribute(const std::string &) const;
%ignore XdmfGrid::getMap() const;
%ignore XdmfGrid::getSet(const unsigned int) const;
%ignore XdmfGrid::getSet(const std::string &) const;
%ignore XdmfGrid::getTime() const;
120
121
122
123
124
125
%ignore XdmfRectilinearGrid::getCoordinates(const unsigned int) const;
%ignore XdmfRectilinearGrid::getCoordinates() const;
%ignore XdmfRectilinearGrid::getDimensions() const;
%ignore XdmfRegularGrid::getBrickSize() const;
%ignore XdmfRegularGrid::getDimensions() const;
%ignore XdmfRegularGrid::getOrigin() const;
126
127
128
129
%ignore XdmfSet::getAttribute(const unsigned int) const;
%ignore XdmfSet::getAttribute(const std::string &) const;

// Ignore ItemTags
130
%ignore XdmfAttribute::ItemTag;
131
%ignore XdmfCurvilinearGrid::ItemTag;
132
133
134
135
%ignore XdmfDomain::ItemTag;
%ignore XdmfGeometry::ItemTag;
%ignore XdmfGrid::ItemTag;
%ignore XdmfGridCollection::ItemTag;
136
%ignore XdmfMap::ItemTag;
137
138
%ignore XdmfRectilinearGrid::ItemTag;
%ignore XdmfRegularGrid::ItemTag;
139
140
141
%ignore XdmfSet::ItemTag;
%ignore XdmfTime::ItemTag;
%ignore XdmfTopology::ItemTag;
142
%ignore XdmfUnstructuredGrid::ItemTag;
143
144

%pragma(java) jniclasscode=%{
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
    static {
        try {
            System.loadLibrary("XdmfCoreJava");
        }
        catch (UnsatisfiedLinkError e) {
            System.err.println("Native code library failed to load for
                                XdmfCoreJava\n" + e);
            System.exit(1);
        }
        try {
            System.loadLibrary("XdmfJava");
        }
        catch (UnsatisfiedLinkError e) {
            System.err.println("Native code library failed to load for
                                XdmfJava\n" + e);
            System.exit(1);
        }
    }
163
164
%}

165
#endif */ SWIGJAVA */
166

167
168
169
#ifdef SWIGPYTHON

%pythoncode {
170
    from XdmfCore import *
171
172
173
}

%typemap(out) boost::shared_ptr<XdmfItem> {
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
    if(boost::shared_ptr<XdmfAttribute> attribute = boost::shared_dynamic_cast<XdmfAttribute>($1)) {
        $result = SWIG_NewPointerObj(SWIG_as_voidptr(new boost::shared_ptr<XdmfAttribute>(attribute)), SWIGTYPE_p_boost__shared_ptrT_XdmfAttribute_t, SWIG_POINTER_OWN);
    }
    else if(boost::shared_ptr<XdmfCurvilinearGrid> gridCurvilinear = boost::shared_dynamic_cast<XdmfCurvilinearGrid>($1)) {
        $result = SWIG_NewPointerObj(SWIG_as_voidptr(new boost::shared_ptr<XdmfCurvilinearGrid>(gridCurvilinear)), SWIGTYPE_p_boost__shared_ptrT_XdmfCurvilinearGrid_t, SWIG_POINTER_OWN);
    }
    else if(boost::shared_ptr<XdmfDomain> domain = boost::shared_dynamic_cast<XdmfDomain>($1)) {
        $result = SWIG_NewPointerObj(SWIG_as_voidptr(new boost::shared_ptr<XdmfDomain>(domain)), SWIGTYPE_p_boost__shared_ptrT_XdmfDomain_t, SWIG_POINTER_OWN);
    }
    else if(boost::shared_ptr<XdmfGeometry> geometry = boost::shared_dynamic_cast<XdmfGeometry>($1)) {
        $result = SWIG_NewPointerObj(SWIG_as_voidptr(new boost::shared_ptr<XdmfGeometry>(geometry)), SWIGTYPE_p_boost__shared_ptrT_XdmfGeometry_t, SWIG_POINTER_OWN);
    }
    else if(boost::shared_ptr<XdmfGridCollection> gridCollection = boost::shared_dynamic_cast<XdmfGridCollection>($1)) {
        $result = SWIG_NewPointerObj(SWIG_as_voidptr(new boost::shared_ptr<XdmfGridCollection>(gridCollection)), SWIGTYPE_p_boost__shared_ptrT_XdmfGridCollection_t, SWIG_POINTER_OWN);
    }
    else if(boost::shared_ptr<XdmfInformation> information = boost::shared_dynamic_cast<XdmfInformation>($1)) {
        $result = SWIG_NewPointerObj(SWIG_as_voidptr(new boost::shared_ptr<XdmfInformation>(information)), SWIGTYPE_p_boost__shared_ptrT_XdmfInformation_t, SWIG_POINTER_OWN);
    }
    else if(boost::shared_ptr<XdmfMap> map = boost::shared_dynamic_cast<XdmfMap>($1)) {
        $result = SWIG_NewPointerObj(SWIG_as_voidptr(new boost::shared_ptr<XdmfMap>(map)), SWIGTYPE_p_boost__shared_ptrT_XdmfMap_t, SWIG_POINTER_OWN);
    }
    else if(boost::shared_ptr<XdmfRectilinearGrid> gridRectilinear = boost::shared_dynamic_cast<XdmfRectilinearGrid>($1)) {
        $result = SWIG_NewPointerObj(SWIG_as_voidptr(new boost::shared_ptr<XdmfRectilinearGrid>(gridRectilinear)), SWIGTYPE_p_boost__shared_ptrT_XdmfRectilinearGrid_t, SWIG_POINTER_OWN);
    }
    else if(boost::shared_ptr<XdmfRegularGrid> gridRegular = boost::shared_dynamic_cast<XdmfRegularGrid>($1)) {
        $result = SWIG_NewPointerObj(SWIG_as_voidptr(new boost::shared_ptr<XdmfRegularGrid>(gridRegular)), SWIGTYPE_p_boost__shared_ptrT_XdmfRegularGrid_t, SWIG_POINTER_OWN);
    }
    else if(boost::shared_ptr<XdmfSet> set = boost::shared_dynamic_cast<XdmfSet>($1)) {
        $result = SWIG_NewPointerObj(SWIG_as_voidptr(new boost::shared_ptr<XdmfSet>(set)), SWIGTYPE_p_boost__shared_ptrT_XdmfSet_t, SWIG_POINTER_OWN);
    }
    else if(boost::shared_ptr<XdmfTime> time = boost::shared_dynamic_cast<XdmfTime>($1)) {
        $result = SWIG_NewPointerObj(SWIG_as_voidptr(new boost::shared_ptr<XdmfTime>(time)), SWIGTYPE_p_boost__shared_ptrT_XdmfTime_t, SWIG_POINTER_OWN);
    }
    else if(boost::shared_ptr<XdmfTopology> topology = boost::shared_dynamic_cast<XdmfTopology>($1)) {
        $result = SWIG_NewPointerObj(SWIG_as_voidptr(new boost::shared_ptr<XdmfTopology>(topology)), SWIGTYPE_p_boost__shared_ptrT_XdmfTopology_t, SWIG_POINTER_OWN);
    }
    else if(boost::shared_ptr<XdmfUnstructuredGrid> gridUnstructured = boost::shared_dynamic_cast<XdmfUnstructuredGrid>($1)) {
        $result = SWIG_NewPointerObj(SWIG_as_voidptr(new boost::shared_ptr<XdmfUnstructuredGrid>(gridUnstructured)), SWIGTYPE_p_boost__shared_ptrT_XdmfUnstructuredGrid_t, SWIG_POINTER_OWN);
    }
    else {
        $result = SWIG_NewPointerObj(SWIG_as_voidptr(new boost::shared_ptr<XdmfItem>($1)), SWIGTYPE_p_boost__shared_ptrT_XdmfItem_t, SWIG_POINTER_OWN);
    }
216
217
218
219
}

#endif /* SWIGPYTHON */

220
// Shared Pointer Templates
221
%shared_ptr(XdmfAttribute)
222
223
%shared_ptr(XdmfAttributeCenter)
%shared_ptr(XdmfAttributeType)
224
%shared_ptr(XdmfCurvilinearGrid)
225
226
%shared_ptr(XdmfDomain)
%shared_ptr(XdmfGeometry)
227
%shared_ptr(XdmfGeometryType)
228
229
%shared_ptr(XdmfGrid)
%shared_ptr(XdmfGridCollection)
230
231
%shared_ptr(XdmfGridCollectionType)
%shared_ptr(XdmfItemFactory)
232
%shared_ptr(XdmfMap)
233
%shared_ptr(XdmfReader)
234
235
%shared_ptr(XdmfRectilinearGrid)
%shared_ptr(XdmfRegularGrid)
236
237
%shared_ptr(XdmfSet)
%shared_ptr(XdmfSetType)
238
%shared_ptr(XdmfTime)
239
%shared_ptr(XdmfTopology)
240
%shared_ptr(XdmfTopologyType)
241
242
%shared_ptr(XdmfUnstructuredGrid)

243
%include Xdmf.hpp
244
%include XdmfGrid.hpp
245

246
%include XdmfAttribute.hpp
247
%include XdmfAttributeCenter.hpp
248
%include XdmfAttributeType.hpp
249
%include XdmfCurvilinearGrid.hpp
Kenneth Leiter's avatar
Kenneth Leiter committed
250
%include XdmfDomain.hpp
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
251
%include XdmfGeometry.hpp
252
%include XdmfGeometryType.hpp
253
254
255
%include XdmfGridCollection.hpp
%include XdmfGridCollectionType.hpp
%include XdmfItemFactory.hpp
256
%include XdmfMap.hpp
257
%include XdmfReader.hpp
258
259
%include XdmfRectilinearGrid.hpp
%include XdmfRegularGrid.hpp
260
261
%include XdmfSet.hpp
%include XdmfSetType.hpp
262
%include XdmfTime.hpp
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
263
%include XdmfTopology.hpp
264
%include XdmfTopologyType.hpp
265
%include XdmfUnstructuredGrid.hpp