File: SbRotation.i

package info (click to toggle)
pivy 0.6.4-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 10,904 kB
  • sloc: python: 36,310; cpp: 787; ansic: 728; makefile: 22; sh: 14
file content (46 lines) | stat: -rw-r--r-- 1,723 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
%typemap(in) float q[4] (float temp[4]) {
    convert_SbVec4f_array($input, temp);
    $1 = temp;
}

%typemap(typecheck) float q[4] {
    $1 = PySequence_Check($input) ? 1 : 0;
}

%typemap(out) float * {
  $result = Py_BuildValue("(ffff)",
                          (double)(*($1)),
                          (double)(*($1+1)),
                          (double)(*($1+2)),
                          (double)(*($1+3)));
}

/* add operator overloading methods instead of the global functions */
%extend SbRotation {
    SbRotation __mul__(const SbRotation &u) { return *self * u; }
    SbRotation __mul__(const double d) { SbRotation res(*self); return (res *= d); }
    SbVec3f __mul__(const SbVec3f & v) { SbVec3f res; self->multVec(v, res); return res; }
    int __eq__(const SbRotation &u) { return *self == u; }
    int __nq__(const SbRotation &u) { return *self != u; }
%pythoncode %{
    def __imul__(self, other):
        return self * other
%}
}

%apply float * OUTPUT { float & q0, float & q1, float & q2, float & q3, float & radians};

/* the next 2 typemaps handle the return value for getMatrix and getAxisAngle ~ getValue */
%typemap(in,numinputs=0) SbVec3f & axis, SbMatrix & matrix {
    $1 = new $1_basetype();
}
%typemap(argout) SbVec3f & axis, SbMatrix & matrix {
    $result = SWIG_NewPointerObj((void *) $1, $1_descriptor, 1);
}
/* undo effect of in typemap for setValue calls */
%typemap(in) const SbVec3f & axis = SWIGTYPE &;
%typemap(argout) const SbVec3f & axis {};

%ignore SbRotation::getValue(float & q0, float & q1, float & q2, float & q3) const;
%rename(getAxisAngle) SbRotation::getValue(SbVec3f & axis, float & radians) const;
%rename(getMatrix) SbRotation::getValue(SbMatrix & matrix) const;