diff --git a/Straight_skeleton_2/changes.txt b/Straight_skeleton_2/changes.txt index 231175221ac..3bf0245766c 100644 --- a/Straight_skeleton_2/changes.txt +++ b/Straight_skeleton_2/changes.txt @@ -5,13 +5,20 @@ - Fixed a bug in the detection of events at time zero (which ought to be ignored) 5 July 2006 Fernando Cacciola +- Merginig of coincident nodes now disabled by default (but can be requested) - Computation of the coordinates of skeleton nodes now filtered -- Split-events are now clustered into parallel priority-queues to reduce processing time (up to 3 times faster now) +- Bug fixes in the handling of degnerate and near degenerate events +- Split-events clustered to reduce processing time (by a factor of 3) 20 June 2006 Fernando Cacciola - Bug fixes from user report (see pseudo_split_5.poly) - Vertex-events replaced by Pseudo-split events + +RELEASE 3.2 + + + 26 March 2006 Fernando Cacciola - Even more fixes for VC8 - More uses of the straight skeleton added to the docs diff --git a/Straight_skeleton_2/demo/Straight_skeleton_2/ss_types.h b/Straight_skeleton_2/demo/Straight_skeleton_2/ss_types.h index 049bed9f46e..17a0dbca14d 100644 --- a/Straight_skeleton_2/demo/Straight_skeleton_2/ss_types.h +++ b/Straight_skeleton_2/demo/Straight_skeleton_2/ss_types.h @@ -15,6 +15,8 @@ // // Author(s) : Fernando Cacciola // +#ifndef SSKEL_DEMO_SS_TYPES_H +#define SSKEL_DEMO_SS_TYPES_H #include #include @@ -23,12 +25,7 @@ namespace demo { -typedef CGAL::Straight_skeleton_2 SSkel; -typedef CGAL::Straight_skeleton_builder_traits_2 SSkelBuilderTraits; -typedef CGAL::Straight_skeleton_builder_2 SSkelBuilder; - -typedef CGAL::Polygon_offset_builder_traits_2 OffsetBuilderTraits; -typedef CGAL::Polygon_offset_builder_2 OffsetBuilder; +typedef CGAL::Straight_skeleton_2 SSkel; typedef SSkel::Halfedge_iterator Halfedge_iterator; typedef SSkel::Vertex_handle Vertex_handle; @@ -38,4 +35,161 @@ typedef SSkel::Vertex_const_handle Vertex_const_handle ; typedef boost::shared_ptr SSkelPtr ; +extern void draw_vertex ( Point const& v, CGAL::Color c ) ; +extern void draw_bisector( Point const& s, Point const& t, CGAL::Color c ) ; + +struct Visitor +{ + void on_initialization_started( int size_of_vertices ) const + { + mTotalVertices = size_of_vertices ; + mVertexCount0 = 0 ; + mVertexCount1 = 0 ; + mReflexVertexCount = 0 ; + mDegenerateVertexCount = 0 ; + mFoundEdgeEventCount = 0 ; + mFoundSplitEventCount = 0 ; + mProcessedEdgeEventCount = 0 ; + mProcessedSplitEventCount = 0 ; + mProcessedPseudoSplitEventCount = 0 ; + mAnihiliationCount = 0 ; + mStage = 0 ; + } + + void on_initial_events_collected( Vertex_const_handle const& v, bool is_reflex, bool is_degenerate ) const + { + ++ mVertexCount0 ; + if ( is_reflex ) + ++ mReflexVertexCount ; + if ( is_degenerate ) + ++ mDegenerateVertexCount ; + + draw_vertex(v->point(),CGAL::BLACK ); + + //printf("\rInitialization: %d/%d (%d%%)",mVertexCount0,mTotalVertices,(mVertexCount0*100/mTotalVertices)); + } + + void on_edge_event_created( Vertex_const_handle const& lnode + , Vertex_const_handle const& rnode + ) const + { + ++ mFoundEdgeEventCount ; + } + + void on_split_event_created( Vertex_const_handle const& node ) const + { + ++ mFoundSplitEventCount ; + } + + void on_pseudo_split_event_created( Vertex_const_handle const& lnode + , Vertex_const_handle const& rnode + ) const + { + } + + void on_initialization_finished() const { printf("\n"); ++ mStage ; } + + void on_propagation_started() const {} + + void on_anihiliation_event_processed ( Vertex_const_handle const& node0 + , Vertex_const_handle const& node1 + ) const + { + draw_bisector(node0->point(),node1->point(),CGAL::BLACK); + ++ mAnihiliationCount ; + } + + void on_edge_event_processed( Vertex_const_handle const& lseed + , Vertex_const_handle const& rseed + , Vertex_const_handle const& node + ) const + { + draw_bisector(lseed->point(),node->point(), CGAL::BLACK ); + draw_bisector(rseed->point(),node->point(), CGAL::BLACK ); + + ++ mProcessedEdgeEventCount ; + } + + void on_split_event_processed( Vertex_const_handle const& seed + , Vertex_const_handle const& node0 + , Vertex_const_handle const& node1 + ) const + { + draw_bisector(seed->point(),node0->point(), CGAL::BLACK ); + ++ mProcessedSplitEventCount ; + } + + void on_pseudo_split_event_processed( Vertex_const_handle const& lseed + , Vertex_const_handle const& rseed + , Vertex_const_handle const& node0 + , Vertex_const_handle const& node1 + ) const + { + draw_bisector(lseed->point(),node0->point(), CGAL::BLACK ); + draw_bisector(rseed->point(),node1->point(), CGAL::BLACK ); + ++ mProcessedPseudoSplitEventCount ; + } + + void on_vertex_processed( Vertex_const_handle const& node ) const + { + if ( node->is_contour() ) + { + ++ mVertexCount1 ; + //printf("\rPropagation: %d/%d (%d%%)",mVertexCount1,mTotalVertices,(mVertexCount1*100/mTotalVertices)); + } + } + + void on_propagation_finished() const { printf("\n"); ++ mStage ; } + + void on_cleanup_started( bool mergin_coincident_nodes ) const {} + + void on_cleanup_finished() const {} + + void on_error( char const* what ) const + { + std::cerr << what << std::endl ; + } + + void on_algorithm_finished ( bool finished_ok ) const + { + } + + mutable int mTotalVertices ; + mutable int mVertexCount0 ; + mutable int mVertexCount1 ; + mutable int mReflexVertexCount ; + mutable int mDegenerateVertexCount ; + mutable int mFoundEdgeEventCount ; + mutable int mFoundSplitEventCount ; + mutable int mProcessedEdgeEventCount ; + mutable int mProcessedSplitEventCount ; + mutable int mProcessedPseudoSplitEventCount ; + mutable int mAnihiliationCount ; + mutable int mStage ; + + void print_stats() + { + std::cout << "VertexCount =" << mTotalVertices << std::endl + << "ReflexVertexCount =" << mReflexVertexCount << std::endl + << "DegenerateVertexCount =" << mDegenerateVertexCount << std::endl + << "FoundEdgeEventCount =" << mFoundEdgeEventCount << std::endl + << "FoundSplitEventCount =" << mFoundSplitEventCount << std::endl + << "ProcessedEdgeEventCount =" << mProcessedEdgeEventCount << std::endl + << "ProcessedSplitEventCount =" << mProcessedSplitEventCount << std::endl + << "ProcessedPseudoSplitEventCount=" << mProcessedPseudoSplitEventCount << std::endl + << "AnihiliationCount =" << mAnihiliationCount << std::endl ; + } + +} ; + +typedef CGAL::Straight_skeleton_builder_traits_2 SSkelBuilderTraits; +typedef CGAL::Straight_skeleton_builder_2 SSkelBuilder; + +typedef CGAL::Polygon_offset_builder_traits_2 OffsetBuilderTraits; +typedef CGAL::Polygon_offset_builder_2 OffsetBuilder; + + } + +#endif // SSKEL_DEMO_SS_TYPES_H + diff --git a/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/Straight_skeleton_aux.h b/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/Straight_skeleton_aux.h index fa509319708..7a81877ead7 100644 --- a/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/Straight_skeleton_aux.h +++ b/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/Straight_skeleton_aux.h @@ -35,6 +35,19 @@ enum Triedge_collinearity , TRIEDGE_COLLINEARITY_ALL } ; +static char const* triedge_collinearity_to_string( Triedge_collinearity c ) +{ + switch ( c ) + { + case TRIEDGE_COLLINEARITY_NONE : return "<>" ; + case TRIEDGE_COLLINEARITY_01 : return "<0,1>" ; + case TRIEDGE_COLLINEARITY_12 : return "<1,2>" ; + case TRIEDGE_COLLINEARITY_02 : return "<0,2>" ; + case TRIEDGE_COLLINEARITY_ALL : return "<0,1,2>" ; + } + + return "!!UNKNOWN COLLINEARITY!!" ; +} namespace CGALi { diff --git a/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/Straight_skeleton_builder_2_impl.h b/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/Straight_skeleton_builder_2_impl.h index c128bc296a3..e3189db742d 100644 --- a/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/Straight_skeleton_builder_2_impl.h +++ b/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/Straight_skeleton_builder_2_impl.h @@ -57,8 +57,6 @@ Straight_skeleton_builder_2::Straight_skeleton_builder_2 ( Traits const template void Straight_skeleton_builder_2::throw_error ( char const* what ) const { - mVisitor.on_error(what); - throw straight_skeleton_exception(what); } @@ -127,7 +125,6 @@ Straight_skeleton_builder_2::FindEdgeEvent( Vertex_handle aLNode, Verte mVisitor.on_edge_event_created(aLNode, aRNode) ; CGAL_STSKEL_DEBUG_CODE( SetEventTimeAndPoint(*rResult) ); - CGAL_STSKEL_STATS_CODE(++sFoundEdgeEventCount); } } } @@ -161,7 +158,11 @@ Straight_skeleton_builder_2::IsPseudoSplitEvent( EventPtr const& aEvent bool lCoupleIsPrev = false ; - if ( !IsDegenerate(lOppPrevN) && ExistEvent(lPrevSTriedge) && AreEventsSimultaneous(lEventSTriedge,lPrevSTriedge) ) + if ( !IsDegenerate(lOppPrevN) + && ExistEvent(lPrevSTriedge) + && CompareEvents(lEventSTriedge,lPrevSTriedge) == EQUAL + //&& AreEventsSimultaneous(lEventSTriedge,lPrevSTriedge) + ) { lIsPseudoSplitEvent = true ; lCoupleIsPrev = true ; @@ -169,7 +170,11 @@ Straight_skeleton_builder_2::IsPseudoSplitEvent( EventPtr const& aEvent } else { - if ( !IsDegenerate(aOppN) && ExistEvent(lNextSTriedge) && AreEventsSimultaneous(lEventSTriedge,lNextSTriedge) ) + if ( !IsDegenerate(aOppN) + && ExistEvent(lNextSTriedge) + && CompareEvents(lEventSTriedge,lNextSTriedge) == EQUAL + //&& AreEventsSimultaneous(lEventSTriedge,lNextSTriedge) + ) { lIsPseudoSplitEvent = true ; lCoupleIsPrev = false ; @@ -218,7 +223,7 @@ void Straight_skeleton_builder_2::CollectSplitEvent( Vertex_handle aN { Sorted_triedge_2 lSortedTriedge = CreateSortedTriedge(aReflexLBorder,aReflexRBorder,aOppositeBorder); - if ( ExistEvent(lSortedTriedge) ) + if ( lSortedTriedge.collinearity() == TRIEDGE_COLLINEARITY_NONE && ExistEvent(lSortedTriedge) ) { if ( ! ( aNode->is_skeleton() && IsNewEventInThePast(aReflexLBorder,aReflexRBorder,aOppositeBorder,lSortedTriedge,aNode) ) ) { @@ -227,7 +232,6 @@ void Straight_skeleton_builder_2::CollectSplitEvent( Vertex_handle aN mVisitor.on_split_event_created(aNode) ; CGAL_STSKEL_DEBUG_CODE( SetEventTimeAndPoint(*lEvent) ) ; - CGAL_STSKEL_STATS_CODE( ++sFoundSplitEventCount ); AddSplitEvent(aNode,lEvent); } @@ -386,8 +390,6 @@ void Straight_skeleton_builder_2::HandleSimultaneousEdgeEvent( Vertex_h { CGAL_STSKEL_BUILDER_TRACE ( 2, "Handling simultaneous EdgeEvent between N" << aA ->id() << " and N" << aB ->id() ) ; - CGAL_STSKEL_STATS_CODE(++sAnihiliationCount); - mVisitor.on_anihiliation_event_processed(aA,aB) ; Halfedge_handle lOA = aA->primary_bisector() ; @@ -506,7 +508,7 @@ void Straight_skeleton_builder_2::CreateInitialEvents() for ( Vertex_iterator v = mSSkel->vertices_begin(); v != mSSkel->vertices_end(); ++ v ) { UpdatePQ(v); - mVisitor.on_initial_events_collected(v) ; + mVisitor.on_initial_events_collected(v,IsReflex(v),IsDegenerate(v)) ; } } @@ -517,8 +519,6 @@ void Straight_skeleton_builder_2::CreateContourBisectors() CGAL_STSKEL_BUILDER_TRACE(0, "Creating contour bisectors..."); for ( Vertex_iterator v = mSSkel->vertices_begin(); v != mSSkel->vertices_end(); ++ v ) { - CGAL_STSKEL_STATS_CODE(++sVertexCount); - mSLAV.push_back(static_cast(v)); Vertex_handle lPrev = GetPrevInLAV(v) ; Vertex_handle lNext = GetNextInLAV(v) ; @@ -528,14 +528,12 @@ void Straight_skeleton_builder_2::CreateContourBisectors() { SetIsDegenerate(v); CGAL_STSKEL_BUILDER_TRACE(1, "COLLINEAR vertex: N" << v->id() ); - CGAL_STSKEL_STATS_CODE(++sDegenerateVertexCount); } else if ( lOrientation == RIGHT_TURN ) { mReflexVertices.push_back(v); SetIsReflex(v); CGAL_STSKEL_BUILDER_TRACE(1,"Reflex vertex: N" << v->id() ); - CGAL_STSKEL_STATS_CODE(++sReflexVertexCount); } Halfedge lOB(mEdgeID++), lIB(mEdgeID++); @@ -561,8 +559,10 @@ void Straight_skeleton_builder_2::CreateContourBisectors() template void Straight_skeleton_builder_2::InitPhase() { + mVisitor.on_initialization_started(mSSkel->size_of_vertices()); CreateContourBisectors(); CreateInitialEvents(); + mVisitor.on_initialization_finished(); } template @@ -855,8 +855,6 @@ bool Straight_skeleton_builder_2::IsProcessed( EventPtr aEvent ) template void Straight_skeleton_builder_2::HandleEdgeEvent( EventPtr aEvent ) { - CGAL_STSKEL_STATS_CODE(++sProcessedEdgeEventCount); - EdgeEvent& lEvent = dynamic_cast(*aEvent) ; Vertex_handle lLSeed = lEvent.seed0() ; @@ -933,15 +931,13 @@ void Straight_skeleton_builder_2::HandleEdgeEvent( EventPtr aEvent ) ); } - mVisitor.on_edge_event_processed(lLSeed,lRSeed) ; + mVisitor.on_edge_event_processed(lLSeed,lRSeed,lNewNode) ; } template void Straight_skeleton_builder_2::HandleSplitEvent( EventPtr aEvent, Vertex_handle aOppR ) { - CGAL_STSKEL_STATS_CODE(++sProcessedSplitEventCount); - SplitEvent& lEvent = dynamic_cast(*aEvent) ; Halfedge_handle lOppBorder = lEvent.border_c() ; @@ -1033,7 +1029,7 @@ void Straight_skeleton_builder_2::HandleSplitEvent( EventPtr aEvent, Ve UpdatePQ(lNewNode_L); UpdatePQ(lNewNode_R); - mVisitor.on_split_event_processed(lSeed) ; + mVisitor.on_split_event_processed(lSeed,lNewNode_L,lNewNode_R) ; } template @@ -1051,7 +1047,6 @@ void Straight_skeleton_builder_2::SetupPseudoSplitEventNode( Vertex_han { SetIsDegenerate(aNode); CGAL_STSKEL_BUILDER_TRACE(1, "COLLINEAR *NEW* vertex: N" << aNode->id() ); - CGAL_STSKEL_STATS_CODE(++sDegenerateVertexCount); } else if ( lOrientation == RIGHT_TURN ) { @@ -1064,7 +1059,6 @@ void Straight_skeleton_builder_2::SetupPseudoSplitEventNode( Vertex_han template void Straight_skeleton_builder_2::HandlePseudoSplitEvent( EventPtr aEvent ) { - CGAL_STSKEL_STATS_CODE(++sProcessedPseudoSplitEventCount); PseudoSplitEvent& lEvent = dynamic_cast(*aEvent) ; @@ -1157,7 +1151,7 @@ void Straight_skeleton_builder_2::HandlePseudoSplitEvent( EventPtr aEve UpdatePQ(lNewNode_L); UpdatePQ(lNewNode_R); - mVisitor.on_pseudo_split_event_processed(lLSeed,lRSeed) ; + mVisitor.on_pseudo_split_event_processed(lLSeed,lRSeed,lNewNode_L,lNewNode_R) ; } template @@ -1171,10 +1165,6 @@ void Straight_skeleton_builder_2::HandleSplitOrPseudoSplitEvent( EventP HandlePseudoSplitEvent(lPseudoSplitEvent); else HandleSplitEvent (aEvent,lOppR); } - else - { - CGAL_STSKEL_STATS_CODE(++sOutOfReachSplitEventCount); - } } template @@ -1204,6 +1194,7 @@ template void Straight_skeleton_builder_2::Propagate() { CGAL_STSKEL_BUILDER_TRACE(0,"Propagating events..."); + mVisitor.on_propagation_started(); while ( !mPQ.empty() ) { @@ -1231,6 +1222,8 @@ void Straight_skeleton_builder_2::Propagate() ++ mStepID ; } } + + mVisitor.on_propagation_finished(); } template @@ -1558,6 +1551,8 @@ bool Straight_skeleton_builder_2::FinishUp( bool aMergeCoincidentNodes { CGAL_STSKEL_BUILDER_TRACE(0, "\n\nFinishing up..."); + mVisitor.on_cleanup_started(aMergeCoincidentNodes); + std::for_each( mSplitNodes.begin() ,mSplitNodes.end () ,boost::bind(&Straight_skeleton_builder_2::MergeSplitNodes,this,_1) @@ -1575,6 +1570,8 @@ bool Straight_skeleton_builder_2::FinishUp( bool aMergeCoincidentNodes MergeCoincidentNodes(); CGAL_expensive_postcondition( ok = mSSkel->is_valid() ) ; } + + mVisitor.on_cleanup_finished(); return ok ; } @@ -1598,7 +1595,7 @@ typename Straight_skeleton_builder_2::SSkelPtr Straight_skeleton_builde } catch( std::exception const& e ) { - std::cerr << "Exception caught: " << e.what() << std::endl ; + mVisitor.on_error ( e.what() ) ; CGAL_STSKEL_BUILDER_TRACE(0,"EXCEPTION THROWN (" << e.what() << ") during straight skeleton construction."); } @@ -1608,26 +1605,7 @@ typename Straight_skeleton_builder_2::SSkelPtr Straight_skeleton_builde mSSkel = SSkelPtr() ; } - -#ifdef CGAL_STRAIGHT_SKELETON_STATS - -std::cerr << "sVertexCount =" << sVertexCount << std::endl - << "sReflexVertexCount =" << sReflexVertexCount << std::endl - << "sDegenerateVertexCount =" << sDegenerateVertexCount << std::endl - << "sFoundEdgeEventCount =" << sFoundEdgeEventCount << std::endl - << "sFoundSplitEventCount =" << sFoundSplitEventCount << std::endl - << "sProcessedEdgeEventCount =" << sProcessedEdgeEventCount << std::endl - << "sProcessedSplitEventCount =" << sProcessedSplitEventCount << std::endl - << "sProcessedPseudoSplitEventCount=" << sProcessedPseudoSplitEventCount << std::endl - << "sOutOfReachSplitEventCount =" << sOutOfReachSplitEventCount << std::endl - << "sAnihiliationCount =" << sAnihiliationCount << std::endl - << "sInFrameCount =" << sInFrameCount << std::endl - << "sOutsideFrameCount =" << sOutsideFrameCount<< std::endl - << "sInTimeRangeCount =" << sInTimeRangeCount << std::endl - << "sOutsideTimeRangeCount =" << sOutsideTimeRangeCount << std::endl - << "sSingularCount =" << sSingularCount << std::endl ; -#endif - + mVisitor.on_algorithm_finished(ok); return mSSkel ; } diff --git a/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/Straight_skeleton_builder_events_2.h b/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/Straight_skeleton_builder_events_2.h index 4d29640a0f9..820a2654213 100644 --- a/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/Straight_skeleton_builder_events_2.h +++ b/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/Straight_skeleton_builder_events_2.h @@ -81,9 +81,8 @@ public: { ss << "[" ; e.dump(ss); - ss << " p=(" << e.point().x() << "," << e.point().y() << ") t=" << e.time() << "]" ; - if ( e.sorted_triedge().collinear_count() > 0 ) - ss << " {collinear count=" << e.sorted_triedge().collinear_count() << "}" ; + ss << " p=(" << e.point().x() << "," << e.point().y() << ") t=" << e.time() << "] " + << triedge_collinearity_to_string(e.sorted_triedge().collinearity()) ; return ss ; } diff --git a/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/Straight_skeleton_builder_traits_2_aux.h b/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/Straight_skeleton_builder_traits_2_aux.h index a572a65ded9..a74014a9bb4 100644 --- a/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/Straight_skeleton_builder_traits_2_aux.h +++ b/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/Straight_skeleton_builder_traits_2_aux.h @@ -356,20 +356,20 @@ class Sorted_triedge_2 : public Triedge_2 typedef typename Base::Segment_2 Segment_2 ; - Sorted_triedge_2( Segment_2 const& aE0 - , Segment_2 const& aE1 - , Segment_2 const& aE2 - , int aCollinearCount + Sorted_triedge_2( Segment_2 const& aE0 + , Segment_2 const& aE1 + , Segment_2 const& aE2 + , Triedge_collinearity aCollinearity ) : Base(aE0,aE1,aE2) - , mCCount(aCollinearCount) + , mCollinearity(aCollinearity) {} - int collinear_count() const { return mCCount ; } + Triedge_collinearity collinearity() const { return mCollinearity ; } private: - int mCCount ; + Triedge_collinearity mCollinearity ; } ; template @@ -442,7 +442,7 @@ struct SS_converter : Converter Target_sorted_triedge_2 operator()( Source_sorted_triedge_2 const& t) const { - return Target_sorted_triedge_2(cvts(t.e0()), cvts(t.e1()), cvts(t.e2()), t.collinear_count() ) ; + return Target_sorted_triedge_2(cvts(t.e0()), cvts(t.e1()), cvts(t.e2()), t.collinearity() ) ; } Target_time_and_point_2 operator() ( Source_time_and_point_2 const& v ) const 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 6714fe79dc5..d7aa846a6b5 100644 --- a/Straight_skeleton_2/include/CGAL/Straight_skeleton_builder_2.h +++ b/Straight_skeleton_2/include/CGAL/Straight_skeleton_builder_2.h @@ -40,21 +40,6 @@ #ifdef CGAL_STRAIGHT_SKELETON_STATS -int sVertexCount ; -int sReflexVertexCount ; -int sDegenerateVertexCount ; -int sFoundEdgeEventCount ; -int sFoundSplitEventCount ; -int sProcessedEdgeEventCount ; -int sProcessedSplitEventCount ; -int sProcessedPseudoSplitEventCount ; -int sOutOfReachSplitEventCount ; -int sAnihiliationCount ; -int sInFrameCount ; -int sOutsideFrameCount ; -int sInTimeRangeCount ; -int sOutsideTimeRangeCount ; -int sSingularCount ; #define CGAL_STSKEL_STATS_CODE(c) c #else @@ -70,8 +55,10 @@ struct Dummy_straight_skeleton_builder_2_visitor typedef typename SSkel::Vertex_const_handle Vertex_const_handle ; - void on_error( char const* ) const {} - + void on_initialization_started( int size_of_vertices ) const {} + + void on_initial_events_collected( Vertex_const_handle const& v, bool is_reflex, bool is_degenerate ) const {} + void on_edge_event_created( Vertex_const_handle const& lnode , Vertex_const_handle const& rnode ) const {} @@ -81,24 +68,43 @@ struct Dummy_straight_skeleton_builder_2_visitor void on_pseudo_split_event_created( Vertex_const_handle const& lnode , Vertex_const_handle const& rnode ) const {} - + + void on_initialization_finished() const {} + + void on_propagation_started() const {} + void on_anihiliation_event_processed ( Vertex_const_handle const& node0 , Vertex_const_handle const& node1 ) const {} - void on_initial_events_collected( Vertex_const_handle const& v ) const {} - void on_edge_event_processed( Vertex_const_handle const& lnode - , Vertex_const_handle const& rnode + void on_edge_event_processed( Vertex_const_handle const& lseed + , Vertex_const_handle const& rseed + , Vertex_const_handle const& node ) const {} - void on_split_event_processed( Vertex_const_handle const& node ) const {} + void on_split_event_processed( Vertex_const_handle const& seed + , Vertex_const_handle const& node0 + , Vertex_const_handle const& node1 + ) const {} - void on_pseudo_split_event_processed( Vertex_const_handle const& lnode - , Vertex_const_handle const& rnode + void on_pseudo_split_event_processed( Vertex_const_handle const& lseed + , Vertex_const_handle const& rseed + , Vertex_const_handle const& node0 + , Vertex_const_handle const& node1 ) const {} void on_vertex_processed( Vertex_const_handle const& node ) const {} + + void on_propagation_finished() const {} + + void on_cleanup_started( bool mergin_coincident_nodes ) const {} + + void on_cleanup_finished() const {} + + void on_algorithm_finished ( bool finished_ok ) const {} + + void on_error( char const* ) const {} } ; @@ -733,10 +739,10 @@ private: Visitor const& mVisitor ; - std::vector mWrappedVertices ; - Vertex_handle_vector mReflexVertices ; - Halfedge_handle_vector mDanglingBisectors ; - Halfedge_handle_vector mContourHalfedges ; + std::vector mWrappedVertices ; + Vertex_handle_vector mReflexVertices ; + Halfedge_handle_vector mDanglingBisectors ; + Halfedge_handle_vector mContourHalfedges ; std::list mSLAV ; diff --git a/Straight_skeleton_2/include/CGAL/Straight_skeleton_builder_traits_2.h b/Straight_skeleton_2/include/CGAL/Straight_skeleton_builder_traits_2.h index 5aa4da697eb..6a1c46887d3 100644 --- a/Straight_skeleton_2/include/CGAL/Straight_skeleton_builder_traits_2.h +++ b/Straight_skeleton_2/include/CGAL/Straight_skeleton_builder_traits_2.h @@ -259,7 +259,7 @@ struct Construct_ss_event_time_and_point_2 : Functor_base_2 FT t(0) ; Point_2 i = ORIGIN ; - CGAL_assertion(triedge.collinear_count() < 3) ; + CGAL_assertion(triedge.collinearity() != TRIEDGE_COLLINEARITY_ALL) ; optional< Rational > ot = compute_offset_lines_isec_timeC2(triedge); diff --git a/Straight_skeleton_2/include/CGAL/certified_quotient_predicates.h b/Straight_skeleton_2/include/CGAL/certified_quotient_predicates.h index 2766572d8f0..43ada53112a 100644 --- a/Straight_skeleton_2/include/CGAL/certified_quotient_predicates.h +++ b/Straight_skeleton_2/include/CGAL/certified_quotient_predicates.h @@ -36,8 +36,8 @@ inline Uncertain certified_quotient_is_positive(const Quotient& x) template inline Uncertain certified_quotient_is_negative(const Quotient& x) { - Uncertain singnum = CGAL_NTS certified_sign(x.num) ; - Uncertain singden = CGAL_NTS certified_sign(x.den) ; + Uncertain signum = CGAL_NTS certified_sign(x.num) ; + Uncertain sigden = CGAL_NTS certified_sign(x.den) ; Uncertain zero(ZERO); return signum != zero & signum != sigden ; 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 e25dbecb4a6..ceb7d5c3edc 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 @@ -153,8 +153,6 @@ optional< Line_2 > compute_normalized_line_ceoffC2( Segment_2 const& e ) template Sorted_triedge_2 construct_sorted_triedge ( Triedge_2 const& triedge, Triedge_collinearity collinearity ) { - int lCollinearCount = -1 ; - int idx0=0, idx1=1, idx2=2 ; switch ( collinearity ) @@ -163,36 +161,34 @@ Sorted_triedge_2 construct_sorted_triedge ( Triedge_2 const& triedge, Trie idx0 = 0 ; idx1 = 1 ; idx2 = 2 ; - lCollinearCount = 0 ; break ; case TRIEDGE_COLLINEARITY_01 : idx0 = 0 ; idx1 = 1 ; idx2 = 2 ; - lCollinearCount = 2 ; break ; case TRIEDGE_COLLINEARITY_12 : idx0 = 1 ; idx1 = 2 ; idx2 = 0 ; - lCollinearCount = 2 ; break ; case TRIEDGE_COLLINEARITY_02 : idx0 = 0 ; idx1 = 2 ; idx2 = 1 ; - lCollinearCount = 2 ; break ; - default : - lCollinearCount = 3 ; + case TRIEDGE_COLLINEARITY_ALL : + idx0 = 0 ; + idx1 = 1 ; + idx2 = 2 ; break ; } - return Sorted_triedge_2(triedge.e(idx0),triedge.e(idx1),triedge.e(idx2),lCollinearCount); + return Sorted_triedge_2(triedge.e(idx0),triedge.e(idx1),triedge.e(idx2),collinearity); } // Given 3 oriented straight line segments: e0, e1, e2 (passed in a SortedTriedge record) @@ -389,27 +385,19 @@ optional< Rational< typename K::FT> > compute_degenerate_offset_lines_isec_timeC return cgal_make_optional(ok,Rational(num,den)) ; } -// -// Calls the appropiate function depending on the collinearity of the edges. -// -template -optional< Rational< typename K::FT > > compute_offset_lines_isec_timeC2 ( Sorted_triedge_2 const& triedge, int ccount ) -{ - CGAL_precondition ( ccount < 3 ) ; - - return ccount == 0 ? compute_normal_offset_lines_isec_timeC2 (triedge) - : compute_degenerate_offset_lines_isec_timeC2(triedge); -} - // // Calls the appropiate function depending on the collinearity of the edges. // template optional< Rational< typename K::FT > > compute_offset_lines_isec_timeC2 ( Sorted_triedge_2 const& triedge ) { - return compute_offset_lines_isec_timeC2(triedge, triedge.collinear_count() ) ; + CGAL_precondition ( triedge.collinearity() != TRIEDGE_COLLINEARITY_ALL ) ; + + return triedge.collinearity() == TRIEDGE_COLLINEARITY_NONE ? compute_normal_offset_lines_isec_timeC2 (triedge) + : compute_degenerate_offset_lines_isec_timeC2(triedge); } + // Given 3 oriented line segments e0, e1 and e2 (passed in a SortedTriedge record) // such that their offsets at a certian distance intersect in a single point, // returns the coordinates (x,y) of such a point. @@ -529,25 +517,16 @@ optional< Point_2 > construct_degenerate_offset_lines_isecC2 ( Sorted_triedge return cgal_make_optional(ok,K().construct_point_2_object()(x,y)) ; } -// -// Calls the appropiate function depending on the collinearity of the edges. -// -template -optional< Point_2 > construct_offset_lines_isecC2 ( Sorted_triedge_2 const& triedge, int ccount ) -{ - CGAL_precondition ( ccount < 3 ) ; - - return ccount == 0 ? construct_normal_offset_lines_isecC2 (triedge) - : construct_degenerate_offset_lines_isecC2(triedge) ; -} - // // Calls the appropiate function depending on the collinearity of the edges. // template optional< Point_2 > construct_offset_lines_isecC2 ( Sorted_triedge_2 const& triedge ) { - return construct_offset_lines_isecC2(triedge, triedge.collinear_count()) ; + CGAL_precondition ( triedge.collinearity() != TRIEDGE_COLLINEARITY_ALL ) ; + + return triedge.collinearity() == TRIEDGE_COLLINEARITY_NONE ? construct_normal_offset_lines_isecC2 (triedge) + : construct_degenerate_offset_lines_isecC2(triedge) ; } // Give a point (px,py) and 3 oriented straight line segments e0,e1 and e2. 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 bb637f082ab..b04034ca20f 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 @@ -161,9 +161,9 @@ Uncertain exist_offset_lines_isec2 ( Sorted_triedge_2 const& event ) Uncertain rResult = Uncertain::indeterminate(); - if ( event.collinear_count() < 3 ) // If the 3 edges are collinear thre is no event. + if ( event.collinearity() != TRIEDGE_COLLINEARITY_ALL ) // If the 3 edges are collinear thre is no event. { - CGAL_STSKEL_TRAITS_TRACE( ( event.collinear_count() == 0 ? " normal edges" : " collinear edges" ) ) ; + CGAL_STSKEL_TRAITS_TRACE( ( event.collinearity() == TRIEDGE_COLLINEAR_NONE ? " normal edges" : " collinear edges" ) ) ; Optional_rational t = compute_offset_lines_isec_timeC2(event) ; if ( t ) @@ -215,8 +215,8 @@ Uncertain compare_offset_lines_isec_timesC2 ( Sorted_triedge_ Uncertain rResult = Uncertain::indeterminate(); - CGAL_assertion ( m.collinear_count() < 3 ) ; - CGAL_assertion ( n.collinear_count() < 3 ) ; + CGAL_assertion ( m.collinearity() != TRIEDGE_COLLINEARITY_ALL ) ; + CGAL_assertion ( n.collinearity() != TRIEDGE_COLLINEARITY_ALL ) ; Optional_rational mt_ = compute_offset_lines_isec_timeC2(m); Optional_rational nt_ = compute_offset_lines_isec_timeC2(n); @@ -260,8 +260,8 @@ compare_offset_lines_isec_dist_to_pointC2 ( optional< Point_2 > const& p if ( p ) { - CGAL_assertion ( m.collinear_count() < 3 ) ; - CGAL_assertion ( n.collinear_count() < 3 ) ; + CGAL_assertion ( m.collinearity() != TRIEDGE_COLLINEARITY_ALL ) ; + CGAL_assertion ( n.collinearity() != TRIEDGE_COLLINEARITY_ALL ) ; optional dm = compute_offset_lines_isec_dist_to_pointC2(p,m); optional dn = compute_offset_lines_isec_dist_to_pointC2(p,n); @@ -287,7 +287,7 @@ compare_offset_lines_isec_dist_to_pointC2 ( Sorted_triedge_2 const& s { Uncertain rResult = Uncertain::indeterminate(); - CGAL_assertion ( s.collinear_count() < 3 ) ; + CGAL_assertion ( s.collinearity() != TRIEDGE_COLLINEARITY_ALL ) ; rResult = compare_offset_lines_isec_dist_to_pointC2(construct_offset_lines_isecC2(s),m,n); @@ -369,7 +369,7 @@ is_offset_lines_isec_inside_offset_zoneC2 ( Sorted_triedge_2 const& event, Tr if ( !is_indeterminate(degenerate_zone) ) { - CGAL_assertion ( event.collinear_count() < 3 ) ; + CGAL_assertion ( event.collinearity() != TRIEDGE_COLLINEARITY_ALL ) ; if ( !degenerate_zone ) { @@ -580,8 +580,8 @@ Uncertain are_events_simultaneousC2 ( Sorted_triedge_2 const& l, Sorted Uncertain rResult = Uncertain::indeterminate(); - CGAL_assertion ( l.collinear_count() < 3 ) ; - CGAL_assertion ( r.collinear_count() < 3 ) ; + CGAL_assertion ( l.collinearity() != TRIEDGE_COLLINEARITY_ALL ) ; + CGAL_assertion ( r.collinearity() != TRIEDGE_COLLINEARITY_ALL ) ; Optional_rational lt_ = compute_offset_lines_isec_timeC2(l); Optional_rational rt_ = compute_offset_lines_isec_timeC2(r); diff --git a/Straight_skeleton_2/test/Straight_skeleton_2/include/CGAL/test_offset_builder_types.h b/Straight_skeleton_2/test/Straight_skeleton_2/include/CGAL/test_offset_builder_types.h index b5285921e89..05382c787eb 100644 --- a/Straight_skeleton_2/test/Straight_skeleton_2/include/CGAL/test_offset_builder_types.h +++ b/Straight_skeleton_2/test/Straight_skeleton_2/include/CGAL/test_offset_builder_types.h @@ -21,6 +21,7 @@ #include #include #include +#include #include #include