This file is indexed.

/usr/include/simgear/io/sg_binobj.hxx is in libsimgear-dev 3.4.0-3.

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
/**
 * \file sg_binobj.hxx
 * Routines to read and write the low level (binary) simgear 3d object format.
 */

// Written by Curtis Olson, started January 2000.
//
// Copyright (C) 2000  Curtis L. Olson  - http://www.flightgear.org/~curt
//
// This program is free software; 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 2 of the License, or
// (at your option) any later version.
//
// This program 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
//
// $Id$


#ifndef _SG_BINOBJ_HXX
#define _SG_BINOBJ_HXX

#include <zlib.h> // for gzFile

#include <simgear/compiler.h>
#include <simgear/constants.h>
#include <simgear/math/sg_types.hxx>
#include <simgear/math/SGMath.hxx>

#include <vector>
#include <string>
#include <boost/array.hpp>

#define MAX_TC_SETS     (4)
#define MAX_VAS         (8)

// I really want to pass around fixed length arrays, as the size 
// has to be hardcoded
// but it's a C++0x feature use boost in its absence
typedef boost::array<int_list, MAX_TC_SETS> tci_list;
typedef boost::array<int_list, MAX_VAS>     vai_list;

/** STL Structure used to store (integer index) object information */
typedef std::vector < int_list > group_list;
typedef group_list::iterator group_list_iterator;
typedef group_list::const_iterator const_group_list_iterator;

/** STL Structure used to store (tc index) object information */
typedef std::vector < tci_list > group_tci_list;
typedef group_tci_list::iterator group_tci_list_iterator;
typedef group_tci_list::const_iterator const_group_tci_list_iterator;

/** STL Structure used to store (va index) object information */
typedef std::vector < vai_list > group_vai_list;
typedef group_vai_list::iterator group_vai_list_iterator;
typedef group_vai_list::const_iterator const_group_vai_list_iterator;


// forward decls
class SGBucket;
class SGPath;

class SGBinObjectPoint {
public:
    std::string material;
    int_list    v_list;
    int_list    n_list;
    int_list    c_list;
    
    void clear( void ) {
        material = "";
        v_list.clear();
        n_list.clear();
        c_list.clear();
    };    
};

class SGBinObjectTriangle {
public:
    std::string material;
    int_list    v_list;
    int_list    n_list;
    int_list    c_list;
    
    tci_list    tc_list;
    vai_list    va_list;

    void clear( void ) {
        material = "";
        v_list.clear();
        n_list.clear();
        c_list.clear();
        for ( unsigned int i=0; i<MAX_TC_SETS; i++ ) {
            tc_list[i].clear();
        }
        for ( unsigned int i=0; i<MAX_VAS; i++ ) {
            va_list[i].clear();
        }
    };
    
};



/**
 * A class to manipulate the simgear 3d object format.
 * This class provides functionality to both read and write the binary format.
 *
 * Here is a really quick overview of the file syntax:
 *
 * - scenery-file: magic, nobjects, object+
 *
 * - magic: "TG" + version
 *
 * - object: obj_typecode, nproperties, nelements, property+, element+
 *
 * - element: nbytes, BYTE+
 *
 * - property: prop_typecode, nbytes, BYTE+
 *
 * - obj_typecode: bounding sphere | vertices | normals | texcoords |
 *                 points | triangles | fans | strips 
 *
 * - prop_typecode: material_name | ???
 *
 * - nelements: USHORT (Gives us 65536 which ought to be enough, right?)
 *
 * - nproperties: USHORT
 *
 * - *_typecode: CHAR
 *
 * - nbytes: INTEGER (If we used short here that would mean 65536 bytes = 16384
 *                    floats = 5461 vertices which is not enough for future
 *	              growth)
 *
 * - vertex: FLOAT, FLOAT, FLOAT
*/
class SGBinObject {
private:
    unsigned short version;

    SGVec3d gbs_center;
    float gbs_radius;

    std::vector<SGVec3d> wgs84_nodes;   // vertex list
    std::vector<SGVec4f> colors;        // color list
    std::vector<SGVec3f> normals;       // normal list
    std::vector<SGVec2f> texcoords;     // texture coordinate list
    std::vector<float>   va_flt;        // vertex attribute list (floats)
    std::vector<int>     va_int;        // vertex attribute list (ints) 
    
    group_list pts_v;               	// points vertex index
    group_list pts_n;               	// points normal index
    group_list pts_c;               	// points color index
    group_tci_list pts_tcs;             // points texture coordinates ( up to 4 sets )
    group_vai_list pts_vas;             // points vertex attributes ( up to 8 sets )
    string_list pt_materials;           // points materials

    group_list tris_v;              	// triangles vertex index
    group_list tris_n;              	// triangles normal index
    group_list tris_c;              	// triangles color index
    group_tci_list tris_tcs;            // triangles texture coordinates ( up to 4 sets )
    group_vai_list tris_vas;            // triangles vertex attributes ( up to 8 sets )
    string_list tri_materials;          // triangles materials

