49 std::vector<number>& val
53 UG_THROW (
"ValueById: Id < 0 not supported!");
57 m_data.clear (); m_assigned.clear ();
58 m_numCols = val.size ();
59 size_t init_size = ident + 1;
60 m_data.resize (init_size * m_numCols);
61 m_assigned.resize (init_size,
false);
65 if (val.size () != m_numCols)
66 UG_THROW (
"ValueById: Data length should be equal for all Id's!");
68 if ((
size_t) ident >= m_assigned.size ())
70 size_t new_size = ident + 1;
71 m_data.resize (new_size * m_numCols);
72 m_assigned.resize (new_size,
false);
74 else if (m_assigned[ident])
75 UG_THROW (
"ValueById: Redefining value for id " << ident);
78 for (
size_t col = 0; col < m_numCols; col++)
79 m_data[ident * m_numCols + col] = val[col];
80 m_assigned[ident] =
true;
90 size_t num_data_lines = 0;
91 std::string input_line;
92 std::vector<number> values;
98 while (! input.eof ())
104 UG_THROW (
"ValueById: Could not load the points from the file!");
105 std::getline (input, input_line);
106 if (input_line.length () == 0)
109 const char * str = input_line.c_str ();
111 while (*str && std::isspace (*str)) str++;
114 ident = std::strtol (str, &end_ptr, 10);
116 UG_THROW (
"ValueById: Failed to parse the identifier.\n");
119 while (*str && std::isspace (*str)) str++;
121 while (*str && *str !=
'#')
123 number v = std::strtod (str, &end_ptr);
125 UG_THROW (
"ValueById: Failed to parse a value.\n");
126 values.push_back (v);
128 while (*str && std::isspace (*str)) str++;
131 append_value (ident, values);
135 UG_CATCH_THROW (
"ValueById: Error in line no. " << num_lines <<
": '" << input_line <<
"'\n");
139 "ValueById: " << num_lines <<
" lines read from the file"
140 " (" << num_data_lines <<
" data lines with " << m_numCols <<
" values per line).\n"
number interpolate(number x, number y, number t) const
gets the value for a given point
Definition value_by_id_impl.h:24