This file is indexed.

/usr/include/rheolef/basic_point.h is in librheolef-dev 5.93-2.

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
# ifndef _RHEO_BASIC_POINT_H
# define _RHEO_BASIC_POINT_H
///
/// This file is part of Rheolef.
///
/// Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
///
/// Rheolef 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.
///
/// Rheolef 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 Rheolef; if not, write to the Free Software
/// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
/// 
/// =========================================================================
//
//    basic_point<T> : set of coordinates of type T
//
//    author: Pierre.Saramito@imag.fr
//

/*Class:point
NAME:  @code{point} - vertex of a mesh
@clindex point
@clindex geo
DESCRIPTION:
  Defines geometrical vertex as an array of coordinates.
  This array is also used as a vector of the three dimensional
  physical space.
End:
*/

#include "rheolef/compiler.h"

namespace rheolef { 
//<point:
template <class T>
class basic_point {
    public:

// typedefs:

	typedef size_t size_type;
	typedef T      float_type;

// allocators:

	explicit basic_point () { _x[0] = T();  _x[1] = T();  _x[2] = T(); } 
	
	explicit basic_point (
		const T& x0, 
		const T& x1 = 0, 
		const T& x2 = 0)
			{ _x[0] = x0; _x[1] = x1; _x[2] = x2; }
	
	template <class T1>
	basic_point<T>(const basic_point<T1>& p)
		{ _x[0] = p._x[0]; _x[1] = p._x[1]; _x[2] = p._x[2]; }

	template <class T1>
	basic_point<T>& operator = (const basic_point<T1>& p)
		{ _x[0] = p._x[0]; _x[1] = p._x[1]; _x[2] = p._x[2]; return *this; }

// accessors:

	T& operator[](int i_coord)	        { return _x[i_coord%3]; }
	const T&  operator[](int i_coord) const { return _x[i_coord%3]; }
	T& operator()(int i_coord)	        { return _x[i_coord%3]; }
	const T&  operator()(int i_coord) const { return _x[i_coord%3]; }


// inputs/outputs:

	std::istream& get (std::istream& s, int d = 3)
	{
	    switch (d) {
	    case 1 : _x[1] = _x[2] = 0; return s >> _x[0];
	    case 2 : _x[2] = 0; return s >> _x[0] >> _x[1];
	    default: return s >> _x[0] >> _x[1] >> _x[2];
	    }
	}
	// output
	std::ostream& put (std::ostream& s, int d = 3) const;

// ccomparators: lexicographic order

	template<int d>
	friend bool lexicographically_less (
		const basic_point<T>& a, const basic_point<T>& b) {  
	    for (size_type i = 0; i < d; i++) {
	      if (a[i] < b[i]) return true;
	      if (a[i] > b[i]) return false;
	    }
	    return false; // equality
	}
// algebra:

	friend bool operator == (const basic_point<T>& u, const basic_point<T>& v)
		{ return u[0] == v[0] && u[1] == v[1] && u[2] == v[2]; }

	basic_point<T>& operator+= (const basic_point<T>& v)
		{ _x[0] += v[0]; _x[1] += v[1]; _x[2] += v[2]; return *this; }

	basic_point<T>& operator-= (const basic_point<T>& v)
		{ _x[0] -= v[0]; _x[1] -= v[1]; _x[2] -= v[2]; return *this; }

	basic_point<T>& operator*= (const T& a)
		{ _x[0] *= a; _x[1] *= a; _x[2] *= a; return *this; }

	basic_point<T>& operator/= (const T& a)
		{ _x[0] /= a; _x[1] /= a; _x[2] /= a; return *this; }

	friend basic_point<T> operator+ (const basic_point<T>& u, const basic_point<T>& v)
		{ return basic_point<T> (u[0]+v[0], u[1]+v[1], u[2]+v[2]); }

	friend basic_point<T> operator- (const basic_point<T>& u)
		{ return basic_point<T> (-u[0], -u[1], -u[2]); }

	friend basic_point<T> operator- (const basic_point<T>& u, const basic_point<T>& v)
		{ return basic_point<T> (u[0]-v[0], u[1]-v[1], u[2]-v[2]); }

	template <class T1>
	friend basic_point<T> operator* (const T1& a, const basic_point<T>& u)
		{ return basic_point<T> (a*u[0], a*u[1], a*u[2]); }

	friend basic_point<T> operator* (const basic_point<T>& u, T a)
		{ return basic_point<T> (a*u[0], a*u[1], a*u[2]); }

	friend basic_point<T> operator/ (const basic_point<T>& u, const T& a)
		{ return basic_point<T> (u[0]/a, u[1]/a, u[2]/a); }

	friend basic_point<T> operator/ (const basic_point<T>& u, basic_point<T> v)
		{ return basic_point<T> (u[0]/v[0], u[1]/v[1], u[2]/v[2]); }

	friend basic_point<T> vect (const basic_point<T>& v, const basic_point<T>& w)
		{ return basic_point<T> (
			v[1]*w[2]-v[2]*w[1],
			v[2]*w[0]-v[0]*w[2],
			v[0]*w[1]-v[1]*w[0]); }
// metric:

	// TODO: non-constant metric
	friend T dot (const basic_point<T>& u, const basic_point<T>& v)
		{ return u[0]*v[0]+u[1]*v[1]+u[2]*v[2]; }
	
	friend T norm2 (const basic_point<T>& u)
		{ return dot(u,u); }

	friend T norm (const basic_point<T>& u)
		{ return ::sqrt(norm2(u)); }

	friend T dist2 (const basic_point<T>& x,  const basic_point<T>& y)
		{ return norm2(x-y); }
	
