[yt-svn] commit/yt: 5 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Sun Nov 13 08:15:40 PST 2016
5 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/d9e59553583f/
Changeset: d9e59553583f
Branch: yt
User: atmyers
Date: 2016-09-30 21:55:00+00:00
Summary: some docstrings for the primitives.pyx file
Affected #: 1 file
diff -r 1d70bf4124996d584483c173e37f29670a73db99 -r d9e59553583f70d9c9e10dd971801502b8e35433 yt/utilities/lib/primitives.pyx
--- a/yt/utilities/lib/primitives.pyx
+++ b/yt/utilities/lib/primitives.pyx
@@ -1,3 +1,16 @@
+"""
+
+This file contains definitions of the various primitives that can be used
+by the Cython ray-tracer for unstructured mesh rendering. To define a new
+primitive type, you need to define a struct that represents it. You also
+need to provide three functions:
+
+1. A function that computes the intersection between a given ray and a given primitive.
+2. A function that computes the centroid of the primitive type.
+3. A function that computes the axis-aligned bounding box of a given primitive.
+
+"""
+
cimport cython
import numpy as np
cimport numpy as np
@@ -17,6 +30,13 @@
@cython.wraparound(False)
@cython.cdivision(True)
cdef np.int64_t ray_bbox_intersect(Ray* ray, const BBox bbox) nogil:
+'''
+
+This returns an integer flag that indicates whether a ray and a bounding
+box intersect. It does not modify either either the ray or the box.
+
+'''
+
# https://tavianator.com/fast-branchless-raybounding-box-intersections/
cdef np.float64_t tmin = -INF
@@ -38,6 +58,16 @@
cdef np.int64_t ray_triangle_intersect(const void* primitives,
const np.int64_t item,
Ray* ray) nogil:
+'''
+
+This returns an integer flag that indicates whether a triangle is the
+closest hit for the ray so far. If it is, the ray is updated to store the
+current triangle index and the distance to the first hit. The triangle used
+is the one indexed by "item" in the array of primitives.
+
+
+'''
+
# https://en.wikipedia.org/wiki/M%C3%B6ller%E2%80%93Trumbore_intersection_algorithm
cdef Triangle tri = (<Triangle*> primitives)[item]
@@ -87,6 +117,13 @@
cdef void triangle_centroid(const void *primitives,
const np.int64_t item,
np.float64_t[3] centroid) nogil:
+'''
+
+This computes the centroid of the input triangle. The triangle used
+is the one indexed by "item" in the array of primitives. The result
+will be stored in the numpy array passed in as "centroid".
+
+'''
cdef Triangle tri = (<Triangle*> primitives)[item]
cdef np.int64_t i
@@ -100,6 +137,13 @@
cdef void triangle_bbox(const void *primitives,
const np.int64_t item,
BBox* bbox) nogil:
+'''
+
+This computes the bounding box of the input triangle. The triangle used
+is the one indexed by "item" in the array of primitives. The result
+will be stored in the input BBox.
+
+'''
cdef Triangle tri = (<Triangle*> primitives)[item]
cdef np.int64_t i
@@ -115,7 +159,16 @@
const cython.floating u,
const cython.floating v,
cython.floating[3] S) nogil:
+'''
+This function is a parametric representation of the surface of a bi-quadratic
+patch. The inputs are the eight nodes that define a face of a 20-node hex element,
+and two parameters u and v that vary from -1 to 1 and tell you where you are on
+the surface of the patch. The output is the array 'S' that stores the physical
+(x, y, z) position of the corresponding point on the patch. This function is needed
+to compute the intersection of rays and bi-quadratic patches.
+
+'''
cdef int i
for i in range(3):
S[i] = 0.25*(1.0 - u)*(1.0 - v)*(-u - v - 1)*verts[0][i] + \
@@ -134,7 +187,12 @@
cdef void patchSurfaceDerivU(const cython.floating[8][3] verts,
const cython.floating u,
const cython.floating v,
- cython.floating[3] Su) nogil:
+ cython.floating[3] Su) nogil:
+'''
+
+This function computes the derivative of the S(u, v) function w.r.t u.
+
+'''
cdef int i
for i in range(3):
Su[i] = (-0.25*(v - 1.0)*(u + v + 1) - 0.25*(u - 1.0)*(v - 1.0))*verts[0][i] + \
@@ -152,6 +210,11 @@
const cython.floating u,
const cython.floating v,
cython.floating[3] Sv) nogil:
+'''
+
+This function computes the derivative of the S(u, v) function w.r.t v.
+
+'''
cdef int i
for i in range(3):
Sv[i] = (-0.25*(u - 1.0)*(u + v + 1) - 0.25*(u - 1.0)*(v - 1.0))*verts[0][i] + \
@@ -168,7 +231,13 @@
cdef RayHitData compute_patch_hit(cython.floating[8][3] verts,
cython.floating[3] ray_origin,
cython.floating[3] ray_direction) nogil:
+"""
+This function iteratively computes whether the bi-quadratic patch defined by the
+eight input nodes intersects with the given ray. Either way, information about
+the potential hit is stored in the returned RayHitData.
+
+"""
# first we compute the two planes that define the ray.
cdef cython.floating[3] n, N1, N2
cdef cython.floating A = dot(ray_direction, ray_direction)
@@ -243,7 +312,15 @@
cdef np.int64_t ray_patch_intersect(const void* primitives,
const np.int64_t item,
Ray* ray) nogil:
+'''
+This returns an integer flag that indicates whether the given patch is the
+closest hit for the ray so far. If it is, the ray is updated to store the
+current primitive index and the distance to the first hit. The patch used
+is the one indexed by "item" in the array of primitives.
+
+
+'''
cdef Patch patch = (<Patch*> primitives)[item]
cdef RayHitData hd = compute_patch_hit(patch.v, ray.origin, ray.direction)
@@ -267,6 +344,13 @@
cdef void patch_centroid(const void *primitives,
const np.int64_t item,
np.float64_t[3] centroid) nogil:
+'''
+
+This computes the centroid of the input patch. The patch used
+is the one indexed by "item" in the array of primitives. The result
+will be stored in the numpy array passed in as "centroid".
+
+'''
cdef np.int64_t i, j
cdef Patch patch = (<Patch*> primitives)[item]
@@ -289,6 +373,14 @@
const np.int64_t item,
BBox* bbox) nogil:
+'''
+
+This computes the bounding box of the input patch. The patch used
+is the one indexed by "item" in the array of primitives. The result
+will be stored in the input BBox.
+
+'''
+
cdef np.int64_t i, j
cdef Patch patch = (<Patch*> primitives)[item]
https://bitbucket.org/yt_analysis/yt/commits/9300f4828598/
Changeset: 9300f4828598
Branch: yt
User: atmyers
Date: 2016-09-30 22:06:31+00:00
Summary: expanding on the BVH docstrings
Affected #: 1 file
diff -r d9e59553583f70d9c9e10dd971801502b8e35433 -r 9300f48285986db774572dbbde6dc7a27c483c11 yt/utilities/lib/bounding_volume_hierarchy.pyx
--- a/yt/utilities/lib/bounding_volume_hierarchy.pyx
+++ b/yt/utilities/lib/bounding_volume_hierarchy.pyx
@@ -47,11 +47,25 @@
This class implements a bounding volume hierarchy (BVH), a spatial acceleration
structure for fast ray-tracing. A BVH is like a kd-tree, except that instead of
partitioning the *volume* of the parent to create the children, we partition the
- triangles themselves into 'left' or 'right' sub-trees. The bounding volume for a
- node is then determined by computing the bounding volume of the triangles that
- belong to it. This allows us to quickly discard triangles that are not close
+ primitives themselves into 'left' or 'right' sub-trees. The bounding volume for a
+ node is then determined by computing the bounding volume of the primitives that
+ belong to it. This allows us to quickly discard primitives that are not close
to intersecting a given ray.
+ This class is currently used to provide software 3D rendering support for
+ finite element datasets. For 1st-order meshes, every element of the mesh is
+ triangulated, and this set of triangles forms the primitives that will be used
+ for the ray-trace. The BVH can then quickly determine which element is hit by
+ each ray associated with the image plane, and the appropriate interpolation can
+ be performed to sample the finite element solution at that hit position.
+
+ Currently, 2nd-order meshes are only supported for 20-node hexahedral elements.
+ There, the primitive type is a bi-quadratic patch instead of a triangle, and
+ each intersection involves computing a Netwon-Raphson solve.
+
+ See yt/utilities/lib/primitives.pyx for the definitions of both of these primitive
+ types.
+
'''
@cython.boundscheck(False)
https://bitbucket.org/yt_analysis/yt/commits/764ccb01ba2c/
Changeset: 764ccb01ba2c
Branch: yt
User: atmyers
Date: 2016-09-30 22:14:21+00:00
Summary: Some more docstrings for the unstructured mesh Cython.
Affected #: 4 files
diff -r 9300f48285986db774572dbbde6dc7a27c483c11 -r 764ccb01ba2ca820ff1c1102bd9b49955616a4dd yt/utilities/lib/mesh_construction.pyx
--- a/yt/utilities/lib/mesh_construction.pyx
+++ b/yt/utilities/lib/mesh_construction.pyx
@@ -4,6 +4,7 @@
the interface between the internal representation of the mesh and the pyembree
representation.
+Note - this file is only used for the Embree-accelerated ray-tracer.
"""
diff -r 9300f48285986db774572dbbde6dc7a27c483c11 -r 764ccb01ba2ca820ff1c1102bd9b49955616a4dd yt/utilities/lib/mesh_intersection.pyx
--- a/yt/utilities/lib/mesh_intersection.pyx
+++ b/yt/utilities/lib/mesh_intersection.pyx
@@ -1,7 +1,8 @@
"""
-This file contains functions used for performing ray-tracing with 2nd-order Lagrange
-Elements.
+This file contains functions used for performing ray-tracing with Embree
+for 2nd-order Lagrange Elements.
+Note - this file is only used for the Embree-accelerated ray-tracer.
"""
diff -r 9300f48285986db774572dbbde6dc7a27c483c11 -r 764ccb01ba2ca820ff1c1102bd9b49955616a4dd yt/utilities/lib/mesh_samplers.pyx
--- a/yt/utilities/lib/mesh_samplers.pyx
+++ b/yt/utilities/lib/mesh_samplers.pyx
@@ -2,6 +2,7 @@
This file contains functions that sample a surface mesh at the point hit by
a ray. These can be used with pyembree in the form of "filter feedback functions."
+Note - this file is only used for the Embree-accelerated ray-tracer.
"""
diff -r 9300f48285986db774572dbbde6dc7a27c483c11 -r 764ccb01ba2ca820ff1c1102bd9b49955616a4dd yt/utilities/lib/mesh_triangulation.pyx
--- a/yt/utilities/lib/mesh_triangulation.pyx
+++ b/yt/utilities/lib/mesh_triangulation.pyx
@@ -1,3 +1,18 @@
+"""
+
+This file contains code for triangulating unstructured meshes. That is, for
+every element in the mesh, it breaks up the element into some number of
+triangles, returning a triangle mesh instead.
+
+It also contains code for removing duplicate triangles from the resulting
+mesh using a hash-table approach, so that we don't waste time rendering
+impossible-to-see triangles.
+
+This code is currently used by the OpenGL-accelerated unstructured mesh
+renderer, as well as when annotating mesh lines on regular slices.
+
+"""
+
import numpy as np
cimport numpy as np
cimport cython
https://bitbucket.org/yt_analysis/yt/commits/262a374c8774/
Changeset: 262a374c8774
Branch: yt
User: atmyers
Date: 2016-10-05 17:26:53+00:00
Summary: fixing docstring identation level
Affected #: 1 file
diff -r 764ccb01ba2ca820ff1c1102bd9b49955616a4dd -r 262a374c8774befc9c9b41d84cbc89970eff1001 yt/utilities/lib/primitives.pyx
--- a/yt/utilities/lib/primitives.pyx
+++ b/yt/utilities/lib/primitives.pyx
@@ -30,14 +30,14 @@
@cython.wraparound(False)
@cython.cdivision(True)
cdef np.int64_t ray_bbox_intersect(Ray* ray, const BBox bbox) nogil:
-'''
+ '''
+
+ This returns an integer flag that indicates whether a ray and a bounding
+ box intersect. It does not modify either either the ray or the box.
+
+ '''
-This returns an integer flag that indicates whether a ray and a bounding
-box intersect. It does not modify either either the ray or the box.
-
-'''
-
-# https://tavianator.com/fast-branchless-raybounding-box-intersections/
+ # https://tavianator.com/fast-branchless-raybounding-box-intersections/
cdef np.float64_t tmin = -INF
cdef np.float64_t tmax = INF
@@ -58,17 +58,17 @@
cdef np.int64_t ray_triangle_intersect(const void* primitives,
const np.int64_t item,
Ray* ray) nogil:
-'''
+ '''
+
+ This returns an integer flag that indicates whether a triangle is the
+ closest hit for the ray so far. If it is, the ray is updated to store the
+ current triangle index and the distance to the first hit. The triangle used
+ is the one indexed by "item" in the array of primitives.
+
+
+ '''
-This returns an integer flag that indicates whether a triangle is the
-closest hit for the ray so far. If it is, the ray is updated to store the
-current triangle index and the distance to the first hit. The triangle used
-is the one indexed by "item" in the array of primitives.
-
-
-'''
-
-# https://en.wikipedia.org/wiki/M%C3%B6ller%E2%80%93Trumbore_intersection_algorithm
+ # https://en.wikipedia.org/wiki/M%C3%B6ller%E2%80%93Trumbore_intersection_algorithm
cdef Triangle tri = (<Triangle*> primitives)[item]
@@ -117,13 +117,13 @@
cdef void triangle_centroid(const void *primitives,
const np.int64_t item,
np.float64_t[3] centroid) nogil:
-'''
-
-This computes the centroid of the input triangle. The triangle used
-is the one indexed by "item" in the array of primitives. The result
-will be stored in the numpy array passed in as "centroid".
-
-'''
+ '''
+
+ This computes the centroid of the input triangle. The triangle used
+ is the one indexed by "item" in the array of primitives. The result
+ will be stored in the numpy array passed in as "centroid".
+
+ '''
cdef Triangle tri = (<Triangle*> primitives)[item]
cdef np.int64_t i
@@ -137,14 +137,14 @@
cdef void triangle_bbox(const void *primitives,
const np.int64_t item,
BBox* bbox) nogil:
-'''
-
-This computes the bounding box of the input triangle. The triangle used
-is the one indexed by "item" in the array of primitives. The result
-will be stored in the input BBox.
-
-'''
-
+ '''
+
+ This computes the bounding box of the input triangle. The triangle used
+ is the one indexed by "item" in the array of primitives. The result
+ will be stored in the input BBox.
+
+ '''
+
cdef Triangle tri = (<Triangle*> primitives)[item]
cdef np.int64_t i
for i in range(3):
@@ -159,26 +159,26 @@
const cython.floating u,
const cython.floating v,
cython.floating[3] S) nogil:
-'''
-
-This function is a parametric representation of the surface of a bi-quadratic
-patch. The inputs are the eight nodes that define a face of a 20-node hex element,
-and two parameters u and v that vary from -1 to 1 and tell you where you are on
-the surface of the patch. The output is the array 'S' that stores the physical
-(x, y, z) position of the corresponding point on the patch. This function is needed
-to compute the intersection of rays and bi-quadratic patches.
-
-'''
- cdef int i
- for i in range(3):
- S[i] = 0.25*(1.0 - u)*(1.0 - v)*(-u - v - 1)*verts[0][i] + \
- 0.25*(1.0 + u)*(1.0 - v)*( u - v - 1)*verts[1][i] + \
- 0.25*(1.0 + u)*(1.0 + v)*( u + v - 1)*verts[2][i] + \
- 0.25*(1.0 - u)*(1.0 + v)*(-u + v - 1)*verts[3][i] + \
- 0.5*(1 - u)*(1 - v*v)*verts[4][i] + \
- 0.5*(1 - u*u)*(1 - v)*verts[5][i] + \
- 0.5*(1 + u)*(1 - v*v)*verts[6][i] + \
- 0.5*(1 - u*u)*(1 + v)*verts[7][i]
+ '''
+
+ This function is a parametric representation of the surface of a bi-quadratic
+ patch. The inputs are the eight nodes that define a face of a 20-node hex element,
+ and two parameters u and v that vary from -1 to 1 and tell you where you are on
+ the surface of the patch. The output is the array 'S' that stores the physical
+ (x, y, z) position of the corresponding point on the patch. This function is needed
+ to compute the intersection of rays and bi-quadratic patches.
+
+ '''
+ cdef int i
+ for i in range(3):
+ S[i] = 0.25*(1.0 - u)*(1.0 - v)*(-u - v - 1)*verts[0][i] + \
+ 0.25*(1.0 + u)*(1.0 - v)*( u - v - 1)*verts[1][i] + \
+ 0.25*(1.0 + u)*(1.0 + v)*( u + v - 1)*verts[2][i] + \
+ 0.25*(1.0 - u)*(1.0 + v)*(-u + v - 1)*verts[3][i] + \
+ 0.5*(1 - u)*(1 - v*v)*verts[4][i] + \
+ 0.5*(1 - u*u)*(1 - v)*verts[5][i] + \
+ 0.5*(1 + u)*(1 - v*v)*verts[6][i] + \
+ 0.5*(1 - u*u)*(1 + v)*verts[7][i]
@cython.boundscheck(False)
@@ -188,19 +188,19 @@
const cython.floating u,
const cython.floating v,
cython.floating[3] Su) nogil:
-'''
-
-This function computes the derivative of the S(u, v) function w.r.t u.
-
-'''
- cdef int i
- for i in range(3):
- Su[i] = (-0.25*(v - 1.0)*(u + v + 1) - 0.25*(u - 1.0)*(v - 1.0))*verts[0][i] + \
- (-0.25*(v - 1.0)*(u - v - 1) - 0.25*(u + 1.0)*(v - 1.0))*verts[1][i] + \
- ( 0.25*(v + 1.0)*(u + v - 1) + 0.25*(u + 1.0)*(v + 1.0))*verts[2][i] + \
- ( 0.25*(v + 1.0)*(u - v + 1) + 0.25*(u - 1.0)*(v + 1.0))*verts[3][i] + \
- 0.5*(v*v - 1.0)*verts[4][i] + u*(v - 1.0)*verts[5][i] - \
- 0.5*(v*v - 1.0)*verts[6][i] - u*(v + 1.0)*verts[7][i]
+ '''
+
+ This function computes the derivative of the S(u, v) function w.r.t u.
+
+ '''
+ cdef int i
+ for i in range(3):
+ Su[i] = (-0.25*(v - 1.0)*(u + v + 1) - 0.25*(u - 1.0)*(v - 1.0))*verts[0][i] + \
+ (-0.25*(v - 1.0)*(u - v - 1) - 0.25*(u + 1.0)*(v - 1.0))*verts[1][i] + \
+ ( 0.25*(v + 1.0)*(u + v - 1) + 0.25*(u + 1.0)*(v + 1.0))*verts[2][i] + \
+ ( 0.25*(v + 1.0)*(u - v + 1) + 0.25*(u - 1.0)*(v + 1.0))*verts[3][i] + \
+ 0.5*(v*v - 1.0)*verts[4][i] + u*(v - 1.0)*verts[5][i] - \
+ 0.5*(v*v - 1.0)*verts[6][i] - u*(v + 1.0)*verts[7][i]
@cython.boundscheck(False)
@@ -210,11 +210,11 @@
const cython.floating u,
const cython.floating v,
cython.floating[3] Sv) nogil:
-'''
-
-This function computes the derivative of the S(u, v) function w.r.t v.
-
-'''
+ '''
+
+ This function computes the derivative of the S(u, v) function w.r.t v.
+
+ '''
cdef int i
for i in range(3):
Sv[i] = (-0.25*(u - 1.0)*(u + v + 1) - 0.25*(u - 1.0)*(v - 1.0))*verts[0][i] + \
@@ -231,13 +231,13 @@
cdef RayHitData compute_patch_hit(cython.floating[8][3] verts,
cython.floating[3] ray_origin,
cython.floating[3] ray_direction) nogil:
-"""
-
-This function iteratively computes whether the bi-quadratic patch defined by the
-eight input nodes intersects with the given ray. Either way, information about
-the potential hit is stored in the returned RayHitData.
-
-"""
+ """
+
+ This function iteratively computes whether the bi-quadratic patch defined by the
+ eight input nodes intersects with the given ray. Either way, information about
+ the potential hit is stored in the returned RayHitData.
+
+ """
# first we compute the two planes that define the ray.
cdef cython.floating[3] n, N1, N2
cdef cython.floating A = dot(ray_direction, ray_direction)
@@ -312,15 +312,15 @@
cdef np.int64_t ray_patch_intersect(const void* primitives,
const np.int64_t item,
Ray* ray) nogil:
-'''
-
-This returns an integer flag that indicates whether the given patch is the
-closest hit for the ray so far. If it is, the ray is updated to store the
-current primitive index and the distance to the first hit. The patch used
-is the one indexed by "item" in the array of primitives.
-
-
-'''
+ '''
+
+ This returns an integer flag that indicates whether the given patch is the
+ closest hit for the ray so far. If it is, the ray is updated to store the
+ current primitive index and the distance to the first hit. The patch used
+ is the one indexed by "item" in the array of primitives.
+
+
+ '''
cdef Patch patch = (<Patch*> primitives)[item]
cdef RayHitData hd = compute_patch_hit(patch.v, ray.origin, ray.direction)
@@ -344,14 +344,14 @@
cdef void patch_centroid(const void *primitives,
const np.int64_t item,
np.float64_t[3] centroid) nogil:
-'''
-
-This computes the centroid of the input patch. The patch used
-is the one indexed by "item" in the array of primitives. The result
-will be stored in the numpy array passed in as "centroid".
-
-'''
-
+ '''
+
+ This computes the centroid of the input patch. The patch used
+ is the one indexed by "item" in the array of primitives. The result
+ will be stored in the numpy array passed in as "centroid".
+
+ '''
+
cdef np.int64_t i, j
cdef Patch patch = (<Patch*> primitives)[item]
@@ -373,13 +373,13 @@
const np.int64_t item,
BBox* bbox) nogil:
-'''
-
-This computes the bounding box of the input patch. The patch used
-is the one indexed by "item" in the array of primitives. The result
-will be stored in the input BBox.
-
-'''
+ '''
+
+ This computes the bounding box of the input patch. The patch used
+ is the one indexed by "item" in the array of primitives. The result
+ will be stored in the input BBox.
+
+ '''
cdef np.int64_t i, j
cdef Patch patch = (<Patch*> primitives)[item]
https://bitbucket.org/yt_analysis/yt/commits/5084dbec0f1d/
Changeset: 5084dbec0f1d
Branch: yt
User: atmyers
Date: 2016-11-12 23:14:14+00:00
Summary: merging with tip
Affected #: 6 files
diff -r 1a290fab65e430186f2c6e80ae19ae6084402dc4 -r 5084dbec0f1d46f3ea3782908daad4890a6adf68 yt/utilities/lib/bounding_volume_hierarchy.pyx
--- a/yt/utilities/lib/bounding_volume_hierarchy.pyx
+++ b/yt/utilities/lib/bounding_volume_hierarchy.pyx
@@ -55,11 +55,25 @@
This class implements a bounding volume hierarchy (BVH), a spatial acceleration
structure for fast ray-tracing. A BVH is like a kd-tree, except that instead of
partitioning the *volume* of the parent to create the children, we partition the
- triangles themselves into 'left' or 'right' sub-trees. The bounding volume for a
- node is then determined by computing the bounding volume of the triangles that
- belong to it. This allows us to quickly discard triangles that are not close
+ primitives themselves into 'left' or 'right' sub-trees. The bounding volume for a
+ node is then determined by computing the bounding volume of the primitives that
+ belong to it. This allows us to quickly discard primitives that are not close
to intersecting a given ray.
+ This class is currently used to provide software 3D rendering support for
+ finite element datasets. For 1st-order meshes, every element of the mesh is
+ triangulated, and this set of triangles forms the primitives that will be used
+ for the ray-trace. The BVH can then quickly determine which element is hit by
+ each ray associated with the image plane, and the appropriate interpolation can
+ be performed to sample the finite element solution at that hit position.
+
+ Currently, 2nd-order meshes are only supported for 20-node hexahedral elements.
+ There, the primitive type is a bi-quadratic patch instead of a triangle, and
+ each intersection involves computing a Netwon-Raphson solve.
+
+ See yt/utilities/lib/primitives.pyx for the definitions of both of these primitive
+ types.
+
'''
@cython.boundscheck(False)
diff -r 1a290fab65e430186f2c6e80ae19ae6084402dc4 -r 5084dbec0f1d46f3ea3782908daad4890a6adf68 yt/utilities/lib/mesh_construction.pyx
--- a/yt/utilities/lib/mesh_construction.pyx
+++ b/yt/utilities/lib/mesh_construction.pyx
@@ -4,6 +4,7 @@
the interface between the internal representation of the mesh and the pyembree
representation.
+Note - this file is only used for the Embree-accelerated ray-tracer.
"""
diff -r 1a290fab65e430186f2c6e80ae19ae6084402dc4 -r 5084dbec0f1d46f3ea3782908daad4890a6adf68 yt/utilities/lib/mesh_intersection.pyx
--- a/yt/utilities/lib/mesh_intersection.pyx
+++ b/yt/utilities/lib/mesh_intersection.pyx
@@ -1,7 +1,8 @@
"""
-This file contains functions used for performing ray-tracing with 2nd-order Lagrange
-Elements.
+This file contains functions used for performing ray-tracing with Embree
+for 2nd-order Lagrange Elements.
+Note - this file is only used for the Embree-accelerated ray-tracer.
"""
diff -r 1a290fab65e430186f2c6e80ae19ae6084402dc4 -r 5084dbec0f1d46f3ea3782908daad4890a6adf68 yt/utilities/lib/mesh_samplers.pyx
--- a/yt/utilities/lib/mesh_samplers.pyx
+++ b/yt/utilities/lib/mesh_samplers.pyx
@@ -2,6 +2,7 @@
This file contains functions that sample a surface mesh at the point hit by
a ray. These can be used with pyembree in the form of "filter feedback functions."
+Note - this file is only used for the Embree-accelerated ray-tracer.
"""
diff -r 1a290fab65e430186f2c6e80ae19ae6084402dc4 -r 5084dbec0f1d46f3ea3782908daad4890a6adf68 yt/utilities/lib/mesh_triangulation.pyx
--- a/yt/utilities/lib/mesh_triangulation.pyx
+++ b/yt/utilities/lib/mesh_triangulation.pyx
@@ -1,3 +1,18 @@
+"""
+
+This file contains code for triangulating unstructured meshes. That is, for
+every element in the mesh, it breaks up the element into some number of
+triangles, returning a triangle mesh instead.
+
+It also contains code for removing duplicate triangles from the resulting
+mesh using a hash-table approach, so that we don't waste time rendering
+impossible-to-see triangles.
+
+This code is currently used by the OpenGL-accelerated unstructured mesh
+renderer, as well as when annotating mesh lines on regular slices.
+
+"""
+
import numpy as np
cimport numpy as np
cimport cython
diff -r 1a290fab65e430186f2c6e80ae19ae6084402dc4 -r 5084dbec0f1d46f3ea3782908daad4890a6adf68 yt/utilities/lib/primitives.pyx
--- a/yt/utilities/lib/primitives.pyx
+++ b/yt/utilities/lib/primitives.pyx
@@ -1,3 +1,16 @@
+"""
+
+This file contains definitions of the various primitives that can be used
+by the Cython ray-tracer for unstructured mesh rendering. To define a new
+primitive type, you need to define a struct that represents it. You also
+need to provide three functions:
+
+1. A function that computes the intersection between a given ray and a given primitive.
+2. A function that computes the centroid of the primitive type.
+3. A function that computes the axis-aligned bounding box of a given primitive.
+
+"""
+
cimport cython
import numpy as np
cimport numpy as np
@@ -17,7 +30,14 @@
@cython.wraparound(False)
@cython.cdivision(True)
cdef np.int64_t ray_bbox_intersect(Ray* ray, const BBox bbox) nogil:
-# https://tavianator.com/fast-branchless-raybounding-box-intersections/
+ '''
+
+ This returns an integer flag that indicates whether a ray and a bounding
+ box intersect. It does not modify either either the ray or the box.
+
+ '''
+
+ # https://tavianator.com/fast-branchless-raybounding-box-intersections/
cdef np.float64_t tmin = -INF
cdef np.float64_t tmax = INF
@@ -38,7 +58,17 @@
cdef np.int64_t ray_triangle_intersect(const void* primitives,
const np.int64_t item,
Ray* ray) nogil:
-# https://en.wikipedia.org/wiki/M%C3%B6ller%E2%80%93Trumbore_intersection_algorithm
+ '''
+
+ This returns an integer flag that indicates whether a triangle is the
+ closest hit for the ray so far. If it is, the ray is updated to store the
+ current triangle index and the distance to the first hit. The triangle used
+ is the one indexed by "item" in the array of primitives.
+
+
+ '''
+
+ # https://en.wikipedia.org/wiki/M%C3%B6ller%E2%80%93Trumbore_intersection_algorithm
cdef Triangle tri = (<Triangle*> primitives)[item]
@@ -87,6 +117,13 @@
cdef void triangle_centroid(const void *primitives,
const np.int64_t item,
np.float64_t[3] centroid) nogil:
+ '''
+
+ This computes the centroid of the input triangle. The triangle used
+ is the one indexed by "item" in the array of primitives. The result
+ will be stored in the numpy array passed in as "centroid".
+
+ '''
cdef Triangle tri = (<Triangle*> primitives)[item]
cdef np.int64_t i
@@ -100,7 +137,14 @@
cdef void triangle_bbox(const void *primitives,
const np.int64_t item,
BBox* bbox) nogil:
-
+ '''
+
+ This computes the bounding box of the input triangle. The triangle used
+ is the one indexed by "item" in the array of primitives. The result
+ will be stored in the input BBox.
+
+ '''
+
cdef Triangle tri = (<Triangle*> primitives)[item]
cdef np.int64_t i
for i in range(3):
@@ -115,17 +159,26 @@
const cython.floating u,
const cython.floating v,
cython.floating[3] S) nogil:
-
- cdef int i
- for i in range(3):
- S[i] = 0.25*(1.0 - u)*(1.0 - v)*(-u - v - 1)*verts[0][i] + \
- 0.25*(1.0 + u)*(1.0 - v)*( u - v - 1)*verts[1][i] + \
- 0.25*(1.0 + u)*(1.0 + v)*( u + v - 1)*verts[2][i] + \
- 0.25*(1.0 - u)*(1.0 + v)*(-u + v - 1)*verts[3][i] + \
- 0.5*(1 - u)*(1 - v*v)*verts[4][i] + \
- 0.5*(1 - u*u)*(1 - v)*verts[5][i] + \
- 0.5*(1 + u)*(1 - v*v)*verts[6][i] + \
- 0.5*(1 - u*u)*(1 + v)*verts[7][i]
+ '''
+
+ This function is a parametric representation of the surface of a bi-quadratic
+ patch. The inputs are the eight nodes that define a face of a 20-node hex element,
+ and two parameters u and v that vary from -1 to 1 and tell you where you are on
+ the surface of the patch. The output is the array 'S' that stores the physical
+ (x, y, z) position of the corresponding point on the patch. This function is needed
+ to compute the intersection of rays and bi-quadratic patches.
+
+ '''
+ cdef int i
+ for i in range(3):
+ S[i] = 0.25*(1.0 - u)*(1.0 - v)*(-u - v - 1)*verts[0][i] + \
+ 0.25*(1.0 + u)*(1.0 - v)*( u - v - 1)*verts[1][i] + \
+ 0.25*(1.0 + u)*(1.0 + v)*( u + v - 1)*verts[2][i] + \
+ 0.25*(1.0 - u)*(1.0 + v)*(-u + v - 1)*verts[3][i] + \
+ 0.5*(1 - u)*(1 - v*v)*verts[4][i] + \
+ 0.5*(1 - u*u)*(1 - v)*verts[5][i] + \
+ 0.5*(1 + u)*(1 - v*v)*verts[6][i] + \
+ 0.5*(1 - u*u)*(1 + v)*verts[7][i]
@cython.boundscheck(False)
@@ -135,14 +188,19 @@
const cython.floating u,
const cython.floating v,
cython.floating[3] Su) nogil:
- cdef int i
- for i in range(3):
- Su[i] = (-0.25*(v - 1.0)*(u + v + 1) - 0.25*(u - 1.0)*(v - 1.0))*verts[0][i] + \
- (-0.25*(v - 1.0)*(u - v - 1) - 0.25*(u + 1.0)*(v - 1.0))*verts[1][i] + \
- ( 0.25*(v + 1.0)*(u + v - 1) + 0.25*(u + 1.0)*(v + 1.0))*verts[2][i] + \
- ( 0.25*(v + 1.0)*(u - v + 1) + 0.25*(u - 1.0)*(v + 1.0))*verts[3][i] + \
- 0.5*(v*v - 1.0)*verts[4][i] + u*(v - 1.0)*verts[5][i] - \
- 0.5*(v*v - 1.0)*verts[6][i] - u*(v + 1.0)*verts[7][i]
+ '''
+
+ This function computes the derivative of the S(u, v) function w.r.t u.
+
+ '''
+ cdef int i
+ for i in range(3):
+ Su[i] = (-0.25*(v - 1.0)*(u + v + 1) - 0.25*(u - 1.0)*(v - 1.0))*verts[0][i] + \
+ (-0.25*(v - 1.0)*(u - v - 1) - 0.25*(u + 1.0)*(v - 1.0))*verts[1][i] + \
+ ( 0.25*(v + 1.0)*(u + v - 1) + 0.25*(u + 1.0)*(v + 1.0))*verts[2][i] + \
+ ( 0.25*(v + 1.0)*(u - v + 1) + 0.25*(u - 1.0)*(v + 1.0))*verts[3][i] + \
+ 0.5*(v*v - 1.0)*verts[4][i] + u*(v - 1.0)*verts[5][i] - \
+ 0.5*(v*v - 1.0)*verts[6][i] - u*(v + 1.0)*verts[7][i]
@cython.boundscheck(False)
@@ -152,6 +210,12 @@
const cython.floating u,
const cython.floating v,
cython.floating[3] Sv) nogil:
+ '''
+
+ This function computes the derivative of the S(u, v) function w.r.t v.
+
+ '''
+
cdef int i
for i in range(3):
Sv[i] = (-0.25*(u - 1.0)*(u + v + 1) - 0.25*(u - 1.0)*(v - 1.0))*verts[0][i] + \
@@ -168,7 +232,13 @@
cdef RayHitData compute_patch_hit(cython.floating[8][3] verts,
cython.floating[3] ray_origin,
cython.floating[3] ray_direction) nogil:
-
+ """
+
+ This function iteratively computes whether the bi-quadratic patch defined by the
+ eight input nodes intersects with the given ray. Either way, information about
+ the potential hit is stored in the returned RayHitData.
+
+ """
# first we compute the two planes that define the ray.
cdef cython.floating[3] n, N1, N2
cdef cython.floating A = dot(ray_direction, ray_direction)
@@ -243,7 +313,15 @@
cdef np.int64_t ray_patch_intersect(const void* primitives,
const np.int64_t item,
Ray* ray) nogil:
-
+ '''
+
+ This returns an integer flag that indicates whether the given patch is the
+ closest hit for the ray so far. If it is, the ray is updated to store the
+ current primitive index and the distance to the first hit. The patch used
+ is the one indexed by "item" in the array of primitives.
+
+
+ '''
cdef Patch patch = (<Patch*> primitives)[item]
cdef RayHitData hd = compute_patch_hit(patch.v, ray.origin, ray.direction)
@@ -267,7 +345,14 @@
cdef void patch_centroid(const void *primitives,
const np.int64_t item,
np.float64_t[3] centroid) nogil:
-
+ '''
+
+ This computes the centroid of the input patch. The patch used
+ is the one indexed by "item" in the array of primitives. The result
+ will be stored in the numpy array passed in as "centroid".
+
+ '''
+
cdef np.int64_t i, j
cdef Patch patch = (<Patch*> primitives)[item]
@@ -289,6 +374,14 @@
const np.int64_t item,
BBox* bbox) nogil:
+ '''
+
+ This computes the bounding box of the input patch. The patch used
+ is the one indexed by "item" in the array of primitives. The result
+ will be stored in the input BBox.
+
+ '''
+
cdef np.int64_t i, j
cdef Patch patch = (<Patch*> primitives)[item]
Repository URL: https://bitbucket.org/yt_analysis/yt/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the yt-svn
mailing list