@@ -419,6 +419,11 @@ SShell::Class SShell::ClassifyRegion(Vector edge_n, Vector inter_surf_n,
419419// using the closest intersection point. If the ray hits a surface on edge,
420420// then just reattempt in a different random direction.
421421// -----------------------------------------------------------------------------
422+
423+ // table of vectors in 6 arbitrary directions covering 4 of the 8 octants.
424+ // use overlapping sets of 3 to reduce memory usage.
425+ static const double Random[8 ] = {1.278 , 5.0103 , 9.427 , -2.331 , 7.13 , 2.954 , 5.034 , -4.777 };
426+
422427bool SShell::ClassifyEdge (Class *indir, Class *outdir,
423428 Vector ea, Vector eb,
424429 Vector p,
@@ -549,7 +554,7 @@ bool SShell::ClassifyEdge(Class *indir, Class *outdir,
549554 // Cast a ray in a random direction (two-sided so that we test if
550555 // the point lies on a surface, but use only one side for in/out
551556 // testing)
552- Vector ray = Vector::From (Random ( 1 ) , Random ( 1 ) , Random ( 1 ) );
557+ Vector ray = Vector::From (Random[cnt] , Random[cnt+ 1 ] , Random[cnt+ 2 ] );
553558
554559 AllPointsIntersecting (
555560 p.Minus (ray), p.Plus (ray), &l,
@@ -598,7 +603,8 @@ bool SShell::ClassifyEdge(Class *indir, Class *outdir,
598603 // then our ray always lies on edge, and that's okay. Otherwise
599604 // try again in a different random direction.
600605 if (!onEdge) break ;
601- if (cnt++ > 5 ) {
606+ cnt++;
607+ if (cnt > 5 ) {
602608 dbp (" can't find a ray that doesn't hit on edge!" );
603609 dbp (" on edge = %d, edge_inters = %d" , onEdge, edge_inters);
604610 SS.nakedEdges .AddEdge (ea, eb);
0 commit comments