This file is indexed.

/usr/include/CGAL/Envelope_diagram_1.h is in libcgal-dev 4.11-2build1.

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
// Copyright (c) 2011  Tel-Aviv University (Israel).
// 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)     : Ron Wein   <wein@post.tau.ac.il>

#ifndef CGAL_ENVELOPE_DIAGRAM_1_H
#define CGAL_ENVELOPE_DIAGRAM_1_H

#include <CGAL/license/Envelope_2.h>


#include <list>

#include <CGAL/basic.h>
#include <CGAL/memory.h>

namespace CGAL {

/*! \class
 * A minimization (or a maximization) diagram that represents the lower (or the
 * upper) envelope of a set of curves in the plane.
 */
template <class Traits_, class Allocator = CGAL_ALLOCATOR(int) >
class Envelope_diagram_1 {
public:
  typedef Traits_                                   Traits_2;
  typedef typename Traits_2::Point_2                Point_2;
  typedef typename Traits_2::X_monotone_curve_2     X_monotone_curve_2;
  typedef std::list<X_monotone_curve_2>             Curve_container;
  typedef typename Curve_container::iterator        Curve_iterator;
  typedef typename Curve_container::const_iterator  Curve_const_iterator;
  typedef std::size_t                               Size;

  /*!
   * Representation of a diagram vertex, which stores the point it represents
   * and a list of all curves that pass at that point.
   */
  class Edge;

  class Vertex {
  private:
    Point_2          _p;
    Curve_container  _cvs;
    Edge* _leftP;
    Edge* _rightP;

  public:
    /*! Constructor. */
    Vertex () :
      _leftP(NULL),
      _rightP(NULL)
    {}

    /*! Constructor with a point. */
    Vertex (const Point_2& p) :
      _p(p),
      _leftP(NULL),
      _rightP(NULL)
    {}

    /*! Get the point. */
    const Point_2& point () const
    {
      return (_p);
    }

    /*! Get the number of curves associated with the vertex. */
    Size number_of_curves () const
    {
      return (_cvs.size());
    }

    /*! Get the range of curves associated with the vertex. */
    Curve_const_iterator curves_begin () const
    {
      return (_cvs.begin());
    }

    Curve_const_iterator curves_end () const
    {
      return (_cvs.end());
    }

    /*! Get the left edge (const version). */
    const Edge* left () const
    {
      return (_leftP);
    }

    /*! Get the left edge (non-const version). */
    Edge* left ()
    {
      return (_leftP);
    }

    /*! Get the right edge (const version). */
    const Edge* right () const
    {
      return (_rightP);
    }

    /*! Get the right edge (non-const version). */
    Edge* right ()
    {
      return (_rightP);
    }

    /*! Set the point. */
    void set_point (const Point_2& p)
    {
      _p = p;
    }

    /*! Clear the list of curves. */
    void clear_curves ()
    {
      _cvs.clear();
    }

    /*! Associate a new curve with the vertex. */
    void add_curve (const X_monotone_curve_2& cv)
    {
      _cvs.push_back (cv);
    }

    /*! Associate a range of new curves with the vertex. */
    void add_curves (Curve_const_iterator begin, Curve_const_iterator end)
    {
      Curve_const_iterator  iter;

      for (iter = begin; iter != end; ++iter)
        _cvs.push_back (*iter);
    }

    /*! Set the left edge. */
    void set_left (Edge* e)
    {
      _leftP = e;
    }

    /*! Get the right edge. */
    void set_right (Edge* e)
    {
      _rightP = e;
    }
  };

  /*!
   * Representation of a diagram edge, which represents an interval and
   * stores all curves that form the envelope on it (usually there's just one
   * curve or zero curves, unless the input contains overlapping curves).
   */
  class Edge
  {
  private:
    Curve_container  _cvs;
    Vertex* _leftP;
    Vertex* _rightP;

  public:
    /*! Constructor. */
    Edge () :
      _leftP(NULL),
      _rightP(NULL)
    {}

    /*! Check if the edge represents an empty interval. */
    bool is_empty () const
    {
      return (_cvs.empty());
    }

    /*! Get the number of curves associated with the edge. */
    Size number_of_curves () const
    {
      return (_cvs.size());
    }

    /*!
     * Get a representative x-monotone curve.
     * \pre The edge does not represent an empty interval.
     */
    const X_monotone_curve_2& curve () const
    {
      CGAL_precondition (! _cvs.empty());
      return (*(_cvs.begin()));
    }

    /*! Get the range of curves associated with the edge. */
    Curve_const_iterator curves_begin () const
    {
      return (_cvs.begin());
    }

    Curve_const_iterator curves_end () const
    {
      return (_cvs.end());
    }

    /*! Get the left vertex (const version). */
    const Vertex* left () const
    {
      return (_leftP);
    }