    group_list strips_v;            	// tristrips vertex index
    group_list strips_n;            	// tristrips normal index
    group_list strips_c;            	// tristrips color index
    group_tci_list strips_tcs;          // tristrips texture coordinates ( up to 4 sets )
    group_vai_list strips_vas;          // tristrips vertex attributes ( up to 8 sets )
    string_list strip_materials;        // tristrips materials

    group_list fans_v;              	// fans vertex index
    group_list fans_n;              	// fans normal index
    group_list fans_c;              	// fans color index
    group_tci_list fans_tcs;            // fanss texture coordinates ( up to 4 sets )
    group_vai_list fans_vas;            // fans vertex attributes ( up to 8 sets )
    string_list fan_materials;	        // fans materials

    void read_properties(gzFile fp, int nproperties);
    
    void read_object( gzFile fp,
                             int obj_type,
                             int nproperties,
                             int nelements,
                             group_list& vertices, 
                             group_list& normals,
                             group_list& colors,
                             group_tci_list& texCoords,
                             group_vai_list& vertexAttribs,
                             string_list& materials);
                             
    void write_header(gzFile fp, int type, int nProps, int nElements);
    void write_objects(gzFile fp, 
                       int type, 
                       const group_list& verts,
                       const group_list& normals, 
                       const group_list& colors, 
                       const group_tci_list& texCoords, 
                       const group_vai_list& vertexAttribs,
                       const string_list& materials);
        
    unsigned int count_objects(const string_list& materials);
    
public:    
    inline unsigned short get_version() const { return version; }

    inline const SGVec3d& get_gbs_center() const { return gbs_center; }
    inline void set_gbs_center( const SGVec3d& p ) { gbs_center = p; }

    inline float get_gbs_radius() const { return gbs_radius; }
    inline void set_gbs_radius( float r ) { gbs_radius = r; }

    inline const std::vector<SGVec3d>& get_wgs84_nodes() const { return wgs84_nodes; }
    inline void set_wgs84_nodes( const std::vector<SGVec3d>& n ) { wgs84_nodes = n; }

    inline const std::vector<SGVec4f>& get_colors() const { return colors; }
    inline void set_colors( const std::vector<SGVec4f>& c ) { colors = c; }
    
    inline const std::vector<SGVec3f>& get_normals() const { return normals; }
    inline void set_normals( const std::vector<SGVec3f>& n ) { normals = n; }
    
    inline const std::vector<SGVec2f>& get_texcoords() const { return texcoords; }
    inline void set_texcoords( const std::vector<SGVec2f>& t ) { texcoords = t; }
    
    // Points API
    bool add_point( const SGBinObjectPoint& pt );
    inline const group_list& get_pts_v() const { return pts_v; }
    inline const group_list& get_pts_n() const { return pts_n; }    
    inline const group_tci_list& get_pts_tcs() const { return pts_tcs; }
    inline const group_vai_list& get_pts_vas() const { return pts_vas; }
    inline const string_list& get_pt_materials() const { return pt_materials; }

    // Triangles API
    bool add_triangle( const SGBinObjectTriangle& tri );
    inline const group_list& get_tris_v() const { return tris_v; }
    inline const group_list& get_tris_n() const { return tris_n; }
    inline const group_list& get_tris_c() const { return tris_c; }
    inline const group_tci_list& get_tris_tcs() const { return tris_tcs; }
    inline const group_vai_list& get_tris_vas() const { return tris_vas; }
    inline const string_list& get_tri_materials() const { return tri_materials; }
    
    // Strips API (deprecated - read only)
    inline const group_list& get_strips_v() const { return strips_v; }
    inline const group_list& get_strips_n() const { return strips_n; }
    inline const group_list& get_strips_c() const { return strips_c; }
    inline const group_tci_list& get_strips_tcs() const { return strips_tcs; }
    inline const group_vai_list& get_strips_vas() const { return strips_vas; }
    inline const string_list& get_strip_materials() const { return strip_materials; }

    // Fans API (deprecated - read only )
    inline const group_list& get_fans_v() const { return fans_v; }
    inline const group_list& get_fans_n() const { return fans_n; }
    inline const group_list& get_fans_c() const { return fans_c; }
    inline const group_tci_list& get_fans_tcs() const { return fans_tcs; }
    inline const group_vai_list& get_fans_vas() const { return fans_vas; }
    inline const string_list& get_fan_materials() const { return fan_materials; }

    /**
     * Read a binary file object and populate the provided structures.
     * @param file input file name
     * @return result of read
     */
    bool read_bin( const std::string& file );

    /** 
     * Write out the structures to a binary file.  We assume that the
     * groups come to us sorted by material property.  If not, things
     * don't break, but the result won't be as optimal.
     * @param base name of output path
     * @param name name of output file
     * @param b bucket for object location
     * @return result of write
     */
    bool write_bin( const std::string& base, const std::string& name, const SGBucket& b );


    bool write_bin_file(const SGPath& file);

    /**
     * Write out the structures to an ASCII file.  We assume that the
     * groups come to us sorted by material property.  If not, things
     * don't break, but the result won't be as optimal.
     * @param base name of output path
     * @param name name of output file
     * @param b bucket for object location
     * @return result of write
     */
    bool write_ascii( const std::string& base, const std::string& name,
		      const SGBucket& b );
};

#endif // _SG_BINOBJ_HXX