This file is indexed.

/usr/include/mia-2.2/mia/3d/iterator.hh is in libmia-2.2-dev 2.2.2-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
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
/* -*- mia-c++  -*-
 *
 * This file is part of MIA - a toolbox for medical image analysis 
 * Copyright (c) Leipzig, Madrid 1999-2014 Gert Wollny
 *
 * MIA 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.
 *
 * 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 MIA; if not, see <http://www.gnu.org/licenses/>.
 *
 */

#ifndef mia_3d_iterator_hh
#define mia_3d_iterator_hh

#include <mia/3d/vector.hh>

NS_MIA_BEGIN



/**
   @ingroup basic 
   \brief a 3D iterator that knows its position in the 3D grid, has a flag indicating 
     whether it is on a boundary, and supports iterating over  sub-ranges 
   
   Iterator to iterate over a sub-range of 3D data that is given on a grid. 
   Two iterators are considered to be equal, if their positions are equal.  
   \tparam the internal iterator that is used to iterate of the original 
   grid without skipping. 
   
 */

template <typename I> 
class range3d_iterator_with_boundary_flag: public std::forward_iterator_tag {
public: 
	/// data type reference 
	typedef typename I::reference reference; 

	/// data type pointer  
	typedef typename I::pointer pointer; 

	/// data value type 
	typedef typename I::value_type value_type; 

	/// data type for the real iterator in the background 
	typedef I internal_iterator; 
	
	/**
	   Enumerate to describe the various positions on the domain boundarys. 
	   These boundaries correspond to the full domain of the data, not to 
           the sub-range this iteratior works on. 
	   I.e. if the sub-range is a subset of the \a open domain (i.e. without its boundary) 
	   then the iterator will never touch the domain boundary. 
	 */
	enum EBoundary {
		eb_none  = 0, /**< no boundary */
		eb_xlow  = 1, /**< at low x-boundary */ 
		eb_xhigh = 2, /**< at high x-boundary */  
		eb_x     = 3, /**< at one of the x-boundaries */  
		eb_ylow = 4,  /**< at low y-boundary */ 
		eb_yhigh = 8, /**< at high y-boundary */
		eb_y     = 0xC, /**< at one of the y-boundaries */  
		eb_zlow = 0x10, /**< at low x-boundary */ 
		eb_zhigh = 0x20,/**< at high z-boundary */
		eb_z     = 0x30 /**< at one of the z-boundaries */  
	}; 
	

	
	/** standard constructor */
	range3d_iterator_with_boundary_flag(); 

	/**
	   Full constructor of the range iterator 
	   @param pos iterator position to initialize the iterator with 
	   @param size size of the original data field 
	   @param start start of the iterator range 
	   @param end end of the iterator range 
	   @param iterator the iterator of the underlying 3D data structure 
	*/
	range3d_iterator_with_boundary_flag(const C3DBounds& pos, const C3DBounds& size, 
			 const C3DBounds& start, const C3DBounds& end, I iterator);
	
	/**
	   End iterator, can't be dereferenced  
	   This iterator is only there to define the end position of the range_iterator. 
	   \param pos end position to set this iterator to. 
	 */
	range3d_iterator_with_boundary_flag(const C3DBounds& pos);

	/// assignment operator 
	range3d_iterator_with_boundary_flag<I>& operator = (const range3d_iterator_with_boundary_flag<I>& other); 
	
	/// copy constructore 
	range3d_iterator_with_boundary_flag(const range3d_iterator_with_boundary_flag<I>& other); 

	/// friend iterator type because we may want to copy a iterator to a const_iterator. 
	template <typename AI> 
	friend class range3d_iterator_with_boundary_flag; 


	/**
	   Constructor to construct the iterator  from one that is based on another 
	   iterator type. The usual idea is that a iterator may be converted  into it's const variant. 
	   \tparam AI the other iterator type. Iterator type I must be copy-constructable from 
	   type AI 
	   \param other 
	 */
	template <typename AI>
	range3d_iterator_with_boundary_flag(const range3d_iterator_with_boundary_flag<AI>& other); 

	/**
	   Assignment operator from another type of iterator 
	   \tparam AI other iterator type. The assignment I b = a; with a of type AI must be defined.
	   \param other 
	 */
	template <typename AI>
	range3d_iterator_with_boundary_flag<I>& operator = (const range3d_iterator_with_boundary_flag<AI>& other); 

	
	/// prefix increment 
	range3d_iterator_with_boundary_flag<I>& operator ++(); 
	/// postfix increment 
	range3d_iterator_with_boundary_flag<I> operator ++(int); 
	
