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

	// Xdmf Includes
31
32
33
	#include <XdmfAttribute.hpp>
	#include <XdmfAttributeCenter.hpp>
	#include <XdmfAttributeType.hpp>
34
	#include <XdmfCurvilinearGrid.hpp>
35
36
37
38
	#include <XdmfDomain.hpp>
	#include <XdmfGeometry.hpp>
	#include <XdmfGeometryType.hpp>
	#include <XdmfGrid.hpp>
39
40
	#include <XdmfGridCollection.hpp>
	#include <XdmfGridCollectionType.hpp>
41
	#include <XdmfItemFactory.hpp>
42
	#include <XdmfMap.hpp>
43
	#include <XdmfReader.hpp>
44
45
	#include <XdmfRectilinearGrid.hpp>
	#include <XdmfRegularGrid.hpp>
46
47
	#include <XdmfSet.hpp>
	#include <XdmfSetType.hpp>
48
	#include <XdmfTime.hpp>
49
50
	#include <XdmfTopology.hpp>
	#include <XdmfTopologyType.hpp>
51
	#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
61
%typemap(out)  boost::shared_ptr<XdmfItem> {
	if(boost::shared_ptr<XdmfAttribute> value = boost::shared_dynamic_cast<XdmfAttribute>($1))
62
	{
63
		*(boost::shared_ptr< XdmfAttribute > **)&($result) = value ? new boost::shared_ptr< XdmfAttribute >(value) : 0;
64
	}
65
66
67
68
	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;
	}
69
	else if(boost::shared_ptr<XdmfDomain> value = boost::shared_dynamic_cast<XdmfDomain>($1))
70
	{
71
		*(boost::shared_ptr< XdmfDomain > **)&($result) = value ? new boost::shared_ptr< XdmfDomain >(value) : 0;
72
	}
73
	else if(boost::shared_ptr<XdmfGeometry> value = boost::shared_dynamic_cast<XdmfGeometry>($1))
74
	{
75
		*(boost::shared_ptr< XdmfGeometry > **)&($result) = value ? new boost::shared_ptr< XdmfGeometry >(value) : 0;
76
	}
77
	else if(boost::shared_ptr<XdmfGridCollection> value = boost::shared_dynamic_cast<XdmfGridCollection>($1))
78
	{
79
		*(boost::shared_ptr< XdmfGridCollection > **)&($result) = value ? new boost::shared_ptr< XdmfGridCollection >(value) : 0;
80
	}
81
	else if(boost::shared_ptr<XdmfInformation> value = boost::shared_dynamic_cast<XdmfInformation>($1))
82
	{
83
		*(boost::shared_ptr< XdmfInformation > **)&($result) = value ? new boost::shared_ptr< XdmfInformation >(value) : 0;
84
	}
85
	else if(boost::shared_ptr<XdmfRectilinearGrid> value = boost::shared_dynamic_cast<XdmfRectilinearGrid>($1))
86
	{
87
		*(boost::shared_ptr< XdmfRectilinearGrid > **)&($result) = value ? new boost::shared_ptr< XdmfRectilinearGrid >(value) : 0;
88
	}
89
	else if(boost::shared_ptr<XdmfRegularGrid> value = boost::shared_dynamic_cast<XdmfRegularGrid>($1))
90
	{
91
		*(boost::shared_ptr< XdmfRegularGrid > **)&($result) = value ? new boost::shared_ptr< XdmfRegularGrid >(value) : 0;
92
	}
93
	else if(boost::shared_ptr<XdmfSet> value = boost::shared_dynamic_cast<XdmfSet>($1))
94
	{
95
		*(boost::shared_ptr< XdmfSet > **)&($result) = value ? new boost::shared_ptr< XdmfSet >(value) : 0;
96
	}
97
	else if(boost::shared_ptr<XdmfTime> value = boost::shared_dynamic_cast<XdmfTime>($1))
98
	{
99
100
101
102
103
		*(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;
104
	}
105
106
107
108
	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;
	}
109
110
	else
	{
111
		*(boost::shared_ptr< XdmfItem > **)&($result) = &($1);
112
113
	}
}
114

115
// Ignore const overloaded methods
116
117
118
%ignore XdmfCurvilinearGrid::getDimensions() const;
%ignore XdmfDomain::getCurvilinearGrid(const unsigned int) const;
%ignore XdmfDomain::getCurvilinearGrid(const std::string &) const;
119
120
%ignore XdmfDomain::getGridCollection(const unsigned int) const;
%ignore XdmfDomain::getGridCollection(const std::string &) const;
121
122
123
124
125
126
%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;
127
128
129
130
131
132
%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;
133
134
135
136
137
138
%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;
139
140
141
142
%ignore XdmfSet::getAttribute(const unsigned int) const;
%ignore XdmfSet::getAttribute(const std::string &) const;

// Ignore ItemTags
143
%ignore XdmfAttribute::ItemTag;
144
%ignore XdmfCurvilinearGrid::ItemTag;
145
146
147
148
%ignore XdmfDomain::ItemTag;
%ignore XdmfGeometry::ItemTag;
%ignore XdmfGrid::ItemTag;
%ignore XdmfGridCollection::ItemTag;
149
%ignore XdmfMap::ItemTag;
150
151
%ignore XdmfRectilinearGrid::ItemTag;
%ignore XdmfRegularGrid::ItemTag;
152
153
154
%ignore XdmfSet::ItemTag;
%ignore XdmfTime::ItemTag;
%ignore XdmfTopology::ItemTag;
155
%ignore XdmfUnstructuredGrid::ItemTag;
156
157

%pragma(java) jniclasscode=%{
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
	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);
		}
	}
179
180
%}

181
#endif */ SWIGJAVA */
182

183
184
185
186
187
188
189
190
191
192
193
#ifdef SWIGPYTHON

%pythoncode {
	from XdmfCore import *
}

%typemap(out) boost::shared_ptr<XdmfItem> {
	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);
	}
194
195
196
197
	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);
	}
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
	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);
	}
218
219
220
221
222
223
224
225
	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);
	}
226
227
228
229
230
231
232
233
234
235
236
237
	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);
	}
238
239
240
241
	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);
	}
242
243
244
245
246
247
248
249
	else
	{
		$result = SWIG_NewPointerObj(SWIG_as_voidptr(new boost::shared_ptr<XdmfItem>($1)), SWIGTYPE_p_boost__shared_ptrT_XdmfItem_t, SWIG_POINTER_OWN);
	}
}

#endif /* SWIGPYTHON */

250
// Shared Pointer Templates
251
%shared_ptr(XdmfAttribute)
252
253
%shared_ptr(XdmfAttributeCenter)
%shared_ptr(XdmfAttributeType)
254
%shared_ptr(XdmfCurvilinearGrid)
255
256
%shared_ptr(XdmfDomain)
%shared_ptr(XdmfGeometry)
257
%shared_ptr(XdmfGeometryType)
258
259
%shared_ptr(XdmfGrid)
%shared_ptr(XdmfGridCollection)
260
261
%shared_ptr(XdmfGridCollectionType)
%shared_ptr(XdmfItemFactory)
262
%shared_ptr(XdmfMap)
263
%shared_ptr(XdmfReader)
264
265
%shared_ptr(XdmfRectilinearGrid)
%shared_ptr(XdmfRegularGrid)
266
267
%shared_ptr(XdmfSet)
%shared_ptr(XdmfSetType)
268
%shared_ptr(XdmfTime)
269
%shared_ptr(XdmfTopology)
270
%shared_ptr(XdmfTopologyType)
271
272
%shared_ptr(XdmfUnstructuredGrid)

273
%include Xdmf.hpp
274
%include XdmfGrid.hpp
275

276
%include XdmfAttribute.hpp
277
%include XdmfAttributeCenter.hpp
278
%include XdmfAttributeType.hpp
279
%include XdmfCurvilinearGrid.hpp
Kenneth Leiter's avatar
Kenneth Leiter committed
280
%include XdmfDomain.hpp
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
281
%include XdmfGeometry.hpp
282
%include XdmfGeometryType.hpp
283
284
285
%include XdmfGridCollection.hpp
%include XdmfGridCollectionType.hpp
%include XdmfItemFactory.hpp
286
%include XdmfMap.hpp
287
%include XdmfReader.hpp
288
289
%include XdmfRectilinearGrid.hpp
%include XdmfRegularGrid.hpp
290
291
%include XdmfSet.hpp
%include XdmfSetType.hpp
292
%include XdmfTime.hpp
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
293
%include XdmfTopology.hpp
294
%include XdmfTopologyType.hpp
295
%include XdmfUnstructuredGrid.hpp