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

%include std_string.i
%include std_vector.i

namespace boost {
10 11 12 13 14
  template<class T> class shared_ptr
  {
  public:
    T * operator-> () const;
  };
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
15 16
}

17
%template(XdmfAttributePtr) boost::shared_ptr<XdmfAttribute>;
Ken Leiter (Civ ARL/CISD) kleiter's avatar
ENH:  
Ken Leiter (Civ ARL/CISD) kleiter committed
18
%template(XdmfArrayPtr) boost::shared_ptr<XdmfArray>;
19
%template(XdmfDataItemPtr) boost::shared_ptr<XdmfDataItem>;
Kenneth Leiter's avatar
Kenneth Leiter committed
20
%template(XdmfDomainPtr) boost::shared_ptr<XdmfDomain>;
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
21 22
%template(XdmfGeometryPtr) boost::shared_ptr<XdmfGeometry>;
%template(XdmfGridPtr) boost::shared_ptr<XdmfGrid>;
23
%template(XdmfItemPtr) boost::shared_ptr<XdmfItem>;
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
24 25
%template(XdmfObjPtr) boost::shared_ptr<XdmfObject>;
%template(XdmfTopologyPtr) boost::shared_ptr<XdmfTopology>;
26
%template(XdmfVisitorPtr) boost::shared_ptr<XdmfVisitor>;
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
27 28 29

%module Xdmf
%{
Ken Leiter (Civ ARL/CISD) kleiter's avatar
ENH:  
Ken Leiter (Civ ARL/CISD) kleiter committed
30
  #include <XdmfArray.hpp>
31
  #include <XdmfAttribute.hpp>
32
  #include <XdmfAttributeCenter.hpp>
33
  #include <XdmfAttributeType.hpp>
34
  #include <XdmfDataItem.hpp>
Kenneth Leiter's avatar
Kenneth Leiter committed
35
  #include <XdmfDomain.hpp>
36
  #include <XdmfGeometry.hpp>
37
  #include <XdmfGeometryType.hpp>
38 39 40 41
  #include <XdmfGrid.hpp>
  #include <XdmfItem.hpp>
  #include <XdmfObject.hpp>
  #include <XdmfTopology.hpp>
42
  #include <XdmfTopologyType.hpp>
43
  #include <XdmfVisitor.hpp>
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
44 45 46 47
%}

%include XdmfObject.hpp

48 49 50
%include XdmfItem.hpp
%include XdmfVisitor.hpp

51 52
%include XdmfDataItem.hpp

53
%include XdmfAttribute.hpp
54
%include XdmfAttributeCenter.hpp
55
%include XdmfAttributeType.hpp
Ken Leiter (Civ ARL/CISD) kleiter's avatar
ENH:  
Ken Leiter (Civ ARL/CISD) kleiter committed
56
%include XdmfArray.hpp
Kenneth Leiter's avatar
Kenneth Leiter committed
57
%include XdmfDomain.hpp
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
58
%include XdmfGeometry.hpp
59
%include XdmfGeometryType.hpp
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
60 61
%include XdmfGrid.hpp
%include XdmfTopology.hpp
62
%include XdmfTopologyType.hpp
Ken Leiter (Civ ARL/CISD) kleiter's avatar
ENH:  
Ken Leiter (Civ ARL/CISD) kleiter committed
63

64
// Provide accessors from python lists to XdmfArrays
Ken Leiter (Civ ARL/CISD) kleiter's avatar
ENH:  
Ken Leiter (Civ ARL/CISD) kleiter committed
65
%extend XdmfArray {
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
  void copyValueAsChar(int index, char value) {
    $self->copyValues(index, &value);
  }

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

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

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

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

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

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

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

%extend boost::shared_ptr<XdmfArray> {
  %pythoncode {
    def copyValuesAsChar(self, startIndex, values):
      for i in range(0, len(values)):
        self.copyValueAsChar(i+startIndex, values[i])

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

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

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

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

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

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

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

    def copyValuesAsUInt(self, startIndex, values):
      for i in range(0, len(values)):
        self.copyValueAsUInt(i+startIndex, values[i])
  };
Ken Leiter (Civ ARL/CISD) kleiter's avatar
ENH:  
Ken Leiter (Civ ARL/CISD) kleiter committed
141
};