Exemplo n.º 1
0
static void readDoubleInShort(const File& file,
                              const string& name,
                              const array<size_t, dimension>& start,
                              const array<size_t, dimension>& count,
                              Type* values,
                              PropertyType Type::*property,
                              const Converter& converter) {
    size_t size = accumulate(count.begin(), count.end(), 1, [](size_t n, size_t m) { return n*m; });
    vector<short> v(size);
    const Var var(file.var(name));
    const double scaleFactor = var.attDouble("scale_factor");
    const double offset = var.attDouble("add_offset");
    var.get(start, count, v.data());
    size_t n = 0;
    for (auto it = v.begin(); it != v.end(); ++it, ++n) {
        values[n].*property = converter(*it*scaleFactor + offset);
    }
}