	/// @returns current value the iterator points to 
	reference  operator *() const;
	
	/// @returns pointer to the current value the iterator points to 
	pointer    operator ->() const;

	/** \returns the current position within the 3D grid with respect to the 
	    full size of the grid. 
	 */
	const C3DBounds& pos() const; 

	/// @cond NOFRIENDDOC
	template <typename T> friend
	bool operator == (const range3d_iterator_with_boundary_flag<T>& left, const range3d_iterator_with_boundary_flag<T>& right); 
	/// @endcond 

	/**
	   Return the internal iterator
	 */
	internal_iterator get_point(); 

	/// \returns the flags describing whether the iterator is on a domain boundary. 
	int get_boundary_flags() const; 

private: 

	void increment_y(); 
	void increment_z(); 

	C3DBounds m_pos; 
	C3DBounds m_size; 
	C3DBounds m_begin; 
	C3DBounds m_end; 
	int m_xstride; 
	int m_ystride; 
	I m_iterator; 
	int m_boundary; 
}; 



/**
   @ingroup basic 
   \brief a 3D iterator that knows its position in the 3D grid ans supports iterating over 
   sub-ranges 
   
   Iterator to iterate over a sub-range of 3D data that is given on a grid. 
   Two iterators are considered to be equal, if their positions are equal.  
   \tparam the internal iterator that is used to iterate of the original 
   grid without skipping. 
   
 */

template <typename I> 
class range3d_iterator: public std::forward_iterator_tag {
public: 
	/// data type reference 
	typedef typename I::reference reference; 
	/// data type pointer  
	typedef typename I::pointer pointer; 

	/// data value type 
	typedef typename I::value_type value_type; 

	/// data type for the real iterator in the background 
	typedef I internal_iterator; 
	
	
	/** standard constructor */
	range3d_iterator(); 

	/**
	   Full constructor of the range iterator 
	   @param pos iterator position to initialize the iterator with 
	   @param size size of the original data field 
	   @param start start of the iterator range 
	   @param end end of the iterator range 
	   @param iterator the iterator of the underlying 3D data structure 
	*/
	range3d_iterator(const C3DBounds& pos, const C3DBounds& size, 
			 const C3DBounds& start, const C3DBounds& end, I iterator);
	
	/**
	   End iterator, can't be dereferenced  
	   This iterator is only there to define the end position of the range_iterator. 
	   \param pos end position to set this iterator to. 
	 */
	range3d_iterator(const C3DBounds& pos);

	/// assignment operator 
	range3d_iterator<I>& operator = (const range3d_iterator<I>& other); 
	
	/// copy constructore 
	range3d_iterator(const range3d_iterator<I>& other); 

	/// friend iterator type because we may want to copy a iterator to a const_iterator. 
	template <typename AI> 
	friend class range3d_iterator; 

	/// friend iterator type because we may want to copy a iterator to a const_iterator. 
	template <typename AI> 
	friend class range3d_iterator_with_boundary_flag; 

	
	/**
	   Constructor to construct the iterator  from one that is based on another 
	   iterator type. The usual idea is that a iterator may be converted  into it's const variant. 
	   \tparam AI the other iterator type. Iterator type I must be copy-constructable from 
	   type AI 
	   \param other 
	 */
	template <typename AI>
	range3d_iterator(const range3d_iterator<AI>& other); 


	/**
	   Assignment operator from another type of iterator 
	   \tparam AI other iterator type. The assignment I b = a; with a of type AI must be defined.
	   \param other 
	 */
	template <typename AI>
	range3d_iterator<I>& operator = (const range3d_iterator<AI>& other); 

	
	/// prefix increment 
	range3d_iterator<I>& operator ++(); 
	/// postfix increment 
	range3d_iterator<I> operator ++(int); 
	
	/// @returns current value the iterator points to 
	reference  operator *() const;
	
	/// @returns pointer to the current value the iterator points to 
	pointer    operator ->() const;

	/** \returns the current position within the 3D grid with respect to the 
	    full size of the grid. 
	 */
	const C3DBounds& pos() const; 

	/// @cond NOFRIENDDOC
	template <typename T> friend
	bool operator == (const range3d_iterator<T>& left, const range3d_iterator<T>& right); 
	/// @endcond 

	/**
	   \return the internal iterator
	 */
	internal_iterator get_point(); 

	/**
	   \returns the same iterator but with boundary checks and flags. 
	*/
	range3d_iterator_with_boundary_flag<I> with_boundary_flag() const;


private: 

	void increment_y(); 
	void increment_z(); 

	C3DBounds m_pos; 
	C3DBounds m_size; 
	C3DBounds m_begin; 
	C3DBounds m_end; 
	int m_xstride; 
	int m_ystride; 
	I m_iterator; 
}; 



template <typename I> 
template <typename AI>
range3d_iterator<I>& range3d_iterator<I>::operator = (const range3d_iterator<AI>& other)
{
	m_pos = other.m_pos; 
	m_size = other.m_size;  
	m_begin = other.m_begin; 
	m_end = other.m_end; 
	m_iterator = other.m_iterator; 
	m_xstride = other.m_xstride; 
	m_ystride = other.m_ystride; 
	return *this; 
}

template <typename I> 
template <typename AI>
range3d_iterator<I>::range3d_iterator(const range3d_iterator<AI>& other):
	m_pos(other.m_pos), 
	m_size(other.m_size), 
	m_begin(other.m_begin), 
	m_end(other.m_end), 
	m_xstride(other.m_xstride),
	m_ystride(other.m_ystride),
	m_iterator(other.m_iterator)
{
}	


/**
   Compare two range iterators. There equivalence is only decided based on the grid position. 
 */

template <typename I> 
bool operator == (const range3d_iterator<I>& left, const range3d_iterator<I>& right)
{
	// we really want these two to the same range 
//	assert(left.m_size == right.m_size);
//	assert(left.m_begin == right.m_begin);
//	assert(left.m_end == right.m_end);

	return left.m_pos == right.m_pos; 

}

/**
   Compare two range iterators. There equivalence is only decided based on the grid position. 
 */
template <typename I> 
bool operator != (const range3d_iterator<I>& a, const range3d_iterator<I>& b)
{
	return !(a == b); 
}





template <typename I> 
template <typename AI>
range3d_iterator_with_boundary_flag<I>& range3d_iterator_with_boundary_flag<I>::operator = (const range3d_iterator_with_boundary_flag<AI>& other)
{
	m_pos = other.m_pos; 
	m_size = other.m_size;  
	m_begin = other.m_begin; 
	m_end = other.m_end; 
	m_iterator = other.m_iterator; 
	m_xstride = other.m_xstride; 
	m_ystride = other.m_ystride; 
	m_boundary = other.m_boundary; 
	return *this; 
}

template <typename I> 
template <typename AI>
range3d_iterator_with_boundary_flag<I>::range3d_iterator_with_boundary_flag(const range3d_iterator_with_boundary_flag<AI>& other):
	m_pos(other.m_pos), 
	m_size(other.m_size), 
	m_begin(other.m_begin), 
	m_end(other.m_end), 
	m_xstride(other.m_xstride),
	m_ystride(other.m_ystride),
	m_iterator(other.m_iterator), 
	m_boundary(other.m_boundary)
{
}	

/**
   Compare two range iterators. There equivalence is only decided based on the grid position. 
 */

template <typename I> 
bool operator == (const range3d_iterator_with_boundary_flag<I>& left, const range3d_iterator_with_boundary_flag<I>& right)
{
	// we really want these two to the same range 
//	assert(left.m_size == right.m_size);
//	assert(left.m_begin == right.m_begin);
//	assert(left.m_end == right.m_end);

	return left.m_pos == right.m_pos; 

}

/**
   Compare two range iterators. There equivalence is only decided based on the grid position. 
 */
template <typename I> 
bool operator != (const range3d_iterator_with_boundary_flag<I>& a, const range3d_iterator_with_boundary_flag<I>& b)
{
	return !(a == b); 
}

NS_MIA_END

namespace std {

template <typename I>
class iterator_traits< mia::range3d_iterator<I> > {
public: 
	typedef typename I::difference_type  difference_type; 
	typedef typename I::value_type	value_type; 
	typedef typename I::pointer	pointer; 
	typedef typename I::reference	reference; 
	typedef forward_iterator_tag	iterator_category; 
}; 

template <typename I>
class iterator_traits< mia::range3d_iterator_with_boundary_flag<I> > {
public: 
	typedef typename I::difference_type  difference_type; 
	typedef typename I::value_type	value_type; 
	typedef typename I::pointer	pointer; 
	typedef typename I::reference	reference; 
	typedef forward_iterator_tag	iterator_category; 
}; 

}

#endif