42 template <
int WDim,
typename TPntIterator,
typename TData>
53 if (pnt_beg == pnt_end)
54 UG_THROW (
"IDWInterpolation: Cannot interpolate using 0 data points!");
58 for (
t_pnt_iter pnt = pnt_beg; pnt != pnt_end; ++pnt)
61 if ((dist =
VecDistance (pos, pnt->pos)) < small_dist)
66 dist = pow (dist, order);
79 template <
int WDim,
typename TPntIterator,
typename TData>
94 (res, pos, pnt_beg, pnt_end, order, small_dist);
98 if (pnt_beg == pnt_end)
99 UG_THROW (
"IDWInterpolation: Cannot interpolate using 0 data points!");
103 bool no_data_in_ball =
true;
104 for (
t_pnt_iter pnt = pnt_beg; pnt != pnt_end; ++pnt)
107 if ((dist =
VecDistance (pos, pnt->pos)) < small_dist)
112 if (dist > R)
continue;
113 no_data_in_ball =
false;
114 dist = pow (dist, order);
121 UG_THROW (
"IDWInterpolation: No interpolation points in the ball with R = " << R
122 <<
" and center at" << pos <<
".");
130 template <
int WDim,
typename TData>
133 std::string input_line;
134 std::istringstream line_stream;
138 line_stream.exceptions (std::istream::failbit | std::istream::badbit);
140 while (!
input.eof ())
143 UG_THROW (
"IDWUserData: Could not load the interpolation points from the file!");
144 std::getline (
input, input_line);
145 if (input_line.length () == 0)
149 line_stream.str (input_line);
151 line_stream >> value;
153 catch (std::istream::failure& e)
155 UG_THROW (
"IDWUserData: Failed to parse line '" << input_line <<
"' in the input file.");
158 this->
append (pos, value);
165 template <
int WDim,
typename TData>
168 std::ifstream
input (file_name, std::ifstream::in);
170 UG_THROW (
"IDWUserData: Cannot open data file '" << file_name <<
"' for input!");
171 this->load_data_from (
input);
static void compute(data_type &res, const MathVector< dim > &pos, t_pnt_iter pnt_beg, t_pnt_iter pnt_end, number order, number small_dist=1e-7)
computes the interpolation basing on all the interpolation points
Definition: invdist_user_data_impl.h:44
TPntIterator t_pnt_iter
type of the interpolation point iterator
Definition: invdist_user_data.h:102
TData data_type
type of the data to extrapolate
Definition: invdist_user_data.h:105
void load_data_from(std::istream &in)
loads data from a given stream (and appends the loaded points to the current list)
Definition: invdist_user_data_impl.h:131
TData data_type
type of the data to extrapolate
Definition: invdist_user_data.h:155
function table append(t1, t2)
#define UG_THROW(msg)
Definition: error.h:57
double number
Definition: types.h:124
vector_t::value_type VecDistance(const vector_t &v1, const vector_t &v2)
returns the distance of two vector_ts.
Definition: math_vector_functions_common_impl.hpp:375
std::istream & read_plain_txt(std::istream &inStream, ug::MathVector< 1 > &v)
plain text input of MathVectors: read space-separated coordinates
Definition: math_vector.cpp:95