{\r
this->ptrAnimable = ptrAnimable;\r
this->ptrColorTitreRGB=ptrColorTitreRGB;\r
+\r
+ this->valueNames = ptrAnimable->getNames();\r
+ this->values = new float[this->valueNames.size()];\r
}\r
\r
Image::~Image(void)\r
\r
// top\r
{\r
- float t = ptrAnimable->getT();\r
- string message = "t = " + StringTools::toString(t);\r
- graphic2D.drawTitleTop(message, ptrfont);\r
+ string title;\r
+ this->ptrAnimable->getValues(this->values);\r
+ for (int i = 0; i < this->valueNames.size(); i++)\r
+ {\r
+ if (i != 0)\r
+ title += ", ";\r
+ title += this->valueNames[i];\r
+ title += StringTools::toString(this->values[i]);\r
+ }\r
+ graphic2D.drawTitleTop(title, ptrfont);\r
}\r
\r
// bottom\r
#ifndef ANIMABLE_I_H_\r
#define ANIMABLE_I_H_\r
\r
-#include <iostream>\r
-#include "cudaTools.h"\r
+#include <string>\r
+#include <vector>\r
\r
-using std::string;\r
+#include "cudaTools.h"\r
\r
/*----------------------------------------------------------------------*\\r
|* Declaration *|\r
virtual int getW()=0;\r
virtual int getH()=0;\r
\r
- /**\r
- * getParaAnimation\r
- */\r
- virtual float getT() = 0;\r
+ /**\r
+ * Ancienne version de l'interface.\r
+ */\r
+ virtual float getT() { return 0.0; };\r
+\r
+ virtual std::vector<std::string> getNames() { std::vector<std::string> def; def.push_back("t = "); return def; }\r
+ virtual void getValues(float* values) { values[0] = this->getT(); }\r
\r
- virtual string getTitle() = 0;\r
+ virtual std::string getTitle() = 0;\r
};\r
\r
#endif\r
// Input\r
Animable_I* ptrAnimable;\r
ColorRGB_01* ptrColorTitreRGB;\r
+\r
+ std::vector<std::string> valueNames;\r
+ float* values;\r
};\r
\r
#endif\r
{\r
this->ptrAnimable = ptrAnimable;\r
this->ptrColorTitreRGB = ptrColorTitreRGB;\r
- this->tName = ptrAnimable->getTName();\r
+ this->valueNames = ptrAnimable->getNames();\r
+ this->values = new float[this->valueNames.size()];\r
\r
setEnableDomaineOverlay(true);\r
}\r
\r
ImageFonctionel::~ImageFonctionel(void)\r
{\r
- delete ptrAnimable;\r
+ delete this->ptrAnimable;\r
+ delete[] this->values;\r
}\r
\r
/**\r
\r
// top\r
{\r
- float t = ptrAnimable->getT();\r
- string message = this->tName + StringTools::toString(t);\r
- graphic2D.drawTitleTop(message, ptrfont);\r
+ string title;\r
+ this->ptrAnimable->getValues(this->values);\r
+ for (int i = 0; i < this->valueNames.size(); i++)\r
+ {\r
+ if (i != 0)\r
+ title += ", ";\r
+ title += this->valueNames[i];\r
+ title += StringTools::toString(this->values[i]);\r
+ }\r
+ graphic2D.drawTitleTop(title, ptrfont);\r
}\r
\r
// bottom\r
#define ANIMABLE_FONCTIONEL_I_H_\r
\r
#include <iostream>\r
+#include <vector>\r
+#include <string>\r
\r
#include "cudaTools.h"\r
#include "DomaineMath.h"\r
\r
-using std::string;\r
-\r
-\r
-\r
/*----------------------------------------------------------------------*\\r
|* Declaration *|\r
\*---------------------------------------------------------------------*/\r
virtual DomaineMath* getDomaineMathInit(void)=0;\r
\r
/**\r
- * getParaAnimation\r
+ * Ancienne version de l'interface.\r
*/\r
- virtual float getT(void)=0;\r
- virtual string getTName() { return "t = "; }\r
+ virtual float getT(void) { return 0.0; };\r
+\r
+ virtual std::vector<std::string> getNames() { std::vector<std::string> def; def.push_back("t = "); return def; }\r
+ virtual void getValues(float* values) { values[0] = this->getT(); }\r
\r
- virtual string getTitle(void)=0;\r
+ virtual std::string getTitle(void)=0;\r
};\r
\r
#endif\r
#ifndef IMAGE_FONCTIONEL_H_\r
#define IMAGE_FONCTIONEL_H_\r
\r
+#include <vector>\r
+\r
#include "ImageFonctionelMOOs_A.h"\r
#include "MathTools.h"\r
#include "ColorRGB_01.h"\r
\r
#include "AnimableFonctionel_I.h"\r
\r
-\r
-\r
/*----------------------------------------------------------------------*\\r
|* Declaration *|\r
\*---------------------------------------------------------------------*/\r
\*-------------------------------------*/\r
\r
private:\r
-\r
- // Input\r
AnimableFonctionel_I* ptrAnimable;\r
ColorRGB_01* ptrColorTitreRGB;\r
\r
- string tName;\r
+ std::vector<std::string> valueNames;\r
+ float* values;\r
};\r
\r
#endif\r
#ifndef RIPPLING_H_\r
#define RIPPLING_H_\r
\r
-#include "cudaTools.h"\r
#include "Animable_I.h"\r
+#include "cudaTools.h"\r
#include "MathTools.h"\r
\r
/*----------------------------------------------------------------------*\\r
virtual int getW(void);\r
virtual int getH(void);\r
\r
- virtual string getTitle(void);\r
+ virtual std::string getTitle(void);\r
\r
private:\r
\r
float t;\r
\r
//Outputs\r
- string title;\r
+ std::string title;\r
};\r
\r
#endif\r
+#include "FractalDevice.h"\r
+\r
#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
using std::cout;\r
using std::endl;\r
\r
-__global__ void fractalMandelbrot(uchar4* ptrDevPixels, int w, int h, DomaineMath domaineMath, int n);\r
-__global__ void fractalJulia(uchar4* ptrDevPixels, int w, int h, DomaineMath domaineMath, int n, float c_r, float c_i);\r
-__device__ void fractal(uchar4* ptrDevPixels, int w, int h, const DomaineMath& domaineMath, int n, const FractalMath& fractalMath);\r
-\r
-__global__ void fractalMandelbrot(uchar4* ptrDevPixels, int w, int h, DomaineMath domaineMath, int n)\r
- {\r
- FractalMandelbrotMath fractalMath(n);\r
- fractal(ptrDevPixels, w, h, domaineMath, n, fractalMath);\r
- }\r
-\r
-__global__ void fractalJulia(uchar4* ptrDevPixels, int w, int h, DomaineMath domaineMath, int n, float c_r, float c_i)\r
- {\r
- FractalJuliaMath fractalMath(n, c_r, c_i);\r
- fractal(ptrDevPixels, w, h, domaineMath, n, fractalMath);\r
- }\r
-\r
__device__ void fractal(uchar4* ptrDevPixels, int w, int h, const DomaineMath& domaineMath, int n, const FractalMath& fractalMath)\r
{\r
const int TID = Indice2D::tid();\r
s += NB_THREAD;\r
}\r
}\r
+\r
+__global__ void fractalMandelbrot(uchar4* ptrDevPixels, int w, int h, DomaineMath domaineMath, int n)\r
+ {\r
+ FractalMandelbrotMath fractalMath(n);\r
+ fractal(ptrDevPixels, w, h, domaineMath, n, fractalMath);\r
+ }\r
+\r
+__global__ void fractalJulia(uchar4* ptrDevPixels, int w, int h, DomaineMath domaineMath, int n, float c_r, float c_i)\r
+ {\r
+ FractalJuliaMath fractalMath(n, c_r, c_i);\r
+ fractal(ptrDevPixels, w, h, domaineMath, n, fractalMath);\r
+ }\r
+\r
--- /dev/null
+#ifndef FRACTALDEVICE_H_
+#define FRACTALDEVICE_H_
+
+#include "DomaineMath.h"
+
+__global__ void fractalMandelbrot(uchar4* ptrDevPixels, int w, int h, DomaineMath domaineMath, int n);
+__global__ void fractalJulia(uchar4* ptrDevPixels, int w, int h, DomaineMath domaineMath, int n, float c_r, float c_i);
+
+#endif
+#include "Fractal.h"\r
+\r
#include <iostream>\r
#include <assert.h>\r
+using namespace std;\r
\r
-#include "Fractal.h"\r
+#include "FractalDevice.h"\r
#include "Device.h"\r
\r
-using std::cout;\r
-using std::endl;\r
-\r
-extern __global__ void fractalMandelbrot(uchar4* ptrDevPixels, int w, int h, DomaineMath domaineMath, int n);\r
-extern __global__ void fractalJulia(uchar4* ptrDevPixels, int w, int h, DomaineMath domaineMath, int n, float c_r, float c_i);\r
-\r
-Fractal::Fractal(int w, int h)\r
- : w(w), h(h),\r
- dg(8, 8, 1),\r
- db(16, 16, 1),\r
- title("Fractal Cuda")\r
+Fractal::Fractal(int w, int h) :\r
+ w(w), h(h),\r
+ dg(8, 8, 1),\r
+ db(16, 16, 1),\r
+ title("Fractal Cuda")\r
{\r
//print(dg, db);\r
Device::assertDim(dg, db);\r
\r
/////\r
\r
-FractalMandelbrot::FractalMandelbrot(int w, int h, float dn)\r
- : Fractal(w, h), variateurAnimationN(IntervalF(30, 100), dn)\r
+FractalMandelbrot::FractalMandelbrot(int w, int h, int dn) :\r
+ Fractal(w, h),\r
+ variateurAnimationN(IntervalI(10, 100), dn),\r
+ n(0)\r
{\r
this->ptrDomaineMathInit = new DomaineMath(-2, -1.3, 0.8, 1.3);\r
}\r
this->n = this->variateurAnimationN.varierAndGet();\r
}\r
\r
-float FractalMandelbrot::getT()\r
+vector<string> FractalMandelbrot::getNames()\r
{\r
- return this->n;\r
+ vector<string> name;\r
+ name.push_back("n = ");\r
+ return name;\r
+ }\r
+\r
+void FractalMandelbrot::getValues(float* values)\r
+ {\r
+ values[0] = float(this->n);\r
}\r
\r
void FractalMandelbrot::runGPU(uchar4* ptrDevPixels, const DomaineMath& domaineMath)\r
\r
/////\r
\r
-FractalJulia::FractalJulia(int w, int h, float dn, float z_r_min, float z_r_max, float z_i_min, float z_i_max)\r
- : Fractal(w, h), z_r(z_r_min), z_i(z_i_min), variateurAnimationR(IntervalF(-0.8, -0.7), 0.0005), variateurAnimationI(IntervalF(-0.3, 0.3/*0.15*/), 0.0004)\r
+FractalJulia::FractalJulia(int w, int h, int n, float z_r_min, float z_r_max, float z_i_min, float z_i_max) :\r
+ Fractal(w, h),\r
+ n(n),\r
+ z_r(z_r_min),\r
+ z_i(z_i_min),\r
+ variateurAnimationR(IntervalF(-0.8, -0.7), 0.0005),\r
+ variateurAnimationI(IntervalF(-0.3, 0.3), 0.0004)\r
{\r
this->ptrDomaineMathInit = new DomaineMath(-1.7, -1.4, 1.7, 1.4);\r
}\r
this->z_i = this->variateurAnimationI.varierAndGet();\r
}\r
\r
-float FractalJulia::getT()\r
+vector<string> FractalJulia::getNames()\r
+ {\r
+ vector<string> name;\r
+ name.push_back("z_r = ");\r
+ name.push_back("z_i = ");\r
+ return name;\r
+ }\r
+\r
+void FractalJulia::getValues(float* values)\r
{\r
- return this->z_r;\r
+ values[0] = this->z_r;\r
+ values[1] = this->z_i;\r
}\r
\r
void FractalJulia::runGPU(uchar4* ptrDevPixels, const DomaineMath& domaineMath)\r
{\r
- fractalJulia<<<dg,db>>>(ptrDevPixels, this->w, this->h, domaineMath, 300, this->z_r, this->z_i);\r
+ fractalJulia<<<dg,db>>>(ptrDevPixels, this->w, this->h, domaineMath, this->n, this->z_r, this->z_i);\r
}\r
\r
#ifndef FRACTAL_H_\r
#define FRACTAL_H_\r
\r
+#include <vector>\r
+#include <string>\r
+\r
#include "cudaTools.h"\r
#include "AnimableFonctionel_I.h"\r
#include "MathTools.h"\r
+#include "VariateurI.h"\r
#include "VariateurF.h"\r
\r
class Fractal : public AnimableFonctionel_I\r
class FractalMandelbrot : public Fractal\r
{\r
public:\r
- FractalMandelbrot(int w, int h, float dn);\r
+ FractalMandelbrot(int w, int h, int dn);\r
void animationStep();\r
- float getT() /*override*/;\r
+\r
+ std::vector<std::string> getNames();\r
+ void getValues(float* values);\r
\r
private:\r
void runGPU(uchar4* ptrDevPixels, const DomaineMath& domaineMath) /*override*/;\r
\r
- VariateurF variateurAnimationN;\r
-\r
- float n;\r
+ VariateurI variateurAnimationN;\r
+ int n;\r
};\r
\r
class FractalJulia : public Fractal\r
{\r
public:\r
- FractalJulia(int w, int h, float dn, float z_r_min, float z_r_max, float z_i_min, float z_i_max);\r
+ FractalJulia(int w, int h, int n, float z_r_min, float z_r_max, float z_i_min, float z_i_max);\r
void animationStep();\r
- float getT() /*override*/;\r
+\r
+ std::vector<std::string> getNames();\r
+ void getValues(float* values);\r
\r
private:\r
void runGPU(uchar4* ptrDevPixels, const DomaineMath& domaineMath) /*override*/;\r
\r
+ const int n;\r
+\r
float z_r, z_i;\r
- VariateurF variateurAnimationI;\r
- VariateurF variateurAnimationR;\r
+ VariateurF variateurAnimationI; // Variateur pour z_i.\r
+ VariateurF variateurAnimationR; // Variateur pour z_r.\r
};\r
\r
#endif\r
int dw = 16 * 50;\r
int dh = 16 * 30;\r
\r
- return new FractalMandelbrot(dw, dh, 0.2);\r
+ return new FractalMandelbrot(dw, dh, 1);\r
}\r
\r
Fractal* JuliaProvider::create()\r
int dw = 16 * 50;\r
int dh = 16 * 30;\r
\r
- return new FractalJulia(dw, dh, 0.01, -0.745, -0.32, -0.09, 0.1);\r
+ return new FractalJulia(dw, dh, 300, -0.745, -0.32, -0.09, 0.1);\r
}\r
\r
ImageFonctionel* MandelbrotProvider::createGL()\r
{\r
- ColorRGB_01* ptrColorTitre = new ColorRGB_01(0, 0, 0);\r
+ ColorRGB_01* ptrColorTitre = new ColorRGB_01(0, 0, 100);\r
return new ImageFonctionel(create(), ptrColorTitre); // both ptr destroy by destructor of ImageFonctionel\r
}\r
\r
-\r
ImageFonctionel* JuliaProvider::createGL()\r
{\r
- ColorRGB_01* ptrColorTitre = new ColorRGB_01(0, 0, 0);\r
+ ColorRGB_01* ptrColorTitre = new ColorRGB_01(0, 0, 100);\r
return new ImageFonctionel(create(), ptrColorTitre); // both ptr destroy by destructor of ImageFonctionel\r
}\r
#define SPHERE_H
#include "cudaTools.h"
-#include "cudaType_CPU.h"
#include "MathTools.h"
class Sphere
{
public:
__host__
- Sphere(cpu::float3 centre, float r, float hue) :
+ Sphere(float3 centre, float r, float hue) :
centre(centre),
hueInitial(hue)
{
}
__host__
- void setCentre(const cpu::float3& centre)
+ void setCentre(const float3& centre)
{
this->centre = centre;
}
}
__device__
- float hCarre(cpu::float2 xySol)
+ float hCarre(float2 xySol)
{
float a = (centre.x - xySol.x);
float b = (centre.y - xySol.y);
private:
float r;
- cpu::float3 centre;
+ float3 centre;
float hueInitial;
float rCarre;
{
rayTracing<<<dg,db>>>(ptrDevPixels, this->w, this->h, this->t);
- HANDLE_ERROR(cudaDeviceSynchronize()); // Pour flusher les 'printf' (pour le DEBUG).
+ // HANDLE_ERROR(cudaDeviceSynchronize()); // Pour flusher les 'printf' (pour le DEBUG).
}
void RayTracing::animationStep()
{
- this->t += 0.1; // TODO
+ this->t += 0.1; // TODO.
}
int RayTracing::getW()
{
spheres[i].setR(float(this->alea.uniformeAB(20, this->w / 10 - 1)));
- cpu::float3 centre
+ float3 centre
{
float(this->alea.uniformeAB(double(bord), double(this->w - bord))),
float(this->alea.uniformeAB(double(bord), double(this->h - bord))),
#include "cudaTools.h"
#include "Animable_I.h"
#include "MathTools.h"
-#include "cudaType_CPU.h"
+#include "AleaTools.h"
#include "Sphere.h"
float getT() /*override*/;
- string getTitle(void) /*override*/;
+ std::string getTitle(void) /*override*/;
private:
Sphere* createSpheres(int n);
const dim3 dg;
const dim3 db;
- const string title;
+ const std::string title;
};
#endif
const float tempCentre = 1.0;\r
const float tempCotes = 0.2;\r
\r
- for (int x = 179; x <= 195; x++)\r
+ for (int x = 279; x <= 295; x++)\r
{\r
- for (int y = 179; y <= 195; y++)\r
+ for (int y = 279; y <= 295; y++)\r
image.set(x, y, tempCotes);\r
- for (int y = 605; y <= 621; y++)\r
+ for (int y = 505; y <= 521; y++)\r
image.set(x, y, tempCotes);\r
}\r
\r
- for (int x = 605; x <= 621; x++)\r
+ for (int x = 505; x <= 521; x++)\r
{\r
- for (int y = 179; y <= 195; y++)\r
+ for (int y = 279; y <= 295; y++)\r
image.set(x, y, tempCotes);\r
- for (int y = 605; y <= 621; y++)\r
+ for (int y = 505; y <= 521; y++)\r
image.set(x, y, tempCotes);\r
}\r
\r
\r
float getT() /*override*/;\r
\r
- string getTitle(void) /*override*/;\r
+ std::string getTitle(void) /*override*/;\r
\r
private:\r
static void setHeaters(HeatImage& image);\r
const dim3 dg;\r
const dim3 db;\r
\r
- const string title;\r
+ const std::string title;\r
};\r
\r
#endif\r
{\r
// Viewer<Rippling0Image, Rippling0Provider> rippling0(true, true, 10, 10);\r
// Viewer<Image, RipplingProvider> rippling0(true, true, 10, 10);\r
- // Viewer<ImageFonctionel, MandelbrotProvider> fractalMandelbrot(true, true, 20, 20);\r
+ Viewer<ImageFonctionel, MandelbrotProvider> fractalMandelbrot(true, true, 20, 20);\r
// Viewer<ImageFonctionel, JuliaProvider> fractalJulia(true, true, 30, 30);\r
- Viewer<ImageFonctionel, NewtonProvider> newtown(true, true, 20, 20);\r
+ // Viewer<ImageFonctionel, NewtonProvider> newtown(true, true, 20, 20);\r
// Viewer<Image, HeatTransfertProvider> heatTransfert(true, false, 20, 20);\r
// Viewer<ImageFonctionel, RayTracingProvider> rayTracing(true, true, 20, 20);\r
\r