Skip to content

ray trace in 3d volume mesh #18

@fab6

Description

@fab6

Hi,

I pretty new to bvh and your implementation :-) Now I am a bit curious if I can apply it to calculate the path of a ray inside a 3d volume mesh. Looking at meshio it seems that one can read gmsh meshes, but I am not sure if this actually the use case!?
So one needs to extract the path inside each volume cell in combination with cell information like temperature.

I tried your example with a simple cube to understand a bit better what I can get out:

mesh = load("cube_default.obj")

# Generate bounding spheres around each triangle in the mesh
bounding_spheres = [BSphere{Float32}(tri) for tri in mesh]

# Build BVH
bvh = BVH(bounding_spheres, BBox{Float32}, UInt32)

points =[-10; 0; 0]
directions =[ 10; 0; 0]
# Traverse BVH to get indices of rays intersecting the bounding spheres
traversal = traverse_rays(bvh, points, directions)
@show traversal.contacts
println(traversal)

The cube is just:

v 1.000000 1.000000 -1.000000
v 1.000000 -1.000000 -1.000000
v 1.000000 1.000000 1.000000
v 1.000000 -1.000000 1.000000
v -1.000000 1.000000 -1.000000
v -1.000000 -1.000000 -1.000000
v -1.000000 1.000000 1.000000
v -1.000000 -1.000000 1.000000
f 1/1/1 5/2/1 7/3/1 3/4/1
f 4/5/2 3/4/2 7/6/2 8/7/2
f 8/8/3 7/9/3 5/10/3 6/11/3
f 6/12/4 2/13/4 4/5/4 8/14/4
f 2/13/5 1/1/5 3/4/5 4/5/5
f 6/11/6 5/10/6 1/1/6 2/13/6

The output is, but I don't understand yet what this means

traversal.contacts = Tuple{Int32, Int32}[(5, 1), (6, 1), (7, 1), (8, 1), (11, 1), (12, 1), (3, 1), (4, 1), (1, 1), (2, 1), (9, 1), (10, 1)]

I expected (hoped) that it gives me somehow the info of the intersection of the left surface and right surface of the cube.
Probably I complete misunderstood the approach and did not check in detail the documentation...

Maybe you have some info for my questions?
This would be great!

Best Regards
Fab

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions