This file is indexed.

/usr/include/CGAL/Nef_polyhedron_S2.h is in libcgal-dev 4.2-5ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
// Copyright (c) 1997-2000  Max-Planck-Institute Saarbruecken (Germany).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
// You can redistribute it and/or modify it under the terms of the GNU
// General Public License as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $URL$
// $Id$
// 
//
// Author(s)     : Michael Seel       <seel@mpi-sb.mpg.de>
//                 Peter Hachenberger <hachenberger@mpi-sb.mpg.de>

#ifndef CGAL_NEF_POLYHEDRON_S2_H
#define CGAL_NEF_POLYHEDRON_S2_H

#if defined(BOOST_MSVC)
#  pragma warning(push)
#  pragma warning(disable:4800) // complaint about performance in std::map where we can't do anything
#endif

#include <CGAL/basic.h>
#include <CGAL/Handle_for.h>
#include <CGAL/Nef_S2/SM_items.h>
#include <CGAL/Nef_S2/Sphere_map.h>
#include <CGAL/Nef_S2/SM_decorator.h>
#include <CGAL/Nef_S2/SM_io_parser.h>
#include <CGAL/Nef_S2/SM_point_locator.h>
#include <CGAL/Nef_S2/SM_overlayer.h>
#include <CGAL/Modifier_base.h>

#include <vector>
#include <list>

#include <boost/random/linear_congruential.hpp>
#include <boost/random/uniform_real.hpp>
#include <boost/random/variate_generator.hpp>

#undef CGAL_NEF_DEBUG
#define CGAL_NEF_DEBUG 53
#include <CGAL/Nef_2/debug.h>

namespace CGAL {

template <typename K, typename I, typename Mk, typename M> class Nef_polyhedron_S2;
template <typename K, typename I, typename Mk, typename M> class Nef_polyhedron_S2_rep;
template <typename K, typename I, typename Mk> class Nef_polyhedron_3;
class SNC_items;

template <typename K, typename I, typename Mk, typename M>
std::ostream& operator<<(std::ostream&, const Nef_polyhedron_S2<K,I,Mk,M>&); 
template <typename K, typename I, typename Mk, typename M>
std::istream& operator>>(std::istream&, Nef_polyhedron_S2<K,I,Mk,M>&);


template <typename K, typename I, typename Mk, typename M>
class Nef_polyhedron_S2_rep { 

  typedef Nef_polyhedron_S2_rep<K,I,Mk,M>        Self;
  friend class Nef_polyhedron_S2<K,I,Mk,M>;

 public:
  typedef CGAL::Sphere_geometry<K>                     Sphere_kernel;
  typedef Mk                                           Mark;
  typedef M                                            Sphere_map;
  typedef CGAL::SM_const_decorator<Sphere_map>         Const_decorator;
  typedef CGAL::SM_decorator<Sphere_map>               Decorator;
  typedef CGAL::SM_overlayer<Decorator>                Overlayer;
  typedef CGAL::SM_point_locator<Const_decorator>      Locator;

