File tree Expand file tree Collapse file tree 3 files changed +11
-39
lines changed
doc/api/next_api_changes/behavior Expand file tree Collapse file tree 3 files changed +11
-39
lines changed Original file line number Diff line number Diff line change 1+ ``TrapezoidMapTriFinder `` uses different random number generator
2+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+ The random number generator used to determine the order of insertion of
5+ triangle edges in ``TrapezoidMapTriFinder `` has changed. This can result in a
6+ different triangle index being returned for a point that lies exactly on an
7+ edge between two triangles. This can also affect triangulation interpolation
8+ and refinement algorithms that use ``TrapezoidMapTriFinder ``.
Original file line number Diff line number Diff line change 1212
1313#include < algorithm>
1414#include < set>
15+ #include < random>
1516
1617
1718TriEdge::TriEdge ()
@@ -1465,8 +1466,8 @@ TrapezoidMapTriFinder::initialize()
14651466 _tree->assert_valid (false );
14661467
14671468 // Randomly shuffle all edges other than first 2.
1468- RandomNumberGenerator rng (1234 );
1469- std::random_shuffle (_edges.begin ()+2 , _edges.end (), rng);
1469+ std::mt19937 rng (1234 );
1470+ std::shuffle (_edges.begin ()+2 , _edges.end (), rng);
14701471
14711472 // Add edges, one at a time, to tree.
14721473 size_t nedges = _edges.size ();
@@ -2056,16 +2057,3 @@ TrapezoidMapTriFinder::Trapezoid::set_upper_right(Trapezoid* upper_right_)
20562057 if (upper_right != 0 )
20572058 upper_right->upper_left = this ;
20582059}
2059-
2060-
2061-
2062- RandomNumberGenerator::RandomNumberGenerator (unsigned long seed)
2063- : _m(21870 ), _a(1291 ), _c(4621 ), _seed(seed % _m)
2064- {}
2065-
2066- unsigned long
2067- RandomNumberGenerator::operator ()(unsigned long max_value)
2068- {
2069- _seed = (_seed*_a + _c) % _m;
2070- return (_seed*max_value) / _m;
2071- }
Original file line number Diff line number Diff line change @@ -791,28 +791,4 @@ class TrapezoidMapTriFinder
791791 Node* _tree; // Root node of the trapezoid map search tree. Owned.
792792};
793793
794-
795-
796- /* Linear congruential random number generator. Edges in the triangulation are
797- * randomly shuffled before being added to the trapezoid map. Want the
798- * shuffling to be identical across different operating systems and the same
799- * regardless of previous random number use. Would prefer to use a STL or
800- * Boost random number generator, but support is not consistent across
801- * different operating systems so implementing own here.
802- *
803- * This is not particularly random, but is perfectly adequate for the use here.
804- * Coefficients taken from Numerical Recipes in C. */
805- class RandomNumberGenerator
806- {
807- public:
808- RandomNumberGenerator (unsigned long seed);
809-
810- // Return random integer in the range 0 to max_value-1.
811- unsigned long operator ()(unsigned long max_value);
812-
813- private:
814- const unsigned long _m, _a, _c;
815- unsigned long _seed;
816- };
817-
818794#endif
You can’t perform that action at this time.
0 commit comments