This file is indexed.

/usr/include/crystalspace-2.0/csgeom/trimesh.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
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
/*
    Copyright (C) 2002 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_TRIMESH_H__
#define __CS_TRIMESH_H__

#include "csextern.h"
#include "csutil/scf_implementation.h"

#include "csgeom/tri.h"
#include "csgeom/vector3.h"
#include "csgeom/box.h"
#include "igeom/trimesh.h"

#include "csutil/array.h"
#include "csutil/flags.h"
#include "csutil/dirtyaccessarray.h"

/**\file
 * Triangle mesh.
 */
/**\addtogroup geom_utils
 * @{ */

/**
 * A mesh of triangles. Note that a mesh of triangles is only valid
 * if used in combination with a vertex or edge table. Every triangle is then
 * a set of three indices in that table.
 */
class CS_CRYSTALSPACE_EXPORT csTriangleMesh :
  public scfImplementation1<csTriangleMesh, iTriangleMesh>
{
protected:
  /// The triangles.
  csDirtyAccessArray<csTriangle> triangles;
  // The vertices.
  csDirtyAccessArray<csVector3> vertices;

  uint32 change_nr;
  csFlags flags;

public:
  ///
  csTriangleMesh () : scfImplementationType (this), change_nr (0) { }
  ///
  csTriangleMesh (const csTriangleMesh& mesh);
  ///
  virtual ~csTriangleMesh ();

  /// Add a vertex to the mesh.
  void AddVertex (const csVector3& v);
  /// Get the number of vertices for this mesh.
  virtual size_t GetVertexCount () { return vertices.GetSize (); }
  /// Get the number of vertices for this mesh.
  size_t GetVertexCount () const { return vertices.GetSize (); }
  /// Get the pointer to the array of vertices.
  virtual csVector3* GetVertices () { return vertices.GetArray (); }
  /// Get the pointer to the array of vertices.
  const csVector3* GetVertices () const { return vertices.GetArray (); }

  /// Add a triangle to the mesh.
  void AddTriangle (int a, int b, int c);
	/// Add another triangle mesh to this one.
	void AddTriangleMesh(const csTriangleMesh& tm);
  /// Query the array of triangles.
  virtual csTriangle* GetTriangles () { return triangles.GetArray (); }
  /// Query the array of triangles.
  const csTriangle* GetTriangles () const { return triangles.GetArray (); }
  ///
  csTriangle& GetTriangle (int i) { return triangles[i]; }
  /// Query the number of triangles.
  size_t GetTriangleCount () const { return triangles.GetSize (); }
  /// Query the number of triangles.
  virtual size_t GetTriangleCount () { return triangles.GetSize (); }

  /// Clear the mesh of triangles.
  void Clear ();
  /// Set the size of the triangle list.
  void SetSize (int count);
  /// Set the triangle array.  The array is copied.
  void SetTriangles (csTriangle const* trigs, int count);

  virtual void Lock () { }
  virtual void Unlock () { }
  virtual csFlags& GetFlags () { return flags; }
  virtual uint32 GetChangeNumber () const { return change_nr; }

	/// Adds another triangle mesh to this one
	csTriangleMesh& operator+=(const csTriangleMesh& tm);
};

/**
 * The representation of a vertex in a triangle mesh.
 * This is basically used as a temporary structure to be able to
 * calculate the cost of collapsing this vertex more quickly.
 */
class CS_CRYSTALSPACE_EXPORT csTriangleVertex
{
public:
  /// Position of this vertex in 3D space.
  csVector3 pos;
  /// Index of this vertex.
  int idx;

  /// Triangles that this vertex is connected to.
  csArray<size_t> con_triangles;

  /// Other vertices that this vertex is connected to.
  csArray<int> con_vertices;

  ///
  csTriangleVertex () { }
  ///
  ~csTriangleVertex () { }
  ///
  void AddTriangle (size_t idx);
  ///
  void AddVertex (int idx);
};

/**
 * A class which holds vertices and connectivity information for a triangle
 * mesh.
 */
class CS_CRYSTALSPACE_EXPORT csTriangleVertices
{
protected:
  csTriangleVertex* vertices;
  int num_vertices;

public:
  /// Build vertex table for a triangle mesh.
  csTriangleVertices (csTriangleMesh* mesh, csVector3* verts, int num_verts);
  ///
  ~csTriangleVertices ();
  /**
   * Update vertex table for a given set of vertices (with the same number
   * as at init).
   */
  void UpdateVertices (csVector3* verts);