	friend T dist (const basic_point<T>& x,  const basic_point<T>& y)
		{ return norm(x-y); }

	friend T dist_infty (const basic_point<T>& x,  const basic_point<T>& y)
		{ return max(_my_abs(x[0]-y[0]), 
			     max(_my_abs(x[1]-y[1]), _my_abs(x[2]-y[2]))); }

// data:
	T _x[3];
// internal:
protected:
  	static T _my_abs(const T& x) { return (x > T(0)) ? x : -x; }
};
template <class T>
T vect2d (const basic_point<T>& v, const basic_point<T>& w);

template <class T>
T mixt (const basic_point<T>& u, const basic_point<T>& v, const basic_point<T>& w);

// robust(exact) floating point predicates: return value as (0, > 0, < 0)
// formally: orient2d(a,b,x) = vect2d(a-x,b-x)
template <class T>
T orient2d(const basic_point<T>& a, const basic_point<T>& b,
   	const basic_point<T>& x = basic_point<T>());

// formally: orient3d(a,b,c,x) = mixt3d(a-x,b-x,c-x)
template <class T>
T orient3d(const basic_point<T>& a, const basic_point<T>& b,
   	const basic_point<T>& c, const basic_point<T>& x = basic_point<T>());
//>point:

// -------------------------------------------------------------------------------------
// inline'd
// -------------------------------------------------------------------------------------
// input/output
template<class T>
inline
std::ostream&
basic_point<T>::put (std::ostream& s, int d) const
{
    switch (d) {
    case 1 : return s << _x[0];
    case 2 : return s << _x[0] << " " << _x[1];
    default: return s << _x[0] << " " << _x[1] << " " << _x[2];
    }
}
template<class T>
inline
std::istream& 
operator >> (std::istream& s, basic_point<T>& p)
{
    return s >> p[0] >> p[1] >> p[2];
}
template<class T>
inline
std::ostream& 
operator << (std::ostream& s, const basic_point<T>& p)
{
    return s << p[0] << " " << p[1] << " " << p[2];
}


#ifdef _RHEOLEF_HAVE_DOUBLEDOUBLE
template<>
inline
std::ostream& 
basic_point<doubledouble>::put (std::ostream& s, int d) const
{
    switch (d) {
    case 1 : return s << double(_x[0]);
    case 2 : return s << double(_x[0]) << " " << double(_x[1]);
    default: return s << double(_x[0]) << " " << double(_x[1]) << " " << double(_x[2]);
    }
}
#endif // _RHEOLEF_HAVE_DOUBLEDOUBLE
// ----------------------------------------------------------
// point extra: inlined
// ----------------------------------------------------------
#define def_point_function2(f,F)	\
template<class T>			\
inline					\
basic_point<T>				\
f (const basic_point<T>& x)		\
{					\
  basic_point<T> y;			\
  for (size_t i = 0; i < 3; i++)	\
    y[i] = F(x[i]);			\
  return y;				\
}

#define def_point_function(f)	def_point_function2(f,f)

def_point_function(sqr)
def_point_function2(sqrt,::sqrt)
def_point_function(log)
def_point_function(log10)
def_point_function(exp)
#undef def_point_function2
#undef def_point_function

template<class T1, class T2>
inline
basic_point<T1>
operator/ (const T2& a, const basic_point<T1>& x)
{
  basic_point<T1> y;
  for (size_t i = 0; i < 3; i++)
    if (x[i] != 0) y[i] = a/x[i];
  return y;
}
// ===============================
// non-robust predicates
// ===============================
template<class T>
T
orient2d (const basic_point<T>& a, const basic_point<T>& b,
	  const basic_point<T>& x)
{
  error_macro ("robust predicate orient2d: not yet implemented");
  T ax0 = a[0] - x[0];
  T bx0 = b[0] - x[0];
  T ax1 = a[1] - x[1];
  T bx1 = b[1] - x[1];
  return ax0*bx1 - ax1*bx0;
}
template <class T>
T
orient3d (const basic_point<T>& a, const basic_point<T>& b,
	  const basic_point<T>& c, const basic_point<T>& x)
{
  error_macro ("robust predicate orient3d: not yet implemented");
  T ax0 = a[0] - x[0];
  T bx0 = b[0] - x[0];
  T cx0 = c[0] - x[0];
  T ax1 = a[1] - x[1];
  T bx1 = b[1] - x[1];
  T cx1 = c[1] - x[1];
  T ax2 = a[2] - x[2];
  T bx2 = b[2] - x[2];
  T cx2 = c[2] - x[2];
  return ax0 * (bx1 * cx2 - bx2 * cx1)
       + bx0 * (cx1 * ax2 - cx2 * ax1)
       + cx0 * (ax1 * bx2 - ax2 * bx1);
}
// ===============================
// robust predicates : when double
// impletation in predicate.cc
// ===============================
template<>
double
orient2d (const basic_point<double>& a, const basic_point<double>& b,
	  const basic_point<double>& c);
template<>
double
orient3d (const basic_point<double>& a, const basic_point<double>& b,
	  const basic_point<double>& c, const basic_point<double>& d);

// vect2d() and mixt() are deduced from:
template <class T>
inline
T
vect2d (const basic_point<T>& v, const basic_point<T>& w)
{
  return orient2d (v, w);
}
template <class T>
inline
T
mixt (const basic_point<T>& u, const basic_point<T>& v, const basic_point<T>& w)
{
  return orient2d (u, v, w);
}
}// namespace rheolef
#endif /* _RHEO_BASIC_POINT_H */