class AnimableFonctionel_I\r
{\r
public:\r
-\r
- //virtual ~Animable_I(void)=0;\r
+ virtual ~AnimableFonctionel_I() {}\r
\r
virtual void runGPU(uchar4* ptrDevPixels,const DomaineMath& domaineMath)=0;\r
virtual void animationStep(void)=0;\r
return new FractalMandelbrot(dw, dh, 0.2);\r
}\r
\r
-\r
Fractal* FractalProvider::createJulia()\r
{\r
int dw = 16 * 50;\r
--- /dev/null
+#include <iostream>\r
+\r
+#include "Indice2D.h"\r
+#include "IndiceTools.h"\r
+#include "DomaineMath.h"\r
+#include "cudaTools.h"\r
+#include "Device.h"\r
+\r
+#include "NewtonMath.h"\r
+\r
+using std::cout;\r
+using std::endl;\r
+\r
+__global__ void newton(uchar4* ptrDevPixels, int w, int h, DomaineMath domaineMath)\r
+ {\r
+ const int TID = Indice2D::tid();\r
+ const int NB_THREAD = Indice2D::nbThread();\r
+ const int WH = w * h;\r
+\r
+ NewtonMath newtonMath;\r
+\r
+ uchar4 color;\r
+ color.z = 255; // Par défaut, l'image est opaque.\r
+\r
+ double x, y;\r
+ int pixelI, pixelJ;\r
+\r
+ int s = TID;\r
+ while (s < WH)\r
+ {\r
+ IndiceTools::toIJ(s, w, &pixelI, &pixelJ); // update (pixelI, pixelJ)\r
+\r
+ // (i,j) domaine ecran\r
+ // (x,y) domaine math\r
+ domaineMath.toXY(pixelI, pixelJ, &x, &y); // (i,j) -> (x,y)\r
+\r
+ newtonMath.colorXY(&color, x, y);\r
+\r
+ ptrDevPixels[s] = color;\r
+\r
+ s += NB_THREAD;\r
+ }\r
+ }\r
--- /dev/null
+#ifndef NEWTON_MATH_H_\r
+#define NEWTON_MATH_H_\r
+\r
+#include <cmath>\r
+\r
+#include "CalibreurF.h"\r
+#include "ColorTools.h"\r
+\r
+class NewtonMath\r
+ {\r
+ public:\r
+ __device__\r
+ NewtonMath()\r
+ : calibreur(IntervalF(1, 100), IntervalF(0, 1))\r
+ {\r
+ }\r
+\r
+ __device__\r
+ virtual ~NewtonMath() {}\r
+\r
+ public:\r
+ /**\r
+ * x=pixelI\r
+ * y=pixelJ\r
+ */\r
+ __device__\r
+ void colorXY(uchar4* ptrColor, float x, float y) const\r
+ {\r
+ ptrColor->x = 0;\r
+ ptrColor->y = 0;\r
+ ptrColor->z = 0;\r
+\r
+ int i = 0;\r
+ float s = static_cast<float>(i);\r
+ this->calibreur.calibrer(s);\r
+ ColorTools::HSB_TO_RVB(s, ptrColor);\r
+ }\r
+\r
+ private:\r
+\r
+ private:\r
+ CalibreurF calibreur;\r
+ };\r
+\r
+#endif\r
--- /dev/null
+#include <iostream>\r
+#include <assert.h>\r
+\r
+#include "Newton.h"\r
+#include "Device.h"\r
+\r
+using std::cout;\r
+using std::endl;\r
+\r
+extern __global__ void newton(uchar4* ptrDevPixels, int w, int h, DomaineMath domaineMath);\r
+\r
+Newton::Newton(int w, int h)\r
+ : variateurAnimation(IntervalF(30, 100), 1),\r
+ w(w), h(h),\r
+ dg(8, 8, 1),\r
+ db(16, 16, 1),\r
+ title("Fractal Newton")\r
+ {\r
+ //print(dg, db);\r
+ Device::assertDim(dg, db);\r
+ }\r
+\r
+Newton::~Newton()\r
+ {\r
+ delete this->ptrDomaineMathInit;\r
+ }\r
+\r
+void Newton::runGPU(uchar4* ptrDevPixels, const DomaineMath& domaineMath)\r
+ {\r
+ newton<<<dg,db>>>(ptrDevPixels, this->w, this->h, domaineMath);\r
+ }\r
+\r
+void Newton::animationStep()\r
+ {\r
+ this->t = this->variateurAnimation.varierAndGet();\r
+ }\r
+\r
+int Newton::getW()\r
+ {\r
+ return this->w;\r
+ }\r
+\r
+int Newton::getH()\r
+ {\r
+ return this->h;\r
+ }\r
+\r
+DomaineMath* Newton::getDomaineMathInit()\r
+ {\r
+ return this->ptrDomaineMathInit;\r
+ }\r
+\r
+float Newton::getT()\r
+ {\r
+ return 0;\r
+ }\r
+\r
+string Newton::getTitle()\r
+ {\r
+ return this->title;\r
+ }\r
+\r
--- /dev/null
+#ifndef NEWTON_H_\r
+#define NEWTON_H_\r
+\r
+#include "cudaTools.h"\r
+#include "AnimableFonctionel_I.h"\r
+#include "MathTools.h"\r
+#include "VariateurF.h"\r
+\r
+class Newton : public AnimableFonctionel_I\r
+ {\r
+ public:\r
+ Newton(int w, int h);\r
+ ~Newton();\r
+\r
+ void runGPU(uchar4* ptrDevPixels, const DomaineMath& domaineMath) /*override*/;\r
+ void animationStep() /*override*/;\r
+\r
+ int getW() /*override*/;\r
+ int getH() /*override*/;\r
+ DomaineMath* getDomaineMathInit() /*override*/;\r
+\r
+ float getT() /*override*/;\r
+\r
+ string getTitle(void) /*override*/;\r
+\r
+ private:\r
+ VariateurF variateurAnimation;\r
+ float t;\r
+\r
+ // Inputs\r
+ const int w;\r
+ const int h;\r
+\r
+ const dim3 dg;\r
+ const dim3 db;\r
+\r
+ DomaineMath* ptrDomaineMathInit;\r
+\r
+ const string title;\r
+ };\r
+\r
+#endif\r
--- /dev/null
+#include "NewtonProvider.h"\r
+\r
+Newton* NewtonProvider::create()\r
+ {\r
+ int dw = 16 * 50;\r
+ int dh = 16 * 30;\r
+\r
+ return new Newton(dw, dh);\r
+ }\r
+\r
+ImageFonctionel* NewtonProvider::createGL()\r
+ {\r
+ ColorRGB_01* ptrColorTitre = new ColorRGB_01(0, 0, 0);\r
+ return new ImageFonctionel(create(), ptrColorTitre); // both ptr destroy by destructor of ImageFonctionel\r
+ }\r
--- /dev/null
+#ifndef NEWTON_PROVIDER_H_\r
+#define NEWTON_PROVIDER_H_\r
+\r
+#include "Newton.h"\r
+#include "ImageFonctionel.h"\r
+\r
+class NewtonProvider\r
+ {\r
+ public:\r
+ static Newton* create();\r
+ static ImageFonctionel* createGL();\r
+ };\r
+\r
+#endif\r
//Rippling0Image* ptrRippling0 = Rippling0Provider::createGL();\r
//Image* ptrRippling = RipplingProvider::createGL();\r
//ImageFonctionel* ptrFractalMandelbrot = FractalProvider::createMandelbrotGL();\r
- ImageFonctionel* ptrFractalJulia = FractalProvider::createJuliaGL();\r
+ //ImageFonctionel* ptrFractalJulia = FractalProvider::createJuliaGL();\r
\r
const bool isAnimation = true;\r
const bool isSelection = true;\r
//GLUTImageViewers rippling0Viewer(ptrRippling0, isAnimation, isSelection, 0, 0);\r
//GLUTImageViewers ripplingViewer(ptrRippling, isAnimation, isSelection, 10, 10);\r
//GLUTImageViewers fractalMandelbrotViewer(ptrFractalMandelbrot, true, true, 20, 20);\r
- GLUTImageViewers fractalJuliaViewer(ptrFractalJulia, true, true, 20, 20);\r
+ //GLUTImageViewers fractalJuliaViewer(ptrFractalJulia, true, true, 20, 20);\r
\r
GLUTImageViewers::runALL(); // Bloquant, Tant qu'une fenetre est ouverte\r
\r