1"""
2Definitions for the traversal code
3
4
5
6
7"""
8
9
10import numpy as np
11
12cimport cython
13cimport numpy as np
14
15from .image_samplers cimport ImageSampler
16from .volume_container cimport VolumeContainer, vc_index, vc_pos_index
17
18ctypedef void sampler_function(
19                VolumeContainer *vc,
20                np.float64_t v_pos[3],
21                np.float64_t v_dir[3],
22                np.float64_t enter_t,
23                np.float64_t exit_t,
24                int index[3],
25                void *data) nogil
26
27#-----------------------------------------------------------------------------
28# walk_volume(VolumeContainer *vc,  np.float64_t v_pos[3], np.float64_t v_dir[3], sampler_function *sample,
29#             void *data, np.float64_t *return_t = NULL, np.float64_t max_t = 1.0)
30#    vc        VolumeContainer*  : Pointer to the volume container to be traversed.
31#    v_pos     np.float64_t[3]   : The x,y,z coordinates of the ray's origin.
32#    v_dir     np.float64_t[3]   : The x,y,z coordinates of the ray's direction.
33#    sample    sampler_function* : Pointer to the sampler function to be used.
34#    return_t  np.float64_t*     : Pointer to the final value of t that is still inside the volume container. Defaulted to NULL.
35#    max_t     np.float64_t      : The maximum value of t that the ray is allowed to travel. Defaulted to 1.0 (no restriction).
36#
37#    Note: 't' is not time here. Rather, it is a factor representing the difference between the initial point 'v_pos'
38#             and the end point, which we might call v_end. It is scaled such that v_pos + v * t = v_pos at t = 0.0, and
39#             v_end at t = 1.0. Therefore, if max_t is set to 1.0, there is no restriction on t.
40#
41# Written by the yt Development Team.
42# Encapsulates the Amanatides & Woo "Fast Traversal Voxel Algorithm" to walk over a volume container 'vc'
43# The function occurs in two phases, initialization and traversal.
44# See: https://www.researchgate.net/publication/2611491_A_Fast_Voxel_Traversal_Algorithm_for_Ray_Tracing
45# Returns: The number of voxels hit during the traversal phase. If the traversal phase is not reached, returns 0.
46#-----------------------------------------------------------------------------
47cdef int walk_volume(VolumeContainer *vc,
48                     np.float64_t v_pos[3],
49                     np.float64_t v_dir[3],
50                     sampler_function *sampler,
51                     void *data,
52                     np.float64_t *return_t = *,
53                     np.float64_t max_t = *) nogil
54