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 internal {
|
||||
struct Random_print_seed{};
|
||||
}
|
||||
|
||||
class Random {
|
||||
public:
|
||||
// types
|
||||
|
|
@ -65,8 +69,9 @@ public:
|
|||
{}
|
||||
};
|
||||
// creation
|
||||
CGAL_EXPORT Random( const char* = 0);
|
||||
CGAL_EXPORT Random( unsigned int seed);
|
||||
CGAL_EXPORT Random( );
|
||||
CGAL_EXPORT Random( internal::Random_print_seed );
|
||||
CGAL_EXPORT Random( unsigned int seed );
|
||||
|
||||
// seed
|
||||
CGAL_EXPORT unsigned int get_seed ( ) const;
|
||||
|
|
@ -232,7 +237,7 @@ public:
|
|||
inline Random& get_default_random()
|
||||
{
|
||||
#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
|
||||
CGAL_STATIC_THREAD_LOCAL_VARIABLE_0(Random, default_random);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -40,16 +40,28 @@ namespace CGAL {
|
|||
// constructors
|
||||
CGAL_INLINE_FUNCTION
|
||||
Random::
|
||||
Random( const char* print_seed /* = 0 */ )
|
||||
Random()
|
||||
: val(0)
|
||||
{
|
||||
// get system's time
|
||||
std::time_t s;
|
||||
std::time( &s);
|
||||
seed = (unsigned int)s;
|
||||
if(print_seed != 0) {
|
||||
std::cerr << "CGAL::Random()::get_seed() = " << seed << std::endl;
|
||||
}
|
||||
// initialize random numbers generator
|
||||
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
|
||||
rng.seed(static_cast<boost::int32_t>(seed));
|
||||
random_value = get_int(0, 1<<15);
|
||||
|
|
|
|||
Loading…
Reference in New Issue