Xdmf.i 12.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

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

32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
    // 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>
54
%}
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
55

56 57
%import XdmfCore.i

58 59
#ifdef SWIGJAVA

60
// Typemaps that work for Java
61

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

104 105 106
// Ignore multiple inheritance warning
#pragma SWIG nowarn=813

107
// Ignore const overloaded methods
108 109 110
%ignore XdmfCurvilinearGrid::getDimensions() const;
%ignore XdmfDomain::getCurvilinearGrid(const unsigned int) const;
%ignore XdmfDomain::getCurvilinearGrid(const std::string &) const;
111 112
%ignore XdmfDomain::getGridCollection(const unsigned int) const;
%ignore XdmfDomain::getGridCollection(const std::string &) const;
113 114 115 116 117 118
%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;
119 120 121
%ignore XdmfGrid::getAttribute(const unsigned int) const;
%ignore XdmfGrid::getAttribute(const std::string &) const;
%ignore XdmfGrid::getMap() const;
122 123 124
%ignore XdmfGrid::getMap(unsigned int const) const;
%ignore XdmfGrid::getMap(unsigned int const &) const;
%ignore XdmfGrid::getMap(std::string const &) const;
125 126 127
%ignore XdmfGrid::getSet(const unsigned int) const;
%ignore XdmfGrid::getSet(const std::string &) const;
%ignore XdmfGrid::getTime() const;
128 129 130 131 132 133
%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;
134 135 136 137
%ignore XdmfSet::getAttribute(const unsigned int) const;
%ignore XdmfSet::getAttribute(const std::string &) const;

// Ignore ItemTags
138
%ignore XdmfAttribute::ItemTag;
139
%ignore XdmfCurvilinearGrid::ItemTag;
140 141 142 143
%ignore XdmfDomain::ItemTag;
%ignore XdmfGeometry::ItemTag;
%ignore XdmfGrid::ItemTag;
%ignore XdmfGridCollection::ItemTag;
144
%ignore XdmfMap::ItemTag;
145 146
%ignore XdmfRectilinearGrid::ItemTag;
%ignore XdmfRegularGrid::ItemTag;
147 148 149
%ignore XdmfSet::ItemTag;
%ignore XdmfTime::ItemTag;
%ignore XdmfTopology::ItemTag;
150
%ignore XdmfUnstructuredGrid::ItemTag;
151 152

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

165
#endif /* SWIGJAVA */
166

167 168
#ifdef SWIGPYTHON

169 170 171 172 173 174 175
%include std_set.i
%include std_map.i

%template(XdmfMapNodeIdSet) std::set<int>;
%template(XdmfMapNodeIdMap) std::map<int, std::set<int> >;
%template(XdmfMapMap) std::map<int, std::map<int, std::set<int> > >;

176
%pythoncode {
177
    from XdmfCore import *
178 179
}

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

225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260
%extend XdmfAttributeCenter {
    bool __eq__(const XdmfAttributeCenter * attributeCenter) {
        return $self == attributeCenter;
    }
}

%extend XdmfAttributeType {
    bool __eq__(const XdmfAttributeType * attributeType) {
   	return $self == attributeType;
    }
}

%extend XdmfGeometryType {
    bool __eq__(const XdmfGeometryType * geometryType) {
   	return $self == geometryType;
    }
}

%extend XdmfGridCollectionType {
    bool __eq__(const XdmfGridCollectionType * gridCollectionType) {
   	return $self == gridCollectionType;
    }
}

%extend XdmfSetType {
    bool __eq__(const XdmfSetType * setType) {
   	return $self == setType;
    }
}

%extend XdmfTopologyType {
    bool __eq__(const XdmfTopologyType * topologyType) {
   	return $self == topologyType;
    }
}

261 262
#endif /* SWIGPYTHON */

263
// Shared Pointer Templates
264
%shared_ptr(XdmfAttribute)
265 266
%shared_ptr(XdmfAttributeCenter)
%shared_ptr(XdmfAttributeType)
267
%shared_ptr(XdmfCurvilinearGrid)
268 269
%shared_ptr(XdmfDomain)
%shared_ptr(XdmfGeometry)
270
%shared_ptr(XdmfGeometryType)
271 272
%shared_ptr(XdmfGrid)
%shared_ptr(XdmfGridCollection)
273 274
%shared_ptr(XdmfGridCollectionType)
%shared_ptr(XdmfItemFactory)
275
%shared_ptr(XdmfMap)
276
%shared_ptr(XdmfReader)
277 278
%shared_ptr(XdmfRectilinearGrid)
%shared_ptr(XdmfRegularGrid)
279 280
%shared_ptr(XdmfSet)
%shared_ptr(XdmfSetType)
281
%shared_ptr(XdmfTime)
282
%shared_ptr(XdmfTopology)
283
%shared_ptr(XdmfTopologyType)
284 285
%shared_ptr(XdmfUnstructuredGrid)

286
%include Xdmf.hpp
287
%include XdmfGrid.hpp
288

289
%include XdmfAttribute.hpp
290
%include XdmfAttributeCenter.hpp
291
%include XdmfAttributeType.hpp
292
%include XdmfCurvilinearGrid.hpp
Kenneth Leiter's avatar
Kenneth Leiter committed
293
%include XdmfDomain.hpp
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
294
%include XdmfGeometry.hpp
295
%include XdmfGeometryType.hpp
296 297 298
%include XdmfGridCollection.hpp
%include XdmfGridCollectionType.hpp
%include XdmfItemFactory.hpp
299
%include XdmfMap.hpp
300
%include XdmfReader.hpp
301 302
%include XdmfRectilinearGrid.hpp
%include XdmfRegularGrid.hpp
303 304
%include XdmfSet.hpp
%include XdmfSetType.hpp
305
%include XdmfTime.hpp
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
306
%include XdmfTopology.hpp
307
%include XdmfTopologyType.hpp
308
%include XdmfUnstructuredGrid.hpp