Ajout du TP HeatTransfert.
[GPU.git] / WCudaMSE / Student_Cuda_Image / src / cpp / core / 05_HeatTransfert / moo / host / HeatImage.h
diff --git a/WCudaMSE/Student_Cuda_Image/src/cpp/core/05_HeatTransfert/moo/host/HeatImage.h b/WCudaMSE/Student_Cuda_Image/src/cpp/core/05_HeatTransfert/moo/host/HeatImage.h
new file mode 100644 (file)
index 0000000..00224c8
--- /dev/null
@@ -0,0 +1,73 @@
+#ifndef HEAT_IMAGE_H
+#define HEAT_IMAGE_H
+
+/*
+ * Une classe représentant une image de float.
+ */
+class HeatImage
+    {
+    public:
+        HeatImage(int w, int h, float* image = 0);
+        ~HeatImage();
+
+        inline void clear()
+            {
+            memset(this->image, 0, this->w * this->h * sizeof(float));
+            }
+
+        __device__
+        inline void setCuda(int x, int y, float value)
+            {
+            this->image[x + this->w * y] = value;
+            }
+
+        inline void set(int x, int y, float value)
+            {
+            this->image[x + this->w * y] = value;
+            }
+
+        __device__
+        inline float getCuda(int x, int y)
+            {
+            return this->image[x + this->w * y];
+            }
+
+        __device__
+        inline int getWCuda()
+            {
+            return this->w;
+            }
+
+        inline int getW()
+            {
+            return this->w;
+            }
+
+        __device__
+        inline int getHCuda()
+            {
+            return this->h;
+            }
+
+        inline int getH()
+            {
+            return this->h;
+            }
+
+        inline void swapWith(HeatImage& other)
+            {
+            float* tmp = this->image;
+            this->image = other.image;
+            other.image = tmp;
+            }
+
+        inline float*& getRaw() { return this->image; }
+        inline void setRaw(float* image) { this->image = image; }
+
+    private:
+        int w, h;
+        float* image;
+    };
+
+
+#endif