1 // SWIG file FieldImplementation.i
2 
3 %{
4 #include "openturns/FieldImplementation.hxx"
5 %}
6 
7 %include FieldImplementation_doc.i
8 
9 #define OT_TYPECHECK_FIELDIMPLEMENTATION 3
10 
11 %typemap(typecheck,precedence=OT_TYPECHECK_FIELDIMPLEMENTATION) const FieldImplementation & {
12   $1  = SWIG_IsOK(SWIG_ConvertPtr($input, NULL, $1_descriptor, SWIG_POINTER_NO_NULL));
13   // || OT::isAPythonSequenceOf<OT::_PySequence_>( $input );
14 }
15 
16 %apply const FieldImplementation & { const OT::FieldImplementation & };
17 
18 %include openturns/FieldImplementation.hxx
19 
20 
21 namespace OT{
22 %extend FieldImplementation {
23 
__getitem__(SignedInteger index)24 Point __getitem__ (SignedInteger index) const
25 {
26   OT::UnsignedInteger size = self->getSize();
27   if (index < 0) {
28     index += self->getSize();
29   }
30   if (index < 0) {
31     throw OT::OutOfBoundException(HERE) << "index should be in [-" << size << ", " << size - 1 << "]." ;
32   }
33   return self->at(index);
34 }
35 
__setitem__(SignedInteger index,const Point & val)36 void __setitem__ (SignedInteger index,
37                   const Point & val)
38 {
39   OT::UnsignedInteger size = self->getSize();
40   if (index < 0) {
41     index += self->getSize();
42   }
43   if (index < 0) {
44     throw OT::OutOfBoundException(HERE) << "index should be in [-" << size << ", " << size - 1 << "]." ;
45   }
46   self->at(index) = val;
47 }
48 
49 
__len__()50 UnsignedInteger __len__() const
51 {
52   return self->getSize();
53 }
54 
__getitem__(PyObject * args)55 Scalar __getitem__(PyObject * args) const {
56 
57           OT::UnsignedInteger arg2 ;
58           OT::UnsignedInteger arg3 ;
59           unsigned long val2 ;
60           int ecode2 = 0 ;
61           unsigned long val3 ;
62           int ecode3 = 0 ;
63           PyObject * obj1 = 0 ;
64           PyObject * obj2 = 0 ;
65 
66           if (!PyArg_ParseTuple(args,(char *)"OO:FieldImplementation___getitem__",&obj1,&obj2)) SWIG_fail;
67 
68           ecode2 = SWIG_AsVal_unsigned_SS_long(obj1, &val2);
69           if (!SWIG_IsOK(ecode2)) {
70             SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "FieldImplementation___getitem__" "', argument " "2"" of type '" "OT::UnsignedInteger""'");
71           }
72           arg2 = static_cast< OT::UnsignedInteger >(val2);
73 
74 
75           ecode3 = SWIG_AsVal_unsigned_SS_long(obj2, &val3);
76           if (!SWIG_IsOK(ecode3)) {
77             SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "FieldImplementation___getitem__" "', argument " "3"" of type '" "OT::UnsignedInteger""'");
78           }
79           arg3 = static_cast< OT::UnsignedInteger >(val3);
80 
81           return (*self).at(arg2, arg3);
82 fail:
83           return 0.;
84 }
85 
86 
87 
__setitem__(PyObject * args,Scalar val)88 void __setitem__(PyObject * args, Scalar val) {
89 
90           OT::UnsignedInteger arg2 ;
91           OT::UnsignedInteger arg3 ;
92           unsigned long val2 ;
93           int ecode2 = 0 ;
94           unsigned long val3 ;
95           int ecode3 = 0 ;
96           PyObject * obj1 = 0 ;
97           PyObject * obj2 = 0 ;
98 
99           if (!PyArg_ParseTuple(args,(char *)"OO:FieldImplementation___setitem__",&obj1,&obj2)) SWIG_fail;
100 
101           ecode2 = SWIG_AsVal_unsigned_SS_long(obj1, &val2);
102           if (!SWIG_IsOK(ecode2)) {
103             SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "FieldImplementation___setitem__" "', argument " "2"" of type '" "OT::UnsignedInteger""'");
104           }
105           arg2 = static_cast< OT::UnsignedInteger >(val2);
106           ecode3 = SWIG_AsVal_unsigned_SS_long(obj2, &val3);
107           if (!SWIG_IsOK(ecode3)) {
108             SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "FieldImplementation___setitem__" "', argument " "3"" of type '" "OT::UnsignedInteger""'");
109           }
110           arg3 = static_cast< OT::UnsignedInteger >(val3);
111           (*self).at(arg2, arg3) = val;
112 fail:
113           return;
114 }
115 
FieldImplementation(const FieldImplementation & other)116 FieldImplementation(const FieldImplementation & other)
117 {
118   return new OT::FieldImplementation(other);
119 }
120 
121 
122 } // %extend
123 } // OT
124