1 #ifndef DOMAINE_MATH_GPU_H
2 #define DOMAINE_MATH_GPU_H
4 #include "envGLImageCudas.h"
6 #include "DomaineEcran_GPU.h"
12 #define GPU_SCOPE __host__ __device__
14 /*----------------------------------------------------------------------*\
16 \*---------------------------------------------------------------------*/
18 /*--------------------------------------*\
20 \*-------------------------------------*/
25 * (x0,y0) upper left corner of a dx x dy square.
28 class CBI_GLIMAGE_CUDA DomaineMath
30 /*--------------------------------------*\
32 \*-------------------------------------*/
37 __device__
DomaineMath() :
38 x0(0.0), y0(0.0), x1(0.0), y1(0.0), dxDw(0.0), dyDh(0.0)
44 __device__
DomaineMath(double x0
, double y0
, double x1
, double y1
) :
45 x0(x0
), y0(y0
), x1(x1
), y1(y1
), dxDw(0.0), dyDh(0.0)
50 /*--------------------------------------*\
52 \*--------------------------------------*/
54 /*------------------------------*\
56 \*-----------------------------*/
61 string
toString() const;
68 * called only by ImageFonctionelMOOs_A, so Host Only!
71 void computeDxDy(int w
, int h
);
73 /*------------------------------*\
75 \*-----------------------------*/
80 gpu::DomaineMath
extractDomaineFromSelection(const gpu::DomaineEcran
&domaineSelection
, int dxEcran
, int dyEcran
) const
82 double zoomX
= dxEcran
/ (double) domaineSelection
.dx
;
83 double zoomY
= dyEcran
/ (double) domaineSelection
.dy
;
85 double dxResult
= dx() / zoomX
;
86 double dyResult
= dy() / zoomY
;
88 double pourcentageX
= domaineSelection
.x0
/ (double) dxEcran
;
89 double pourcentageY
= domaineSelection
.y0
/ (double) dyEcran
;
91 return DomaineMath::create(x0
+ (pourcentageX
* dx()), y0
+ (pourcentageY
* dy()), dxResult
, dyResult
);
107 * toXY est uniquement utilisable lorsque le domaine a été associé a une ImageFonctionelle!
111 void toXY(int i
, int j
, double* ptrX
, double* ptrY
) const
113 *ptrX
= x0
+ j
* dxDw
;
114 *ptrY
= y0
+ i
* dyDh
;
118 static gpu::DomaineMath
create(double x0
, double y0
, double dx
, double dy
)
120 return DomaineMath(x0
, y0
, x0
+ dx
, y0
+ dy
);
123 /*--------------------------------------*\
125 \*-------------------------------------*/
138 double dxDw
; //old dx
139 double dyDh
; //old dy
141 friend class ImageFonctionelMOOs_A
;
142 // Toutes les méthode de la classe ImageFonctionelMOOs_A sont amie
145 CBI_GLIMAGE_CUDA __host__ ostream
& operator<<(ostream
& stream
, const gpu::DomaineMath
& domaine
);
150 /*----------------------------------------------------------------------*\
152 \*---------------------------------------------------------------------*/