This file is indexed.

/usr/include/mia-2.2/mia/core/boundary_conditions.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
/* -*- 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_core_boundary_conditions_hh
#define mia_core_boundary_conditions_hh

#include <mia/core/msgstream.hh>
#include <mia/core/type_traits.hh>
#include <mia/core/factory.hh>
#include <mia/core/product_base.hh>
#include <mia/core/splinekernel.hh>

#include <vector>
#include <memory>

NS_MIA_BEGIN

enum EBoundaryConditions  {
	bc_mirror_on_bounds, 
	bc_repeat, 
	bc_zero, 
	bc_unknown
}; 

/**
   \ingroup interpol 

   \brief Abstract base class for B-spline interpolation boundary conditions 
   
   This class is the abstract base class for B-spline interpolation boundary conditions. 

   The actual boundary conditions are implemented as plug-ins and instances are 
   created by calling produce_spline_boundary_condition. 
*/
class EXPORT_CORE CSplineBoundaryCondition : public CProductBase{
public: 

	/// helper typedef for plug-in handling 
	typedef CSplineBoundaryCondition plugin_data; 
	
	/// helper typedef for plug-in handling 
	typedef CSplineBoundaryCondition plugin_type; 

	/// type portion of the plugin search path 
	static const char * const type_descr; 
	
	/// data portion of the plugin search path 
	static const char * const data_descr; 


	/// pointer type to this boundary condition
	typedef std::unique_ptr<CSplineBoundaryCondition> Pointer; 

	CSplineBoundaryCondition(); 


	/**
	   Default copy constructor 
	 */
	CSplineBoundaryCondition(const CSplineBoundaryCondition& /*other*/) = default; 

	/**
	   Constructor for the boundary conditions. 
	   \param width size of the coefficent domain 
	 */
	
	CSplineBoundaryCondition(int width); 

	/**
	   Apply the boundary conditions 
	   \param index - indices into the coeffisicnt domain will be changed to fit domain 
	   \param weights - according weights
	   \returns true if the index set was in the coefficient domain 
	 */
	bool apply(CSplineKernel::VIndex& index, CSplineKernel::VWeight& weights) const;
	
	/**
	   (re-)set the width of the supported index range 
	   \param width new width 
	 */

	void set_width(int width); 

	/// \returns the width of the coefficient domain 
	int get_width() const {
		return m_width; 
	}
	
	/**
	   Prefiltering function to convert a vector of input data to spline coefficients 
	   \tparam T must either be a scalar type or an array of scalar data types whose elements 
	   can be accessed by using the operator[]. This restriction is currently necessary to 
	   allow a dynamic polymorphic implementation  of the pre-filtering step needed for 
           different boundary condition models. 
	   \param[in,out] coeff vector of function values that will be converted to spline coefficients 
	   \param poles the poles of the B-spline the coefficients are created for 
	   
	 */
	template <typename T> 
	void filter_line(std::vector<T>& coeff, const std::vector<double>& poles) const;

        /**
	   Prefiltering function to convert a vector of double valued input data to spline coefficients 
	   This is the actual work routine that will be called by the other filter_line functions 
	   after type conversion and decomposition has been executed 
	   \param[in,out] coeff vector of function values that will be converted to spline coefficients 
	   \param poles the poles of the B-spline the coefficients are created for 
	*/
	void filter_line(std::vector<double>& coeff, const std::vector<double>& poles) const;

	/**
	   Prefiltering function to convert a vector of scalar valued input data to spline coefficients. 
	   \tparam T a scalar type. 
	   \param[in,out] coeff vector of function values that will be converted to spline coefficients 
	   \param poles the poles of the B-spline the coefficients are created for 
	*/
	
	template <typename T> 
	void template_filter_line(std::vector<T>& coeff, const std::vector<double>& poles) const;

	/**
	   \returns a copy of the (derived) instance of this boundary condition 
	 */
	virtual 
		CSplineBoundaryCondition *clone() const __attribute__((warn_unused_result)) = 0 ; 
private:

	virtual void do_apply(CSplineKernel::VIndex& index, CSplineKernel::VWeight& weights) const = 0;
	virtual void test_supported(int npoles) const = 0;
	
	virtual void do_set_width(int width); 

	
	virtual double initial_coeff(const std::vector<double>& coeff, double pole) const = 0;
	virtual double initial_anti_coeff(const std::vector<double>& coeff, double pole)const = 0;


	int m_width; 
}; 



