[MOAB-dev] create ray_intersect_all_sets function

hongjun at mcs.anl.gov hongjun at mcs.anl.gov
Mon Apr 5 10:57:54 CDT 2010


I think my way of communication looks wrong.
Sorry. I think I need more explanations here as follows.

To find all surface intersections to geomtry (not just only one intersection to geometry), current "ray_intersect_sets" needs large distance tolerance to cover all geometries.
The large tolerance makes it take long time to find all surface intersections. (several minutes for simple geometry)

My version is similar to the function "ray_intersect_triangles" as follows.
It does box intersection test at first to store intersected boxes and surface sets.
After that, it checks "GeomUtil::ray_tri_intersect" to do intersection check with triangles in stored boxes.
However, current "ray_intersect_sets" searches all leaf nodes within large tolerance and then do "GeomUtil::ray_tri_intersect" check for almost all triangles.

I think current "ray_intersect_sets" function is best to find the first intersection set but not to find all intersection sets.
That is one reason I made it as a new seperate function.
----------------------------------------------------------------------
ErrorCode OrientedBoxTreeTool::ray_intersect_all_sets( 
                                    std::vector<double>& distances_out,
                                    std::vector<EntityHandle>& sets_out,
                                    std::vector<EntityHandle>& facets_out,
                                    EntityHandle 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 )
{
  Range boxes, box_sets;
  ErrorCode rval;
  
  rval = ray_intersect_boxes_sets( boxes, box_sets, root_set, tolerance,
				   ray_point, unit_ray_dir, ray_length, accum );
  if (MB_SUCCESS != rval)
    return rval;
    
  return ray_intersect_all_sets( distances_out, sets_out, facets_out,
				 boxes, box_sets, tolerance,
				 ray_point, unit_ray_dir, ray_length );

  RayIntersectAllSets op( this, ray_point, unit_ray_dir, ray_length, tolerance, 
			  boxes, box_sets ); 
  return preorder_traverse( root_set, op, accum );
}
--------------------------------------------------------

> Why is your version faster?  How does the returned data/functionality
> differ
> from the existing function?  Did you look at the existing function in
> a
> profiler to see if it could easily be made faster?
> 
> > To minimize possible errors with other codes, I made it as a new
> function
> > not modyfing existing "MBOrientedBoxTreeTool::ray_intersect_sets"
> > function.
> > 
> 
> Having two functions that do almost the same thing will result in a
> confusing API.
> 
> > Is it ok to all for me to commit it? Thanks.
> > 
> 
> Does it do something significantly different than the existing
> function?
> Have you documented it in the header?  Did you add any unit tests for
> it?




> 
> - jason


More information about the moab-dev mailing list