18f7e3ba248313ce52a405c3922a0e185863479c
4 #include "RipplingMOO.h"
5 #include "RipplingMath.h"
8 #include "IndiceTools.h"
15 /*----------------------------------------------------------------------*\
17 \*---------------------------------------------------------------------*/
19 /*--------------------------------------*\
21 \*-------------------------------------*/
23 /*--------------------------------------*\
25 \*-------------------------------------*/
27 /*----------------------------------------------------------------------*\
29 \*---------------------------------------------------------------------*/
31 /*--------------------------------------*\
33 \*-------------------------------------*/
35 RipplingMOO::RipplingMOO(unsigned int w
, unsigned int h
, float dt
)
36 : w(w
), h(h
), t(0), dt(dt
), isEntrelacement(false)
40 RipplingMOO::~RipplingMOO(void)
46 /*--------------------------------------*\
48 \*-------------------------------------*/
50 void RipplingMOO::process(uchar4
* ptrTabPixels
, int w
, int h
) // Pourquoi w et h ne sont pas utilisé??
52 if (this->isEntrelacement
)
53 this->entrelacementOMP(ptrTabPixels
); // Plus lent.
55 this->forAutoOMP(ptrTabPixels
); // Plus rapide.
57 this->isEntrelacement
= ! this->isEntrelacement
; // Pour tester que les deux implementations fonctionnent
61 void RipplingMOO::animationStep()
70 float RipplingMOO::getT()
75 /*--------------------------------------*\
77 \*-------------------------------------*/
80 * Code entrainement Cuda
82 void RipplingMOO::entrelacementOMP(uchar4
* ptrTabPixels
)
84 RipplingMath
ripplingMath(w
,h
); // ici pour preparer cuda
89 const int NB_THREAD
= OmpTools::getNbThread();
90 const int TID
= OmpTools::getTid();
96 IndiceTools::toIJ(s
, w
, &i
, &j
); // s[0,W*H[ --> i[0,H[ j[0,W[
97 ripplingMath
.colorIJ(&ptrTabPixels
[s
], i
, j
,t
);
104 * Code naturel et direct OMP
106 void RipplingMOO::forAutoOMP(uchar4
* ptrTabPixels
)
108 RipplingMath
ripplingMath(w
,h
); // ici pour preparer cuda
110 #pragma omp parallel for
111 for (int i
= 0; i
< h
; i
++)
112 for (int j
= 0; j
< w
; j
++)
114 // int s = i * W + j;
115 const int s
= IndiceTools::toS(w
, i
, j
); // i[0,H[ j[0,W[ --> s[0,W*H[
116 ripplingMath
.colorIJ(&ptrTabPixels
[s
], i
, j
,t
);
120 /*----------------------------------------------------------------------*\
122 \*---------------------------------------------------------------------*/