This file is indexed.

/usr/include/crystalspace-2.0/csgeom/poly2d.h is in libcrystalspace-dev 2.0+dfsg-1build1.

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
/*
    Copyright (C) 1998,2000 by Jorrit Tyberghein

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public
    License along with this library; if not, write to the Free
    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#ifndef __CS_POLY2D_H__
#define __CS_POLY2D_H__

#include "csextern.h"

#include "csgeom/vector2.h"
/**\file 
 * General 2D polygon.
 */
/**
 * \addtogroup geom_utils
 * @{ */

class csBox2;
class csPlane2;

struct iClipper2D;

/**
 * The following class represents a general 2D polygon.
 */
class CS_CRYSTALSPACE_EXPORT csPoly2D
{
protected:
  /// The 2D vertices.
  csVector2* vertices;
  ///
  size_t num_vertices;
  ///
  size_t max_vertices;
public:
  /**
   * Make a new empty polygon.
   */
  csPoly2D (size_t start_size = 10);

  /// Copy constructor.
  csPoly2D (const csPoly2D& copy);

  /// Destructor.
  ~csPoly2D ();

  /// Assignment operator.
  csPoly2D& operator= (const csPoly2D& other);

  /**
   * Initialize the polygon to empty.
   */
  void MakeEmpty ();

  /**
   * Get the number of vertices.
   */
  size_t GetVertexCount () const { return num_vertices; }

  /**
   * Get the array with all vertices.
   */
  csVector2* GetVertices () { return vertices; }

  /**
   * Get the array with all vertices.
   */
  const csVector2* GetVertices () const { return vertices; }

  /**
   * Get the specified vertex.
   */
  csVector2* GetVertex (size_t i)
  {
    if (i>=num_vertices) return 0;
    return &vertices[i];
  }

  /**
   * Get the specified vertex.
   */
  csVector2& operator[] (size_t i)
  {
    CS_ASSERT (i < num_vertices);
    return vertices[i];
  }

  /**
   * Get the specified vertex.
   */
  const csVector2& operator[] (size_t i) const
  {
    CS_ASSERT (i < num_vertices);
    return vertices[i];
  }

  /**
   * Get the first vertex.
   */
  csVector2* GetFirst ()
  { if (num_vertices<=0) return 0;  else return vertices; }

  /**
   * Get the last vertex.
   */
  csVector2* GetLast ()
  { if (num_vertices<=0) return 0;  else return &vertices[num_vertices-1]; }

  /**
   * Test if this vector is inside the polygon. This assumes a convex polygon.
   */
  bool In (const csVector2& v);

  /**
   * Test if a vector is inside the given polygon. This assumes a convex polygon.
   */
  static bool In (csVector2* poly, size_t num_poly, const csVector2& v);

  /**
   * Make room for at least the specified number of vertices.
   */
  void MakeRoom (size_t new_max);

  /**
   * Set the number of vertices.
   */
  void SetVertexCount (size_t n)
  {
    MakeRoom (n);
    num_vertices = n;
  }

  /**
   * Add a vertex (2D) to the polygon.
   * Return index of added vertex.
   */
  size_t AddVertex (const csVector2& v) { return AddVertex (v.x, v.y); }

  /**
   * Add a vertex (2D) to the polygon.
   * Return index of added vertex.
   */
  size_t AddVertex (float x, float y);

  /**
   * Set all polygon vertices at once.  Copies the array.
   * Note! This doesn't update the bounding box!
   */
  void SetVertices (csVector2 const* v, size_t num)
  {
    MakeRoom (num);
    memcpy (vertices, v, (num_vertices = num) * sizeof (csVector2));
  }

  /**
   * Clipping routines. They return false if the resulting polygon is not
   * visible for some reason.
   * Note that these routines must not be called if the polygon is not visible.
   * These routines will not check that.
   * Note that these routines will put the resulting clipped 2D polygon
   * in place of the original 2D polygon.
   */
  bool ClipAgainst (iClipper2D* view);

  /**
   * Intersect this polygon with a given plane and return the
   * two resulting polygons in left and right. This version is
   * robust. If one of the edges of this polygon happens to be
   * on the same plane as 'plane' then the edge will go to the
   * polygon which already has most edges. i.e. you will not
   * get degenerate polygons.
   */
  void Intersect (const csPlane2& plane, csPoly2D& left,
  	csPoly2D& right) const;

  /**
   * This routine is similar to Intersect but it only returns the
   * polygon on the 'right' (positive) side of the plane.
   */
  void ClipPlane (const csPlane2& plane, csPoly2D& right) const;

  /**
   * Extend this polygon with another polygon so that the resulting
   * polygon is: (a) still convex, (b) fully contains this polygon,
   * and (c) contains as much as possible of the other polgon.
   * 'this_edge' is the index of the common edge for this polygon.
   * Edges are indexed with 0 being the edge from 0 to 1 and n-1 being
   * the edge from n-1 to 0.
   */
  void ExtendConvex (const csPoly2D& other, size_t this_edge);

  /**
   * Calculate the signed area of this polygon.
   */
  float GetSignedArea();

  /**
   * Generate a random convex polygon with the specified number
   * of vertices. The polygon will be inside the given bounding box.
   * \todo Extend the Random() function to support more then only triangles.
   */
  void Random (size_t num, const csBox2& max_bbox);
};

/**
 * This factory is responsible for creating csPoly2D objects or subclasses
 * of csPoly2D. To create a new factory which can create subclasses of csPoly2D
 * you should create a subclass of this factory.
 */
class csPoly2DFactory
{
public:
  // Needed for GCC4. Otherwise emits a flood of "virtual functions but
  // non-virtual destructor" warnings.
  virtual ~csPoly2DFactory() {}

  /// A shared factory that you can use.
   CS_DECLARE_STATIC_CLASSVAR(sharedFactory,SharedFactory,csPoly2DFactory)

  /// Create a poly2d.
  virtual csPoly2D* Create ()
  {
    csPoly2D* p = new csPoly2D ();
    return p;
  }
};

/** @} */

#endif // __CS_POLY2D_H__