-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Arrangement_on_surface_2.h
3064 lines (2630 loc) · 111 KB
/
Arrangement_on_surface_2.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright (c) 2005,2006,2007,2008,2009,2010,2011 Tel-Aviv University (Israel).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
//
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
//
//
// Author(s): Ron Wein <wein@post.tau.ac.il>
// Efi Fogel <efif@post.tau.ac.il>
// Eric Berberich <ericb@post.tau.ac.il>
// (based on old version by: Iddo Hanniel,
// Eyal Flato,
// Oren Nechushtan,
// Ester Ezra,
// Shai Hirsch,
// and Eugene Lipovetsky)
#ifndef CGAL_ARRANGEMENT_ON_SURFACE_2_H
#define CGAL_ARRANGEMENT_ON_SURFACE_2_H
#include <CGAL/license/Arrangement_on_surface_2.h>
#include <CGAL/disable_warnings.h>
/*! \file
* The header file for the Arrangement_on_surface_2<Traits,Dcel> class.
*/
#include <map>
#include <vector>
#include <algorithm>
#include <boost/mpl/assert.hpp>
#include <CGAL/Arr_tags.h>
#include <CGAL/Arr_enums.h>
#include <CGAL/HalfedgeDS_iterator.h>
#include <CGAL/Arrangement_2/Arrangement_2_iterators.h>
#include <CGAL/In_place_list.h>
#include <CGAL/Arr_default_dcel.h>
#include <CGAL/Arr_observer.h>
#include <CGAL/Arr_accessor.h>
#include <CGAL/Arrangement_2/Arr_traits_adaptor_2.h>
#include <CGAL/function_objects.h>
#include <CGAL/Iterator_project.h>
#include <CGAL/Iterator_transform.h>
#include <boost/pool/pool_alloc.hpp>
namespace CGAL {
/*! \class Arrangement_on_surface_2
* The arrangement class, representing 2-dimensional subdivisions induced on
* an arbitrary surface by a set of arbitrary planar curves.
* The GeomTraits parameter corresponds to a geometry-traits class that
* defines the Point_2 and X_monotone_curve_2 types and implements the
* geometric predicates and constructions for the family of curves it defines.
* The TopTraits parameter corresponds to a topology-traits class that defines
* the topological structure of the surface. Note that the geometry traits
* class should also be aware of the kind of surface on which its curves and
* points are defined.
*/
template <typename GeomTraits_, typename TopTraits_>
class Arrangement_on_surface_2 {
public:
typedef GeomTraits_ Geometry_traits_2;
typedef TopTraits_ Topology_traits;
typedef boost::fast_pool_allocator<int> Allocator;
// first define adaptor ...
typedef Arr_traits_basic_adaptor_2<Geometry_traits_2> Traits_adaptor_2;
// .. as it completes (potentially) missing side tags
typedef typename Traits_adaptor_2::Left_side_category Left_side_category;
typedef typename Traits_adaptor_2::Bottom_side_category Bottom_side_category;
typedef typename Traits_adaptor_2::Top_side_category Top_side_category;
typedef typename Traits_adaptor_2::Right_side_category Right_side_category;
BOOST_MPL_ASSERT(
(typename
Arr_sane_identified_tagging<Left_side_category,
Bottom_side_category,
Top_side_category,
Right_side_category>::result)
);
public:
typedef Arrangement_on_surface_2<Geometry_traits_2, Topology_traits>
Self;
typedef typename Geometry_traits_2::Point_2 Point_2;
typedef typename Geometry_traits_2::X_monotone_curve_2 X_monotone_curve_2;
// maybe remove this in a future version (that supports complete handling
// of all sides)
typedef typename Arr_are_all_sides_oblivious_tag<Left_side_category,
Bottom_side_category,
Top_side_category,
Right_side_category>::result
Are_all_sides_oblivious_category;
typedef typename Arr_has_identified_sides<Left_side_category,
Bottom_side_category>::result
Has_identified_sides_category;
typedef typename Arr_two_sides_category<Bottom_side_category,
Top_side_category>::result
Top_or_bottom_sides_category;
public:
typedef typename Topology_traits::Dcel Dcel;
typedef typename Dcel::Size Size;
protected:
friend class Arr_observer<Self>;
friend class Arr_accessor<Self>;
// Internal DCEL types:
typedef typename Dcel::Vertex DVertex;
typedef typename Dcel::Halfedge DHalfedge;
typedef typename Dcel::Face DFace;
typedef typename Dcel::Outer_ccb DOuter_ccb;
typedef typename Dcel::Inner_ccb DInner_ccb;
typedef typename Dcel::Isolated_vertex DIso_vertex;
typedef typename Dcel::difference_type DDifference;
typedef typename Dcel::iterator_category DIterator_category;
typedef typename Dcel::Vertex_iterator DVertex_iter;
typedef typename Dcel::Vertex_const_iterator DVertex_const_iter;
typedef typename Dcel::Halfedge_iterator DHalfedge_iter;
typedef typename Dcel::Halfedge_const_iterator DHalfedge_const_iter;
typedef typename Dcel::Edge_iterator DEdge_iter;
typedef typename Dcel::Edge_const_iterator DEdge_const_iter;
typedef typename Dcel::Face_iterator DFace_iter;
typedef typename Dcel::Face_const_iterator DFace_const_iter;
typedef typename DFace::Outer_ccb_iterator DOuter_ccb_iter;
typedef typename DFace::Outer_ccb_const_iterator DOuter_ccb_const_iter;
typedef typename DFace::Inner_ccb_iterator DInner_ccb_iter;
typedef typename DFace::Inner_ccb_const_iterator DInner_ccb_const_iter;
typedef typename DFace::Isolated_vertex_iterator DIso_vertex_iter;
typedef typename DFace::Isolated_vertex_const_iterator
DIso_vertex_const_iter;
protected:
/*! \class
* A functor for filtering DCEL vertices at infinity.
*/
class _Is_concrete_vertex {
private:
const Topology_traits* m_topol_traits;
public:
_Is_concrete_vertex() : m_topol_traits(nullptr) {}
_Is_concrete_vertex(const Topology_traits* topol_traits) :
m_topol_traits(topol_traits)
{}
bool operator()(const DVertex& v) const
{
if (m_topol_traits == nullptr)
return true;
return (m_topol_traits->is_concrete_vertex(&v));
}
};
/*! \class
* A functor for filtering fictitious DCEL vertices.
*/
class _Is_valid_vertex {
private:
const Topology_traits* m_topol_traits;
public:
_Is_valid_vertex() : m_topol_traits(nullptr) {}
_Is_valid_vertex(const Topology_traits* topol_traits) :
m_topol_traits(topol_traits)
{}
bool operator()(const DVertex& v) const
{
if (m_topol_traits == nullptr)
return true;
return (m_topol_traits->is_valid_vertex(&v));
}
};
/*! \struct
* A functor for filtering fictitious DCEL halfedges.
*/
class _Is_valid_halfedge {
private:
const Topology_traits* m_topol_traits;
public:
_Is_valid_halfedge() : m_topol_traits(nullptr) {}
_Is_valid_halfedge(const Topology_traits* topol_traits) :
m_topol_traits(topol_traits)
{}
bool operator()(const DHalfedge& he) const
{
if (m_topol_traits == nullptr)
return true;
return (m_topol_traits->is_valid_halfedge(&he));
}
};
/*! \struct
* A functor for filtering the fictitious faces.
*/
class _Is_valid_face {
private:
const Topology_traits* m_topol_traits;
public:
_Is_valid_face() : m_topol_traits(nullptr) {}
_Is_valid_face(const Topology_traits* topol_traits) :
m_topol_traits(topol_traits)
{}
bool operator()(const DFace& f) const
{
if (m_topol_traits == nullptr)
return true;
return (m_topol_traits->is_valid_face(&f));
}
};
/*! \struct
* A functor for filtering bounded faces.
*/
class _Is_unbounded_face {
private:
const Topology_traits* m_topol_traits;
public:
_Is_unbounded_face() : m_topol_traits(nullptr) {}
_Is_unbounded_face(const Topology_traits* topol_traits) :
m_topol_traits(topol_traits)
{}
const Topology_traits* topology_traits() const { return m_topol_traits; }
bool operator()(const DFace& f) const
{
return (m_topol_traits->is_valid_face(&f) &&
m_topol_traits->is_unbounded(&f));
}
};
public:
// Forward declerations:
class Vertex;
class Halfedge;
class Face;
// Definition of the halfedge data-structure itereators and circulators:
typedef I_Filtered_iterator<DVertex_iter, _Is_concrete_vertex,
Vertex, DDifference, DIterator_category>
Vertex_iterator;
typedef I_Filtered_const_iterator<DVertex_const_iter, _Is_concrete_vertex,
DVertex_iter, Vertex, DDifference,
DIterator_category>
Vertex_const_iterator;
typedef I_Filtered_iterator<DHalfedge_iter, _Is_valid_halfedge,
Halfedge, DDifference, DIterator_category>
Halfedge_iterator;
typedef I_Filtered_const_iterator<DHalfedge_const_iter, _Is_valid_halfedge,
DHalfedge_iter, Halfedge, DDifference,
DIterator_category>
Halfedge_const_iterator;
/*! \class
* Edges iterator - defined as a derived class to make it assignable
* to the halfedge iterator type.
*/
class Edge_iterator :
public I_Filtered_iterator<DEdge_iter, _Is_valid_halfedge,
Halfedge, DDifference, DIterator_category>
{
typedef I_Filtered_iterator<DEdge_iter, _Is_valid_halfedge,
Halfedge, DDifference, DIterator_category>
Base;
public:
Edge_iterator() {}
Edge_iterator(DEdge_iter iter, DEdge_iter iend,
const _Is_valid_halfedge& pred) :
Base(iter, iend, pred)
{}
Edge_iterator(const Base& base) :
Base(base)
{}
// Casting to a halfedge iterator.
operator Halfedge_iterator() const
{
return (Halfedge_iterator(DHalfedge_iter(this->current_iterator())));
}
operator Halfedge_const_iterator() const
{
return (Halfedge_const_iterator
(DHalfedge_const_iter(this->current_iterator())));
}
};
class Edge_const_iterator :
public I_Filtered_const_iterator<DEdge_const_iter, _Is_valid_halfedge,
DEdge_iter, Halfedge, DDifference,
DIterator_category>
{
typedef I_Filtered_const_iterator<DEdge_const_iter, _Is_valid_halfedge,
DEdge_iter, Halfedge, DDifference,
DIterator_category> Base;
public:
Edge_const_iterator() {}
Edge_const_iterator(Edge_iterator iter) :
Base(iter.current_iterator(), iter.past_the_end(), iter.filter())
{}
Edge_const_iterator(DEdge_const_iter iter, DEdge_const_iter iend,
const _Is_valid_halfedge& pred) :
Base(iter, iend, pred)
{}
Edge_const_iterator(const Base& base) :
Base(base)
{}
// Casting to a halfedge iterator.
operator Halfedge_const_iterator() const
{
return (Halfedge_const_iterator
(DHalfedge_const_iter(this->current_iterator())));
}
};
typedef I_Filtered_iterator<DFace_iter, _Is_valid_face,
Face, DDifference,
DIterator_category> Face_iterator;
typedef I_Filtered_const_iterator<DFace_const_iter, _Is_valid_face,
DFace_iter, Face,
DDifference, DIterator_category>
Face_const_iterator;
typedef _HalfedgeDS_vertex_circ<Halfedge, Halfedge_iterator,
Bidirectional_circulator_tag>
Halfedge_around_vertex_circulator;
typedef _HalfedgeDS_vertex_const_circ<Halfedge, Halfedge_const_iterator,
Bidirectional_circulator_tag>
Halfedge_around_vertex_const_circulator;
typedef _HalfedgeDS_facet_circ<Halfedge, Halfedge_iterator,
Bidirectional_circulator_tag>
Ccb_halfedge_circulator;
typedef _HalfedgeDS_facet_const_circ<Halfedge, Halfedge_const_iterator,
Bidirectional_circulator_tag>
Ccb_halfedge_const_circulator;
/*! \class
* Unbounded faces iterator - defined as a derived class to make it
* assignable to the face iterator type.
*/
class Unbounded_face_iterator :
public I_Filtered_iterator<DFace_iter, _Is_unbounded_face,
Face, DDifference, DIterator_category>
{
typedef I_Filtered_iterator<DFace_iter, _Is_unbounded_face,
Face, DDifference, DIterator_category>
Base;
public:
Unbounded_face_iterator() {}
Unbounded_face_iterator(DFace_iter iter, DFace_iter iend,
const _Is_unbounded_face& is_unbounded) :
Base(iter, iend, is_unbounded)
{}
// Casting to a face iterator.
operator Face_iterator() const
{
return (Face_iterator(DFace_iter(this->current_iterator()),
DFace_iter(this->past_the_end()),
_Is_valid_face(this->filter().topology_traits())));
}
operator Face_const_iterator() const
{
return (Face_const_iterator
(DFace_const_iter(this->current_iterator()),
DFace_const_iter(this->past_the_end()),
_Is_valid_face(this->filter().topology_traits())));
}
};
class Unbounded_face_const_iterator :
public I_Filtered_const_iterator<DFace_const_iter, _Is_unbounded_face,
DFace_iter, Face, DDifference,
DIterator_category>
{
typedef I_Filtered_const_iterator<DFace_const_iter, _Is_unbounded_face,
DFace_iter, Face, DDifference,
DIterator_category> Base;
public:
Unbounded_face_const_iterator() {}
Unbounded_face_const_iterator(Unbounded_face_iterator iter) : Base(iter) {}
Unbounded_face_const_iterator(DFace_const_iter iter,
DFace_const_iter iend,
const _Is_unbounded_face& is_unbounded) :
Base(iter, iend, is_unbounded)
{}
Unbounded_face_const_iterator(const Base& base) :
Base(base)
{}
// Casting to a face iterator.
operator Face_const_iterator() const
{
return (Face_const_iterator(DFace_const_iter(this->current_iterator()),
DFace_const_iter(this->past_the_end())));
}
};
protected:
struct _Halfedge_to_ccb_circulator {
typedef DHalfedge* argument_type;
typedef Ccb_halfedge_circulator result_type;
result_type operator()(argument_type s) const
{ return Ccb_halfedge_circulator(Halfedge_iterator(s)); }
};
struct _Const_halfedge_to_ccb_circulator {
typedef const DHalfedge* argument_type;
typedef Ccb_halfedge_const_circulator result_type;
result_type operator()(argument_type s) const
{ return Ccb_halfedge_const_circulator(Halfedge_const_iterator(s)); }
};
typedef Cast_function_object<DVertex, Vertex> _Vertex_to_vertex;
public:
typedef Iterator_transform<DOuter_ccb_iter, _Halfedge_to_ccb_circulator>
Outer_ccb_iterator;
typedef Iterator_transform<DOuter_ccb_const_iter,
_Const_halfedge_to_ccb_circulator>
Outer_ccb_const_iterator;
typedef Iterator_transform<DInner_ccb_iter, _Halfedge_to_ccb_circulator>
Inner_ccb_iterator;
typedef Iterator_transform<DInner_ccb_const_iter,
_Const_halfedge_to_ccb_circulator>
Inner_ccb_const_iterator;
/*! \class
* Isolated vertices iterator - defined as a class to make it assignable
* to the vertex iterator type.
*/
class Isolated_vertex_iterator :
public Iterator_project<DIso_vertex_iter, _Vertex_to_vertex>
{
typedef Iterator_project<DIso_vertex_iter, _Vertex_to_vertex> Base;
public:
Isolated_vertex_iterator() {}
Isolated_vertex_iterator(DIso_vertex_iter iter) : Base(iter) {}
// Casting to a vertex iterator.
operator Vertex_iterator() const
{ return (Vertex_iterator(DVertex_iter(this->ptr()))); }
operator Vertex_const_iterator() const
{ return (Vertex_const_iterator(DVertex_const_iter(this->ptr()))); }
};
class Isolated_vertex_const_iterator :
public Iterator_project<DIso_vertex_const_iter, _Vertex_to_vertex>
{
typedef Iterator_project<DIso_vertex_const_iter, _Vertex_to_vertex> Base;
public:
Isolated_vertex_const_iterator() {}
Isolated_vertex_const_iterator(Isolated_vertex_iterator iter) :
Base(iter)
{}
Isolated_vertex_const_iterator(DIso_vertex_const_iter iter) :
Base(iter)
{}
// Casting to a vertex iterator.
operator Vertex_const_iterator() const
{ return (Vertex_const_iterator(DVertex_const_iter(this->ptr()))); }
};
protected:
class _Valid_vertex_iterator :
public I_Filtered_iterator<DVertex_iter, _Is_valid_vertex, Vertex,
DDifference, DIterator_category>
{
typedef I_Filtered_iterator<DVertex_iter, _Is_valid_vertex, Vertex,
DDifference, DIterator_category> Base;
public:
_Valid_vertex_iterator() {}
_Valid_vertex_iterator(DVertex_iter iter, DVertex_iter iend,
const _Is_valid_vertex& pred) :
Base(iter, iend, pred)
{}
// Casting to a vertex iterator.
operator Vertex_iterator() const
{ return (Vertex_iterator(DVertex_iter(this->current_iterator()))); }
operator Vertex_const_iterator() const
{
return (Vertex_const_iterator(DVertex_const_iter
(this->current_iterator())));
}
};
public:
// Definition of handles (equivalent to iterators):
typedef Vertex_iterator Vertex_handle;
typedef Halfedge_iterator Halfedge_handle;
typedef Face_iterator Face_handle;
typedef Vertex_const_iterator Vertex_const_handle;
typedef Halfedge_const_iterator Halfedge_const_handle;
typedef Face_const_iterator Face_const_handle;
/*! \class
* The arrangement vertex class.
*/
class Vertex : public DVertex {
typedef DVertex Base;
public:
/*! Default constrcutor. */
Vertex() {}
/*! Check whether the vertex lies on an open boundary. */
bool is_at_open_boundary() const { return (Base::has_null_point()); }
/*! Get the vertex degree (number of incident edges). */
Size degree() const
{
if (this->is_isolated())
return (0);
// Go around the vertex and count the incident halfedges.
const DHalfedge* he_first = Base::halfedge();
const DHalfedge* he_curr = he_first;
Size n = 0;
if (he_curr != nullptr) {
do {
++n;
he_curr = he_curr->next()->opposite();
} while (he_curr != he_first);
}
return (n);
}
/*!
* Get the incident halfedges (non-const version).
* \pre The vertex is not isolated.
*/
Halfedge_around_vertex_circulator incident_halfedges()
{
CGAL_precondition(! this->is_isolated());
return Halfedge_around_vertex_circulator
(DHalfedge_iter(Base::halfedge()));
}
/*!
* Get the incident halfedges (const version).
* \pre The vertex is not isolated.
*/
Halfedge_around_vertex_const_circulator incident_halfedges() const
{
CGAL_precondition(! this->is_isolated());
return Halfedge_around_vertex_const_circulator
(DHalfedge_const_iter(Base::halfedge()));
}
/*!
* Get the face that contains the vertex (non-const version).
* \pre The vertex is isolated.
*/
Face_handle face()
{
CGAL_precondition(this->is_isolated());
return (DFace_iter(Base::isolated_vertex()->face()));
}
/*!
* Get the face that contains the vertex (const version).
* \pre The vertex is isolated.
*/
Face_const_handle face() const
{
CGAL_precondition(this->is_isolated());
return (DFace_const_iter(Base::isolated_vertex()->face()));
}
private:
// Blocking access to inherited functions from the Dcel::Vertex.
bool has_null_point() const;
void set_point(Point_2* );
void set_boundary(Arr_parameter_space , Arr_parameter_space );
const DHalfedge* halfedge() const;
DHalfedge* halfedge();
void set_halfedge(DHalfedge* );
const DIso_vertex* isolated_vertex() const;
DIso_vertex* isolated_vertex();
void set_isolated_vertex(DIso_vertex* );
};
/*!
* \class The arrangement halfedge class.
*/
class Halfedge : public DHalfedge {
typedef DHalfedge Base;
public:
/*! Default constrcutor. */
Halfedge() {}
/*! Check whether the halfedge is fictitious. */
bool is_fictitious() const
{ return (Base::has_null_curve()); }
/*! Get the source vertex (non-const version). */
Vertex_handle source()
{ return (DVertex_iter(Base::opposite()->vertex())); }
/*! Get the source vertex (const version). */
Vertex_const_handle source() const
{ return (DVertex_const_iter(Base::opposite()->vertex())); }
/*! Get the target vertex (non-const version). */
Vertex_handle target()
{ return (DVertex_iter(Base::vertex())); }
/*! Get the target vertex (const version). */
Vertex_const_handle target() const
{ return (DVertex_const_iter(Base::vertex())); }
/*! Get the incident face (non-const version). */
Face_handle face()
{
return (! Base::is_on_inner_ccb()) ?
DFace_iter(Base::outer_ccb()->face()) :
DFace_iter(Base::inner_ccb()->face());
}
/*! Get the incident face (const version). */
Face_const_handle face() const
{
return (! Base::is_on_inner_ccb()) ?
DFace_const_iter(Base::outer_ccb()->face()) :
DFace_const_iter(Base::inner_ccb()->face());
}
/*! Get the twin halfedge (non-const version). */
Halfedge_handle twin()
{ return (DHalfedge_iter(Base::opposite())); }
/*! Get the twin halfedge (const version). */
Halfedge_const_handle twin() const
{ return (DHalfedge_const_iter(Base::opposite())); }
/*! Get the previous halfegde in the chain (non-const version). */
Halfedge_handle prev()
{ return (DHalfedge_iter(Base::prev())); }
/*! Get the previous halfegde in the chain (const version). */
Halfedge_const_handle prev() const
{ return (DHalfedge_const_iter(Base::prev())); }
/*! Get the next halfegde in the chain (non-const version). */
Halfedge_handle next()
{ return (DHalfedge_iter(Base::next())); }
/*! Get the next halfegde in the chain (const version). */
Halfedge_const_handle next() const
{ return (DHalfedge_const_iter(Base::next())); }
/*! Get the connected component of the halfedge (non-const version). */
Ccb_halfedge_circulator ccb()
{ return Ccb_halfedge_circulator(DHalfedge_iter(this)); }
/*! Get the connected component of the halfedge (const version). */
Ccb_halfedge_const_circulator ccb() const
{ return Ccb_halfedge_const_circulator(DHalfedge_const_iter(this)); }
private:
// Blocking access to inherited functions from the Dcel::Halfedge.
bool has_null_curve() const;
void set_curve(X_monotone_curve_2* );
const DHalfedge* opposite() const;
DHalfedge* opposite();
void set_opposite(DHalfedge* );
void set_direction(Arr_halfedge_direction );
void set_prev(DHalfedge* );
void set_next(DHalfedge* );
const DVertex* vertex() const ;
DVertex* vertex();
void set_vertex(DVertex* );
const DOuter_ccb* outer_ccb() const;
DOuter_ccb* outer_ccb();
void set_outer_ccb(DOuter_ccb* );
const DInner_ccb* inner_ccb() const;
DInner_ccb* inner_ccb();
void set_inner_ccb(DInner_ccb* );
};
/*!
* \class The arrangement face class.
*/
class Face : public DFace {
typedef DFace Base;
public:
/*! Default constrcutor. */
Face() {}
/*! Get an iterator for the outer CCBs of the face (non-const version). */
Outer_ccb_iterator outer_ccbs_begin()
{ return (DOuter_ccb_iter(Base::outer_ccbs_begin())); }
/*! Get an iterator for the outer CCBs the face (const version). */
Outer_ccb_const_iterator outer_ccbs_begin() const
{ return (DOuter_ccb_const_iter(Base::outer_ccbs_begin())); }
/*! Get a past-the-end iterator for the outer CCBs (non-const version). */
Outer_ccb_iterator outer_ccbs_end()
{ return (DOuter_ccb_iter(Base::outer_ccbs_end())); }
/*! Get a past-the-end iterator for the outer CCBs (const version). */
Outer_ccb_const_iterator outer_ccbs_end() const
{ return (DOuter_ccb_const_iter(Base::outer_ccbs_end())); }
/*! Get an iterator for the inner CCBs of the face (non-const version). */
Inner_ccb_iterator inner_ccbs_begin()
{ return (DInner_ccb_iter(Base::inner_ccbs_begin())); }
/*! Get an iterator for the inner CCBs the face (const version). */
Inner_ccb_const_iterator inner_ccbs_begin() const
{ return (DInner_ccb_const_iter(Base::inner_ccbs_begin())); }
/*! Get a past-the-end iterator for the inner CCBs (non-const version). */
Inner_ccb_iterator inner_ccbs_end()
{ return (DInner_ccb_iter(Base::inner_ccbs_end())); }
/*! Get a past-the-end iterator for the inner CCBs (const version). */
Inner_ccb_const_iterator inner_ccbs_end() const
{ return (DInner_ccb_const_iter(Base::inner_ccbs_end())); }
/*! Get an iterator for the isolated_vertices inside the face
* (non-const version).
*/
Isolated_vertex_iterator isolated_vertices_begin()
{ return (DIso_vertex_iter(Base::isolated_vertices_begin())); }
/*! Get an iterator for the isolated_vertices inside the face
* (const version).
*/
Isolated_vertex_const_iterator isolated_vertices_begin() const
{ return (DIso_vertex_const_iter(Base::isolated_vertices_begin())); }
/*! Get a past-the-end iterator for the isolated_vertices
* (non-const version).
*/
Isolated_vertex_iterator isolated_vertices_end()
{ return (DIso_vertex_iter(Base::isolated_vertices_end())); }
/*! Get a past-the-end iterator for the isolated_vertices
* (const version).
*/
Isolated_vertex_const_iterator isolated_vertices_end() const
{ return (DIso_vertex_const_iter(Base::isolated_vertices_end())); }
/// \name These functions are kept for Arrangement_2 compatibility:
//@{
/*!
* Check whether the face has an outer CCB.
*/
bool has_outer_ccb() const
{ return (Base::number_of_outer_ccbs() > 0); }
/*!
* Get a circulator for the outer boundary (non-const version).
* \pre The face has a single outer CCB.
*/
Ccb_halfedge_circulator outer_ccb()
{
CGAL_precondition(Base::number_of_outer_ccbs() == 1);
DOuter_ccb_iter iter = Base::outer_ccbs_begin();
DHalfedge* he = *iter;
return Ccb_halfedge_circulator(DHalfedge_iter(he));
}
/*!
* Get a circulator for the outer boundary (const version).
* \pre The face has a single outer CCB.
*/
Ccb_halfedge_const_circulator outer_ccb() const
{
CGAL_precondition(Base::number_of_outer_ccbs() == 1);
DOuter_ccb_const_iter iter = Base::outer_ccbs_begin();
const DHalfedge* he = *iter;
return Ccb_halfedge_const_circulator(DHalfedge_const_iter(he));
}
/*! Get the number of holes (inner CCBs) inside the face. */
Size number_of_holes() const
{ return (Base::number_of_inner_ccbs()); }
/*! Get an iterator for the holes inside the face (non-const version). */
Inner_ccb_iterator holes_begin()
{ return (this->inner_ccbs_begin()); }
/*! Get an iterator for the holes inside the face (const version). */
Inner_ccb_const_iterator holes_begin() const
{ return (this->inner_ccbs_begin()); }
/*! Get a past-the-end iterator for the holes (non-const version). */
Inner_ccb_iterator holes_end()
{ return (this->inner_ccbs_end()); }
/*! Get a past-the-end iterator for the holes (const version). */
Inner_ccb_const_iterator holes_end() const
{ return (this->inner_ccbs_end()); }
//@}
private:
// Blocking access to inherited functions from the Dcel::Face.
void set_unbounded(bool);
void set_fictitious(bool);
void add_outer_ccb(DOuter_ccb*, Halfedge*);
void erase_outer_ccb(DOuter_ccb*);
void add_inner_ccb(DInner_ccb*, Halfedge*);
void erase_inner_ccb(DInner_ccb*);
void add_isolated_vertex(DIso_vertex*, DVertex*);
void erase_isolated_vertex(DIso_vertex*);
};
protected:
typedef CGAL_ALLOCATOR(Point_2) Points_alloc;
typedef CGAL_ALLOCATOR(X_monotone_curve_2) Curves_alloc;
typedef Arr_observer<Self> Observer;
typedef std::list<Observer*> Observers_container;
typedef typename Observers_container::iterator Observers_iterator;
typedef typename Observers_container::reverse_iterator
Observers_rev_iterator;
// Data members:
Topology_traits m_topol_traits; // the topology traits.
Points_alloc m_points_alloc; // allocator for the points.
Curves_alloc m_curves_alloc; // allocator for the curves.
Observers_container m_observers; // pointers to existing observers.
const Traits_adaptor_2* m_geom_traits; // the geometry-traits adaptor.
bool m_own_traits; // inidicates whether the geometry
// traits should be freed up.
bool m_sweep_mode = false;
// sweep mode efficiently
// merges inner CCB but
// keeps invalid inner CCB
// and memory overhead that
// should be cleaned
// afterwards
public:
/// \name Constructors.
//@{
/*! Default constructor. */
Arrangement_on_surface_2();
/*! Copy constructor. */
Arrangement_on_surface_2(const Self & arr);
/*! Constructor given a traits object. */
Arrangement_on_surface_2(const Geometry_traits_2* geom_traits);
//@}
/// \name Assignment functions.
//@{
/*! Assignment operator. */
Self& operator=(const Self& arr);
/*! Assign an arrangement. */
void assign(const Self& arr);
//@}
/// \name Destruction functions.
//@{
/*! Destructor. */
virtual ~Arrangement_on_surface_2();
/*! Change mode. */
void set_sweep_mode (bool mode) { m_sweep_mode = mode; }
/*! Clear the arrangement. */
virtual void clear();
//@}
/// \name Access the traits-class objects.
//@{
/*! Access the geometry-traits object (const version). */
inline const Traits_adaptor_2* traits_adaptor() const
{ return (m_geom_traits); }
/*! Access the geometry-traits object (const version). */
inline const Geometry_traits_2* geometry_traits() const
{ return (m_geom_traits); }
/*! Access the topology-traits object (non-const version). */
inline Topology_traits* topology_traits()
{ return (&m_topol_traits); }
/*! Access the topology-traits object (const version). */
inline const Topology_traits* topology_traits() const
{ return (&m_topol_traits); }
//@}
/// \name Access the arrangement dimensions.
//@{
/*! Check whether the arrangement is empty. */
bool is_empty() const
{ return (m_topol_traits.is_empty_dcel()); }
/*!
* Check whether the arrangement is valid. In particular, check the
* validity of each vertex, halfedge and face, their incidence relations
* and the geometric properties of the arrangement.
*/
bool is_valid() const;
/*! Get the number of arrangement vertices. */
Size number_of_vertices() const
{ return (m_topol_traits.number_of_concrete_vertices()); }
/*! Get the number of isolated arrangement vertices. */
Size number_of_isolated_vertices() const
{ return (_dcel().size_of_isolated_vertices()); }