From 23a9ab5a495979832c1b59b474956bd6794cda49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 22 Feb 2023 10:39:54 +0100 Subject: [PATCH] Improve debug messages --- .../include/CGAL/Straight_skeleton_2/debug.h | 6 +-- .../CGAL/Straight_skeleton_builder_2.h | 7 ++- .../include/CGAL/Trisegment_2.h | 7 +-- .../Straight_skeleton_cons_ftC2.h | 43 ++++++++----------- .../predicates/Straight_skeleton_pred_ftC2.h | 8 +++- 5 files changed, 37 insertions(+), 34 deletions(-) diff --git a/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/debug.h b/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/debug.h index 4bcb1b87a63..b9527369698 100644 --- a/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/debug.h +++ b/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/debug.h @@ -72,7 +72,7 @@ inline std::string n2str( N const& n ) { std::ostringstream ss ; ss << std::setprecision(17); - ss << CGAL_NTS to_double(n); + ss << n; return ss.str(); } @@ -120,7 +120,7 @@ inline std::string n2str( CGAL::MP_Float const& n ) { std::ostringstream ss ; ss << std::setprecision(17) ; - ss << CGAL_NTS to_double(n) ; + ss << n ; return ss.str(); } @@ -128,7 +128,7 @@ inline std::string n2str( CGAL::Quotient< CGAL::MP_Float > const& n ) { std::ostringstream ss ; ss << std::setprecision(17) ; - ss << CGAL_NTS to_double(n) ; + ss << n ; return ss.str(); } #endif diff --git a/Straight_skeleton_2/include/CGAL/Straight_skeleton_builder_2.h b/Straight_skeleton_2/include/CGAL/Straight_skeleton_builder_2.h index c07ea4c281c..3c47cb4b19b 100644 --- a/Straight_skeleton_2/include/CGAL/Straight_skeleton_builder_2.h +++ b/Straight_skeleton_2/include/CGAL/Straight_skeleton_builder_2.h @@ -865,7 +865,7 @@ private : if ( !lPQ.empty() ) { // When there are simultaneous split events, we sort them to handle nearby pseudo split events - // together as to avoid multiple fronts crossing each other without seeing + // together as to avoid multiple fronts crossing each other without noticing each other. // and creating an invalid SLS. // // Unfortunately, the way that this sorting is performed requires knowing whether an event @@ -941,7 +941,10 @@ private : Comparison_result CompareEvents ( EventPtr const& aA, EventPtr const& aB ) const { - return aA->triedge() != aB->triedge() ? CompareEvents( aA->trisegment(), aB->trisegment() ) : EQUAL ; + Comparison_result rResult = aA->triedge() != aB->triedge() ? CompareEvents( aA->trisegment(), aB->trisegment() ) : EQUAL; + + CGAL_STSKEL_BUILDER_TRACE(3, "Compare events " << aA->triedge() << " and " << aB->triedge() << " -> " << rResult); + return rResult; } Comparison_result CompareEvents( Trisegment_2_ptr const& aTrisegment, Vertex_handle aSeedNode ) const diff --git a/Straight_skeleton_2/include/CGAL/Trisegment_2.h b/Straight_skeleton_2/include/CGAL/Trisegment_2.h index 81a3494c5cf..d217ae70df8 100644 --- a/Straight_skeleton_2/include/CGAL/Trisegment_2.h +++ b/Straight_skeleton_2/include/CGAL/Trisegment_2.h @@ -192,9 +192,10 @@ public: friend std::ostream& operator << ( std::ostream& os, Self const& aTrisegment ) { return os << "[" - << "\n\te0 " << s2str(aTrisegment.e0()) << " weight = " << n2str(aTrisegment.w0()) << ";" - << "\n\te1 " << s2str(aTrisegment.e1()) << " weight = " << n2str(aTrisegment.w1()) << ";" - << "\n\te2 " << s2str(aTrisegment.e2()) << " weight = " << n2str(aTrisegment.w2()) << ";" + << "\n\tE" << aTrisegment.e0().mID << " E" << aTrisegment.e1().mID << " E" << aTrisegment.e2().mID + << "\n\t" << s2str(aTrisegment.e0()) << " w = " << n2str(aTrisegment.w0()) << ";" + << "\n\t" << s2str(aTrisegment.e1()) << " w = " << n2str(aTrisegment.w1()) << ";" + << "\n\t" << s2str(aTrisegment.e2()) << " w = " << n2str(aTrisegment.w2()) << ";" << "\n\tCollinearity: " << trisegment_collinearity_to_string(aTrisegment.collinearity()) << "\n]"; } diff --git a/Straight_skeleton_2/include/CGAL/constructions/Straight_skeleton_cons_ftC2.h b/Straight_skeleton_2/include/CGAL/constructions/Straight_skeleton_cons_ftC2.h index da257754632..4ec1a8e56f6 100644 --- a/Straight_skeleton_2/include/CGAL/constructions/Straight_skeleton_cons_ftC2.h +++ b/Straight_skeleton_2/include/CGAL/constructions/Straight_skeleton_cons_ftC2.h @@ -114,10 +114,11 @@ inline Lazy_exact_nt inexact_sqrt( Lazy_exact_nt const& lz) template boost::optional< typename K::Line_2> compute_normalized_line_coeffC2( Segment_2 const& e ) { - bool finite = true ; - typedef typename K::FT FT ; + CGAL_STSKEL_TRAITS_TRACE("\n~~ Unweighted line coefficients for " << s2str(e) ); + + bool finite = true ; FT a(0), b(0), c(0) ; if(e.source().y() == e.target().y()) @@ -139,9 +140,7 @@ boost::optional< typename K::Line_2> compute_normalized_line_coeffC2( Segment_2< c = e.source().y(); } - CGAL_STSKEL_TRAITS_TRACE("Unweighted line coefficients for HORIZONTAL line: " << s2str(e) - << "\na="<< n2str(a) << ", b=" << n2str(b) << ", c=" << n2str(c) - ) ; + CGAL_STSKEL_TRAITS_TRACE("HORIZONTAL line; a="<< n2str(a) << ", b=" << n2str(b) << ", c=" << n2str(c) ) ; } else if(e.target().x() == e.source().x()) { @@ -162,9 +161,7 @@ boost::optional< typename K::Line_2> compute_normalized_line_coeffC2( Segment_2< c = -e.source().x(); } - CGAL_STSKEL_TRAITS_TRACE("Unweighted line coefficients for VERTICAL line: " << s2str(e) - << "\na="<< n2str(a) << ", b=" << n2str(b) << ", c=" << n2str(c) - ) ; + CGAL_STSKEL_TRAITS_TRACE("VERTICAL line; a="<< n2str(a) << ", b=" << n2str(b) << ", c=" << n2str(c) ) ; } else { @@ -216,7 +213,7 @@ boost::optional< typename K::Line_2 > compute_weighted_line_coeffC2( Segment_2_w FT b = l->b() * aWeight ; FT c = l->c() * aWeight ; - CGAL_STSKEL_TRAITS_TRACE("Weighted line coefficients for line: " << s2str(e) + CGAL_STSKEL_TRAITS_TRACE("\n~~ Weighted line coefficients for line: " << s2str(e) << "\nweight=" << n2str(aWeight) << "\na="<< n2str(a) << "\nb=" << n2str(b) << "\nc=" << n2str(c) ) ; @@ -308,7 +305,8 @@ compute_normal_offset_lines_isec_timeC2 ( boost::intrusive_ptr< Trisegment_2 Optional_line_2 ; - CGAL_STSKEL_TRAITS_TRACE(" ~~ Computing normal offset lines isec time for: " << tri ) ; + CGAL_STSKEL_TRAITS_TRACE("\n~~ Computing normal offset lines isec time [" << typeid(FT).name() << "]") ; + CGAL_STSKEL_TRAITS_TRACE("Event" << tri ); FT num(0), den(0) ; @@ -343,12 +341,9 @@ compute_normal_offset_lines_isec_timeC2 ( boost::intrusive_ptr< Trisegment_2e0().mID << " w: " << n2str(tri->w0()) ) ; - CGAL_STSKEL_TRAITS_TRACE("\tl1 ID: " << tri->e1().mID << " w: " << n2str(tri->w1()) ); - CGAL_STSKEL_TRAITS_TRACE("\tl2 ID: " << tri->e2().mID << " w: " << n2str(tri->w2()) ) ; - CGAL_STSKEL_TRAITS_TRACE("\tLabc [" << n2str(l0->a()) << "; " << n2str(l0->b()) << "; " << n2str(l0->c()) << "]" - << "[" << n2str(l1->a()) << "; " << n2str(l1->b()) << "; " << n2str(l1->c()) << "]" - << "[" << n2str(l2->a()) << "; " << n2str(l2->b()) << "; " << n2str(l2->c()) << "]") ; + CGAL_STSKEL_TRAITS_TRACE("coeffs 0 [" << n2str(l0->a()) << "; " << n2str(l0->b()) << "; " << n2str(l0->c()) << "]" + << "\ncoeffs 1 [" << n2str(l1->a()) << "; " << n2str(l1->b()) << "; " << n2str(l1->c()) << "]" + << "\ncoeffs 2 [" << n2str(l2->a()) << "; " << n2str(l2->b()) << "; " << n2str(l2->c()) << "]") ; num = (l2->a()*l0->b()*l1->c()) -(l2->a()*l1->b()*l0->c()) @@ -514,7 +509,7 @@ compute_degenerate_offset_lines_isec_timeC2 ( boost::intrusive_ptr< Trisegment_2 typedef boost::optional Optional_point_2 ; typedef boost::optional Optional_line_2 ; - CGAL_STSKEL_TRAITS_TRACE(" ~~ Computing degenerate offset lines isec time for: " << tri ) ; + CGAL_STSKEL_TRAITS_TRACE("\n~~ Computing degenerate offset lines isec time for: " << tri ) ; // DETAILS: // @@ -716,7 +711,8 @@ construct_normal_offset_lines_isecC2 ( boost::intrusive_ptr< Trisegment_2 Optional_line_2 ; - CGAL_STSKEL_TRAITS_TRACE(" ~~ Computing normal offset lines isec point for:" << tri ) ; + CGAL_STSKEL_TRAITS_TRACE("\n~~ Computing normal offset lines isec point [" << typeid(FT).name() << "]"); + CGAL_STSKEL_TRAITS_TRACE("Event:" << tri ) ; FT x(0), y(0) ; @@ -737,6 +733,8 @@ construct_normal_offset_lines_isecC2 ( boost::intrusive_ptr< Trisegment_2b()*l2->c() - l0->b()*l1->c() - l1->b()*l2->c() + l2->b()*l1->c() + l1->b()*l0->c() - l2->b()*l0->c(); FT numY = l0->a()*l2->c() - l0->a()*l1->c() - l1->a()*l2->c() + l2->a()*l1->c() + l1->a()*l0->c() - l2->a()*l0->c(); + CGAL_STSKEL_TRAITS_TRACE("\tnumX=" << n2str(numX) << "\n\tnumY=" << n2str(numY) ) ; + if ( CGAL_NTS is_finite(den) && CGAL_NTS is_finite(numX) && CGAL_NTS is_finite(numY) ) { ok = true ; @@ -744,13 +742,11 @@ construct_normal_offset_lines_isecC2 ( boost::intrusive_ptr< Trisegment_2e0().mID << ",E" << tri->e1().mID << ",E" << tri->e2().mID - << tri ) ; + CGAL_STSKEL_TRAITS_TRACE("\n~~ Computing degenerate offset lines isec point [" << typeid(FT).name() << "]"); + CGAL_STSKEL_TRAITS_TRACE("Event: " << tri ) ; FT x(0),y(0) ; diff --git a/Straight_skeleton_2/include/CGAL/predicates/Straight_skeleton_pred_ftC2.h b/Straight_skeleton_2/include/CGAL/predicates/Straight_skeleton_pred_ftC2.h index 3a443cffe18..993a5166cf5 100644 --- a/Straight_skeleton_2/include/CGAL/predicates/Straight_skeleton_pred_ftC2.h +++ b/Straight_skeleton_2/include/CGAL/predicates/Straight_skeleton_pred_ftC2.h @@ -185,7 +185,9 @@ Uncertain exist_offset_lines_isec2 ( boost::intrusive_ptr< Trisegment_2 rResult = Uncertain::indeterminate(); - CGAL_STSKEL_TRAITS_TRACE( "Checking existence of an event for E" << tri->e0().mID << " E" << tri->e1().mID << " E" << tri->e2().mID ) ; + + CGAL_STSKEL_TRAITS_TRACE( "\n~~ Checking existence of an event [" << typeid(FT).name() << "]"); + CGAL_STSKEL_TRAITS_TRACE("Event:" << tri ) ; if ( tri->collinearity() != TRISEGMENT_COLLINEARITY_ALL ) { @@ -260,6 +262,7 @@ compare_offset_lines_isec_timesC2 ( boost::intrusive_ptr< Trisegment_2to_quotient(); Quotient nt = nt_->to_quotient(); + if ( CGAL_NTS certified_is_positive(mt) && CGAL_NTS certified_is_positive(nt) ) rResult = CGAL_NTS certified_compare(mt,nt); } @@ -416,7 +419,8 @@ oriented_side_of_event_point_wrt_bisectorC2 ( boost::intrusive_ptr< Trisegment_2 Line_2 l0 = validate(compute_weighted_line_coeffC2(e0, w0, aCoeff_cache)) ; Line_2 l1 = validate(compute_weighted_line_coeffC2(e1, w1, aCoeff_cache)) ; - CGAL_STSKEL_TRAITS_TRACE("Getting oriented side of point " << p2str(p) + CGAL_STSKEL_TRAITS_TRACE("\n~~ Oriented side of point [" << typeid(FT).name() << "]" ); + CGAL_STSKEL_TRAITS_TRACE("p = " << p2str(p) << " w.r.t. bisector [" << s2str(e0) << ( primary_is_0 ? "*" : "" ) << ","