mirror of https://github.com/CGAL/cgal
Split constructor of Random
This commit is contained in:
parent
b8aa40feb8
commit
63c87af293
|
|
@ -46,6 +46,10 @@
|
||||||
|
|
||||||
namespace CGAL {
|
namespace CGAL {
|
||||||
|
|
||||||
|
namespace internal {
|
||||||
|
struct Random_print_seed{};
|
||||||
|
}
|
||||||
|
|
||||||
class Random {
|
class Random {
|
||||||
public:
|
public:
|
||||||
// types
|
// types
|
||||||
|
|
@ -65,8 +69,9 @@ public:
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
// creation
|
// creation
|
||||||
CGAL_EXPORT Random( const char* = 0);
|
CGAL_EXPORT Random( );
|
||||||
CGAL_EXPORT Random( unsigned int seed);
|
CGAL_EXPORT Random( internal::Random_print_seed );
|
||||||
|
CGAL_EXPORT Random( unsigned int seed );
|
||||||
|
|
||||||
// seed
|
// seed
|
||||||
CGAL_EXPORT unsigned int get_seed ( ) const;
|
CGAL_EXPORT unsigned int get_seed ( ) const;
|
||||||
|
|
@ -232,7 +237,7 @@ public:
|
||||||
inline Random& get_default_random()
|
inline Random& get_default_random()
|
||||||
{
|
{
|
||||||
#if (defined( CGAL_TEST_SUITE ) || defined( CGAL_PRINT_SEED )) && !defined(CGAL_HEADER_ONLY)
|
#if (defined( CGAL_TEST_SUITE ) || defined( CGAL_PRINT_SEED )) && !defined(CGAL_HEADER_ONLY)
|
||||||
CGAL_STATIC_THREAD_LOCAL_VARIABLE(Random, default_random, "print seed");
|
CGAL_STATIC_THREAD_LOCAL_VARIABLE(Random, default_random, internal::Random_print_seed() ));
|
||||||
#else
|
#else
|
||||||
CGAL_STATIC_THREAD_LOCAL_VARIABLE_0(Random, default_random);
|
CGAL_STATIC_THREAD_LOCAL_VARIABLE_0(Random, default_random);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -40,16 +40,28 @@ namespace CGAL {
|
||||||
// constructors
|
// constructors
|
||||||
CGAL_INLINE_FUNCTION
|
CGAL_INLINE_FUNCTION
|
||||||
Random::
|
Random::
|
||||||
Random( const char* print_seed /* = 0 */ )
|
Random()
|
||||||
: val(0)
|
: val(0)
|
||||||
{
|
{
|
||||||
// get system's time
|
// get system's time
|
||||||
std::time_t s;
|
std::time_t s;
|
||||||
std::time( &s);
|
std::time( &s);
|
||||||
seed = (unsigned int)s;
|
seed = (unsigned int)s;
|
||||||
if(print_seed != 0) {
|
// initialize random numbers generator
|
||||||
std::cerr << "CGAL::Random()::get_seed() = " << seed << std::endl;
|
rng.seed(static_cast<boost::int32_t>(seed));
|
||||||
}
|
random_value = get_int(0, 1<<15);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGAL_INLINE_FUNCTION
|
||||||
|
Random::
|
||||||
|
Random(internal::Random_print_seed)
|
||||||
|
: val(0)
|
||||||
|
{
|
||||||
|
// get system's time
|
||||||
|
std::time_t s;
|
||||||
|
std::time( &s);
|
||||||
|
seed = (unsigned int)s;
|
||||||
|
std::cerr << "CGAL::Random()::get_seed() = " << seed << std::endl;
|
||||||
// initialize random numbers generator
|
// initialize random numbers generator
|
||||||
rng.seed(static_cast<boost::int32_t>(seed));
|
rng.seed(static_cast<boost::int32_t>(seed));
|
||||||
random_value = get_int(0, 1<<15);
|
random_value = get_int(0, 1<<15);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue