mirror of https://github.com/CGAL/cgal
Change rng; Remove random_shuffle
This commit is contained in:
parent
7a6f7f3e21
commit
be700acaba
|
|
@ -187,7 +187,6 @@ public:
|
|||
int n = number_of_vertices();
|
||||
|
||||
std::vector<Point> points (first, last);
|
||||
std::random_shuffle (points.begin(), points.end());
|
||||
spatial_sort (points.begin(), points.end(), geom_traits());
|
||||
Face_handle f;
|
||||
for (typename std::vector<Point>::const_iterator p = points.begin(), end = points.end();
|
||||
|
|
|
|||
|
|
@ -248,7 +248,6 @@ public:
|
|||
int n = number_of_vertices();
|
||||
|
||||
std::vector<Point> points (first, last);
|
||||
std::random_shuffle (points.begin(), points.end());
|
||||
CGAL::spatial_sort (points.begin(), points.end(), geom_traits());
|
||||
|
||||
Face_handle hint;
|
||||
|
|
|
|||
|
|
@ -204,7 +204,6 @@ public:
|
|||
|
||||
std::vector<Point> points (first, last);
|
||||
|
||||
std::random_shuffle (points.begin(), points.end());
|
||||
spatial_sort (points.begin(), points.end(), geom_traits());
|
||||
|
||||
Face_handle hint;
|
||||
|
|
|
|||
|
|
@ -163,7 +163,6 @@ public:
|
|||
int n = this->number_of_vertices();
|
||||
|
||||
std::vector<Point> points (first, last);
|
||||
std::random_shuffle (points.begin(), points.end());
|
||||
spatial_sort (points.begin(), points.end(), geom_traits());
|
||||
Face_handle f;
|
||||
for (typename std::vector<Point>::const_iterator p = points.begin(), end = points.end();
|
||||
|
|
|
|||
|
|
@ -332,7 +332,6 @@ public:
|
|||
int n = number_of_vertices();
|
||||
|
||||
std::vector<Weighted_point> points (first, last);
|
||||
std::random_shuffle (points.begin(), points.end());
|
||||
spatial_sort (points.begin(), points.end(), geom_traits());
|
||||
|
||||
Face_handle hint;
|
||||
|
|
|
|||
|
|
@ -38,10 +38,12 @@
|
|||
#include <CGAL/Triangulation_vertex_base_2.h>
|
||||
#include <CGAL/Triangulation_face_base_2.h>
|
||||
#include <CGAL/Triangulation_line_face_circulator_2.h>
|
||||
#include <CGAL/Random.h>
|
||||
|
||||
#include <CGAL/spatial_sort.h>
|
||||
|
||||
#include <boost/random/linear_congruential.hpp>
|
||||
#include <boost/random/uniform_smallint.hpp>
|
||||
#include <boost/random/variate_generator.hpp>
|
||||
|
||||
CGAL_BEGIN_NAMESPACE
|
||||
template < class Gt, class Tds > class Triangulation_2;
|
||||
template < class Gt, class Tds > std::istream& operator>>
|
||||
|
|
@ -179,7 +181,6 @@ protected:
|
|||
Gt _gt;
|
||||
Tds _tds;
|
||||
Vertex_handle _infinite_vertex;
|
||||
mutable Random rng;
|
||||
|
||||
public:
|
||||
// CONSTRUCTORS
|
||||
|
|
@ -1813,6 +1814,11 @@ march_locate_2D(Face_handle c,
|
|||
{
|
||||
CGAL_triangulation_assertion(! is_infinite(c));
|
||||
|
||||
boost::rand48 rng;
|
||||
|
||||
boost::uniform_smallint<> two(0, 1);
|
||||
boost::variate_generator<boost::rand48&, boost::uniform_smallint<> > coin(rng, two);
|
||||
|
||||
Face_handle prev = Face_handle();
|
||||
bool first = true;
|
||||
while (1) {
|
||||
|
|
@ -1832,7 +1838,7 @@ march_locate_2D(Face_handle c,
|
|||
// We do loop unrolling in order to find out if this is faster.
|
||||
// In the very beginning we do not have a prev, but for the first step
|
||||
// we do not need randomness
|
||||
int left_first = rng.template get_bits<1>();
|
||||
int left_first = coin()%1;
|
||||
|
||||
const Point & p0 = c->vertex( 0 )->point();
|
||||
const Point & p1 = c->vertex( 1 )->point();
|
||||
|
|
@ -1985,7 +1991,10 @@ march_locate_2D(Face_handle c,
|
|||
int& li) const
|
||||
{
|
||||
CGAL_triangulation_assertion(! is_infinite(c));
|
||||
|
||||
|
||||
boost::uniform_smallint<> four(0, 3);
|
||||
boost::variate_generator<boost::rand48&, boost::uniform_smallint<> > die4(rng, four);
|
||||
|
||||
Face_handle prev = Face_handle();
|
||||
while (1) {
|
||||
if ( is_infinite(c) ) {
|
||||
|
|
@ -1999,7 +2008,7 @@ march_locate_2D(Face_handle c,
|
|||
// we test its edges in a random order until we find a
|
||||
// neighbor to go further
|
||||
|
||||
int i = rng.template get_bits<2>();
|
||||
int i = die4();
|
||||
int ccwi = ccw(i);
|
||||
int cwi = cw(i);
|
||||
const Point & p0 = c->vertex( i )->point();
|
||||
|
|
|
|||
|
|
@ -22,10 +22,13 @@
|
|||
#define CGAL_TRIANGULATION_HIERARCHY_2_H
|
||||
|
||||
#include <CGAL/basic.h>
|
||||
#include <CGAL/Random.h>
|
||||
#include <CGAL/Triangulation_hierarchy_vertex_base_2.h>
|
||||
#include <map>
|
||||
|
||||
#include <boost/random/linear_congruential.hpp>
|
||||
#include <boost/random/geometric_distribution.hpp>
|
||||
#include <boost/random/variate_generator.hpp>
|
||||
|
||||
CGAL_BEGIN_NAMESPACE
|
||||
|
||||
// parameterization of the hierarchy
|
||||
|
|
@ -60,7 +63,7 @@ class Triangulation_hierarchy_2
|
|||
private:
|
||||
// here is the stack of triangulations which form the hierarchy
|
||||
Tr_Base* hierarchy[Triangulation_hierarchy_2__maxlevel];
|
||||
Random random; // random generator
|
||||
boost::rand48 random;
|
||||
|
||||
public:
|
||||
Triangulation_hierarchy_2(const Geom_traits& traits = Geom_traits());
|
||||
|
|
@ -69,7 +72,7 @@ public:
|
|||
template<class InputIterator>
|
||||
Triangulation_hierarchy_2(InputIterator first, InputIterator beyond,
|
||||
const Geom_traits& traits = Geom_traits())
|
||||
: Tr_Base(traits), random((long)0)
|
||||
: Tr_Base(traits)
|
||||
{
|
||||
hierarchy[0] = this;
|
||||
for(int i=1;i<Triangulation_hierarchy_2__maxlevel;++i)
|
||||
|
|
@ -102,7 +105,6 @@ public:
|
|||
int n = this->number_of_vertices();
|
||||
|
||||
std::vector<Point> points (first, last);
|
||||
std::random_shuffle (points.begin(), points.end());
|
||||
CGAL::spatial_sort (points.begin(), points.end(), geom_traits());
|
||||
|
||||
// hints[i] is the face of the previously inserted point in level i.
|
||||
|
|
@ -205,7 +207,7 @@ private:
|
|||
template <class Tr >
|
||||
Triangulation_hierarchy_2<Tr>::
|
||||
Triangulation_hierarchy_2(const Geom_traits& traits)
|
||||
: Tr_Base(traits), random((long)0)
|
||||
: Tr_Base(traits)
|
||||
{
|
||||
hierarchy[0] = this;
|
||||
for(int i=1;i<Triangulation_hierarchy_2__maxlevel;++i)
|
||||
|
|
@ -217,7 +219,7 @@ Triangulation_hierarchy_2(const Geom_traits& traits)
|
|||
template <class Tr>
|
||||
Triangulation_hierarchy_2<Tr>::
|
||||
Triangulation_hierarchy_2(const Triangulation_hierarchy_2<Tr> &tr)
|
||||
: Tr_Base(), random((long)0)
|
||||
: Tr_Base()
|
||||
{
|
||||
// create an empty triangulation to be able to delete it !
|
||||
hierarchy[0] = this;
|
||||
|
|
@ -564,16 +566,14 @@ int
|
|||
Triangulation_hierarchy_2<Tr>::
|
||||
random_level()
|
||||
{
|
||||
int l = 0;
|
||||
while (1) {
|
||||
if ( random(Triangulation_hierarchy_2__ratio) ) break;
|
||||
++l;
|
||||
}
|
||||
if (l >= Triangulation_hierarchy_2__maxlevel)
|
||||
l = Triangulation_hierarchy_2__maxlevel -1;
|
||||
return l;
|
||||
boost::geometric_distribution<> proba(1.0/Triangulation_hierarchy_2__ratio);
|
||||
boost::variate_generator<boost::rand48&, boost::geometric_distribution<> > die(random, proba);
|
||||
|
||||
return (std::min)(die(), Triangulation_hierarchy_2__maxlevel)-1;
|
||||
|
||||
}
|
||||
|
||||
CGAL_END_NAMESPACE
|
||||
|
||||
#endif // CGAL_TRIANGULATION_HIERARCHY_2_H
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue