19 std::cerr <<
"obb_time [-r <int>] [-i <int>] <filename>" << std::endl
20 <<
" -r - Specify total rays to fire." << std::endl
21 <<
" Zero implies unbounded. Default: " <<
NUM_RAYS << std::endl
22 <<
" -i - Specify total intersecting rays to fire." << std::endl
23 <<
" Zero implies unbounded. Default: " <<
NUM_XSCT << std::endl
24 <<
" -s - Use set-based tree." << std::endl
25 <<
" -p - Measure and report traversal performance statistics" << std::endl
26 <<
" The input file should be generated using the '-s'" << std::endl
27 <<
" option with 'obb_test'" << std::endl;
33 const int H = RAND_MAX / 2;
34 point[0] = (double)rand() / H - 1;
35 point[1] = (double)rand() / H - 1;
36 point[2] = (double)rand() / H - 1;
37 point *= sphere_radius;
39 dir[0] = (double)rand() * -point[0];
40 dir[1] = (double)rand() * -point[1];
41 dir[2] = (double)rand() * -point[2];
44 point += sphere_center;
57 return instance->
tag_get_data( tag, &root, 1, &tree_root_out );
75 std::cout <<
filename <<
":" << std::endl
76 <<
rays <<
" of " <<
num_rays <<
" ray fires done" << std::endl
77 <<
xsct <<
" of " <<
num_xsct <<
" intersecting fires" << std::endl
78 <<
gen <<
" unique rays used" << std::endl
79 << (double)
ttimer / CLOCKS_PER_SEC <<
" seconds" << std::endl;
84 int main(
int argc,
char* argv[] )
88 for(
int i = 1; i < argc; ++i )
90 if( !strcmp( argv[i],
"-r" ) )
93 if( i == argc || !argv[i][0] )
95 std::cerr <<
"Expected value following '-r'" << std::endl;
99 long t1 = strtol( argv[i], &end, 0 );
101 if( *end || t1 < 0 ||
num_rays != t1 )
103 std::cerr <<
"Expected positive integer following '-r'" << std::endl;
107 else if( !strcmp( argv[i],
"-i" ) )
110 if( i == argc || !argv[i][0] )
112 std::cerr <<
"Expected value following '-i'" << std::endl;
116 long t1 = strtol( argv[i], &end, 0 );
118 if( *end || t1 < 0 ||
num_xsct != t1 )
120 std::cerr <<
"Expected positive integer following '-i'" << std::endl;
124 else if( !strcmp( argv[i],
"-s" ) )
128 else if( !strcmp( argv[i],
"-p" ) )
134 std::cerr <<
"Invalid options or multiple file names specified." << std::endl;
144 std::cerr <<
"No file name specified." << std::endl;
154 std::cerr <<
"Failed to read \"" <<
filename <<
'"' << std::endl;
160 rval = tool.
box( root,
box );
163 std::cerr <<
"Corrupt tree. Cannot get box for root node." << std::endl;
173 const unsigned cached = 1000;
174 std::vector< double > intersections;
175 std::vector< EntityHandle > sets, facets;
177 std::vector< CartVect > randrays;
178 randrays.reserve( cached );
196 if( randrays.size() < cached )
203 point = randrays[cached_idx++];
204 dir = randrays[cached_idx++];
205 cached_idx = cached_idx % randrays.size();
208 intersections.clear();
217 search_win, int_reg_ctxt, stats );
226 std::cerr <<
"Rayfire #" <<
rays <<
" failed." << std::endl;
230 if( !intersections.empty() )
237 randrays.push_back( point );
238 randrays.push_back( dir );
243 std::cout <<
rays <<
" ray fires done" << std::endl
244 <<
gen <<
" unique rays used" << std::endl
245 <<
xsct <<
" intersecting fires" << std::endl
246 << (double)
ttimer / CLOCKS_PER_SEC <<
" seconds" << std::endl;
250 std::cout <<
"Traversal statistics: " << std::endl;
251 stats->
print( std::cout );