Commit f0faf9e1ec1b4a281f662cac9be8ed89bce6e624

Authored by Thiago Franco de Moraes
1 parent cc3c0dc3
Exists in ff_mask

Adapted invesalius cython extensions to use fused types

invesalius/data/cy_my_types.pxd
... ... @@ -2,4 +2,11 @@ import numpy as np
2 2 cimport numpy as np
3 3 cimport cython
4 4  
5   -ctypedef np.int16_t image_t
  5 +# ctypedef np.uint16_t image_t
  6 +
  7 +ctypedef fused image_t:
  8 + np.float64_t
  9 + np.int16_t
  10 + np.uint8_t
  11 +
  12 +ctypedef np.uint8_t mask_t
... ...
invesalius/data/transforms.pyx
... ... @@ -12,7 +12,7 @@ from cython.parallel import prange
12 12 @cython.boundscheck(False) # turn of bounds-checking for entire function
13 13 @cython.cdivision(True)
14 14 @cython.wraparound(False)
15   -cdef inline void mul_mat4_vec4(np.float64_t[:, :] M,
  15 +cdef inline void mul_mat4_vec4(double[:, :] M,
16 16 double* coord,
17 17 double* out) nogil:
18 18  
... ... @@ -25,7 +25,7 @@ cdef inline void mul_mat4_vec4(np.float64_t[:, :] M,
25 25 @cython.boundscheck(False) # turn of bounds-checking for entire function
26 26 @cython.cdivision(True)
27 27 @cython.wraparound(False)
28   -cdef image_t coord_transform(image_t[:, :, :] volume, np.float64_t[:, :] M, int x, int y, int z, double sx, double sy, double sz, short minterpol, image_t cval) nogil:
  28 +cdef image_t coord_transform(image_t[:, :, :] volume, double[:, :] M, int x, int y, int z, double sx, double sy, double sz, short minterpol, image_t cval) nogil:
29 29  
30 30 cdef double coord[4]
31 31 coord[0] = z*sz
... ... @@ -71,7 +71,7 @@ cdef image_t coord_transform(image_t[:, :, :] volume, np.float64_t[:, :] M, int
71 71 @cython.wraparound(False)
72 72 def apply_view_matrix_transform(image_t[:, :, :] volume,
73 73 spacing,
74   - np.float64_t[:, :] M,
  74 + double[:, :] M,
75 75 unsigned int n, str orientation,
76 76 int minterpol,
77 77 image_t cval,
... ...