| 12
 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
 
 | #define SIZE_OF_DOUBLE (sizeof(double))
 
class module {
private:
	struct Data {
		double values[4][4];
	};
 
	std::unordered_map<unsigned int, Data> cache;
 
public:
	module() {
		std::ifstream file("path.bin, ios::in | ios::binary");
		pour tous les indices {
			// lire tes 16 doubles
			unsigned index = calcul(x, y);
			Data d;
			file.seekg(index*SIZE_OF_DOUBLE, ios::beg);
			file.read(reinterpret_cast<char *> (&d.value[0]), 4*SIZE_DOUBLE);
			file.seekg(ligne_suivante*SIZE_OF_DOUBLE, ios::cur);
			file.read(reinterpret_cast<char *> (&d.value[1]), 4*SIZE_DOUBLE);
			file.seekg(ligne_suivante*SIZE_OF_DOUBLE, ios::cur);
			file.read(reinterpret_cast<char *> (&d.value[2]), 4*SIZE_DOUBLE);
			file.seekg(ligne_suivante*SIZE_OF_DOUBLE, ios::cur);
			file.read(reinterpret_cast<char *> (&d.value[3]), 4*SIZE_DOUBLE);
			cache.insert(index, d);
		}
	}
 
	double getValue(const double x, const double y) const {
		unsigned int index = calcul(x, y);
		auto const& d = cache[index];
 
		// si ce calcul est long et fait plusieurs
		// fois, il peut aussi est mis en cache
		return bicubicInterpo(x, y, d.values);
	}
}; | 
Partager