From aff1bf74aacf2cfa31f090c196b36c0eb205db74 Mon Sep 17 00:00:00 2001 From: Sylvain Pion Date: Wed, 6 Aug 2008 13:16:04 +0000 Subject: [PATCH] Replace CGAL::Interval_nt<>::number_of_failures() by a CGAL_PROFILER() counter. --- .../test/Filtered_kernel/Static_filters.cpp | 3 --- Installation/CHANGES | 8 ++++++++ .../include/CGAL/Filtered_extended_homogeneous.h | 3 +-- Nef_2/noweb/Filtered_extended_kernel.lw | 3 +-- .../NumberTypeSupport_ref/Interval_nt.tex | 6 +----- Number_types/include/CGAL/Interval_nt.h | 3 --- .../doc_tex/STL_Extension_ref/Uncertain.tex | 4 +++- STL_Extension/include/CGAL/Uncertain.h | 16 +++++----------- .../test/Straight_skeleton_2/test_sls.cpp | 6 ------ 9 files changed, 19 insertions(+), 33 deletions(-) diff --git a/Filtered_kernel/test/Filtered_kernel/Static_filters.cpp b/Filtered_kernel/test/Filtered_kernel/Static_filters.cpp index db2afe05860..5feaa11fcb2 100644 --- a/Filtered_kernel/test/Filtered_kernel/Static_filters.cpp +++ b/Filtered_kernel/test/Filtered_kernel/Static_filters.cpp @@ -292,8 +292,5 @@ int main(int argc, char **argv) for(int i=0; i}, which can be probed for uncertainty explicitely, and which has a conversion to the normal type (e.g. \ccc{bool}) which throws an exception when the conversion is not certain. Note that each failed conversion increments -the counter \ccc{number_of_failures()}, and then throw the exception of +a profiling counter (see \ccc{CGAL_PROFILE}), and then throws the exception of type \ccc{unsafe_comparison}. %SetThreeColumns{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}{}{\hspace*{8cm}} @@ -157,10 +157,6 @@ type \ccc{unsafe_comparison}. \ccGlue \ccFunction{Uncertain sign(Interval_nt i);}{} -\ccFunction{static unsigned number_of_failures();} -{Returns a global counter incremented at each conversion which thrown an -exception.} - \ccTypedef{typedef Interval_nt Interval_nt_advanced;} {This typedef (at namespace CGAL scope) exists for backward compatibility, as well as removing the need to remember the Boolean value for the template diff --git a/Number_types/include/CGAL/Interval_nt.h b/Number_types/include/CGAL/Interval_nt.h index fea24938b1d..19382f0589c 100644 --- a/Number_types/include/CGAL/Interval_nt.h +++ b/Number_types/include/CGAL/Interval_nt.h @@ -90,9 +90,6 @@ public: Interval_nt(const Pair & p) : _inf(p.first), _sup(p.second) {} - static unsigned number_of_failures() - { return Uncertain::number_of_failures(); } - IA operator-() const { return IA (-sup(), -inf()); } IA & operator+= (const IA &d) { return *this = *this + d; } diff --git a/STL_Extension/doc_tex/STL_Extension_ref/Uncertain.tex b/STL_Extension/doc_tex/STL_Extension_ref/Uncertain.tex index 93ad214bb33..9f4630c4578 100644 --- a/STL_Extension/doc_tex/STL_Extension_ref/Uncertain.tex +++ b/STL_Extension/doc_tex/STL_Extension_ref/Uncertain.tex @@ -136,7 +136,9 @@ Another option is : \ccMethod{T make_certain() const;} {if \ccVar.\ccc{is_certain()}, then returns the certain value which is represented. - Otherwise, throws an exception of type \ccc{Uncertain_conversion_exception}.} + Otherwise, throws an exception of type \ccc{Uncertain_conversion_exception}. + A profile counter of the number of such exceptions thrown during the execution of + the program is available with \ccc{CGAL_PROFILE}.} \ccMethod{operator T() const;} {conversion operator to \ccc{T}. It does and returns the same thing as diff --git a/STL_Extension/include/CGAL/Uncertain.h b/STL_Extension/include/CGAL/Uncertain.h index 5f0102df92f..ec9708fa709 100644 --- a/STL_Extension/include/CGAL/Uncertain.h +++ b/STL_Extension/include/CGAL/Uncertain.h @@ -23,7 +23,9 @@ #include #include #include +#include #include +#include CGAL_BEGIN_NAMESPACE @@ -85,8 +87,6 @@ class Uncertain { T _i, _s; - static unsigned failures; // Number of conversion failures. - public: typedef T value_type; @@ -117,9 +117,10 @@ public: { if (is_certain()) return _i; - ++Uncertain::number_of_failures(); + CGAL_PROFILER(std::string("Uncertain_conversion_exception thrown for CGAL::Uncertain< ") + + typeid(T).name() + " >"); throw Uncertain_conversion_exception( - "undecidable conversion of CGAL::Uncertain"); + "Undecidable conversion of CGAL::Uncertain"); } #if 1 // Comment out in order to spot some unwanted conversions. @@ -144,17 +145,10 @@ public: } #endif - static unsigned & number_of_failures() { return failures; } - static Uncertain indeterminate(); }; -template < typename T > -unsigned -Uncertain::failures = 0; - - // Access functions // ---------------- diff --git a/Straight_skeleton_2/test/Straight_skeleton_2/test_sls.cpp b/Straight_skeleton_2/test/Straight_skeleton_2/test_sls.cpp index 52dda7c421e..70d047842c5 100644 --- a/Straight_skeleton_2/test/Straight_skeleton_2/test_sls.cpp +++ b/Straight_skeleton_2/test/Straight_skeleton_2/test_sls.cpp @@ -1278,12 +1278,6 @@ int main( int argc, char const* argv[] ) cout << "Failed cases: " << lFailed_cases << endl ; cout << endl ; - if ( Uncertain::number_of_failures() > 0 ) - { - cout << "!! " << Uncertain::number_of_failures() << " uncertain conversion failures. " << endl ; - cout << endl ; - } - int lTotalPred = sTotalPredFailures + sTotalPredSuccess ; int lTotalCons = sTotalConsFailures + sTotalConsSuccess ;