00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef GPOINTINITIALISATION_HPP
00023 #define GPOINTINITIALISATION_HPP
00024 #include "Commun.hpp"
00025 #include <iostream>
00026 #include <iomanip>
00027 #include <cstdlib>
00028 #include <vector>
00036 namespace Fractale
00037 {
00038
00039
00044 struct GPointInitialisation
00045 {
00046 zone m_zone;
00051 virtual void debut() = 0;
00056 virtual point nouveauPoint() =0;
00057
00062 virtual bool fin() = 0;
00063 };
00064
00065
00069 class PointAleatoire : public GPointInitialisation
00070 {
00071 const unsigned long int nbMPointMax;
00072 unsigned long int nbMPoint;
00073 unsigned long int nbPoint;
00074 Random myrand;
00075 double facteurZone;
00077 public:
00084 PointAleatoire(unsigned long int nbMPointMax = 100,double facteurZone = 1.)
00085 :nbMPointMax(nbMPointMax),facteurZone(facteurZone)
00086 {}
00087
00088 void debut()
00089 {
00090
00091 nbPoint = nbMPoint = 0;
00092 }
00093
00094 point nouveauPoint()
00095 {
00096
00097 ++nbPoint;
00098 if( (nbMPoint * 1000000 + nbPoint) % 1000 == 0)
00099 {
00100 std::cout << std::setprecision(2) << std::fixed << std::setw(5) << std::left << 100.* (nbMPoint * 1000000. + nbPoint) /(nbMPointMax* 1000000.) << " % \r" << std::flush;
00101 }
00102
00103 if( nbPoint >= 1000000)
00104 {
00105 ++nbMPoint;
00106 nbPoint = 0;
00107 }
00108
00109 return point
00110 (
00111 m_zone.x - (facteurZone * m_zone.l - m_zone.l) / 2. + facteurZone * m_zone.l * myrand.generateDouble(),
00112 m_zone.y - (facteurZone * m_zone.h - m_zone.l) / 2. + facteurZone * m_zone.h * myrand.generateDouble()
00113 );
00114 }
00115 bool fin()
00116 {
00117
00118 return nbMPoint >= nbMPointMax;
00119 }
00120 };
00121
00125 class PointImage : public GPointInitialisation
00126 {
00127 unsigned int i;
00128 unsigned int j;
00130 public:
00131 void debut()
00132 {
00133
00134 i = j = 0;
00135 }
00136
00137 point nouveauPoint()
00138 {
00139
00140 const point p
00141 (
00142 m_zone.x + m_zone.l * (j + .5) / (m_zone.imgL - 1),
00143 m_zone.y + m_zone.h * (i + .5) / (m_zone.imgH - 1)
00144 );
00145
00146 ++j;
00147
00148 if (j >= m_zone.imgL)
00149 {
00150 std::cout << std::setprecision(2) << std::fixed << std::setw(5) << std::left << 100.* i /m_zone.imgH << " % \r" << std::flush;
00151 ++i;
00152 j = 0;
00153 }
00154
00155 return p;
00156 }
00157
00158 bool fin()
00159 {
00160
00161 return i >= m_zone.imgH ;
00162 }
00163 };
00164
00165
00166 }
00167 #endif