/**  \ingroup interpol 
     Pointer type of the boundary conditions. 
*/
typedef CSplineBoundaryCondition::Pointer PSplineBoundaryCondition; 

extern template class EXPORT_CORE TFactory<CSplineBoundaryCondition>; 

/**  \ingroup interpol 
     \brief Base plugin for spline boundary conditions
*/
class EXPORT_CORE CSplineBoundaryConditionPlugin: public TFactory<CSplineBoundaryCondition> {
public: 
	/**
	   Constructor for the spline boundary conditions plug-ins. 
	 */

	CSplineBoundaryConditionPlugin(const char * name); 
private: 
	virtual CSplineBoundaryCondition *do_create() const;
	
	virtual CSplineBoundaryCondition *do_create(int width) const = 0; 

	int m_width; 
}; 



/**
   \ingroup interpol 
   Plugin handler for the creation of spline boundary conditions
*/
typedef THandlerSingleton<TFactoryPluginHandler<CSplineBoundaryConditionPlugin> > CSplineBoundaryConditionPluginHandler;

extern template class EXPORT_CORE THandlerSingleton<TFactoryPluginHandler<CSplineBoundaryConditionPlugin> >; 

/// make spline boundary conditions parsable by the command line 
FACTORY_TRAIT(CSplineBoundaryConditionPluginHandler); 


/**
   Create a specific instance of a spline interpolation boundary condition. 
   \param descr Description of the requested boundary conditions
   \returns the actual boundary condition 
*/
inline 
PSplineBoundaryCondition produce_spline_boundary_condition(const std::string& descr)
{
	return CSplineBoundaryConditionPluginHandler::instance().produce_unique(descr); 
}


/**
   Create a specific instance of a spline interpolation boundary condition. 
   \param descr Description of the requested boundary conditions
   \param width width of the input domain 
   \returns the actual boundary condition 
*/
EXPORT_CORE PSplineBoundaryCondition produce_spline_boundary_condition(const std::string& descr, int width)
 __attribute__((deprecated)); 


/// @cond INTERNAL 

/**
   \ingroup traits 
   \brief This trait handles dispatching the pre-filtering of coefficients
   
   This trait handles dispatching the pre-filtering of coefficients based on the number of 
   elements a coefficient holds. If the number of components is one, then the filtering can be called directly, 
   otherwise the data needs to be copied element-wiese  to and from a temporary array. 
   This is required to make the actual filtering template-free and, hence make it possible to call it as a virtual function. 

   \tparam T the data type of the coefficients, if the type holds more than one element, it must support the operator []
   for element indexing. 
   \tparam size the number of scalar elements the type holds 
   \remark performance wise it could be better to copy the data to a flat array and add a stride parametsr to the 
   filter algorithm
*/
template <typename T, int size>
struct __dispatch_filter_line {
	static void apply(const CSplineBoundaryCondition& bc, std::vector<T>& coeff, const std::vector<double>& poles); 
}; 

template <typename T, int size>
void __dispatch_filter_line<T, size>::apply(const CSplineBoundaryCondition& bc, std::vector<T>& coeff, 
					 const std::vector<double>& poles) 
{
	std::vector<double> temp(coeff.size());
	for (int i = 0; i < size; ++i) {
		std::transform(coeff.begin(), coeff.end(), temp.begin(), 
			       [i](const T& x) { return x[i]; }); 
		bc.filter_line(temp, poles); 
		for (size_t j = 0; j < coeff.size(); ++j)
			coeff[j][i] = temp[j]; 
	}
}

/**
   \ingroup traits 
   \brief This trait handles dispatching the pre-filtering of coefficients in the one-element case 

*/ 
template <typename T>
struct __dispatch_filter_line<T,1> {
	static void apply(const CSplineBoundaryCondition& bc, std::vector<T>& coeff, const std::vector<double>& poles) {
		bc.template_filter_line(coeff, poles); 
	}
}; 

/// @endcond 

template <typename T> 
void CSplineBoundaryCondition::filter_line(std::vector<T>& coeff, const std::vector<double>& poles) const
{
	typedef atomic_data<T> atom; 
	__dispatch_filter_line<T, atom::size>::apply(*this, coeff, poles); 
}


template <typename T> 
void CSplineBoundaryCondition::template_filter_line(std::vector<T>& coeff, const std::vector<double>& poles) const
{
	std::vector<double> temp(coeff.begin(), coeff.end()); 
	filter_line(temp, poles); 
	std::transform(temp.begin(), temp.end(), coeff.begin(), [](double x) {return static_cast<T>(x);});
}

NS_MIA_END
#endif