This file is indexed.

/usr/include/miaviewit-1.0/viewit/mesh.hh is in libmiaviewit-dev 1.0.4-1+b1.

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
/* -*- mia-c++ -*-
 *
 * This file is part of viewitgui - a library and program for the
 * visualization of 3D data sets. 
 *
 * Copyright (c) Leipzig, Madrid 1999-2013 Mirco Hellmann, Gert Wollny
 *
 * viewitgui 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 3 of the License, or
 * (at your option) any later version.
 *
 * viewitgui 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 viewitgui; if not, see <http://www.gnu.org/licenses/>.
 */


#ifndef d__mesh_hh
#define d__mesh_hh

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <GL/gl.h>

#include <viewit/drawable.hh>

#include <mia.hh>
using namespace mia; 

#include <memory>
#include <viewit/structures.hh>

struct base_header {
	char name_space[3];
	char type[14];
	short endian_test;
};

struct tri_mesh_header {
	base_header base; 
	size_t n_vertices; 
	size_t n_triangles; 
};	
	

#define TRIMESH_TYPENAME "TriMesh"
#define SMOOTHTRIMESH_TYPENAME "STriMesh"
#define COLORSMOOTHTRIMESH_TYPENAME "CSTriMesh"
#define TRIANGLEMESHABASE_CLASSNAME "CTriangleMeshABase"
#define TRIANGLEMESH_CLASSNAME "CTriangleMeshA"
#define SMOOTHTRIANGLEMESH_CLASSNAME "TSmoothTriangleMesh"
#define COLORSMOOTHMESH_CLASSNAME "TColorSmoothMesh"

/// the base class for all triangle meshes
class CTriangleMeshABase: public TDrawable {
protected:
	size_t n_triangles;
	
	triangle_ui_t *triangles; 
	size_t n_vertices; 
	C3DFVector *triangle_mid_points; 
	mutable C3DFVector m_center; 
	
public:
	CTriangleMeshABase(const string& name, size_t n_triangles, triangle_ui_t *t,size_t _num_vertices);
	CTriangleMeshABase(const string& name, const CTriangleMeshABase& org);
	~CTriangleMeshABase();
	
	virtual const TVertexList *get_vertex_list(int stride)const = 0; 
	
	virtual const char* get_type_name()const = 0; 
	virtual const char* get_classname()const;
	virtual void get_classname_list(list<string> *classlist)const;
	
	const C3DFVector get_center()const; 
	
	bool do_export(FILE*f)const; 
protected:
	triangle_ui_t *tri_mirror;
	
	virtual bool do_handle_key_event(int key);
	virtual void do_gl_draw(const TCamera& c) const;
private:
	class collect_t {
	public:
		int i; 
		float d; 
		bool operator < (const collect_t& o)const {
			return d < o.d; 
		}
	};
	void povray_output_description(FILE *f)const;
	virtual bool write_vertices(FILE *f)const=0; 
	
protected:			
	
	template <class Vertex> 
	bool do_write_vertices(FILE *f)const; 
	
	template <class triangle>
	void sort_triangles(const triangle *in, triangle *out, const TCamera& c)const;
	
	template <class vertex_type>
	void calc_triangle_mid_points(vertex_type *vertex);
	
	template <class vertex_type>
	void calc_center(vertex_type *vertex);
	
};

/// a triangle mesh with no normals (can not be lit)
class CTriangleMeshA: public CTriangleMeshABase {
	vertex_t *vertices;
public:
	CTriangleMeshA(const string& name, int _n_triangles, triangle_ui_t *t,
			    int _num_vertices, vertex_t *v);
	~CTriangleMeshA();
	const vertex_t *get_vertices()const {return vertices;}
	virtual TVertexList *get_vertex_list(int stride)const;

	virtual void povray_output_object(FILE *f)const;
	virtual const char* get_type_name()const;
	virtual const char* get_classname()const;
	virtual void get_classname_list(list<string> *classlist)const;

protected: 	
	virtual bool write_vertices(FILE *f)const; 
	void gl_attach();
	void do_gl_draw(const TCamera& c) const; 
};

/// a trinagle mesh with normals at the vertexes
class TSmoothTriangleMesh: public CTriangleMeshABase {
	normal_vertex_t *vertices; 
public:
	TSmoothTriangleMesh(const string& name, int _n_triangles, triangle_ui_t *t,
			    int _num_vertices, normal_vertex_t *v);
	
	TSmoothTriangleMesh(const string& name, int _n_triangles, triangle_ui_t *t,
			    int _num_vertices, vertex_t *v);
	
	TSmoothTriangleMesh(const string& name, const CTriangleMeshA& mesh);
	TSmoothTriangleMesh(const string& name, const TSmoothTriangleMesh& mesh,
			    const C3DTransformation& deform);
	TSmoothTriangleMesh(const string& name, const CTriangleMeshA& mesh,
			    const C3DTransformation& deform);
	~TSmoothTriangleMesh();
	
	void deform(const C3DTransformation& shift);
	const normal_vertex_t *get_vertices()const {return vertices;}
	virtual TVertexList *get_vertex_list(int stride)const; 

	virtual void povray_output_object(FILE *f)const;

	virtual const char* get_type_name()const;
	virtual const char* get_classname()const;
	virtual void get_classname_list(list<string> *classlist)const;
	
protected:
	virtual void do_gl_draw(const TCamera& c) const; 	
	
private: 	
	virtual bool write_vertices(FILE *f)const; 
	void create_from_vertex_array(const vertex_t *v);
	void recalc_normals();
	void gl_attach();	
};


/// a mesh with normals and colors defined per vertex
class TColorSmoothMesh: public CTriangleMeshABase {
	color_normal_vertex_t *vertices;
	float *vertex_deform_scale;
	float max_shrink; 
	float max_grow;
 	float inv_max_shrink; 
	float inv_max_grow;
	float inv_max_shrink_log; 
	float inv_max_grow_log;	
	float max_grow_log;
	float max_shrink_log;
	
	float ms,ims; 
	int scale_type; 
	bool do_draw_decoration;
public:	
	enum EScaleType  {
		st_standart,
		st_divide, 
		st_log,
		st_scale_2mm,
		st_scale_4mm,
		st_scale_8mm,
		st_scale_16mm,
		st_scale_32mm,
		st_last
	};

	TColorSmoothMesh(const string& name, int _n_triangles, triangle_ui_t *t,
			 int _n_vertices, color_normal_vertex_t *v);

	TColorSmoothMesh(const string& name, int _n_triangles, triangle_ui_t *t,
			 int _n_vertices, color_normal_vertex_t *v, float *scale);

	template <class Deformation>
	TColorSmoothMesh(const string& name, const TSmoothTriangleMesh& mesh, 
			 const Deformation& deform,bool bdeform); 
	
	~TColorSmoothMesh();
	
	virtual TVertexList *get_vertex_list(int stride)const; 
	unique_ptr<TNormalVertexList> get_vertex_normal_list(int stride)const;

	virtual const char* get_type_name()const;
	virtual const char* get_classname()const;
	virtual void get_classname_list(list<string> *classlist)const;
	
	void apply_color_change();
	float get_max_shrink()const; 
	float get_max_grow()const;
	void show_decoration(bool value); 
	virtual void set_transparency(float alpha);
	void set_scale_type(EScaleType t) {
		scale_type = t;
	}
	void toggle_scale_type();
	

	virtual void draw_decoration(const C2DBounds& viewport,const TGLText& writer);
	virtual void povray_output_object(FILE *f)const;
	virtual void povray_output_description(FILE *f)const;

protected: 	
	virtual bool do_handle_key_event(int key);
	virtual void do_gl_draw(const TCamera& c) const;
private:
	virtual bool write_vertices(FILE *f)const; 
	void povray_write_color(FILE *f,float scale)const;
	void gl_attach();
};

inline void TColorSmoothMesh::show_decoration(bool value) 
{
	do_draw_decoration = value; 
}

inline float TColorSmoothMesh::get_max_shrink()const
{
	return max_shrink; 
}

inline float TColorSmoothMesh::get_max_grow()const
{
	return max_grow;
}

template <class Deformation>
TColorSmoothMesh::TColorSmoothMesh(const string& name, const TSmoothTriangleMesh& mesh, 
				   const Deformation& deform, bool bdeform):
	CTriangleMeshABase(name,mesh),
	max_shrink(0.0f),
	max_grow(0.0f),
	max_grow_log(0.0f),
	max_shrink_log(0.0f),
	scale_type(st_standart),
	do_draw_decoration(true)
{
	vertices = new color_normal_vertex_t[n_vertices];
	vertex_deform_scale = new float[n_vertices];
	color_normal_vertex_t *cnv = vertices; 
	const normal_vertex_t *nv = mesh.get_vertices();
	
	for (size_t i = 0; i < n_vertices; i++,++cnv,++nv) {
		cnv->normal = nv->normal;
		cnv->vertex = nv->vertex; 
		C3DFVector defo = deform(cnv->vertex  - (0.5f * cnv->normal)); 
		if (bdeform) 
			cnv->vertex += defo; 
		float shift =  dot(defo, cnv->normal);
		if (shift  > 0) {
			vertex_deform_scale[i] = -shift; 
			if (shift > max_shrink) max_shrink = shift; 
			shift = log(shift + 1.0);
			if (shift > max_shrink_log) max_shrink_log = shift; 
		}else{
			shift = -shift;
			vertex_deform_scale[i] = shift; 
			if (shift > max_grow) max_grow = shift; 
			shift = log(shift + 1.0);
			if (shift > max_grow_log) max_grow_log = shift; 
		}
	}
	
	if (max_shrink != 0 ) {
		inv_max_shrink = 1.0f / max_shrink;
		inv_max_shrink_log = 1.0f / max_shrink_log;		
		cerr << "max_shrink : " << max_shrink << endl; 
	}
	
	if (max_grow != 0 ) {
		inv_max_grow_log = 1.0f / max_grow_log;
		inv_max_grow = 1.0f / max_grow;
		cerr << "max_grow : " << max_grow << endl; 
	}
	
}

#endif