00001 #ifndef __GPOINTINITIALISATION_HPP__
00002 #define __GPOINTINITIALISATION_HPP__
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "Commun.hpp"
00027 #include <iostream>
00028 #include <iomanip>
00029 #include <cstdlib>
00030 #include <vector>
00038 namespace Fractale
00039 {
00040
00041
00046 struct GPointInitialisation
00047 {
00048 Zone m_zone;
00053 virtual void debut() = 0;
00058 virtual point nouveauPoint() =0;
00059
00064 virtual bool fin() = 0;
00065 };
00066
00067
00071 class PointAleatoire : public GPointInitialisation
00072 {
00073 const unsigned long int nbMPointMax;
00074 unsigned long int nbMPoint;
00075 unsigned long int nbPoint;
00076 Random myrand;
00077 double facteurZone;
00079 public:
00086 PointAleatoire(unsigned long int nbMPointMax = 100,double facteurZone = 1.)
00087 :nbMPointMax(nbMPointMax),facteurZone(facteurZone)
00088 {}
00089
00090 void debut()
00091 {
00092
00093 nbPoint = nbMPoint = 0;
00094 }
00095
00096 point nouveauPoint()
00097 {
00098
00099 ++nbPoint;
00100 if( (nbMPoint * 1000000 + nbPoint) % 1000 == 0)
00101 {
00102 #ifdef _CALLBACK_QT
00103 int pourcentage = 100* (nbMPoint * 1000000 + nbPoint);
00104
00105
00106 retourPourcentage(pourcentage);
00107 #endif
00108 }
00109
00110 if( nbPoint >= 1000000)
00111 {
00112 ++nbMPoint;
00113 nbPoint = 0;
00114 }
00115
00116 return point
00117 (
00118 m_zone.x - (facteurZone * m_zone.l - m_zone.l) / 2. + facteurZone * m_zone.l * myrand.generateDouble(),
00119 m_zone.y - (facteurZone * m_zone.h - m_zone.l) / 2. + facteurZone * m_zone.h * myrand.generateDouble()
00120 );
00121 }
00122 bool fin()
00123 {
00124
00125 return nbMPoint >= nbMPointMax;
00126 }
00127 };
00128
00132 class PointImage : public GPointInitialisation
00133 {
00134 unsigned int i;
00135 unsigned int j;
00137 public:
00138 void debut()
00139 {
00140
00141 i = j = 0;
00142 }
00143
00144 point nouveauPoint()
00145 {
00146
00147 const point p
00148 (
00149 m_zone.x + m_zone.l * (j + .5) / (m_zone.imgL - 1),
00150 m_zone.y + m_zone.h * (i + .5) / (m_zone.imgH - 1)
00151 );
00152
00153 ++j;
00154
00155 if (j >= m_zone.imgL)
00156 {
00157 #ifdef _CALLBACK_QT
00158 int pourcentage = 100* i /m_zone.imgH;
00159
00160
00161 retourPourcentage(pourcentage);
00162 #endif
00163
00164 ++i;
00165 j = 0;
00166 }
00167
00168 return p;
00169 }
00170
00171 bool fin()
00172 {
00173
00174 return i >= m_zone.imgH ;
00175 }
00176 };
00177
00178
00179 }
00180
00181 #endif