XdmfCore.i 5.13 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/*
XdmfCorePython.cpp:
swig -v -c++ -python -o XdmfCorePython.cpp XdmfCore.i
*/

%module XdmfCore
%{
	#include <XdmfArray.hpp>
	#include <XdmfArrayType.hpp>
	#include <XdmfCoreItemFactory.hpp>
	#include <XdmfCoreReader.hpp>
	#include <XdmfDataItem.hpp>
	#include <XdmfHDF5Controller.hpp>
	#include <XdmfHDF5Writer.hpp>
15
	#include <XdmfInformation.hpp>
16 17
	#include <XdmfItem.hpp>
	#include <XdmfItemProperty.hpp>
18
	#include <XdmfSystemUtils.hpp>
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
	#include <XdmfVisitor.hpp>
	#include <XdmfWriter.hpp>
%}

%include boost_shared_ptr.i
%include std_string.i
%include std_vector.i
%include loki/Visitor.h

// Shared Pointer Templates
%shared_ptr(XdmfArray)
%shared_ptr(XdmfArrayType)
%shared_ptr(XdmfBaseVisitor)
%shared_ptr(XdmfCoreItemFactory)
%shared_ptr(XdmfCoreReader)
%shared_ptr(XdmfDataItem)
%shared_ptr(XdmfHDF5Controller)
%shared_ptr(XdmfHDF5Writer)
37
%shared_ptr(XdmfInformation)
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
%shared_ptr(XdmfItem)
%shared_ptr(XdmfItemProperty)
%shared_ptr(XdmfVisitor)
%shared_ptr(XdmfWriter)

// Abstract Base Classes
%template() Loki::BaseVisitable<void>;
%template() Loki::Visitor<XdmfArray>;
%template() Loki::Visitor<XdmfItem>;

%include XdmfItem.hpp
%include XdmfDataItem.hpp
%include XdmfItemProperty.hpp
%include XdmfVisitor.hpp

%include XdmfCoreItemFactory.hpp
%include XdmfCoreReader.hpp
55
%include XdmfInformation.hpp
56 57 58 59 60 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 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
%include XdmfHDF5Controller.hpp
%include XdmfHDF5Writer.hpp
%include XdmfWriter.hpp

%include XdmfArray.hpp
%include XdmfArrayType.hpp

%template(getValueCopyAsInt8) XdmfArray::getValueCopy<char>;
%template(getValueCopyAsInt16) XdmfArray::getValueCopy<short>;
%template(getValueCopyAsInt32) XdmfArray::getValueCopy<int>;
%template(getValueCopyAsInt64) XdmfArray::getValueCopy<long>;
%template(getValueCopyAsFloat32) XdmfArray::getValueCopy<float>;
%template(getValueCopyAsFloat64) XdmfArray::getValueCopy<double>;
%template(getValueCopyAsUInt8) XdmfArray::getValueCopy<unsigned char>;
%template(getValueCopyAsUInt16) XdmfArray::getValueCopy<unsigned short>;
%template(getValueCopyAsUInt32) XdmfArray::getValueCopy<unsigned int>;

%template(pushBackAsInt8) XdmfArray::pushBack<char>;
%template(pushBackAsInt16) XdmfArray::pushBack<short>;
%template(pushBackAsInt32) XdmfArray::pushBack<int>;
%template(pushBackAsInt64) XdmfArray::pushBack<long>;
%template(pushBackAsFloat32) XdmfArray::pushBack<float>;
%template(pushBackAsFloat64) XdmfArray::pushBack<double>;
%template(pushBackAsUInt8) XdmfArray::pushBack<unsigned char>;
%template(pushBackAsUInt16) XdmfArray::pushBack<unsigned short>;
%template(pushBackAsUInt32) XdmfArray::pushBack<unsigned int>;

%template(resizeAsInt8) XdmfArray::resize<char>;
%template(resizeAsInt16) XdmfArray::resize<short>;
%template(resizeAsInt32) XdmfArray::resize<int>;
%template(resizeAsInt64) XdmfArray::resize<long>;
%template(resizeAsFloat32) XdmfArray::resize<float>;
%template(resizeAsFloat64) XdmfArray::resize<double>;
%template(resizeAsUInt8) XdmfArray::resize<unsigned char>;
%template(resizeAsUInt16) XdmfArray::resize<unsigned short>;
%template(resizeAsUInt32) XdmfArray::resize<unsigned int>;

// Provide accessors from python lists to XdmfArrays
%extend XdmfArray {
	void copyValueAsInt8(int index, char value) {
		$self->copyValues(index, &value);
	}

	void copyValueAsInt16(int index, short value) {
		$self->copyValues(index, &value);
	}

	void copyValueAsInt32(int index, int value) {
		$self->copyValues(index, &value);
	}

	void copyValueAsInt64(int index, long value) {
		$self->copyValues(index, &value);
	}

	void copyValueAsFloat32(int index, float value) {
		$self->copyValues(index, &value);
	}

	void copyValueAsFloat64(int index, double value) {
		$self->copyValues(index, &value);
	}

	void copyValueAsUInt8(int index, unsigned char value) {
		$self->copyValues(index, &value);
	}

	void copyValueAsUInt16(int index, unsigned short value) {
		$self->copyValues(index, &value);
	}

	void copyValueAsUInt32(int index, unsigned int value) {
		$self->copyValues(index, &value);
	}
};

%extend XdmfArray {
	%pythoncode {
		def copyValuesAsInt8(self, startIndex, values):
			for i in range(0, len(values)):
				self.copyValueAsInt8(i+startIndex, values[i])

		def copyValuesAsInt16(self, startIndex, values):
			for i in range(0, len(values)):
				self.copyValueAsInt16(i+startIndex, values[i])

		def copyValuesAsInt32(self, startIndex, values):
			for i in range(0, len(values)):
				self.copyValueAsInt32(i+startIndex, values[i])

		def copyValuesAsInt64(self, startIndex, values):
			for i in range(0, len(values)):
				self.copyValueAsInt64(i+startIndex, values[i])

		def copyValuesAsFloat32(self, startIndex, values):
			for i in range(0, len(values)):
				self.copyValueAsFloat32(i+startIndex, values[i])

		def copyValuesAsFloat64(self, startIndex, values):
			for i in range(0, len(values)):
				self.copyValueAsFloat64(i+startIndex, values[i])

		def copyValuesAsUInt8(self, startIndex, values):
			for i in range(0, len(values)):
				self.copyValueAsUInt8(i+startIndex, values[i])

		def copyValuesAsUInt16(self, startIndex, values):
			for i in range(0, len(values)):
				self.copyValueAsUInt16(i+startIndex, values[i])

		def copyValuesAsUInt32(self, startIndex, values):
			for i in range(0, len(values)):
				self.copyValueAsUInt32(i+startIndex, values[i])
	};
};