From 9f79883b49ae42a2cbe6b26550e6f5890a2eb5cb Mon Sep 17 00:00:00 2001 From: Chris Gyurgyik <37983775+cgyurgyik@users.noreply.github.com> Date: Sat, 8 Feb 2020 21:33:16 -0500 Subject: [PATCH 1/6] Documentation for walk_volume. Contains necessary TODOs. --- yt/utilities/lib/grid_traversal.pxd | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/yt/utilities/lib/grid_traversal.pxd b/yt/utilities/lib/grid_traversal.pxd index f34be6cad54..7614821f9c7 100644 --- a/yt/utilities/lib/grid_traversal.pxd +++ b/yt/utilities/lib/grid_traversal.pxd @@ -29,6 +29,24 @@ ctypedef void sampler_function( int index[3], void *data) nogil +#----------------------------------------------------------------------------- +# walk_volume(VolumeContainer *vc, np.float64_t v_pos[3], np.float64_t v_dir[3], sampler_function *sample, +# void *data, np.float64_t *return_t = NULL, np.float64_t max_t = 1.0) +# vc VolumeContainer* : Pointer to the volume container to be traversed. +# v_pos np.float64_t[3] : The x,y,z coordinates of the ray's origin. +# v_dir np.float64_t[3] : The x,y,z coordinates of the ray's direction. +# sample sampler_function* : Pointer to the sample function to be used. +# return_t np.float64_t* : # TODO: Unsure of behavior. Defaulted to NULL. +# max_t np.float64_t : # TODO: Unsure of behavior. Defaulted to 1.0. +# +# Written by the yt Development Team. +# Encapsulates the Amanatides & Woo "Fast Traversal Voxel Algorithm" to walk over a volume container 'vc' +# The function occurs in two phases, initialization and traversal. +# See: https://www.researchgate.net/publication/2611491_A_Fast_Voxel_Traversal_Algorithm_for_Ray_Tracing +# +# TODO: Add more to this. walk_volume is a LARGE function. Breaking this function up into sub-components +# may lead to better readability and maintenance as well. +#----------------------------------------------------------------------------- cdef int walk_volume(VolumeContainer *vc, np.float64_t v_pos[3], np.float64_t v_dir[3], @@ -36,4 +54,3 @@ cdef int walk_volume(VolumeContainer *vc, void *data, np.float64_t *return_t = *, np.float64_t max_t = *) nogil - From 83de4d269a3f63b7038e8ec7779fb6c3d4d381c3 Mon Sep 17 00:00:00 2001 From: Chris Gyurgyik <37983775+cgyurgyik@users.noreply.github.com> Date: Sat, 8 Feb 2020 21:38:27 -0500 Subject: [PATCH 2/6] Remove whitespace. From a88ab0d062895f5d7744f8e83b265fc0085f46b9 Mon Sep 17 00:00:00 2001 From: Chris Gyurgyik <37983775+cgyurgyik@users.noreply.github.com> Date: Sun, 9 Feb 2020 21:11:47 -0500 Subject: [PATCH 3/6] Add returns. --- yt/utilities/lib/grid_traversal.pxd | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/yt/utilities/lib/grid_traversal.pxd b/yt/utilities/lib/grid_traversal.pxd index 7614821f9c7..489c87613db 100644 --- a/yt/utilities/lib/grid_traversal.pxd +++ b/yt/utilities/lib/grid_traversal.pxd @@ -43,9 +43,7 @@ ctypedef void sampler_function( # Encapsulates the Amanatides & Woo "Fast Traversal Voxel Algorithm" to walk over a volume container 'vc' # The function occurs in two phases, initialization and traversal. # See: https://www.researchgate.net/publication/2611491_A_Fast_Voxel_Traversal_Algorithm_for_Ray_Tracing -# -# TODO: Add more to this. walk_volume is a LARGE function. Breaking this function up into sub-components -# may lead to better readability and maintenance as well. +# Returns: The number of voxels hit during the traversal phase. If the traversal phase is not reached, returns 0. #----------------------------------------------------------------------------- cdef int walk_volume(VolumeContainer *vc, np.float64_t v_pos[3], From 70af3b8e8f7d4af6956920ab8fa3a444c0f09315 Mon Sep 17 00:00:00 2001 From: Chris Gyurgyik <37983775+cgyurgyik@users.noreply.github.com> Date: Sun, 9 Feb 2020 22:30:49 -0500 Subject: [PATCH 4/6] Update max_t, return_t. --- yt/utilities/lib/grid_traversal.pxd | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/yt/utilities/lib/grid_traversal.pxd b/yt/utilities/lib/grid_traversal.pxd index 489c87613db..199dceef3bf 100644 --- a/yt/utilities/lib/grid_traversal.pxd +++ b/yt/utilities/lib/grid_traversal.pxd @@ -36,8 +36,12 @@ ctypedef void sampler_function( # v_pos np.float64_t[3] : The x,y,z coordinates of the ray's origin. # v_dir np.float64_t[3] : The x,y,z coordinates of the ray's direction. # sample sampler_function* : Pointer to the sample function to be used. -# return_t np.float64_t* : # TODO: Unsure of behavior. Defaulted to NULL. -# max_t np.float64_t : # TODO: Unsure of behavior. Defaulted to 1.0. +# return_t np.float64_t* : Pointer to the final value of t that is still inside the volume container. Defaulted to NULL (nothing passed). +# max_t np.float64_t : The maximum value of t that the ray is allowed to travel. Defaulted to 1.0 (no restriction). +# +# Note: 't' is not time here. Rather, it is a factor representing the difference between the initial point 'v_pos' +# 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 +# v_end at t = 1.0. Therefore, if max_t is set to 1.0, there is no restriction on t. # # Written by the yt Development Team. # Encapsulates the Amanatides & Woo "Fast Traversal Voxel Algorithm" to walk over a volume container 'vc' From a902f1d65dd4294cf52e217262c2db758e742d1f Mon Sep 17 00:00:00 2001 From: Chris Gyurgyik <37983775+cgyurgyik@users.noreply.github.com> Date: Mon, 10 Feb 2020 16:50:57 -0500 Subject: [PATCH 5/6] Update comment about return_t. --- yt/utilities/lib/grid_traversal.pxd | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/yt/utilities/lib/grid_traversal.pxd b/yt/utilities/lib/grid_traversal.pxd index 199dceef3bf..cde7b2b5a10 100644 --- a/yt/utilities/lib/grid_traversal.pxd +++ b/yt/utilities/lib/grid_traversal.pxd @@ -32,14 +32,14 @@ ctypedef void sampler_function( #----------------------------------------------------------------------------- # walk_volume(VolumeContainer *vc, np.float64_t v_pos[3], np.float64_t v_dir[3], sampler_function *sample, # void *data, np.float64_t *return_t = NULL, np.float64_t max_t = 1.0) -# vc VolumeContainer* : Pointer to the volume container to be traversed. -# v_pos np.float64_t[3] : The x,y,z coordinates of the ray's origin. -# v_dir np.float64_t[3] : The x,y,z coordinates of the ray's direction. -# sample sampler_function* : Pointer to the sample function to be used. -# return_t np.float64_t* : Pointer to the final value of t that is still inside the volume container. Defaulted to NULL (nothing passed). -# max_t np.float64_t : The maximum value of t that the ray is allowed to travel. Defaulted to 1.0 (no restriction). +# vc VolumeContainer* : Pointer to the volume container to be traversed. +# v_pos np.float64_t[3] : The x,y,z coordinates of the ray's origin. +# v_dir np.float64_t[3] : The x,y,z coordinates of the ray's direction. +# sample sampler_function* : Pointer to the sample function to be used. +# return_t np.float64_t* : Pointer to the final value of t that is still inside the volume container. Defaulted to NULL. +# max_t np.float64_t : The maximum value of t that the ray is allowed to travel. Defaulted to 1.0 (no restriction). # -# Note: 't' is not time here. Rather, it is a factor representing the difference between the initial point 'v_pos' +# Note: 't' is not time here. Rather, it is a factor representing the difference between the initial point 'v_pos' # 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 # v_end at t = 1.0. Therefore, if max_t is set to 1.0, there is no restriction on t. # From c5dc82fbbaeb54cc60fbd5ebdd6c71bf190a5b6f Mon Sep 17 00:00:00 2001 From: Chris Gyurgyik <37983775+cgyurgyik@users.noreply.github.com> Date: Mon, 10 Feb 2020 16:59:16 -0500 Subject: [PATCH 6/6] Add 'r' to sampler. --- yt/utilities/lib/grid_traversal.pxd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yt/utilities/lib/grid_traversal.pxd b/yt/utilities/lib/grid_traversal.pxd index cde7b2b5a10..b62d565a1f1 100644 --- a/yt/utilities/lib/grid_traversal.pxd +++ b/yt/utilities/lib/grid_traversal.pxd @@ -35,7 +35,7 @@ ctypedef void sampler_function( # vc VolumeContainer* : Pointer to the volume container to be traversed. # v_pos np.float64_t[3] : The x,y,z coordinates of the ray's origin. # v_dir np.float64_t[3] : The x,y,z coordinates of the ray's direction. -# sample sampler_function* : Pointer to the sample function to be used. +# sample sampler_function* : Pointer to the sampler function to be used. # return_t np.float64_t* : Pointer to the final value of t that is still inside the volume container. Defaulted to NULL. # max_t np.float64_t : The maximum value of t that the ray is allowed to travel. Defaulted to 1.0 (no restriction). #