1 #include "HeatTransfertDevice.h"
\r
6 #include "Indice2D.h"
\r
7 #include "IndiceTools.h"
\r
8 #include "cudaTools.h"
\r
11 #include "ColorTools.h"
\r
13 #include "HeatImage.h"
\r
16 void display(HeatImage image, uchar4* ptrDevPixels, CalibreurF calibreur)
\r
18 const int TID = Indice2D::tid();
\r
19 const int NB_THREAD = Indice2D::nbThread();
\r
20 const int WH = image.getWCuda() * image.getHCuda();
\r
30 IndiceTools::toIJ(s, image.getWCuda(), &pixelI, &pixelJ);
\r
32 float heatValue = image.getCuda(pixelJ, pixelI);
\r
33 calibreur.calibrer(heatValue);
\r
34 ColorTools::HSB_TO_RVB(heatValue, &color);
\r
36 ptrDevPixels[s] = color;
\r
42 void copyHeaters(HeatImage heaters, HeatImage destination)
\r
44 const int TID = Indice2D::tid();
\r
45 const int NB_THREAD = Indice2D::nbThread();
\r
46 const int WH = heaters.getWCuda() * heaters.getHCuda();
\r
54 IndiceTools::toIJ(s, heaters.getWCuda(), &pixelI, &pixelJ);
\r
56 float heatValue = heaters.getCuda(pixelJ, pixelI);
\r
57 if (heatValue > 0.0)
\r
58 destination.setCuda(pixelJ, pixelI, heatValue);
\r
65 void diffuseMethode1(HeatImage from, HeatImage to)
\r
67 const int TID = Indice2D::tid();
\r
68 const int NB_THREAD = Indice2D::nbThread();
\r
70 const int W = from.getWCuda() - 2;
\r
71 const int H = from.getHCuda() - 2;
\r
72 const int WH = W * H;
\r
74 const float k = 0.2;
\r
82 IndiceTools::toIJ(s, W, &pixelI, &pixelJ);
\r
83 const int x = pixelJ + 1;
\r
84 const int y = pixelI + 1;
\r
85 const float t_old = from.getCuda(x, y);
\r
86 const float t_up = from.getCuda(x, y - 1);
\r
87 const float t_down = from.getCuda(x, y + 1);
\r
88 const float t_left = from.getCuda(x - 1, y);
\r
89 const float t_right = from.getCuda(x + 1, y);
\r
91 to.setCuda(x, y, t_old + k * (t_up + t_down + t_left + t_right - 4.0 * t_old));
\r
98 void diffuseMethode2(HeatImage from, HeatImage to)
\r
100 const int TID = Indice2D::tid();
\r
101 const int NB_THREAD = Indice2D::nbThread();
\r
103 const int W = from.getWCuda() - 2;
\r
104 const int H = from.getHCuda() - 2;
\r
105 const int WH = W * H;
\r
113 IndiceTools::toIJ(s, W, &pixelI, &pixelJ);
\r
114 const int x = pixelJ + 1;
\r
115 const int y = pixelI + 1;
\r
116 const float t_old = from.getCuda(x, y);
\r
117 const float t_up = from.getCuda(x, y - 1);
\r
118 const float t_down = from.getCuda(x, y + 1);
\r
119 const float t_left = from.getCuda(x - 1, y);
\r
120 const float t_right = from.getCuda(x + 1, y);
\r
122 to.setCuda(x, y, (t_up + t_down + t_left + t_right + 4.0 * t_old) / 8.0);
\r