    /*! Get the left vertex (const version). */
    Vertex* left ()
    {
      return (_leftP);
    }

    /*! Get the right vertex (const version). */
    const Vertex* right () const
    {
      return (_rightP);
    }

    /*! Get the right vertex (non-const version). */
    Vertex* right ()
    {
      return (_rightP);
    }

    /*! Clear the list of curves. */
    void clear_curves ()
    {
      _cvs.clear();
    }

    /*! Associate a new curve with the edge. */
    void add_curve (const X_monotone_curve_2& cv)
    {
      _cvs.push_back (cv);
    }

    /*! Associate a range of new curves with the edge. */
    void add_curves (Curve_const_iterator begin, Curve_const_iterator end)
    {
      Curve_const_iterator  iter;

      for (iter = begin; iter != end; ++iter)
        _cvs.push_back (*iter);
    }

    /*! Set the left vertex. */
    void set_left (Vertex* v)
    {
      _leftP = v;
    }

    /*! Get the right vertex. */
    void set_right (Vertex* v)
    {
      _rightP = v;
    }
  };

  typedef Vertex*                        Vertex_handle;
  typedef const Vertex*                  Vertex_const_handle;
  typedef Edge*                          Edge_handle;
  typedef const Edge*                    Edge_const_handle;

private:

  // Vertex allocator.
  typedef typename Allocator::template rebind<Vertex>    Vertex_alloc_rebind;
  typedef typename Vertex_alloc_rebind::other            Vertex_allocator;

  // Halfedge allocator.
  typedef typename Allocator::template rebind<Edge>      Edge_alloc_rebind;
  typedef typename Edge_alloc_rebind::other              Edge_allocator;


  Edge* _leftmostP;                   // The leftmost edge of the diagram
                                      // (representing the range from -oo).
  Edge* _rightmostP;                  // The rightmost edge of the diagram
                                      // (representing the range to +oo).

  Vertex_allocator  vertex_alloc;     // An allocator for vertices.
  Edge_allocator    edge_alloc;       // An allocator for edges.

public:

  /*!
   * Constructor.
   */
  Envelope_diagram_1 ()
  {
    // An empty diagram contains one (empty) edge, representing (-oo, +oo):
    _leftmostP = _rightmostP = new_edge();
  }

  /*!
   * Destructor.
   */
  ~Envelope_diagram_1 ()
  {
    _free();
  }

  /*!
   * Get the leftmost edge of the diagram (const version).
   */
  Edge_const_handle leftmost () const
  {
    return (_leftmostP);
  }

  /*!
   * Get the leftmost edge of the diagram (non-const version).
   */
  Edge_handle leftmost ()
  {
    return (_leftmostP);
  }

  /*!
   * Get the rightmost edge of the diagram (const version).
   */
  Edge_const_handle rightmost () const
  {
    return (_rightmostP);
  }

  /*!
   * Get the rightmost edge of the diagram (non-const version).
   */
  Edge_handle rightmost ()
  {
    return (_rightmostP);
  }

  /*!
   * Clear the diagram.
   */
  void clear ()
  {
    _free();

    // An empty diagram contains one (empty) edge, representing (-oo, +oo):
    _leftmostP = _rightmostP = new_edge();
  }

  /*!
   * Set the leftmost edge.
   */
  void set_leftmost (Edge_handle e)
  {
    _leftmostP = e;
  }

  /*!
   * Set the rightmost edge.
   */
  void set_rightmost (Edge_handle e)
  {
    _rightmostP = e;
  }

  /*! Create a new vertex. */
  Vertex_handle new_vertex (const Point_2& p)
  {
    Vertex* v = vertex_alloc.allocate (1);

    vertex_alloc.construct (v, Vertex(p));
    return (v);
  }

  /*! Create a new edge. */
  Edge_handle new_edge ()
  {
    Edge* e = edge_alloc.allocate (1);

    edge_alloc.construct (e, Edge());
    return (e);
  }
   
  /*! Delete an existing vertex. */
  void delete_vertex (Vertex_handle v)
  {
    vertex_alloc.destroy (v);
    vertex_alloc.deallocate (v, 1);
  }
  
  /*! Delete an existing edge. */
  void delete_edge (Edge_handle e)
  {
    edge_alloc.destroy (e);
    edge_alloc.deallocate (e, 1);
  }
  
private:
  /*!
   * Free all diagram elements.
   */
  void _free ()
  {
    Vertex* v;
    Edge* e = _leftmostP;

    while (e != NULL) {
      // Get a pointer to the next vertex.
      v = e->right();

      // Free the edge and update it to be the next one after v.
      delete_edge (e);

      if (v != NULL) {
        e = v->right();

        // Free the current vertex.
        delete_vertex (v);
      }
      else
      {
        e = NULL;
      }
    }
     
    _leftmostP = NULL;
    _rightmostP = NULL;
  }
};

} //namespace CGAL

#endif