Ajout du TP HeatTransfert.
[GPU.git] / WCudaMSE / Student_Cuda_Image / src / cpp / core / 05_HeatTransfert / moo / host / HeatImage.h
1 #ifndef HEAT_IMAGE_H
2 #define HEAT_IMAGE_H
3
4 /*
5 * Une classe représentant une image de float.
6 */
7 class HeatImage
8 {
9 public:
10 HeatImage(int w, int h, float* image = 0);
11 ~HeatImage();
12
13 inline void clear()
14 {
15 memset(this->image, 0, this->w * this->h * sizeof(float));
16 }
17
18 __device__
19 inline void setCuda(int x, int y, float value)
20 {
21 this->image[x + this->w * y] = value;
22 }
23
24 inline void set(int x, int y, float value)
25 {
26 this->image[x + this->w * y] = value;
27 }
28
29 __device__
30 inline float getCuda(int x, int y)
31 {
32 return this->image[x + this->w * y];
33 }
34
35 __device__
36 inline int getWCuda()
37 {
38 return this->w;
39 }
40
41 inline int getW()
42 {
43 return this->w;
44 }
45
46 __device__
47 inline int getHCuda()
48 {
49 return this->h;
50 }
51
52 inline int getH()
53 {
54 return this->h;
55 }
56
57 inline void swapWith(HeatImage& other)
58 {
59 float* tmp = this->image;
60 this->image = other.image;
61 other.image = tmp;
62 }
63
64 inline float*& getRaw() { return this->image; }
65 inline void setRaw(float* image) { this->image = image; }
66
67 private:
68 int w, h;
69 float* image;
70 };
71
72
73 #endif