From ae390dade2985ac13070b24ba6e28d79e4ef5e32 Mon Sep 17 00:00:00 2001 From: Michael Seel Date: Fri, 28 Dec 2001 12:55:20 +0000 Subject: [PATCH] added headers and such --- .../CGAL/IO/Nef_polyhedron_2_PS_stream.h | 27 + .../Nef_2/include/CGAL/Nef_2/Object_handle.h | 8 +- .../CGAL/Nef_2/Segment_overlay_traits.h | 1405 ++++++++--------- .../Nef_2/include/CGAL/Nef_2/redefine_MSC.h | 25 + 4 files changed, 702 insertions(+), 763 deletions(-) diff --git a/Packages/Nef_2/include/CGAL/IO/Nef_polyhedron_2_PS_stream.h b/Packages/Nef_2/include/CGAL/IO/Nef_polyhedron_2_PS_stream.h index c3b1a18db14..66f6274a006 100644 --- a/Packages/Nef_2/include/CGAL/IO/Nef_polyhedron_2_PS_stream.h +++ b/Packages/Nef_2/include/CGAL/IO/Nef_polyhedron_2_PS_stream.h @@ -1,3 +1,30 @@ +// ============================================================================ +// +// Copyright (c) 1997-2000 The CGAL Consortium +// +// This software and related documentation is part of an INTERNAL release +// of the Computational Geometry Algorithms Library (CGAL). It is not +// intended for general use. +// +// ---------------------------------------------------------------------------- +// +// release : $CGAL_Revision$ +// release_date : $CGAL_Date$ +// +// file : include/CGAL/IO/Nef_polyhedron_2_PS_stream.h +// package : Nef_2 +// chapter : Nef Polyhedra +// +// revision : $Revision$ +// revision_date : $Date$ +// +// author(s) : Michael Seel +// maintainer : Michael Seel +// coordinator : Michael Seel +// +// implementation: Nef polyhedra in the plane +// ============================================================================ + #ifndef NEF_POLYHEDRON_2_PS_STREAM_H #define NEF_POLYHEDRON_2_PS_STREAM_H diff --git a/Packages/Nef_2/include/CGAL/Nef_2/Object_handle.h b/Packages/Nef_2/include/CGAL/Nef_2/Object_handle.h index fd1d98c3a85..5120833ce3f 100644 --- a/Packages/Nef_2/include/CGAL/Nef_2/Object_handle.h +++ b/Packages/Nef_2/include/CGAL/Nef_2/Object_handle.h @@ -11,9 +11,9 @@ // release : $CGAL_Revision: CGAL-2.4-I-33 $ // release_date : $CGAL_Date: 2001/12/04 $ // -// file : include/CGAL/Object.h -// package : Kernel_basic (3.68) -// maintainer : Sylvain Pion +// file : include/CGAL/Object_handle.h +// package : Nef_2 +// maintainer : Michael Seel // revision : $Revision$ // revision_date : $Date$ // author(s) : Stefan Schirra @@ -22,8 +22,6 @@ // Michael Seel // Sylvain Pion // -// coordinator : MPI Saarbruecken, Germany -// // ====================================================================== #ifndef CGAL_OBJECT_HANDLE_H diff --git a/Packages/Nef_2/include/CGAL/Nef_2/Segment_overlay_traits.h b/Packages/Nef_2/include/CGAL/Nef_2/Segment_overlay_traits.h index 1d997415f8b..8f0f3764ec9 100644 --- a/Packages/Nef_2/include/CGAL/Nef_2/Segment_overlay_traits.h +++ b/Packages/Nef_2/include/CGAL/Nef_2/Segment_overlay_traits.h @@ -1,4 +1,3 @@ -#line 2325 "Segment_overlay.lw" // ============================================================================ // // Copyright (c) 1997-2000 The CGAL Consortium @@ -26,7 +25,6 @@ // // implementation: generic segment intersection sweep // ============================================================================ -#line 338 "Segment_overlay.lw" #ifndef CGAL_SEGMENT_OVERLAY_TRAITS_H #define CGAL_SEGMENT_OVERLAY_TRAITS_H @@ -37,7 +35,6 @@ //#define INCLUDEBOTH #if defined(CGAL_USE_LEDA) || defined(INCLUDEBOTH) -#line 368 "Segment_overlay.lw" #include #include #include @@ -49,453 +46,387 @@ #include namespace CGAL { -#line 958 "Segment_overlay.lw" #ifdef _DEBUG #define PIS(s) (s->first()) #endif -#line 390 "Segment_overlay.lw" template class leda_seg_overlay_traits { public: - -#line 416 "Segment_overlay.lw" -typedef IT ITERATOR; -typedef std::pair INPUT; -typedef PMDEC OUTPUT; -typedef typename PMDEC::Vertex_handle Vertex_handle; -typedef typename PMDEC::Halfedge_handle Halfedge_handle; -typedef GEOM GEOMETRY; -typedef typename GEOMETRY::Point_2 Point_2; -typedef typename GEOMETRY::Segment_2 Segment_2; + typedef IT ITERATOR; + typedef std::pair INPUT; + typedef PMDEC OUTPUT; + typedef typename PMDEC::Vertex_handle Vertex_handle; + typedef typename PMDEC::Halfedge_handle Halfedge_handle; + typedef GEOM GEOMETRY; + typedef typename GEOMETRY::Point_2 Point_2; + typedef typename GEOMETRY::Segment_2 Segment_2; -#line 394 "Segment_overlay.lw" - -#line 433 "Segment_overlay.lw" -typedef leda_two_tuple seg_pair; -typedef seg_pair* ISegment; -typedef leda_list IList; -typedef typename IList::iterator ilist_iterator; + typedef leda_two_tuple seg_pair; + typedef seg_pair* ISegment; + typedef leda_list IList; + typedef typename IList::iterator ilist_iterator; -#line 396 "Segment_overlay.lw" // types interfacing the generic sweep frame: ITERATOR its, ite; OUTPUT& GO; const GEOMETRY& K; - -#line 446 "Segment_overlay.lw" -class cmp_segs_at_sweepline : public leda_cmp_base -{ const Point_2& p; - ISegment s_bottom, s_top; // sentinel segments - const GEOMETRY& K; -public: - cmp_segs_at_sweepline(const Point_2& pi, - ISegment s1, ISegment s2, const GEOMETRY& k) : - p(pi), s_bottom(s1), s_top(s2), K(k) {} + class cmp_segs_at_sweepline : public leda_cmp_base + { const Point_2& p; + ISegment s_bottom, s_top; // sentinel segments + const GEOMETRY& K; + public: + cmp_segs_at_sweepline(const Point_2& pi, + ISegment s1, ISegment s2, const GEOMETRY& k) : + p(pi), s_bottom(s1), s_top(s2), K(k) {} - int operator()(const ISegment& is1, const ISegment& is2) const - { // Precondition: p is identical to the left endpoint of s1 or s2. - if ( is2 == s_top || is1 == s_bottom ) return -1; - if ( is1 == s_top || is2 == s_bottom ) return 1; - if ( is1 == is2 ) return 0; - const Segment_2& s1 = is1->first(); - const Segment_2& s2 = is2->first(); - int s = 0; - if ( p == K.source(s1) ) s = K.orientation(s2,p); - else if ( p == K.source(s2) ) s = - K.orientation(s1,p); - else ASSERT(0,"compare error in sweep."); - if ( s || K.is_degenerate(s1) || K.is_degenerate(s2) ) + int operator()(const ISegment& is1, const ISegment& is2) const + { // Precondition: p is identical to the left endpoint of s1 or s2. + if ( is2 == s_top || is1 == s_bottom ) return -1; + if ( is1 == s_top || is2 == s_bottom ) return 1; + if ( is1 == is2 ) return 0; + const Segment_2& s1 = is1->first(); + const Segment_2& s2 = is2->first(); + int s = 0; + if ( p == K.source(s1) ) s = K.orientation(s2,p); + else if ( p == K.source(s2) ) s = - K.orientation(s1,p); + else ASSERT(0,"compare error in sweep."); + if ( s || K.is_degenerate(s1) || K.is_degenerate(s2) ) + return s; + + s = K.orientation(s2,K.target(s1)); + if (s==0) return ( is1 - is2 ); + // overlapping segments are not equal return s; - - s = K.orientation(s2,K.target(s1)); - if (s==0) return ( is1 - is2 ); - // overlapping segments are not equal - return s; - } -}; + } + }; -#line 479 "Segment_overlay.lw" -struct cmp_pnts_xy : public leda_cmp_base -{ const GEOMETRY& K; -public: - cmp_pnts_xy(const GEOMETRY& k) : K(k) {} - int operator()(const Point_2& p1, const Point_2& p2) const - { return K.compare_xy(p1,p2); } -}; + struct cmp_pnts_xy : public leda_cmp_base + { const GEOMETRY& K; + public: + cmp_pnts_xy(const GEOMETRY& k) : K(k) {} + int operator()(const Point_2& p1, const Point_2& p2) const + { return K.compare_xy(p1,p2); } + }; -#line 402 "Segment_overlay.lw" - -#line 526 "Segment_overlay.lw" -typedef leda_sortseq EventQueue; -typedef leda_sortseq SweepStatus; -typedef leda_p_queue SegQueue; -typedef leda_map AssocEdgeMap; -typedef leda_slist IsoList; -typedef leda_map AssocIsoMap; -typedef leda_map2 EventHash; + typedef leda_sortseq EventQueue; + typedef leda_sortseq SweepStatus; + typedef leda_p_queue SegQueue; + typedef leda_map AssocEdgeMap; + typedef leda_slist IsoList; + typedef leda_map AssocIsoMap; + typedef leda_map2 EventHash; - seq_item event; - Point_2 p_sweep; - cmp_pnts_xy cmp; - EventQueue XS; - seg_pair sl,sh; - cmp_segs_at_sweepline SLcmp; - SweepStatus YS; - SegQueue SQ; + seq_item event; + Point_2 p_sweep; + cmp_pnts_xy cmp; + EventQueue XS; + seg_pair sl,sh; + cmp_segs_at_sweepline SLcmp; + SweepStatus YS; + SegQueue SQ; - EventHash IEvent; - IList Internal; - AssocEdgeMap Edge_of; - AssocIsoMap Isos_of; + EventHash IEvent; + IList Internal; + AssocEdgeMap Edge_of; + AssocIsoMap Isos_of; - leda_seg_overlay_traits(const INPUT& in, OUTPUT& G, - const GEOMETRY& k) : - its(in.first), ite(in.second), GO(G), K(k), - cmp(K), XS(cmp), SLcmp(p_sweep,&sl,&sh,K), YS(SLcmp), SQ(cmp), - IEvent(0), Edge_of(0), Isos_of(0) {} + leda_seg_overlay_traits(const INPUT& in, OUTPUT& G, + const GEOMETRY& k) : + its(in.first), ite(in.second), GO(G), K(k), + cmp(K), XS(cmp), SLcmp(p_sweep,&sl,&sh,K), YS(SLcmp), SQ(cmp), + IEvent(0), Edge_of(0), Isos_of(0) {} -#line 403 "Segment_overlay.lw" - -#line 558 "Segment_overlay.lw" -leda_string dump_structures() const -{ - std::ostrstream out; - out << "SQ= "; - pq_item pqit; - forall_items(pqit,SQ) { - if (SQ.prio(pqit)==XS.key(XS.succ(XS.min_item()))) - { out << SQ.inf(pqit)->first(); } - pqit = SQ.next_item(pqit); - } - seq_item sit; - out << "\nXS=\n"; - forall_items(sit,XS) - out << " " << XS.key(sit) << " " << XS.inf(sit) - <first()<<" "<first()); } -Point_2 target(ISegment is) const -{ return K.target(is->first()); } -ITERATOR original(ISegment s) const -{ return s->second(); } - -int orientation(seq_item sit, const Point_2& p) const -{ return K.orientation(YS.key(sit)->first(),p); } - -bool collinear(seq_item sit1, seq_item sit2) const -{ Point_2 ps = source(YS.key(sit2)), pt = target(YS.key(sit2)); - return ( orientation(sit1,ps)==0 && - orientation(sit1,pt)==0 ); -} - - -#line 404 "Segment_overlay.lw" - -#line 611 "Segment_overlay.lw" -void compute_intersection(seq_item sit0) -{ - seq_item sit1 = YS.succ(sit0); - if ( sit0 == YS.min_item() || sit1 == YS.max_item() ) return; - ISegment s0 = YS.key(sit0); - ISegment s1 = YS.key(sit1); - int or0 = K.orientation(s0->first(),target(s1)); - int or1 = K.orientation(s1->first(),target(s0)); - if ( or0 <= 0 && or1 >= 0 ) { - seq_item it = IEvent(YS.key(sit0),YS.key(sit1)); - if ( it==0 ) { - Point_2 q = K.intersection(s0->first(),s1->first()); - it = XS.insert(q,sit0); + leda_string dump_structures() const + { + std::ostrstream out; + out << "SQ= "; + pq_item pqit; + forall_items(pqit,SQ) { + if (SQ.prio(pqit)==XS.key(XS.succ(XS.min_item()))) + { out << SQ.inf(pqit)->first(); } + pqit = SQ.next_item(pqit); } - YS.change_inf(sit0, it); + seq_item sit; + out << "\nXS=\n"; + forall_items(sit,XS) + out << " " << XS.key(sit) << " " << XS.inf(sit) + <first()<<" "<push(it_s); - continue; // ignore zero-length segments in SQ/YS + + Point_2 source(ISegment is) const + { return K.source(is->first()); } + Point_2 target(ISegment is) const + { return K.target(is->first()); } + ITERATOR original(ISegment s) const + { return s->second(); } + + int orientation(seq_item sit, const Point_2& p) const + { return K.orientation(YS.key(sit)->first(),p); } + + bool collinear(seq_item sit1, seq_item sit2) const + { Point_2 ps = source(YS.key(sit2)), pt = target(YS.key(sit2)); + return ( orientation(sit1,ps)==0 && + orientation(sit1,pt)==0 ); + } + + + void compute_intersection(seq_item sit0) + { + seq_item sit1 = YS.succ(sit0); + if ( sit0 == YS.min_item() || sit1 == YS.max_item() ) return; + ISegment s0 = YS.key(sit0); + ISegment s1 = YS.key(sit1); + int or0 = K.orientation(s0->first(),target(s1)); + int or1 = K.orientation(s1->first(),target(s0)); + if ( or0 <= 0 && or1 >= 0 ) { + seq_item it = IEvent(YS.key(sit0),YS.key(sit1)); + if ( it==0 ) { + Point_2 q = K.intersection(s0->first(),s1->first()); + it = XS.insert(q,sit0); + } + YS.change_inf(sit0, it); } - - Point_2 p = XS.key(it1); - Point_2 q = XS.key(it2); - - Segment_2 s1; - if ( K.compare_xy(p,q) < 0 ) - s1 = K.construct_segment(p,q); - else - s1 = K.construct_segment(q,p); - - Internal.append(seg_pair(s1,it_s)); - SQ.insert(K.source(s1),&Internal[Internal.last()]); - } + } - // insert a lower and an upper sentinel segment - YS.insert(&sl,seq_item(nil)); - YS.insert(&sh,seq_item(nil)); - TRACEN("end of initialization\n"<>> process_event: "<push(it_s); + continue; // ignore zero-length segments in SQ/YS + } -sit_pred = sit; -sit_first = sit_pred_succ = YS.succ(sit_pred); // first item of bundle + Point_2 p = XS.key(it1); + Point_2 q = XS.key(it2); + + Segment_2 s1; + if ( K.compare_xy(p,q) < 0 ) + s1 = K.construct_segment(p,q); + else + s1 = K.construct_segment(q,p); + + Internal.append(seg_pair(s1,it_s)); + SQ.insert(K.source(s1),&Internal[Internal.last()]); + } -TRACE("event bundles between\n "<>> process_event: "< #include #include @@ -506,400 +437,358 @@ namespace CGAL { template class stl_seg_overlay_traits { public: - -#line 1052 "Segment_overlay.lw" -typedef IT ITERATOR; -typedef std::pair INPUT; -typedef PMDEC OUTPUT; -typedef typename PMDEC::Vertex_handle Vertex_handle; -typedef typename PMDEC::Halfedge_handle Halfedge_handle; -typedef GEOM GEOMETRY; -typedef typename GEOMETRY::Point_2 Point_2; -typedef typename GEOMETRY::Segment_2 Segment_2; + typedef IT ITERATOR; + typedef std::pair INPUT; + typedef PMDEC OUTPUT; + typedef typename PMDEC::Vertex_handle Vertex_handle; + typedef typename PMDEC::Halfedge_handle Halfedge_handle; + typedef GEOM GEOMETRY; + typedef typename GEOMETRY::Point_2 Point_2; + typedef typename GEOMETRY::Segment_2 Segment_2; -#line 1031 "Segment_overlay.lw" - -#line 1064 "Segment_overlay.lw" -typedef std::pair seg_pair; -typedef seg_pair* ISegment; -typedef std::list IList; -typedef typename IList::const_iterator ilist_iterator; + typedef std::pair seg_pair; + typedef seg_pair* ISegment; + typedef std::list IList; + typedef typename IList::const_iterator ilist_iterator; -#line 1033 "Segment_overlay.lw" // types interfacing the generic sweep frame ITERATOR its, ite; OUTPUT& GO; const GEOMETRY& K; - -#line 1072 "Segment_overlay.lw" -class lt_segs_at_sweepline -{ const Point_2& p; - ISegment s_bottom, s_top; // sentinel segments - const GEOMETRY& K; -public: - lt_segs_at_sweepline(const Point_2& pi, - ISegment s1, ISegment s2, const GEOMETRY& k) : - p(pi), s_bottom(s1), s_top(s2), K(k) {} - lt_segs_at_sweepline(const lt_segs_at_sweepline& lt) : - p(lt.p), s_bottom(lt.s_bottom), s_top(lt.s_top), K(lt.K) {} + class lt_segs_at_sweepline + { const Point_2& p; + ISegment s_bottom, s_top; // sentinel segments + const GEOMETRY& K; + public: + lt_segs_at_sweepline(const Point_2& pi, + ISegment s1, ISegment s2, const GEOMETRY& k) : + p(pi), s_bottom(s1), s_top(s2), K(k) {} + lt_segs_at_sweepline(const lt_segs_at_sweepline& lt) : + p(lt.p), s_bottom(lt.s_bottom), s_top(lt.s_top), K(lt.K) {} - bool operator()(const ISegment& is1, const ISegment& is2) const - { - if ( is2 == s_top || is1 == s_bottom ) return true; - if ( is1 == s_top || is2 == s_bottom ) return false; - if ( is1 == is2 ) return false; - // Precondition: p is contained in s1 or s2. - const Segment_2& s1 = is1->first; - const Segment_2& s2 = is2->first; - int s = 0; - if ( K.orientation(s1,p) == 0 ) - s = K.orientation(s2,p); - else if ( K.orientation(s2,p) == 0 ) - s = - K.orientation(s1,p); - else ASSERT(0,"compare error in sweep."); - if ( s || K.is_degenerate(s1) || K.is_degenerate(s2) ) + bool operator()(const ISegment& is1, const ISegment& is2) const + { + if ( is2 == s_top || is1 == s_bottom ) return true; + if ( is1 == s_top || is2 == s_bottom ) return false; + if ( is1 == is2 ) return false; + // Precondition: p is contained in s1 or s2. + const Segment_2& s1 = is1->first; + const Segment_2& s2 = is2->first; + int s = 0; + if ( K.orientation(s1,p) == 0 ) + s = K.orientation(s2,p); + else if ( K.orientation(s2,p) == 0 ) + s = - K.orientation(s1,p); + else ASSERT(0,"compare error in sweep."); + if ( s || K.is_degenerate(s1) || K.is_degenerate(s2) ) + return ( s < 0 ); + + s = K.orientation(s2,K.target(s1)); + if (s==0) return ( is1 - is2 ) < 0; + // overlapping segments are not equal return ( s < 0 ); - - s = K.orientation(s2,K.target(s1)); - if (s==0) return ( is1 - is2 ) < 0; - // overlapping segments are not equal - return ( s < 0 ); - } -}; + } + }; -struct lt_pnts_xy -{ const GEOMETRY& K; -public: - lt_pnts_xy(const GEOMETRY& k) : K(k) {} - lt_pnts_xy(const lt_pnts_xy& lt) : K(lt.K) {} - int operator()(const Point_2& p1, const Point_2& p2) const - { return K.compare_xy(p1,p2) < 0; } -}; + struct lt_pnts_xy + { const GEOMETRY& K; + public: + lt_pnts_xy(const GEOMETRY& k) : K(k) {} + lt_pnts_xy(const lt_pnts_xy& lt) : K(lt.K) {} + int operator()(const Point_2& p1, const Point_2& p2) const + { return K.compare_xy(p1,p2) < 0; } + }; -#line 1039 "Segment_overlay.lw" - -#line 1124 "Segment_overlay.lw" -typedef std::map - SweepStatus; -typedef typename SweepStatus::iterator ss_iterator; -typedef typename SweepStatus::value_type ss_pair; + typedef std::map + SweepStatus; + typedef typename SweepStatus::iterator ss_iterator; + typedef typename SweepStatus::value_type ss_pair; -typedef std::list IsoList; -typedef std::map EventQueue; -typedef typename EventQueue::iterator event_iterator; -typedef typename EventQueue::value_type event_pair; + typedef std::list IsoList; + typedef std::map EventQueue; + typedef typename EventQueue::iterator event_iterator; + typedef typename EventQueue::value_type event_pair; -typedef std::multimap SegQueue; -typedef typename SegQueue::iterator seg_iterator; -typedef typename SegQueue::value_type ps_pair; + typedef std::multimap SegQueue; + typedef typename SegQueue::iterator seg_iterator; + typedef typename SegQueue::value_type ps_pair; -event_iterator event; -Point_2 p_sweep; -EventQueue XS; -seg_pair sl,sh; -SweepStatus YS; -SegQueue SQ; -IList Internal; + event_iterator event; + Point_2 p_sweep; + EventQueue XS; + seg_pair sl,sh; + SweepStatus YS; + SegQueue SQ; + IList Internal; -stl_seg_overlay_traits(const INPUT& in, OUTPUT& G, - const GEOMETRY& k) : - its(in.first), ite(in.second), GO(G), K(k), - XS(lt_pnts_xy(K)), YS(lt_segs_at_sweepline(p_sweep,&sl,&sh,K)), - SQ(lt_pnts_xy(K)) {} + stl_seg_overlay_traits(const INPUT& in, OUTPUT& G, + const GEOMETRY& k) : + its(in.first), ite(in.second), GO(G), K(k), + XS(lt_pnts_xy(K)), YS(lt_segs_at_sweepline(p_sweep,&sl,&sh,K)), + SQ(lt_pnts_xy(K)) {} -#line 1040 "Segment_overlay.lw" - -#line 1157 "Segment_overlay.lw" -std::string dump_structures() const -{ - std::ostrstream out; - out << "EventQueue:\n"; - typename EventQueue::const_iterator sit1; - for(sit1 = XS.begin(); sit1 != XS.end(); ++sit1) - out << " " << sit1->first << std::endl; + std::string dump_structures() const + { + std::ostrstream out; + out << "EventQueue:\n"; + typename EventQueue::const_iterator sit1; + for(sit1 = XS.begin(); sit1 != XS.end(); ++sit1) + out << " " << sit1->first << std::endl; - out << "SegQueue:\n"; - typename SegQueue::const_iterator sit2; - for(sit2 = SQ.begin(); sit2 != SQ.end(); ++sit2) - out << " " << sit2->first << " " << sit2->second - << " " << sit2->first << std::endl; + out << "SegQueue:\n"; + typename SegQueue::const_iterator sit2; + for(sit2 = SQ.begin(); sit2 != SQ.end(); ++sit2) + out << " " << sit2->first << " " << sit2->second + << " " << sit2->first << std::endl; - out << "SweepStatus:\n"; - typename SweepStatus::const_iterator sit3; - for( sit3 = YS.begin(); sit3 != YS.end(); ++sit3 ) - out << sit3->first << " " << &*(sit3->second) << std::endl; - std::string res(out.str()); out.freeze(0); return res; -} - -Point_2 source(ISegment is) const -{ return K.source(is->first); } -Point_2 target(ISegment is) const -{ return K.target(is->first); } - -ITERATOR original(ISegment s) const -{ return s->second; } - -int orientation(ss_iterator sit, const Point_2& p) const -{ return K.orientation(sit->first->first,p); } - -bool collinear(ss_iterator sit1, ss_iterator sit2) const -{ Point_2 ps = source(sit2->first), pt = target(sit2->first); - return ( orientation(sit1,ps)==0 && - orientation(sit1,pt)==0 ); -} - -#line 1041 "Segment_overlay.lw" - -#line 1198 "Segment_overlay.lw" -void compute_intersection(ss_iterator sit0) -{ - // Given an item |sit0| in the Y-structure compute the point of - // intersection with its successor and (if existing) insert it into - // the event queue and do all necessary updates. - ss_iterator sit1 = sit0; ++sit1; - TRACEN("compute_intersection "<first<<" "<first); - if ( sit0 == YS.begin() || sit1 == --YS.end() ) return; - const Segment_2& s0 = sit0->first->first; - const Segment_2& s1 = sit1->first->first; - int or0 = K.orientation(s0,K.target(s1)); - int or1 = K.orientation(s1,K.target(s0)); - if ( or0 <= 0 && or1 >= 0 ) { - Point_2 q = K.intersection(s0,s1); - XS.insert(event_pair(q,0)); // only done if none existed!!! + out << "SweepStatus:\n"; + typename SweepStatus::const_iterator sit3; + for( sit3 = YS.begin(); sit3 != YS.end(); ++sit3 ) + out << sit3->first << " " << &*(sit3->second) << std::endl; + std::string res(out.str()); out.freeze(0); return res; } -} -#line 1042 "Segment_overlay.lw" - -#line 1380 "Segment_overlay.lw" -void initialize_structures() -{ - /* INITIALIZATION - - insert all vertices into the x-structure - - insert sentinels into y-structure - - exploit the fact that insert operations into the x-structure - leave previously inserted points unchanged to achieve that - any pair of endpoints $p$ and $q$ with |p == q| are identical - */ - TRACEN("initialize_structures"); - - ITERATOR it_s; - for ( it_s=its; it_s != ite; ++it_s ) { - const Segment_2& s = *it_s; - event_iterator it1 = (XS.insert(event_pair(K.source(s),0))).first; - event_iterator it2 = (XS.insert(event_pair(K.target(s),0))).first; - // note that the STL only inserts if key is not yet in XS - if (it1 == it2) { - if ( it1->second == 0 ) it1->second = new IsoList; - it1->second->push_front(it_s); - continue; // ignore zero-length segments regarding YS + Point_2 source(ISegment is) const + { return K.source(is->first); } + Point_2 target(ISegment is) const + { return K.target(is->first); } + + ITERATOR original(ISegment s) const + { return s->second; } + + int orientation(ss_iterator sit, const Point_2& p) const + { return K.orientation(sit->first->first,p); } + + bool collinear(ss_iterator sit1, ss_iterator sit2) const + { Point_2 ps = source(sit2->first), pt = target(sit2->first); + return ( orientation(sit1,ps)==0 && + orientation(sit1,pt)==0 ); + } + + void compute_intersection(ss_iterator sit0) + { + // Given an item |sit0| in the Y-structure compute the point of + // intersection with its successor and (if existing) insert it into + // the event queue and do all necessary updates. + ss_iterator sit1 = sit0; ++sit1; + TRACEN("compute_intersection "<first<<" "<first); + if ( sit0 == YS.begin() || sit1 == --YS.end() ) return; + const Segment_2& s0 = sit0->first->first; + const Segment_2& s1 = sit1->first->first; + int or0 = K.orientation(s0,K.target(s1)); + int or1 = K.orientation(s1,K.target(s0)); + if ( or0 <= 0 && or1 >= 0 ) { + Point_2 q = K.intersection(s0,s1); + XS.insert(event_pair(q,0)); // only done if none existed!!! } - - Point_2 p = it1->first; - Point_2 q = it2->first; - - Segment_2 s1; - if ( K.compare_xy(p,q) < 0 ) - s1 = K.construct_segment(p,q); - else - s1 = K.construct_segment(q,p); - - Internal.push_back(seg_pair(s1,it_s)); - SQ.insert(ps_pair(K.source(s1),&Internal.back())); - } + } - // insert a lower and an upper sentinel segment to avoid special - // cases when traversing the Y-structure - YS.insert(ss_pair(&sl,Halfedge_handle())); - YS.insert(ss_pair(&sh,Halfedge_handle())); - TRACEN("end of initialization\n"); -} - - -#line 1043 "Segment_overlay.lw" - -#line 1427 "Segment_overlay.lw" -bool event_exists() -{ - if (!XS.empty()) { - // event is set at end of loop and in init - event = XS.begin(); - p_sweep = event->first; - return true; - } - return false; -} - -void procede_to_next_event() -{ XS.erase(event); } - -#line 1044 "Segment_overlay.lw" - -#line 1220 "Segment_overlay.lw" -void process_event() -{ - TRACEN("\n\n >>> process_event: "<first is ending or passing segment - // Determine upper bundle item: - TRACEN("ending/passing segs"); - - /* Walk down until |sit_pred|, close edges for all segments - in the bundle, delete all segments in the bundle, but - reinsert the continuing ones */ - - std::list L_tmp; - bool overlapping; - do { - ISegment s = sit->first; - ss_iterator sit_next(sit); --sit_next; - overlapping = (sit_next != YS.begin()) && collinear(sit,sit_next); - Halfedge_handle e = sit->second; - if ( overlapping ) { - TRACEN("overlapping segment "<first); - TRACEN("\n "<first); - - /* Interfaceproposition for next chunk: - - succ(sit_pred) == sit_first == sit_succ - - bundle not empty: sit_first != sit_succ + void initialize_structures() + { + /* INITIALIZATION + - insert all vertices into the x-structure + - insert sentinels into y-structure + - exploit the fact that insert operations into the x-structure + leave previously inserted points unchanged to achieve that + any pair of endpoints $p$ and $q$ with |p == q| are identical */ - - // delete and reinsert the continuing bundle - YS.erase(sit_first,sit_succ); - typename std::list::const_iterator lit; - for ( lit = L_tmp.begin(); lit != L_tmp.end(); ++lit ) { - YS.insert(sit_pred,ss_pair(*lit,Halfedge_handle())); + TRACEN("initialize_structures"); + + ITERATOR it_s; + for ( it_s=its; it_s != ite; ++it_s ) { + const Segment_2& s = *it_s; + event_iterator it1 = (XS.insert(event_pair(K.source(s),0))).first; + event_iterator it2 = (XS.insert(event_pair(K.target(s),0))).first; + // note that the STL only inserts if key is not yet in XS + if (it1 == it2) { + if ( it1->second == 0 ) it1->second = new IsoList; + it1->second->push_front(it_s); + continue; // ignore zero-length segments regarding YS + } + + Point_2 p = it1->first; + Point_2 q = it2->first; + + Segment_2 s1; + if ( K.compare_xy(p,q) < 0 ) + s1 = K.construct_segment(p,q); + else + s1 = K.construct_segment(q,p); + + Internal.push_back(seg_pair(s1,it_s)); + SQ.insert(ps_pair(K.source(s1),&Internal.back())); } - } // if (sit != ss_iterator() ) - -#line 1232 "Segment_overlay.lw" - -#line 1318 "Segment_overlay.lw" - assert( sit_pred != YS.end() ); - GO.halfedge_below(v,sit_pred->second); - if ( event->second != 0 ) { - const IsoList& IL = *(event->second); - typename IsoList::const_iterator iso_it; - for (iso_it = IL.begin(); iso_it != IL.end(); ++iso_it) - GO.trivial_segment(v,*iso_it); - delete (event->second); + // insert a lower and an upper sentinel segment to avoid special + // cases when traversing the Y-structure + YS.insert(ss_pair(&sl,Halfedge_handle())); + YS.insert(ss_pair(&sh,Halfedge_handle())); + TRACEN("end of initialization\n"); } -#line 1233 "Segment_overlay.lw" - -#line 1331 "Segment_overlay.lw" - ISegment next_seg; - seg_iterator next_it = SQ.begin(); - while ( next_it != SQ.end() && - ( next_seg = next_it->second, p_sweep == source(next_seg)) ) { - TRACEN("inserting "<first<<"\n "<first); - if ( sit_curr != YS.begin() && sit_prev != --YS.end() && - collinear(sit_curr,sit_prev) ) // overlapping - sit_curr->second = sit_prev->second; - else { - TRACEN("creating new edge"); - sit_curr->second = GO.new_halfedge_pair_at_source(v); + bool event_exists() + { + if (!XS.empty()) { + // event is set at end of loop and in init + event = XS.begin(); + p_sweep = event->first; + return true; } + return false; } - sit_first = sit_prev; + + void procede_to_next_event() + { XS.erase(event); } + + void process_event() + { + TRACEN("\n\n >>> process_event: "<first is ending or passing segment + // Determine upper bundle item: + TRACEN("ending/passing segs"); + + /* Walk down until |sit_pred|, close edges for all segments + in the bundle, delete all segments in the bundle, but + reinsert the continuing ones */ + + std::list L_tmp; + bool overlapping; + do { + ISegment s = sit->first; + ss_iterator sit_next(sit); --sit_next; + overlapping = (sit_next != YS.begin()) && collinear(sit,sit_next); + Halfedge_handle e = sit->second; + if ( overlapping ) { + TRACEN("overlapping segment "<first); + TRACEN("\n "<first); + + /* Interfaceproposition for next chunk: + - succ(sit_pred) == sit_first == sit_succ + - bundle not empty: sit_first != sit_succ + */ + + // delete and reinsert the continuing bundle + YS.erase(sit_first,sit_succ); + typename std::list::const_iterator lit; + for ( lit = L_tmp.begin(); lit != L_tmp.end(); ++lit ) { + YS.insert(sit_pred,ss_pair(*lit,Halfedge_handle())); + } + } // if (sit != ss_iterator() ) -#line 1234 "Segment_overlay.lw" - -#line 1360 "Segment_overlay.lw" - // compute possible intersections between |sit_pred| and its - // successor and |sit_succ| and its predecessor - TRACEN("pred,succ = "<first<<" "<first); - compute_intersection(sit_pred); - sit = sit_succ; --sit; - if (sit != sit_pred) - compute_intersection(sit); - -#line 1235 "Segment_overlay.lw" -} - -#line 1045 "Segment_overlay.lw" - -#line 1442 "Segment_overlay.lw" -void complete_structures() {} -void check_invariants() {TRACEN("check_invariants\n"<second); + if ( event->second != 0 ) { + const IsoList& IL = *(event->second); + typename IsoList::const_iterator iso_it; + for (iso_it = IL.begin(); iso_it != IL.end(); ++iso_it) + GO.trivial_segment(v,*iso_it); + delete (event->second); + } + + + ISegment next_seg; + seg_iterator next_it = SQ.begin(); + while ( next_it != SQ.end() && + ( next_seg = next_it->second, p_sweep == source(next_seg)) ) { + TRACEN("inserting "<first<<"\n "<first); + if ( sit_curr != YS.begin() && sit_prev != --YS.end() && + collinear(sit_curr,sit_prev) ) // overlapping + sit_curr->second = sit_prev->second; + else { + TRACEN("creating new edge"); + sit_curr->second = GO.new_halfedge_pair_at_source(v); + } + } + sit_first = sit_prev; + + + // compute possible intersections between |sit_pred| and its + // successor and |sit_succ| and its predecessor + TRACEN("pred,succ = "<first<<" "<first); + compute_intersection(sit_pred); + sit = sit_succ; --sit; + if (sit != sit_pred) + compute_intersection(sit); + + } + + void complete_structures() {} + void check_invariants() {TRACEN("check_invariants\n"< +// maintainer : Michael Seel +// coordinator : Michael Seel +// ============================================================================ + #ifndef CGAL_REDEFINE_MSC_H #define CGAL_REDEFINE_MSC_H #ifdef _MSC_VER