[MOAB-dev] ray_intersect_sets function
Hongjun Kim
hongjun at mcs.anl.gov
Tue Mar 16 12:47:22 CDT 2010
Thanks for all your help.
Hong-Jun
----- Original Message -----
From: "Brandon Smith" <bsmith82 at yahoo.com>
To: hongjun at mcs.anl.gov
Cc: moab-dev at mcs.anl.gov
Sent: Tuesday, March 16, 2010 12:40:16 PM GMT -06:00 US/Canada Central
Subject: Re: [MOAB-dev] ray_intersect_sets function
Hi Hong-Jun,
Yes, to find every intersection the tolerance needs to be slightly larger than the distance of the farthest ray.
Brandon
From: "hongjun at mcs.anl.gov" <hongjun at mcs.anl.gov>
To: Brandon Smith <bsmith82 at yahoo.com>
Cc: moab-dev at mcs.anl.gov
Sent: Tue, March 16, 2010 12:36:16 PM
Subject: Re: [MOAB-dev] ray_intersect_sets function
Thank you for your reply.
It works for me when I set "tolerance" as 100 like you set.
So, do I have to increase the tolerance as large as distances between ray and all geometries?
Thanks.
Hong-Jun
----- Original Message -----
From: "Brandon Smith" < bsmith82 at yahoo.com >
To: hongjun at mcs.anl.gov
Cc: moab-dev at mcs.anl.gov
Sent: Monday, March 15, 2010 10:56:53 PM GMT -06:00 US/Canada Central
Subject: Re: [MOAB-dev] ray_intersect_sets function
Hi Hung-Jun,
Here is what I did:
1) In Cubit, I created a sphere or radius 10 centered at the origin and exported as *.sat (attached). It is a volume with one surface. I checked this using mbsize:
$ mbsize -g sphere.sat
File sphere.sat:
Read 1 ACIS Entities from the input file
ERROR: Attribute type -1 not recognized.
Constructed 1 Volume: 1
type count total minimum average rms maximum std.dev.
------- ------ ------- ----------------- ----------------- ----------------- ----------------- -----------------
Tri 69168 1.3e+03 0.00067391 0.018166 0.020102 0.028321 0.0086069
1D Side 207504 4.7e+04 0.0056637 0.22681 0.23829 0.33655 0.073068
Vertex 34586
Surface 1:
type count total minimum average rms maximum std.dev.
------- ------ ------- ----------------- ----------------- ----------------- ----------------- -----------------
Tri 69168 1.3e+03 0.00067391 0.018166 0.020102 0.028321 0.0086069
1D Side 207504 4.7e+04 0.0056637 0.22681 0.23829 0.33655 0.073068
Vertex 34586
Volume 1:
NO MESH
2) Use gdb to run ray_fire_test in /tools/dagmc. I use a debugger so that I can set variable values and check the results of MBOrientedBoxTreeTool::ray_intersect_sets. Fire a ray in the +x direction from (-20,0,0) against volume 1. This takes a long time to run because the default faceting tolerance is unexpectedly small (10^-4).
$ gdb ray_fire_test
(gdb) run -f -20 0 0 1 0 0 -i 1 sphere.sat
Firing user-specified rays at volume 1
Ray: point = [-20 0 0] dir = [1 0 0]
hits surf_id 1 dist=10.0001 new_xyz=[-9.99993 0 0]
done.
Things are looking good. With the default values of this test, the entrance intersection into the sphere was found at (-10,0,0).
3) Now try to find both intersections. Set a breakpoint before the ray_intersect_sets call and change the tolerance to a value larger than the farthest possible intersection in your geometry.
(gdb) run
(gdb) break MBOrientedBoxTreeTool::ray_intersect_sets
Breakpoint 2 at 0x45027a: file ../../../../trunk/src/MBOrientedBoxTreeTool.cpp, line 1030.
(gdb) continue
Breakpoint 2, MBOrientedBoxTreeTool::ray_intersect_sets (this=0x12c8210, distances_out=@0x12c84f0,
sets_out=@0x12c84c0, facets_out=@0x12c84d8, root_set=12682136550675316740, tolerance=0.001,
min_tolerace_intersections=1000, ray_point=0x7fff5d269e90, unit_ray_dir=0x7fff5d269e70,
ray_length=0x7fff5d269e68, accum=0x0) at ../../../../trunk/src/MBOrientedBoxTreeTool.cpp:1030
1030 min_tolerace_intersections, distances_out, sets_out, facets_out );
(gdb) set tolerance = 100
(gdb) next
1031 return preorder_traverse( root_set, op, accum );
(gdb) next
1032 }
(gdb) print distances_out.size()
$4 = 2
(gdb) print distances_out[0]
$5 = (const double &) @0x7680f80: 29.999929428100586
(gdb) print distances_out[1]
$6 = (const double &) @0x7680f88: 10.000070571899414
(gdb) print sets_out[0]
$7 = (const long unsigned int &) @0x73bfca0: 12682136550675316737
(gdb) print sets_out[1]
$8 = (const long unsigned int &) @0x73bfca8: 12682136550675316737
Because I changed the tolerance, both intersections were found (at 10 and 30). They are both from the only surface set.
Any leaf node that intersects the ray will have its triangles tested if the length of the ray is not limited. Sometimes it is limited as an optimization for particle tracking.
Brandon
From: " hongjun at mcs.anl.gov " < hongjun at mcs.anl.gov >
To: Brandon Smith < bsmith82 at yahoo.com >
Cc: moab-dev at mcs.anl.gov
Sent: Mon, March 15, 2010 9:33:20 PM
Subject: Re: [MOAB-dev] ray_intersect_sets function
I tried to run "ray_fire_test" with sphere, but I only can get one intersection per surface.
Could you please explain more how you tested it?
Did you get any case that the number of intersected distances/surfaces/facets are more than 1?
Since "MBOrientedBoxTreeTool::ray_intersect_sets" just find one leaf tree node intersected and check intersection test with triangles in the node, I think there can not be more than 1 intersections per surface.
Hong-Jun
----- Original Message -----
From: "Brandon Smith" < bsmith82 at yahoo.com >
To: hongjun at mcs.anl.gov
Cc: moab-dev at mcs.anl.gov
Sent: Saturday, March 13, 2010 10:53:24 PM GMT -06:00 US/Canada Central
Subject: Re: [MOAB-dev] ray_intersect_sets function
Hi Hong-Jun,
I like to use the ray_fire_test that Steve recently improved.
As a quick check, I was able to determine both intersections of a ray passing through a spherical surface. In Cubit I created a spherical volume, with one surface. I used ray_fire_test to cast a ray through the sphere (in one side, out the other). I set the tolerance in MBOrientedBoxTreeTool::ray_intersect_sets to a very large number.
This worked as desired and I found both intersections in a single surface meshset.
Brandon
----- Original Message ----
From: " hongjun at mcs.anl.gov " < hongjun at mcs.anl.gov >
To: Brandon Smith < bsmith82 at yahoo.com >
Cc: moab-dev at mcs.anl.gov
Sent: Sat, March 13, 2010 9:57:25 PM
Subject: Re: [MOAB-dev] ray_intersect_sets function
Thank you for your reply.
I used "min_tolerance_intersections" as 20000 which is large enough.
I think "ray_intersect_sets" finds an intersected box of leaf tree node and then, triangles only in the leaf tree node are checked for intersection again.
"min_tolerance_intersections" is used just for the latter triangle intersection check as a maximum number of intersection checks.
Therefore, only one intersection per geometry surface meshset is found.
If it is correct and it is not intended, I will change it.
Thanks.
Hong-Jun
----- Original Message -----
From: "Brandon Smith" < bsmith82 at yahoo.com >
To: hongjun at mcs.anl.gov , moab-dev at mcs.anl.gov
Sent: Friday, March 12, 2010 6:23:11 PM GMT -06:00 US/Canada Central
Subject: Re: [MOAB-dev] ray_intersect_sets function
Hi Hong-jun,
If I remember correctly (which I may not), this function returns up to min_tolerance_intersections outside of the tolerance distance, and all intersections inside of the tolerance distance. This is an optimization for particle tracking where in general, only the closest intersection is desired.
If you want all intersections, set the tolerance larger than the maximum extent of your geometry. Alternatively, set min_tolerance_intersections to a large number.
Brandon
----- Original Message ----
From: " hongjun at mcs.anl.gov " < hongjun at mcs.anl.gov >
To: moab-dev at mcs.anl.gov
Sent: Fri, March 12, 2010 5:30:44 PM
Subject: [MOAB-dev] ray_intersect_sets function
Hi! All
I have a question about ray tracing function,
MBOrientedBoxTreeTool::ray_intersect_sets(
std::vector<double>& distances_out,
std::vector<MBEntityHandle>& sets_out,
std::vector<MBEntityHandle>& facets_out,
MBEntityHandle root_set,
double tolerance,
unsigned min_tolerace_intersections,
const double ray_point[3],
const double unit_ray_dir[3],
const double* ray_length,
TrvStats* accum );
When I use this function, it just returns one intersection distance/set/facet for sphere or curved surfaces.
Is it a bug or is it intended?
Otherwise, am I using incorrectly?
Could any body give me some advices for me?
Thanks.
Hong-Jun
More information about the moab-dev
mailing list