Debug code improvements

This commit is contained in:
Mael Rouxel-Labbé 2023-02-09 23:22:21 +01:00
parent f58cd7fb9d
commit ad4b82383d
13 changed files with 64 additions and 48 deletions

View File

@ -213,7 +213,7 @@ public :
if ( begin->is_border())
++nb;
}
CGAL_STSKEL_VALIDITY_TRACE("summe border halfedges (2*nb) = " << 2 * nb );
CGAL_STSKEL_VALIDITY_TRACE("sum of border halfedges (2*nb) = " << 2 * nb );
bool nvalid = ( n == this->size_of_halfedges());

View File

@ -66,7 +66,8 @@ Polygon_offset_builder_2<Ss,Gt,Cont,Visitor>::LocateHook( FT
Halfedge_const_handle lNext = aBisector->next();
CGAL_POLYOFFSET_TRACE(2,"Testing hook on " << e2str(*aBisector) ) ;
CGAL_POLYOFFSET_TRACE(4, "Next: " << e2str(*lNext) << " ; Prev: " << e2str(*lPrev) ) ;
CGAL_POLYOFFSET_TRACE(4, "Next: " << e2str(*lNext) ) ;
CGAL_POLYOFFSET_TRACE(4, "Prev: " << e2str(*lPrev) ) ;
if ( !IsVisited(aBisector) )
{

View File

@ -46,6 +46,8 @@ Straight_skeleton_builder_2<Gt,Ss,V>::Straight_skeleton_builder_2 ( boost::optio
,mPQ(mEventCompare)
,mSSkel( new SSkel() )
{
if( mMaxTime )
CGAL_STSKEL_BUILDER_TRACE(4, "Init with mMaxTime = " << *mMaxTime)
}
template<class Gt, class Ss, class V>
@ -98,6 +100,9 @@ Straight_skeleton_builder_2<Gt,Ss,V>::FindEdgeEvent( Vertex_handle aLNode, Verte
{
Trisegment_2_ptr lTrisegment = CreateTrisegment(lTriedge,aLNode,aRNode);
CGAL_STSKEL_BUILDER_TRACE(4, "\n[] Considering E" << lTrisegment->e0().mID << " E" << lTrisegment->e1().mID << " E" << lTrisegment->e2().mID
<< " Collinearity: " << trisegment_collinearity_to_string(lTrisegment->collinearity()) ) ;
// The 02 collinearity configuration is problematic: 01 or 12 collinearity has a seed position
// giving the point through which the bisector passes. However, for 02, it is not a given.
//
@ -163,7 +168,9 @@ Straight_skeleton_builder_2<Gt,Ss,V>::FindEdgeEvent( Vertex_handle aLNode, Verte
}
else
{
CGAL_STSKEL_BUILDER_TRACE(4, "Edge event: " << lTriedge << " is in the past. Compared to L=" << lLNodeD << " to R=" << lRNodeD ) ;
CGAL_STSKEL_BUILDER_TRACE(4, "Edge event: " << lTriedge << " is in the past." ) ;
CGAL_STSKEL_BUILDER_TRACE(4, "\tCompared to L=" << aLNode->id() << " (" << lLNodeD << ")" ) ;
CGAL_STSKEL_BUILDER_TRACE(4, "\tCompared to R=" << aRNode->id() << " (" << lRNodeD << ")" ) ;
}
}
}
@ -605,6 +612,8 @@ void Straight_skeleton_builder_2<Gt,Ss,V>::CreateContourBisectors()
template<class Gt, class Ss, class V>
void Straight_skeleton_builder_2<Gt,Ss,V>::HarmonizeSpeeds(boost::mpl::bool_<true>)
{
CGAL_STSKEL_BUILDER_TRACE ( 2, "Harmonize speeds..." ) ;
// Collinear input edges might not have the exact same speed if an inexact square root is used.
// This might cause some inconsistencies in time, resulting in invalid skeletons. Therefore,
// if the square root is not exact, we enforce that collinear input edges have the same speed,
@ -1058,7 +1067,7 @@ void Straight_skeleton_builder_2<Gt,Ss,V>::HandleEdgeEvent( EventPtr aEvent )
SetBisectorSlope(lLSeed,lNewNode);
SetBisectorSlope(lRSeed,lNewNode);
CGAL_STSKEL_BUILDER_TRACE( 1, "E" << e2str(*(lRSeed->halfedge()->defining_contour_edge())) << " collapsed." );
CGAL_STSKEL_BUILDER_TRACE( 1, e2str(*(lRSeed->halfedge()->defining_contour_edge())) << " collapsed." );
CGAL_STSKEL_BUILDER_TRACE( 3, "fictitious node along collapsed face is N" << lRIFicNode->id()
<< " between " << e2str(*lROBisector) << " and " << e2str(*lLIBisector) ) ;
@ -1539,16 +1548,16 @@ void Straight_skeleton_builder_2<Gt,Ss,V>::Propagate()
if ( !mPQ.empty() )
{
#ifdef CGAL_SLS_PRINT_QUEUE_BEFORE_EACH_POP
std::cout << "MAIN QUEUE -------------------------------------------------- " << std::endl;
std::cout << "Queue size: " << mPQ.size() << std::endl;
CGAL_STSKEL_BUILDER_TRACE(4, "MAIN QUEUE -------------------------------------------------- ");
CGAL_STSKEL_BUILDER_TRACE(4, "Queue size: " << mPQ.size());
auto mpq = mPQ;
while(!mpq.empty())
{
EventPtr event = mpq.top();
mpq.pop();
std::cout << *event << std::endl;
CGAL_STSKEL_BUILDER_TRACE(4, *event);
}
std::cout << "END MAIN QUEUE --------------------------------------------- " << std::endl;
CGAL_STSKEL_BUILDER_TRACE(4, "END MAIN QUEUE --------------------------------------------- ");
#endif
EventPtr lEvent = PopEventFromPQ();
@ -2031,7 +2040,7 @@ bool Straight_skeleton_builder_2<Gt,Ss,V>::FinishUp()
mVisitor.on_cleanup_finished();
// @todo if 'mMaxTime' is sufficiently large, it will be a full skeleton and should be validated as such
// If 'mMaxTime' is sufficiently large, it will be a full skeleton and could be validated as such...
if(mMaxTime) // might be a partial skeleton
return mSSkel->is_valid(true);
else

View File

@ -178,7 +178,7 @@ private :
virtual void dump ( std::ostream& ss ) const
{
this->Base::dump(ss);
ss << " (Split Event, Seed=" << mSeed->id() << " (" << mSeed->point() << ") OppBorder=" << this->triedge().e2()->id() << ')' ;
ss << " (Split Event, Seed=" << mSeed->id() << "pos: (" << mSeed->point() << ") OppBorder=" << this->triedge().e2()->id() << ')' ;
}
private :

View File

@ -22,7 +22,7 @@
#if defined(CGAL_STRAIGHT_SKELETON_ENABLE_TRACE) \
|| defined(CGAL_POLYGON_OFFSET_ENABLE_TRACE) \
|| defined(CGAL_STRAIGHT_SKELETON_TRAITS_ENABLE_TRACE) \
|| defined(CGAL_STRAIGHT_SKELETON_ENABLE_VALIDITY_TRACE) \
|| defined(CGAL_STRAIGHT_SKELETON_VALIDITY_ENABLE_TRACE) \
|| defined(CGAL_STRAIGHT_SKELETON_ENABLE_INTRINSIC_TESTING)
#
# define CGAL_STSKEL_TRACE_ON
@ -231,6 +231,7 @@ template<class VH, class Triedge>
inline std::string newn2str( char const* name, VH const& v, Triedge const& aTriedge )
{
std::ostringstream ss ;
ss.precision(17);
ss << "New Node " << name <<" is N" << v->id() << " at " << v->point()
<< " [E" << aTriedge.e0()->id()
@ -283,7 +284,7 @@ bool sEnableTraitsTrace = true;
#endif
#ifdef CGAL_STRAIGHT_SKELETON_ENABLE_VALIDITY_TRACE
#ifdef CGAL_STRAIGHT_SKELETON_VALIDITY_ENABLE_TRACE
# define CGAL_STSKEL_VALIDITY_TRACE(m) CGAL_STSKEL_TRACE(m)
# define CGAL_STSKEL_VALIDITY_TRACE_IF(cond,m) if ( cond ) CGAL_STSKEL_VALIDITY_TRACE(m)
#else

View File

@ -447,7 +447,7 @@ private :
}
}
// @todo Should split events always have lower priority than split events?
// @todo Should split events always have lower priority than edge events?
Comparison_result CompareEventsSupportAngles ( EventPtr const& aA, EventPtr const& aB )
{
CGAL_precondition ( aA->type() != Event::cEdgeEvent && aB->type() != Event::cEdgeEvent ) ;
@ -1404,8 +1404,6 @@ public:
}
}
CGAL_assertion_code(std::cout << "lFaceCountThroughWeights = " << lFaceCountThroughWeights << std::endl;)
CGAL_assertion_code(std::cout << "mSSkel->SSkel::Base::size_of_faces() = " << mSSkel->SSkel::Base::size_of_faces() << std::endl;)
CGAL_assertion( lFaceCountThroughWeights == mSSkel->SSkel::Base::size_of_faces() ) ;
return *this;

View File

@ -89,7 +89,7 @@ public:
Halfedge_const_handle defining_contour_edge() const { return this->face()->halfedge() ; }
Halfedge_handle defining_contour_edge() { return this->face()->halfedge() ; }
// @fixme this isn't documented in the `StraightSkeletonHalfedge_2` concept
// @fixme below is not documented in the `StraightSkeletonHalfedge_2` concept
Sign slope() const { return mSlope ; }
void set_slope( Sign aSlope ) { mSlope = aSlope ; }

View File

@ -156,10 +156,10 @@ public:
friend std::ostream& operator << ( std::ostream& os, Self const& aTrisegment )
{
return os << "[" << s2str(aTrisegment.e0())
<< " " << s2str(aTrisegment.e1())
<< " " << s2str(aTrisegment.e2())
<< " " << trisegment_collinearity_to_string(aTrisegment.collinearity())
return os << "[e0 " << s2str(aTrisegment.e0())
<< "; e1 " << s2str(aTrisegment.e1())
<< "; e2 " << s2str(aTrisegment.e2())
<< "; Collinearity: " << trisegment_collinearity_to_string(aTrisegment.collinearity())
<< "]";
}

View File

@ -48,7 +48,9 @@ boost::optional< Point_2<K> > construct_offset_pointC2 ( typename K::FT const& t
FT x(0.0),y(0.0) ;
CGAL_STSKEL_TRAITS_TRACE("Constructing offset point for t=" << t << " e0=" << s2str(e0) << " e1=" << s2str(e1) << " tri=" << tri ) ;
CGAL_STSKEL_TRAITS_TRACE("Constructing offset point for t=" << t ) ;
CGAL_STSKEL_TRAITS_TRACE("Edges " << " e0=" << s2str(e0) << " w = " << weight0 ) ;
CGAL_STSKEL_TRAITS_TRACE( " e1=" << s2str(e1) << " w = " << weight1 << " tri=" << tri ) ;
Optional_line_2 l0 = compute_normalized_line_ceoffC2(e0, aCoeff_cache) ;
Optional_line_2 l1 = compute_normalized_line_ceoffC2(e1, aCoeff_cache) ;

View File

@ -142,8 +142,7 @@ boost::optional< Line_2<K> > compute_normalized_line_ceoffC2( Segment_2<K> const
c = e.source().y();
}
CGAL_STSKEL_TRAITS_TRACE("Unweighted line coefficients for HORIZONTAL line:\n"
<< s2str(e)
CGAL_STSKEL_TRAITS_TRACE("Unweighted line coefficients for HORIZONTAL line: " << s2str(e)
<< "\na="<< n2str(a) << ", b=" << n2str(b) << ", c=" << n2str(c)
) ;
}
@ -166,8 +165,7 @@ boost::optional< Line_2<K> > compute_normalized_line_ceoffC2( Segment_2<K> const
c = -e.source().x();
}
CGAL_STSKEL_TRAITS_TRACE("Unweighted line coefficients for VERTICAL line:\n"
<< s2str(e)
CGAL_STSKEL_TRAITS_TRACE("Unweighted line coefficients for VERTICAL line: " << s2str(e)
<< "\na="<< n2str(a) << ", b=" << n2str(b) << ", c=" << n2str(c)
) ;
}
@ -186,8 +184,7 @@ boost::optional< Line_2<K> > compute_normalized_line_ceoffC2( Segment_2<K> const
c = -e.source().x()*a - e.source().y()*b;
CGAL_STSKEL_TRAITS_TRACE("Unweighted line coefficients for line:\n"
<< s2str(e)
CGAL_STSKEL_TRAITS_TRACE("Unweighted line coefficients for line: " << s2str(e)
<< "\nsa="<< n2str(sa) << "\nsb=" << n2str(sb) << "\nl2=" << n2str(l2) << "\nl=" << n2str(l)
<< "\na="<< n2str(a) << "\nb=" << n2str(b) << "\nc=" << n2str(c)
) ;
@ -211,9 +208,8 @@ boost::optional< Line_2<K> > compute_normalized_line_ceoffC2( Segment_2<K> const
CGAL_precondition( CGAL_NTS is_finite(b) ) ;
CGAL_precondition( CGAL_NTS is_finite(c) ) ;
CGAL_STSKEL_TRAITS_TRACE("Weighted line coefficients for line:\n"
<< s2str(e)
<< "\nscaling=" << n2str(lScale)
CGAL_STSKEL_TRAITS_TRACE("Weighted line coefficients for line: " << s2str(e)
<< "\nweight=" << n2str(aWeight)
<< "\na="<< n2str(a) << "\nb=" << n2str(b) << "\nc=" << n2str(c)
) ;
@ -312,8 +308,8 @@ compute_normal_offset_lines_isec_timeC2 ( boost::intrusive_ptr< Trisegment_2<K,
// or 'time', can be computed solving for 't' in the linear system formed by 3 such equations.
// The result is :
//
// t = a2*b0*c1 - a2*b1*c0 - b2*a0*c1 + b2*a1*c0 + b1*a0*c2 - b0*a1*c2
// ---------------------------------------------------------------
// a2*b0*c1 - a2*b1*c0 - b2*a0*c1 + b2*a1*c0 + b1*a0*c2 - b0*a1*c2
// t = ---------------------------------------------------------------
// -a2*b1 + a2*b0 + b2*a1 - b2*a0 + b1*a0 - b0*a1 ;
bool ok = false ;
@ -368,8 +364,9 @@ boost::optional< Point_2<K> > compute_oriented_midpoint ( Segment_2_with_ID<K> c
if ( CGAL_NTS is_finite(delta01) && CGAL_NTS is_finite(delta10) )
{
if ( delta01 <= delta10 )
mp = CGAL::midpoint(e0.target(),e1.source());
else mp = CGAL::midpoint(e1.target(),e0.source());
mp = CGAL::midpoint(e0.target(),e1.source());
else
mp = CGAL::midpoint(e1.target(),e0.source());
CGAL_STSKEL_TRAITS_TRACE("Computing oriented midpoint between:"
<< "\ne0: " << s2str(e0)
@ -668,7 +665,7 @@ construct_normal_offset_lines_isecC2 ( boost::intrusive_ptr< Trisegment_2<K, Seg
{
FT den = l0->a()*l2->b() - l0->a()*l1->b() - l1->a()*l2->b() + l2->a()*l1->b() + l0->b()*l1->a() - l0->b()*l2->a();
CGAL_STSKEL_TRAITS_TRACE("den=" << n2str(den) )
CGAL_STSKEL_TRAITS_TRACE("\tden=" << n2str(den) )
if ( ! CGAL_NTS certified_is_zero(den) )
{
@ -682,9 +679,8 @@ construct_normal_offset_lines_isecC2 ( boost::intrusive_ptr< Trisegment_2<K, Seg
x = numX / den ;
y = -numY / den ;
CGAL_STSKEL_TRAITS_TRACE("numX=" << n2str(numX) << "\nnumY=" << n2str(numY)
<< "\nx=" << n2str(x) << "\ny=" << n2str(y)
)
CGAL_STSKEL_TRAITS_TRACE("\tnumX=" << n2str(numX) << "\n\tnumY=" << n2str(numY)
<< "\n\tx=" << n2str(x) << "\n\ty=" << n2str(y) ) ;
}
}
}
@ -704,6 +700,7 @@ construct_normal_offset_lines_isecC2 ( boost::intrusive_ptr< Trisegment_2<K, Seg
//
// POSTCONDITION: In case of overflow an empty optional is returned.
//
// See detailed computations in compute_degenerate_offset_lines_isec_timeC2()
template <class K, class CoeffCache>
boost::optional< Point_2<K> >
construct_degenerate_offset_lines_isecC2 ( boost::intrusive_ptr< Trisegment_2<K, Segment_2_with_ID<K> > > const& tri,
@ -717,7 +714,9 @@ construct_degenerate_offset_lines_isecC2 ( boost::intrusive_ptr< Trisegment_2<K,
typedef boost::optional<Point_2> Optional_point_2 ;
typedef boost::optional<Line_2> Optional_line_2 ;
CGAL_STSKEL_TRAITS_TRACE("Computing degenerate offset lines isec point for: " << tri ) ;
CGAL_STSKEL_TRAITS_TRACE("Computing degenerate offset lines isec point for:"
<< " E" << tri->e0().mID << ",E" << tri->e1().mID << ",E" << tri->e2().mID << std::endl
<< tri ) ;
FT x(0.0),y(0.0) ;
@ -824,7 +823,7 @@ construct_degenerate_offset_lines_isecC2 ( boost::intrusive_ptr< Trisegment_2<K,
}
}
CGAL_STSKEL_TRAITS_TRACE("\nDegenerate " << (CGAL_NTS is_zero(l0->b()) ? "(vertical)" : "") << " event point: x=" << n2str(x) << " y=" << n2str(y) )
CGAL_STSKEL_TRAITS_TRACE("\nDegenerate" << (CGAL_NTS is_zero(l0->b()) ? " (vertical)" : "") << " event point: x=" << n2str(x) << " y=" << n2str(y) )
return cgal_make_optional(ok,K().construct_point_2_object()(x,y)) ;
}

View File

@ -389,7 +389,7 @@ create_exterior_skeleton_and_offset_polygons_2(const FT& aOffset,
ofk);
}
// Overloads common to both polygons with and without holes, a simple polygons are returned in any case
// Overloads common to both polygons with and without holes, a simple polygons is returned in any case
template<class FT, class APolygon, class OfK,
class OutPolygon = typename CGAL_SS_i::Default_return_polygon_type<APolygon, OfK>::type>
std::vector< boost::shared_ptr<OutPolygon> >

View File

@ -195,6 +195,8 @@ create_exterior_weighted_straight_skeleton_2(const FT& max_offset,
frame[2] = Point_2(fxmax,fymax);
frame[3] = Point_2(fxmin,fymax);
CGAL_STSKEL_BUILDER_TRACE(2, "Frame:\n" << frame[0] << "\n" << frame[1] << "\n" << frame[2] << "\n" << frame[3]);
typedef std::vector<Point_2> Hole;
Hole poly(vertices_begin, vertices_end);

View File

@ -187,6 +187,8 @@ Uncertain<bool> exist_offset_lines_isec2 ( boost::intrusive_ptr< Trisegment_2<K,
Uncertain<bool> rResult = Uncertain<bool>::indeterminate();
CGAL_STSKEL_TRAITS_TRACE( "Checking existence of an event for E" << tri->e0().mID << " E" << tri->e1().mID << " E" << tri->e2().mID ) ;
if ( tri->collinearity() != TRISEGMENT_COLLINEARITY_ALL )
{
CGAL_STSKEL_TRAITS_TRACE( ( tri->collinearity() == TRISEGMENT_COLLINEARITY_NONE ? " normal edges" : " collinear edges" ) ) ;
@ -206,25 +208,27 @@ Uncertain<bool> exist_offset_lines_isec2 ( boost::intrusive_ptr< Trisegment_2<K,
if ( aMaxTime && CGAL_NTS certainly(rResult) )
rResult = CGAL_NTS certified_is_smaller_or_equal(tq,Quotient(*aMaxTime));
CGAL_STSKEL_TRAITS_TRACE("\nEvent time: " << *t << ". Event " << ( rResult ? "exist." : "doesn't exist." ) ) ;
CGAL_STSKEL_TRAITS_TRACE("Event time: " << *t << ". Event " << ( rResult ? "exist." : "doesn't exist." ) ) ;
}
else
{
CGAL_STSKEL_TRAITS_TRACE("\nDenominator exactly zero, Event doesn't exist." ) ;
CGAL_STSKEL_TRAITS_TRACE("Denominator exactly zero, Event doesn't exist." ) ;
rResult = false;
}
}
else{
CGAL_STSKEL_TRAITS_TRACE("\nDenominator is probably zero (but not exactly), event existence is indeterminate." ) ;
else
{
CGAL_STSKEL_TRAITS_TRACE("Denominator is probably zero (but not exactly), event existence is indeterminate." ) ;
}
}
else{
CGAL_STSKEL_TRAITS_TRACE("\nEvent time overflowed, event existence is indeterminate." ) ;
else
{
CGAL_STSKEL_TRAITS_TRACE("Event time overflowed, event existence is indeterminate." ) ;
}
}
else
{
CGAL_STSKEL_TRAITS_TRACE("\nAll the edges are collinear. Event doesn't exist." ) ;
CGAL_STSKEL_TRAITS_TRACE("All the edges are collinear. Event doesn't exist." ) ;
rResult = false;
}