 private:
  Sphere_map sm_; 
  
public:
  Nef_polyhedron_S2_rep() : sm_() {}
  Nef_polyhedron_S2_rep(const Self&) : sm_() {}
  ~Nef_polyhedron_S2_rep() { sm_.clear(); }
};

/*{\Moptions print_title=yes }*/ 
/*{\Manpage {Nef_polyhedron_S2}{K}
{Nef Polyhedra in the sphere surface}{N}}*/

/*{\Mdefinition An instance of data type |\Mname| is a subset of $S_2$
that is the result of forming complements and intersections starting
from a finite set |H| of half-spaces. |\Mtype| is closed under all
binary set operations |intersection|, |union|, |difference|,
|complement| and under the topological operations |boundary|,
|closure|, and |interior|.

The template parameter |Kernel| is specified via a kernel concept. 
|Kernel| must be a model of the concept |NefSphereKernelTraits_2|.
}*/

template <typename Kernel_, typename Items_ = SM_items, typename Mark_ = bool,  
	  typename Map_ = Sphere_map<Sphere_geometry<Kernel_>,Items_, Mark_> >
class Nef_polyhedron_S2 : public Handle_for< Nef_polyhedron_S2_rep<Kernel_,Items_,Mark_,Map_> >, 
			  public Nef_polyhedron_S2_rep<Kernel_,Items_,Mark_,Map_>::Const_decorator { 
  
  using Nef_polyhedron_S2_rep<Kernel_,Items_,Mark_,Map_>::Const_decorator::set_sm;

public:
  /*{\Mtypes 7}*/
  typedef Items_                                              Items;
  typedef Kernel_                                             Kernel;
  typedef Map_                                                Sphere_map;
  typedef Mark_                                               Mark;
  typedef Nef_polyhedron_S2<Kernel,Items,Mark,Sphere_map>     Self;
  typedef Nef_polyhedron_S2_rep<Kernel,Items,Mark,Sphere_map> Rep;
  typedef Handle_for< Nef_polyhedron_S2_rep<Kernel,Items,Mark,Sphere_map> >  Base;
  typedef typename Rep::Sphere_kernel                         Sphere_kernel;
//  typedef typename Rep::Sphere_map                            Sphere_map;

  typedef typename Sphere_kernel::Sphere_point   Sphere_point;
  /*{\Mtypemember points in the sphere surface.}*/

  typedef typename Sphere_kernel::Sphere_segment Sphere_segment;
  /*{\Mtypemember segments in the sphere surface.}*/

  typedef typename Sphere_kernel::Sphere_circle  Sphere_circle;
  /*{\Mtypemember oriented great circles modeling spherical half-spaces}*/

  typedef typename Sphere_kernel::Sphere_direction Sphere_direction;


//  typedef typename Rep::Mark Mark;
  /*{\Xtypemember marking set membership or exclusion.}*/

  enum Boundary { EXCLUDED=0, INCLUDED=1 };
  /*{\Menum construction selection.}*/

  enum Content { EMPTY=0, COMPLETE=1 };
  /*{\Menum construction selection}*/

  const Sphere_map& sphere_map() const { return this->ptr()->sm_; }
protected:
  Sphere_map& sphere_map() { return this->ptr()->sm_; } 

  struct AND { bool operator()(const Mark& b1, const Mark& b2)  const { return b1&&b2; }  };
  struct OR { bool operator()(const Mark& b1, const Mark& b2)   const { return b1||b2; }  };
  struct DIFF { bool operator()(const Mark& b1, const Mark& b2) const { return b1&&!b2; } };
  struct XOR { bool operator()(const Mark& b1, const Mark& b2)  const 
               { return (b1&&!b2)||(!b1&&b2); } };   

  typedef Nef_polyhedron_S2_rep<Kernel,Items,Mark,Sphere_map>  Nef_rep;
  typedef typename Nef_rep::Decorator                     Decorator;
public:
  typedef typename Nef_rep::Const_decorator               Const_decorator;
protected:
  typedef typename Nef_rep::Overlayer                     Overlayer;
  typedef typename Nef_rep::Locator                       Locator;

  friend std::ostream& operator<< <>
      (std::ostream& os, const Self& NP);
  friend std::istream& operator>> <>
      (std::istream& is, Self& NP);

public:
  typedef typename Decorator::SVertex_handle         SVertex_handle;
  typedef typename Decorator::SHalfedge_handle       SHalfedge_handle;
  typedef typename Decorator::SHalfloop_handle       SHalfloop_handle;
  typedef typename Decorator::SFace_handle           SFace_handle;

  typedef typename Sphere_map::SVertex_base          SVertex;
  typedef typename Sphere_map::SHalfedge_base        SHalfedge;
  typedef typename Sphere_map::SHalfloop             SHalfloop;
  typedef typename Sphere_map::SFace_base            SFace;

  typedef typename Decorator::SVertex_const_handle   SVertex_const_handle;
  typedef typename Decorator::SHalfedge_const_handle SHalfedge_const_handle;
  typedef typename Decorator::SHalfloop_const_handle SHalfloop_const_handle;
  typedef typename Decorator::SFace_const_handle     SFace_const_handle;

  typedef typename Decorator::SVertex_iterator       SVertex_iterator;
  typedef typename Decorator::SHalfedge_iterator     SHalfedge_iterator;
  typedef typename Decorator::SHalfloop_iterator     SHalfloop_iterator;
  typedef typename Decorator::SFace_iterator         SFace_iterator;

  typedef typename Const_decorator::SVertex_const_iterator   
                                                    SVertex_const_iterator;
  typedef typename Const_decorator::SHalfedge_const_iterator 
                                                    SHalfedge_const_iterator;
  typedef typename Const_decorator::SHalfloop_const_iterator 
                                                    SHalfloop_const_iterator;
  typedef typename Const_decorator::SFace_const_iterator     
                                                    SFace_const_iterator;
  typedef typename Const_decorator::Size_type Size_type;
  typedef Size_type size_type;
  
  typedef std::list<Sphere_segment>  SS_list;
  typedef typename SS_list::const_iterator SS_iterator;

  friend class Nef_polyhedron_3<Kernel, SNC_items, Mark>;

public:
  /*{\Mcreation 3}*/

  Nef_polyhedron_S2(Content sphere = EMPTY) : Base(Nef_rep())
  /*{\Mcreate creates an instance |\Mvar| of type |\Mname|
  and initializes it to the empty set if |sphere == EMPTY|
  and to the whole sphere if |sphere == COMPLETE|.}*/
  {
    set_sm(&sphere_map());
    Decorator D(&sphere_map());
    SFace_handle sf=D.new_sface();
    sf->mark() = bool(sphere);
  }


  Nef_polyhedron_S2(const Sphere_circle& c, 
		    Boundary circle = INCLUDED) : Base(Nef_rep()) {
  /*{\Mcreate creates a Nef polyhedron |\Mvar| containing the half-sphere
  left of |c| including |c| if |circle==INCLUDED|, excluding |c| if 
  |circle==EXCLUDED|.}*/  
    
    set_sm(&sphere_map());
    CGAL_NEF_TRACEN("Nef_polyhedron_S2(): construction from circle "<<c);
    Decorator D(&sphere_map());
    Overlayer O(&sphere_map()); 
    O.create(c);
    SHalfloop_handle h = D.shalfloop();
    if ( h->circle() != c ) h = h->twin();
    h->incident_sface()->mark() = true;
    h->mark() = h->twin()->mark() = bool(circle);
  }


  template <class Forward_iterator>
  Nef_polyhedron_S2(Forward_iterator first, Forward_iterator beyond,
    Boundary b = INCLUDED) : Base(Nef_rep())
  /*{\Mcreate creates a Nef polyhedron |\Mvar| from the set of sphere
    segments in the iterator range |[first,beyond)|. If the set of sphere
    segments is a simple polygon that separates the sphere surface
    into two regions, then the polygonal region that is left of the
    segment |*first| is selected. The polygonal region includes its
    boundary if |b = INCLUDED| and excludes the boundary
    otherwise. |Forward_iterator| has to be an iterator with value
    type |Sphere_segment|.}*/
  { CGAL_NEF_TRACEN("Nef_polyhedron_S2(): creation from segment range");
    CGAL_assertion(first!=beyond);
    set_sm(&sphere_map());
    Overlayer D(&sphere_map());
    Sphere_segment s = *first;
    D.create_from_segments(first,beyond);
    SHalfedge_iterator e;
    CGAL_forall_shalfedges(e,D) {
      Sphere_circle c(e->circle());
      if ( c == s.sphere_circle() ) break;
    }
    if ( e != SHalfedge_iterator() ) {
      if ( e->circle() != s.sphere_circle() ) e = e->twin();
      CGAL_assertion( e->circle() == s.sphere_circle() );
      D.set_marks_in_face_cycle(e,bool(b));
      if ( D.number_of_sfaces() > 2 ) e->incident_sface()->mark() = true;
      else                            e->incident_sface()->mark() = !bool(b);
      return;
    }
    D.simplify();
  }

  Nef_polyhedron_S2(const Self& N1) : Base(N1), Const_decorator() {
    set_sm(&sphere_map());
  }
  Nef_polyhedron_S2& operator=(const Self& N1)
  { Base::operator=(N1); set_sm(&sphere_map()); return (*this); }
  ~Nef_polyhedron_S2() {}

  template <class Forward_iterator>
  Nef_polyhedron_S2(Forward_iterator first, Forward_iterator beyond, 
    double p) : Base(Nef_rep())
  /*{\Xcreate creates a random Nef polyhedron from the arrangement of
  the set of circles |S = set[first,beyond)|. The cells of the arrangement
  are selected uniformly at random with probability $p$. \precond $0 < p
  < 1$.}*/
  { CGAL_assertion(0<=p && p<=1);
    CGAL_assertion(first!=beyond);
    set_sm(&sphere_map());
    Overlayer D(&sphere_map());
    D.create_from_circles(first, beyond); D.simplify();

    boost::rand48 rng;
    boost::uniform_real<> dist(0,1);
    boost::variate_generator<boost::rand48&, boost::uniform_real<> > get_double(rng,dist);

    SVertex_iterator v; SHalfedge_iterator e; SFace_iterator f;
    CGAL_forall_svertices(v,D)
      v->mark() = ( get_double() < p ? true : false );
    CGAL_forall_shalfedges(e,D)
      e->mark() = ( get_double() < p ? true : false );
    CGAL_forall_sfaces(f,D)
      f->mark() = ( get_double() < p ? true : false );
    D.simplify();
  }

 void delegate( Modifier_base<Sphere_map>& modifier) {
   // calls the `operator()' of the `modifier'. Precondition: The
   // `modifier' returns a consistent representation.
   modifier(sphere_map());
   //   CGAL_expensive_postcondition( is_valid());
 }

//protected:
  Nef_polyhedron_S2(const Sphere_map& H, bool clone=true) : Base(Nef_rep()) 
  /*{\Xcreate makes |\Mvar| a new object.  If |clone==true| then the
  underlying structure of |H| is copied into |\Mvar|.}*/
{ 
    if(clone)
      this->ptr()->sm_ = H; 
    set_sm(&sphere_map());
  }
  
  void clone_rep() { *this = Self(sphere_map()); }

  /*{\Moperations 4 3 }*/
  public:

  void clear(Content plane = EMPTY)
  { *this = Nef_polyhedron_S2(plane); }
  /*{\Mop makes |\Mvar| the empty set if |plane == EMPTY| and the
  full plane if |plane == COMPLETE|.}*/

  bool is_empty() const
  /*{\Mop returns true if |\Mvar| is empty, false otherwise.}*/
  { Const_decorator D(&sphere_map());
    CGAL_NEF_TRACEN("is_empty()"<<*this);
    SFace_const_iterator f = D.sfaces_begin();
    return (D.number_of_svertices()==0 &&
            D.number_of_sedges()==0 &&
            D.number_of_sloops()==0 &&
            D.number_of_sfaces()==1 &&
            f->mark() == false);
  }

  bool is_plane() const
  /*{\Mop returns true if |\Mvar| is the whole plane, false otherwise.}*/
  { Const_decorator D(&sphere_map());
    SFace_const_iterator f = D.sfaces_begin();
    return (D.number_of_svertices()==0 &&
            D.number_of_sedges()==0 &&
            D.number_of_sloops()==0 &&
            D.number_of_sfaces()==1 &&
            f->mark() == true);
  }

  void extract_complement()
  { CGAL_NEF_TRACEN("extract complement");
    if ( this->is_shared() ) clone_rep();
    Overlayer D(&sphere_map());
    SVertex_iterator v;
    SHalfedge_iterator e;
    SFace_iterator f;
    CGAL_forall_svertices(v,D) v->mark() = !v->mark();
    CGAL_forall_sedges(e,D) e->mark() = !e->mark();
    CGAL_forall_sfaces(f,D) f->mark() = !f->mark();
    
    if ( D.has_shalfloop() )
      D.shalfloop()->mark() = 
	D.shalfloop()->twin()->mark() = 
	!D.shalfloop()->mark();
  }

  void extract_interior()
  { CGAL_NEF_TRACEN("extract interior");
    if ( this->is_shared() ) clone_rep();
    Overlayer D(&sphere_map());
    SVertex_iterator v;
    SHalfedge_iterator e;
    CGAL_forall_svertices(v,D) v->mark() = false;
    CGAL_forall_sedges(e,D) e->mark() = false;
    if ( D.has_sloop() ) D.shalfloop()->mark() = false;
    D.simplify();
  }


  void extract_boundary()
  { CGAL_NEF_TRACEN("extract boundary");
    if ( this->is_shared() ) clone_rep();
    Overlayer D(&sphere_map());
    SVertex_iterator v;
    SHalfedge_iterator e;
    SFace_iterator f;
    CGAL_forall_svertices(v,D) v->mark() = true;
    CGAL_forall_sedges(e,D)    e->mark() = true;
    CGAL_forall_sfaces(f,D)    f->mark() = false;
    if ( D.has_sloop() )       D.shalfloop()->mark() = D.shalfoop()->twin() = true;
    D.simplify();
  }

  void extract_closure()
  /*{\Xop converts |\Mvar| to its closure. }*/
  { CGAL_NEF_TRACEN("extract closure");
    extract_complement();
    extract_interior();
    extract_complement();
  }

  void extract_regularization()
  /*{\Xop converts |\Mvar| to its regularization. }*/
  { CGAL_NEF_TRACEN("extract regularization");
    extract_interior();
    extract_closure();
  }

  /*{\Mtext \headerline{Constructive Operations}}*/

  Self complement() const
  /*{\Mop returns the complement of |\Mvar| in the plane.}*/
  { Self res = *this;
    res.extract_complement();
    return res;
  }


  Self interior() const
  /*{\Mop returns the interior of |\Mvar|.}*/
  { Self res = *this;
    res.extract_interior();
    return res;
  }

  Self closure() const
  /*{\Mop returns the closure of |\Mvar|.}*/
  { Self res = *this;
    res.extract_closure();
    return res;
  }

  Self boundary() const
  /*{\Mop returns the boundary of |\Mvar|.}*/
  { Self res = *this;
    res.extract_boundary();
    return res;
  }

  Self regularization() const
  /*{\Mop returns the regularized polyhedron (closure of interior).}*/
  { Self res = *this;
    res.extract_regularization();
    return res;
  }


  Self intersection(const Self& N1) const
  /*{\Mop returns |\Mvar| $\cap$ |N1|. }*/
  { Self res(sphere_map(),false); // empty
    Overlayer D(&res.sphere_map());
    D.subdivide(&sphere_map(),&N1.sphere_map());
    AND _and; D.select(_and); D.simplify();
    return res;
  }


  Self join(const Self& N1) const
  /*{\Mop returns |\Mvar| $\cup$ |N1|. }*/
  { Self res(sphere_map(),false); // empty
    Overlayer D(&res.sphere_map());
    D.subdivide(&sphere_map(),&N1.sphere_map());
    OR _or; D.select(_or); D.simplify();
    return res;
  }

  Self difference(const Self& N1) const
  /*{\Mop returns |\Mvar| $-$ |N1|. }*/
  { Self res(sphere_map(),false); // empty
    Overlayer D(&res.sphere_map());
    D.subdivide(&sphere_map(),&N1.sphere_map());
    DIFF _diff; D.select(_diff); D.simplify();
    return res;
  }    

  Self symmetric_difference(
    const Self& N1) const
  /*{\Mop returns the symmectric difference |\Mvar - T| $\cup$ 
          |T - \Mvar|. }*/
  { Self res(sphere_map(),false); // empty
    Overlayer D(&res.sphere_map());
    D.subdivide(&sphere_map(),&N1.sphere_map());
    XOR _xor; D.select(_xor); D.simplify();
    return res;
  }

  /*{\Mtext Additionally there are operators |*,+,-,^,!| which
  implement the binary operations \emph{intersection}, \emph{union},
  \emph{difference}, \emph{symmetric difference}, and the unary
  operation \emph{complement} respectively. There are also the
  corresponding modification operations |*=,+=,-=,^=|.}*/

  Self  operator*(const Self& N1) const
  { return intersection(N1); }

  Self  operator+(const Self& N1) const
  { return join(N1); }

  Self  operator-(const Self& N1) const
  { return difference(N1); }

  Self  operator^(const Self& N1) const
  { return symmetric_difference(N1); }

  Self  operator!() const
  { return complement(); }
   
  Self& operator*=(const Self& N1)
  { *this = intersection(N1); return *this; }

  Self& operator+=(const Self& N1)
  { *this = join(N1); return *this; }

  Self& operator-=(const Self& N1)
  { *this = difference(N1); return *this; }

  Self& operator^=(const Self& N1)
  { *this = symmetric_difference(N1); return *this; }

  /*{\Mtext There are also comparison operations like |<,<=,>,>=,==,!=|
  which implement the relations subset, subset or equal, superset, superset
  or equal, equality, inequality, respectively.}*/

  bool operator==(const Self& N1) const
  { return symmetric_difference(N1).is_empty(); }

  bool operator!=(const Self& N1) const
  { return !operator==(N1); }  

  bool operator<=(const Self& N1) const
  { return difference(N1).is_empty(); } 

  bool operator<(const Self& N1) const
  { return difference(N1).is_empty() && !N1.difference(*this).is_empty(); } 

  bool operator>=(const Self& N1) const
  { return N1.difference(*this).is_empty(); } 

  bool operator>(const Self& N1) const   
  { return N1.difference(*this).is_empty() && !difference(N1).is_empty(); } 


  /*{\Mtext \headerline{Exploration - Point location - Ray shooting}
  As Nef polyhedra are the result of forming complements 
  and intersections starting from a set |H| of half-spaces that are
  defined by oriented lines in the plane, they can be represented by
  an attributed plane map $M = (V,E,F)$. For topological queries
  within |M| the following types and operations allow exploration
  access to this structure.}*/

  /*{\Mtypes 3}*/
  typedef Const_decorator Topological_explorer;

  typedef Const_decorator Explorer;
  /*{\Mtypemember a decorator to examine the underlying plane map. 
  See the manual page of |Explorer|.}*/

  typedef typename Locator::Object_handle Object_handle;
  /*{\Mtypemember a generic handle to an object of the underlying
  plane map. The kind of object |(vertex, halfedge, face)| can 
  be determined and the object can be assigned to a corresponding
  handle by the three functions:\\
  |bool assign(SVertex_const_handle& h, Object_handle)|\\
  |bool assign(SHalfedge_const_handle& h, Object_handle)|\\
  |bool assign(SFace_const_handle& h, Object_handle)|\\
  where each function returns |true| iff the assignment to
  |h| was done.}*/


  /*{\Moperations 3 1 }*/

  bool contains(Object_handle h) const
  /*{\Mop  returns true iff the object |h| is contained in the set
  represented by |\Mvar|.}*/
  { Locator PL(&sphere_map()); return PL.mark(h); }

  bool contained_in_boundary(Object_handle h) const
  /*{\Mop  returns true iff the object |h| is contained in the $1$-skeleton
  of |\Mvar|.}*/
  { SVertex_const_handle v;
    SHalfedge_const_handle e;
    return  ( CGAL::assign(v,h) || CGAL::assign(e,h) );
  }


  Object_handle locate(const Sphere_point& p) const
  /*{\Mop  returns a generic handle |h| to an object (face, halfedge, vertex) 
  of the underlying plane map that contains the point |p| in its relative 
  interior. The point |p| is contained in the set represented by |\Mvar| if 
  |\Mvar.contains(h)| is true. The location mode flag |m| allows one to choose
  between different point location strategies.}*/
  { 
    Locator PL(&sphere_map());
    return PL.locate(p); 
  }

  struct INSET {
    const Const_decorator& D;
    INSET(const Const_decorator& Di) : D(Di) {}
    bool operator()(SVertex_const_handle v) const { return v->mark(); }
    bool operator()(SHalfedge_const_handle e) const { return e->mark(); }
    bool operator()(SHalfloop_const_handle l) const { return l->mark(); }
    bool operator()(SFace_const_handle f) const { return f->mark(); }
  };

  Object_handle ray_shoot(const Sphere_point& p, 
			  const Sphere_direction& d) const
  /*{\Mop returns a handle |h| with |\Mvar.contains(h)| that can be
  converted to a |SVertex_/SHalfedge_/SFace_const_handle| as described
  above. The object returned is intersected by the ray starting in |p|
  with direction |d| and has minimal distance to |p|.  The operation
  returns the null handle |NULL| if the ray shoot along |d| does not hit
  any object |h| of |\Mvar| with |\Mvar.contains(h)|.}*/
  { 
    Locator PL(&sphere_map());
    return PL.ray_shoot(p,d,INSET(PL));
  }

  struct INSKEL {
    bool operator()(SVertex_const_handle) const { return true; }
    bool operator()(SHalfedge_const_handle) const { return true; }
    bool operator()(SHalfloop_const_handle) const { return true; }
    bool operator()(SFace_const_handle) const { return false; }
  };

  Object_handle ray_shoot_to_boundary(const Sphere_point& p, 
				      const Sphere_direction& d) const
  /*{\Mop returns a handle |h| that can be converted to a
  |SVertex_/SHalfedge_const_handle| as described above. The object
  returned is part of the $1$-skeleton of |\Mvar|, intersected by the
  ray starting in |p| with direction |d| and has minimal distance to
  |p|.  The operation returns the null handle |NULL| if the ray shoot
  along |d| does not hit any $1$-skeleton object |h| of |\Mvar|. The
  location mode flag |m| allows one to choose between different point
  location strategies.}*/
  { 
    Locator PL(&sphere_map());
    return PL.ray_shoot(p,d,INSKEL());
  }


  //  Explorer explorer() const 
  /*{\Mop returns a decorator object which allows read-only access of
  the underlying plane map. See the manual page |Explorer| for its 
  usage.}*/
  //  { return Explorer(const_cast<Sphere_map*>(&sphere_map())); }

  /*{\Mtext\headerline{Input and Output}
  A Nef polyhedron |\Mvar| can be visualized in an open GL window. The 
  output operator is defined in the file 
  |CGAL/IO/Nef_\-poly\-hedron_2_\-Win\-dow_\-stream.h|.
  }*/

  /*{\Mimplementation Nef polyhedra are implemented on top of a halfedge
  data structure and use linear space in the number of vertices, edges
  and facets.  Operations like |empty| take constant time. The
  operations |clear|, |complement|, |interior|, |closure|, |boundary|,
  |regularization|, input and output take linear time. All binary set
  operations and comparison operations take time $O(n \log n)$ where $n$
  is the size of the output plus the size of the input.

  The point location and ray shooting operations are implemented in
  the naive way. The operations run in linear query time without
  any preprocessing.}*/

  /*{\Mexample Nef polyhedra are parameterized by a standard CGAL
  kernel. 

  \begin{Mverb}
  #include <CGAL/Homogeneous.h>
  #include <CGAL/leda_integer.h>
  #include <CGAL/Nef_polyhedron_S2.h>
  #include <CGAL/SM_items.h>

  using namespace CGAL;
  typedef  Homogeneous<leda_integer>   Kernel;
  typedef  SM_items<Kernel, bool>      SM_items;
  typedef  Nef_polyhedron_S2<SM_items> Nef_polyhedron;
  typedef  Nef_polyhedron::Sphere_circle Sphere_circle;

  int main()
  {
    Nef_polyhedron N1(Sphere_circle(1,0,0));
    Nef_polyhedron N2(Sphere_circle(0,1,0), Nef_polyhedron::EXCLUDED);
    Nef_polyhedron N3 = N1 * N2; // line (*)
    return 0;
  }
  \end{Mverb}
  After line (*) |N3| is the intersection of |N1| and |N2|.}*/


}; // end of Nef_polyhedron_S2

template <typename Kernel,typename Items,typename Mark, typename Sphere_map>
std::ostream& operator<<
 (std::ostream& os, const Nef_polyhedron_S2<Kernel,Items,Mark,Sphere_map>& NP)
{
  os << "Nef_polyhedron_S2\n";
  typedef typename Nef_polyhedron_S2<Kernel,Items,Mark,Sphere_map>::Explorer Decorator;
  CGAL::SM_io_parser<Decorator> O(os, Decorator(&NP.sphere_map())); 
  O.print();
  return os;
}

template <typename Kernel,typename Items, typename Mark, typename Sphere_map>
std::istream& operator>>
  (std::istream& is, Nef_polyhedron_S2<Kernel,Items,Mark,Sphere_map>& NP)
{
  typedef typename Nef_polyhedron_S2<Kernel,Items,Mark,Sphere_map>::Decorator Decorator;
  CGAL::SM_io_parser<Decorator> I(is, Decorator(&NP.sphere_map())); 
  //  if ( I.check_sep("Nef_polyhedron_S2") ) 
  I.read();
  /*
  else {
    std::cerr << "Nef_polyhedron_S2 input corrupted." << std::endl;
    NP = Nef_polyhedron_S2<Kernel,Items,Mark,Sphere_map>();
  }
  */
  /*
  typename Nef_polyhedron_S2<Kernel,Items,Mark,Sphere_map>::Topological_explorer D(NP.explorer());
  D.check_integrity_and_topological_planarity();
  */
  return is;
}


#if defined(BOOST_MSVC)
#  pragma warning(pop)
#endif

} //namespace CGAL
#endif //CGAL_NEF_POLYHEDRON_S2_H