Commit a4e19548 authored by Damien L-G's avatar Damien L-G

Improve readability when adding a spline to the map

parent 37961801
......@@ -103,20 +103,17 @@ Spline2D<Bicubic> *SplineMap::get_spline(std::string const &which) {
// object.
auto it = _splines.find(key);
if (it == _splines.end()) {
auto const x = [&filenames]() {
std::ifstream fs(filenames[0]);
return parse_x(fs);
}();
auto const y = [&filenames]() {
std::ifstream fs(filenames[1]);
return parse_y(fs);
}();
auto const z = transpose_z(x.size(), y.size(), [&filenames]() {
std::ifstream fs(filenames[2]);
return parse_z(fs);
}());
auto extract_from = [](std::string const &filename,
std::vector<double> (*parse)(std::istream &)) {
std::fstream fs(filename);
return parse(fs);
};
auto const x = extract_from(filenames[0], parse_x);
auto const y = extract_from(filenames[1], parse_y);
auto const z = extract_from(filenames[2], parse_z);
auto const tz = transpose_z(x.size(), y.size(), z);
std::tie(it, std::ignore) =
_splines.insert({key, std::make_unique<Spline2D<Bicubic>>(x, y, z)});
_splines.insert({key, std::make_unique<Spline2D<Bicubic>>(x, y, tz)});
}
return (it->second).get();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment