From 2674244cded1b98664223c81a25cc74dd49b9fec Mon Sep 17 00:00:00 2001 From: kgv Date: Fri, 22 Jan 2016 15:55:55 +0300 Subject: [PATCH] 0026939: Configuration, NCollection_UBTreeFiller - do not use _REENTRANT in a header file Use std::mt19937 random number generator instead of rand() in NCollection_UBTreeFiller. boolean gdml_private ZI7 ZJ7 - TODO "bopcheck failed" is only for Linux now, checkshape faulty is unstable (issue #27052) boolean volumemaker B6 - Added TODO (bopcheck and checkshape faulties) boolean volumemaker C9 - Added TODO (checkprops and checkshape faulties) boolean volumemaker D2 - Added TODO (checkshape faulty) boolean volumemaker H4 - Added TODO (checkprops and checkshape faulties Linux only) boolean volumemaker D5 - IMVPROVEMENT, TODOs were deleted (bopcheck and checkshape faulties) bugs modalg_1 buc60462_2 - modified TODOs according to new behavior boolean gdml_private ZI7 ZJ7 - unstable case, added check for surface area and TODO samples/tcl/ANC101.tcl - amended due to changed order of edges in BOP result --- samples/tcl/ANC101.tcl | 4 +-- src/NCollection/NCollection_UBTreeFiller.hxx | 37 ++++---------------- tests/boolean/gdml_private/ZI7 | 11 +++--- tests/boolean/gdml_private/ZJ7 | 11 +++--- tests/boolean/volumemaker/B6 | 3 ++ tests/boolean/volumemaker/C9 | 3 ++ tests/boolean/volumemaker/D2 | 2 ++ tests/boolean/volumemaker/D5 | 4 --- tests/boolean/volumemaker/H4 | 3 ++ tests/bugs/modalg_1/buc60462_2 | 5 ++- 10 files changed, 36 insertions(+), 47 deletions(-) diff --git a/samples/tcl/ANC101.tcl b/samples/tcl/ANC101.tcl index f8e28d2b01..9944fe7d2c 100644 --- a/samples/tcl/ANC101.tcl +++ b/samples/tcl/ANC101.tcl @@ -264,11 +264,11 @@ bfuse _model _model t_s explode _model e # Make a weld at joint edges of platform and wedge +blend _model _model 2 _model_26 +blend _model _model 2 _model_27 blend _model _model 2 _model_28 blend _model _model 2 _model_29 -blend _model _model 2 _model_30 blend _model _model 2 _model_31 -blend _model _model 2 _model_33 # Cylinder on wedge blend result _model 2 _model_161 diff --git a/src/NCollection/NCollection_UBTreeFiller.hxx b/src/NCollection/NCollection_UBTreeFiller.hxx index eb237a80ef..1c6d080598 100644 --- a/src/NCollection/NCollection_UBTreeFiller.hxx +++ b/src/NCollection/NCollection_UBTreeFiller.hxx @@ -18,8 +18,8 @@ #include #include -#include -#include + +#include /** * This class is used to fill an UBTree in a random order. @@ -69,15 +69,8 @@ template class NCollection_UBTreeFiller const Handle(NCollection_BaseAllocator)& theAlloc=0L, const Standard_Boolean isFullRandom = Standard_True) : myTree(theTree), mySeqPtr(1000, theAlloc), - mySeed(1), myIsFullRandom (isFullRandom) - { -#ifndef _REENTRANT - // We use srand/rand for a single threaded application - // and rand_r for a multi threaded one. - // _REENTRANT must be defined for a multi threaded application. - srand (mySeed); -#endif - } + myRandGen (5489u /* == std::mt19937::default_seed, not defined in older environments, e.g, on Debian 6.0 with GCC 4.4.5 */), + myIsFullRandom (isFullRandom) {} //! Adds a pair (theObj, theBnd) to my sequence void Add (const TheObjType& theObj, const TheBndType& theBnd) @@ -137,22 +130,10 @@ template class NCollection_UBTreeFiller UBTree& myTree; NCollection_Vector mySeqPtr; - int mySeed; //!< seed for rand + std::mt19937 myRandGen; //!< random number generator Standard_Boolean myIsFullRandom; }; -#ifdef _REENTRANT -inline int take_random (int * theSeed) -{ - return rand_r ((unsigned *) theSeed); -} -#else -inline int take_random (int *) -{ - return rand(); -} -#endif - //======================================================================= //function : Fill //purpose : @@ -165,11 +146,7 @@ Standard_Integer NCollection_UBTreeFiller::Fill () // Fisher-Yates randomization if (myIsFullRandom) for (i = nbAdd; i > 0; i--) { - unsigned int ind = take_random(&mySeed); - if (i > RAND_MAX) { - const unsigned int ind1 = take_random(&mySeed); - ind += (ind1 << 15); - } + unsigned int ind = myRandGen(); ind = ind % i; const ObjBnd& aObjBnd = mySeqPtr(ind); myTree.Add (aObjBnd.myObj, aObjBnd.myBnd); @@ -177,7 +154,7 @@ Standard_Integer NCollection_UBTreeFiller::Fill () } else for (i = nbAdd; i > 0; i--) { - unsigned int ind = take_random(&mySeed); + unsigned int ind = myRandGen(); ind = i - (ind % i) - 1; const ObjBnd& aObjBnd = mySeqPtr(ind); myTree.Add (aObjBnd.myObj, aObjBnd.myBnd); diff --git a/tests/boolean/gdml_private/ZI7 b/tests/boolean/gdml_private/ZI7 index e6bb6b86be..b3d4723895 100644 --- a/tests/boolean/gdml_private/ZI7 +++ b/tests/boolean/gdml_private/ZI7 @@ -1,9 +1,12 @@ -puts "TODO ?OCC27052 All: Faulty shapes in variables faulty_1 to" -puts "TODO OCC26018 ALL: bopcheck failed" +puts "TODO ?OCC27052 ALL: Faulty shapes in variables faulty_1 to" +puts "TODO OCC27052 Windows: Error : The command is not valid. The area is" +puts "TODO OCC27052 Windows: Error : The area of result shape is" +puts "TODO OCC26018 Linux: bopcheck failed" source [locate_data_file mos2014-asm-scf-final.asm.1.gdml.tcl] set bcheck [bopcheck result] puts $bcheck if {![regexp {This shape seems to be OK.} $bcheck]} { - puts "Error: bopcheck failed" -} \ No newline at end of file + puts "Error: bopcheck failed" +} +checkprops result -s 618615 \ No newline at end of file diff --git a/tests/boolean/gdml_private/ZJ7 b/tests/boolean/gdml_private/ZJ7 index 952af7c23d..ae81a38f15 100644 --- a/tests/boolean/gdml_private/ZJ7 +++ b/tests/boolean/gdml_private/ZJ7 @@ -1,9 +1,12 @@ -puts "TODO ?OCC27052 All: Faulty shapes in variables faulty_1 to" -puts "TODO OCC26018 ALL: bopcheck failed" +puts "TODO ?OCC27052 ALL: Faulty shapes in variables faulty_1 to" +puts "TODO OCC27052 Windows: Error : The command is not valid. The area is" +puts "TODO OCC27052 Windows: Error : The area of result shape is" +puts "TODO OCC26018 Linux: bopcheck failed" source [locate_data_file mos2014-scf-final.prt.1.gdml.tcl] set bcheck [bopcheck result] puts $bcheck if {![regexp {This shape seems to be OK.} $bcheck]} { - puts "Error: bopcheck failed" -} \ No newline at end of file + puts "Error: bopcheck failed" +} +checkprops result -s 618615 \ No newline at end of file diff --git a/tests/boolean/volumemaker/B6 b/tests/boolean/volumemaker/B6 index e55a34411f..f3edcef215 100644 --- a/tests/boolean/volumemaker/B6 +++ b/tests/boolean/volumemaker/B6 @@ -1,3 +1,6 @@ +puts "TODO OCC26020 ALL: Faulty shapes in variables faulty_1 to faulty_" +puts "TODO OCC26020 ALL: Error: bopcheck failed" + # test script on make volume operation # plane diff --git a/tests/boolean/volumemaker/C9 b/tests/boolean/volumemaker/C9 index b6f66c461b..de1638a3db 100644 --- a/tests/boolean/volumemaker/C9 +++ b/tests/boolean/volumemaker/C9 @@ -1,3 +1,6 @@ +puts "TODO OCC26020 ALL: Error : The area of result shape is" +puts "TODO OCC26020 ALL: Faulty shapes in variables faulty_1 to faulty_" + # test script on make volume operation # cylinder plane unstable diff --git a/tests/boolean/volumemaker/D2 b/tests/boolean/volumemaker/D2 index 5e211c510b..3828782057 100644 --- a/tests/boolean/volumemaker/D2 +++ b/tests/boolean/volumemaker/D2 @@ -1,3 +1,5 @@ +puts "TODO OCC26020 ALL: Faulty shapes in variables faulty_1 to faulty_" + # test script on make volume operation # cylinder plane unstable diff --git a/tests/boolean/volumemaker/D5 b/tests/boolean/volumemaker/D5 index 23f23cbea4..865f460c33 100644 --- a/tests/boolean/volumemaker/D5 +++ b/tests/boolean/volumemaker/D5 @@ -1,9 +1,5 @@ # test script on make volume operation # cylinder plane - -puts "TODO OCC26020 Linux: Error: bopcheck failed" -puts "TODO OCC26020 Linux: Faulty shapes in variables faulty_1 to" - # planar face plane pln_f1 0 -1450 -4.4408920985006262e-015 0 1 1.1102230246251565e-016 erase pln_f1 diff --git a/tests/boolean/volumemaker/H4 b/tests/boolean/volumemaker/H4 index ea5501ec45..450c465a9b 100644 --- a/tests/boolean/volumemaker/H4 +++ b/tests/boolean/volumemaker/H4 @@ -1,3 +1,6 @@ +puts "TODO OCC26020 Linux: Error : The area of result shape is" +puts "TODO OCC26020 Linux: Error: bopcheck failed" + # test script on make volume operation # cylinder plane diff --git a/tests/bugs/modalg_1/buc60462_2 b/tests/bugs/modalg_1/buc60462_2 index 8d59f400bf..a3f18ad7fc 100755 --- a/tests/bugs/modalg_1/buc60462_2 +++ b/tests/bugs/modalg_1/buc60462_2 @@ -1,6 +1,5 @@ -#puts "TODO OCC27024 ALL: Faulty shapes in variables faulty_1 to faulty_" -puts "TODO OCC27024 ALL: Tcl Exception: result is not a topological shape!!!" -puts "TODO OCC27024 All:TEST INCOMPLETE" +puts "TODO OCC27024 ALL: Error : operation bfuse is WRONG because number of SOLID entities in shape" +puts "TODO OCC27024 ALL: Faulty shapes in variables faulty_1 to faulty_" puts "==========" puts "BUC60462"