Remplacement des 'powf(a, 2)' par 'a*a'.
[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 #include <cstring>
5
6 /*
7 * Une classe représentant une image de float.
8 */
9 class HeatImage
10 {
11 public:
12 HeatImage(int w, int h, float* image = 0) :
13 w(w), h(h), image(image)
14 {
15 }
16
17 ~HeatImage() {}
18
19 inline void clear()
20 {
21 memset(this->image, 0, this->w * this->h * sizeof(float));
22 }
23
24 __device__
25 inline void setCuda(int x, int y, float value)
26 {
27 this->image[x + this->w * y] = value;
28 }
29
30 inline void set(int x, int y, float value)
31 {
32 this->image[x + this->w * y] = value;
33 }
34
35 __device__
36 inline float getCuda(int x, int y)
37 {
38 return this->image[x + this->w * y];
39 }
40
41 __device__
42 inline int getWCuda()
43 {
44 return this->w;
45 }
46
47 inline int getW()
48 {
49 return this->w;
50 }
51
52 __device__
53 inline int getHCuda()
54 {
55 return this->h;
56 }
57
58 inline int getH()
59 {
60 return this->h;
61 }
62
63 inline void swapWith(HeatImage& other)
64 {
65 float* tmp = this->image;
66 this->image = other.image;
67 other.image = tmp;
68 }
69
70 inline float*& getRaw() { return this->image; }
71 inline void setRaw(float* image) { this->image = image; }
72
73 private:
74 int w, h;
75 float* image;
76 };
77
78
79 #endif