  ///
  int GetVertexCount () const { return num_vertices; }
  ///
  csTriangleVertex& GetVertex (int idx) { return vertices[idx]; }
};

/**
 * A convenience triangle mesh implementation that represents a cube.
 */
class CS_CRYSTALSPACE_EXPORT csTriangleMeshBox :
  public scfImplementation1<csTriangleMeshBox,iTriangleMesh>
{
private:
  csVector3 vertices[8];
  csTriangle triangles[12];
  uint32 change_nr;
  csFlags flags;

public:
  /**
   * Construct a cube triangle mesh.
   */
  csTriangleMeshBox (const csBox3& box) : scfImplementationType(this)
  {
    change_nr = 0;
    triangles[0].Set (4, 5, 1);
    triangles[1].Set (4, 1, 0);
    triangles[2].Set (5, 7, 3);
    triangles[3].Set (5, 3, 1);
    triangles[4].Set (7, 6, 2);
    triangles[5].Set (7, 2, 3);
    triangles[6].Set (6, 4, 0);
    triangles[7].Set (6, 0, 2);
    triangles[8].Set (6, 7, 5);
    triangles[9].Set (6, 5, 4);
    triangles[10].Set (0, 1, 3);
    triangles[11].Set (0, 3, 2);
    SetBox (box);

    flags.SetAll (CS_TRIMESH_CLOSED | CS_TRIMESH_CONVEX);
  }

  virtual ~csTriangleMeshBox ()
  {
  }

  /**
   * Set the box.
   */
  void SetBox (const csBox3& box)
  {
    change_nr++;
    vertices[0] = box.GetCorner (0);
    vertices[1] = box.GetCorner (1);
    vertices[2] = box.GetCorner (2);
    vertices[3] = box.GetCorner (3);
    vertices[4] = box.GetCorner (4);
    vertices[5] = box.GetCorner (5);
    vertices[6] = box.GetCorner (6);
    vertices[7] = box.GetCorner (7);
  }

  virtual size_t GetVertexCount () { return 8; }
  virtual csVector3* GetVertices () { return vertices; }
  virtual size_t GetTriangleCount () { return 12; }
  virtual csTriangle* GetTriangles () { return triangles; }
  virtual void Lock () { }
  virtual void Unlock () { }
  virtual csFlags& GetFlags () { return flags; }
  virtual uint32 GetChangeNumber () const { return change_nr; }
};

/**
 * A convenience triangle mesh which takes vertex and triangle
 * pointers from another source. Take care of object life time
 * when using this class; i.e. make sure the real owner of the
 * vertex and triangle data is not destroyed at a time when
 * this class is still in use.
 */
class CS_CRYSTALSPACE_EXPORT csTriangleMeshPointer :
  public scfImplementation1<csTriangleMeshPointer,iTriangleMesh>
{
private:
  csVector3* vertices;
  size_t num_vertices;
  csTriangle* triangles;
  size_t num_triangles;
  uint32 change_nr;
  csFlags flags;

public:
  /**
   * Construct a triangle mesh.
   */
  csTriangleMeshPointer (csVector3* vertices, size_t num_vertices,
      csTriangle* triangles, size_t num_triangles)
    : scfImplementationType(this)
  {
    change_nr = 0;
    csTriangleMeshPointer::vertices = vertices;
    csTriangleMeshPointer::num_vertices = num_vertices;
    csTriangleMeshPointer::triangles = triangles;
    csTriangleMeshPointer::num_triangles = num_triangles;
  }

  virtual ~csTriangleMeshPointer ()
  {
  }

  virtual size_t GetVertexCount () { return num_vertices; }
  virtual csVector3* GetVertices () { return vertices; }
  virtual size_t GetTriangleCount () { return num_triangles; }
  virtual csTriangle* GetTriangles () { return triangles; }
  virtual void Lock () { }
  virtual void Unlock () { }
  virtual csFlags& GetFlags () { return flags; }
  virtual uint32 GetChangeNumber () const { return change_nr; }
};

/** @} */

#endif // __CS_TRIMESH_H__