- Move random generator to CGAL::Random.

This commit is contained in:
Sylvain Pion 2004-01-21 13:03:34 +00:00
parent 3a486c8c57
commit 3b9dd3946f
4 changed files with 9 additions and 37 deletions

View File

@ -1,3 +1,6 @@
Version 1.190 (?? January 04)
- Move random generator to CGAL::Random.
Version 1.189 (18 January 04)
- Replace obsolete CGAL_TYPENAME_MSVC_NULL by typename.
- Remove CGAL_CFG_EARLY_INSTANTIATION_BUG.

View File

@ -41,6 +41,7 @@
#include <CGAL/function_objects.h>
#include <CGAL/functional.h>
#include <CGAL/Iterator_project.h>
#include <CGAL/Random.h>
CGAL_BEGIN_NAMESPACE
@ -204,6 +205,7 @@ protected:
Tds _tds;
GT _gt;
Vertex_handle infinite; //infinite vertex
mutable Random rng;
Comparison_result
compare_xyz(const Point &p, const Point &q) const
@ -1464,8 +1466,8 @@ locate(const Point & p, Locate_type & lt, int & li, int & lj,
}
// FIXME: do more benchmarks.
i = rand_4(); // For the (remembering) stochastic walk
// i = 0; // For the (remembering) visibility walk. Ok for Delaunay only
i = rng.template get_bits<2>(); // For the remembering stochastic walk
// i = 0; // For the remembering visibility walk. Ok for Delaunay only
Orientation test_or = (i&1)==0 ? NEGATIVE : POSITIVE;
const Point & p1 = c->vertex( (i+1)&3 )->point();
@ -1607,7 +1609,7 @@ locate(const Point & p, Locate_type & lt, int & li, int & lj,
// else c is finite
// we test its edges in a random order until we find a
// neighbor to go further
i = rand_3();
i = rng.get_int(0, 3);
const Point & p0 = c->vertex( i )->point();
const Point & p1 = c->vertex( ccw(i) )->point();
const Point & p2 = c->vertex( cw(i) )->point();

View File

@ -33,8 +33,6 @@ template < class T = void >
struct Triangulation_utils_base_3
{
static const char tab_next_around_edge[4][4];
static unsigned int random_value, count, val;
};
template < class T >
@ -44,16 +42,6 @@ const char Triangulation_utils_base_3<T>::tab_next_around_edge[4][4] = {
{1, 3, 5, 0},
{2, 0, 1, 5} };
template < class T >
unsigned int Triangulation_utils_base_3<T>::random_value = 0;
template < class T >
unsigned int Triangulation_utils_base_3<T>::count = 0;
template < class T >
unsigned int Triangulation_utils_base_3<T>::val;
// We derive from Triangulation_cw_ccw_2 because we still use cw() and ccw()
// in the 2D part of the code. Ideally, this should go away when we re-use
// T2D entirely.
@ -71,28 +59,6 @@ struct Triangulation_utils_3
( i != j ) );
return tab_next_around_edge[i][j];
}
// rand_4() outputs pseudo random unsigned ints < 4.
// We compute random 16 bit values, that we slice/shift to make it faster.
static unsigned int rand_4()
{
if (count==0)
{
count = 16;
random_value = (421 * random_value + 2073) % 32749;
val = random_value;
}
count--;
unsigned int ret = val & 3;
val = val >> 1;
return ret;
}
static unsigned int rand_3()
{
unsigned int i = rand_4();
return i==3 ? 0 : i;
}
};
CGAL_END_NAMESPACE

View File

@ -11,6 +11,7 @@ include $(CGAL_MAKEFILE)
#---------------------------------------------------------------------#
CXXFLAGS = \
-I../../../All/Random_numbers/include \
-I../../include \
-I./include \
$(CGAL_CXXFLAGS) \