00001
00002
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 "mainpage.h"
00027
00029 #ifndef _CA_HH_
00030 #define _CA_HH_
00031 #include <vector>
00032 #include <stdio.h>
00033 #include "graph.h"
00034 #include "pde.h"
00035
00036 #include "cell.h"
00037
00038 class Dish;
00039
00040 class Dir {
00041
00042
00043 friend class CellularPotts;
00044 public:
00045
00046 Dir() {
00047 aa1=0.; aa2=0.;
00048 bb1=0.; bb2=0.;
00049 lb1=0.; lb2=0.;
00050 }
00051
00052 double aa1,aa2;
00053 double bb1,bb2;
00054 double lb1,lb2;
00055 };
00056
00057 class CellularPotts {
00058
00059 friend class Info;
00060 friend class Morphometry;
00061
00062 public:
00064 CellularPotts(std::vector<Cell> *cells, const int sizex=200,
00065 const int sizey=200 );
00066
00067
00068 CellularPotts(void);
00069
00070
00071
00072
00073
00074 virtual void AllocateSigma(int sx, int sy);
00075
00076
00077 virtual ~CellularPotts();
00078
00086 int **SearchNandPlot(Graphics *g=0, bool get_neighbours=true);
00087
00089 inline void Plot(Graphics *g) {
00090 SearchNandPlot(g, false);
00091 }
00092
00094 inline int **SearchNeighbours(void) {
00095 return SearchNandPlot(0, true);
00096 }
00097
00099 inline int Mass(void) {
00100 int mass=0;
00101 for (int i=0;i<sizex*sizey;i++) {
00102 if (sigma[0][i]>0) mass++;
00103 }
00104 return mass;
00105 }
00106
00111 void PlotSigma(Graphics *g, int mag=2);
00112
00113
00115 void DivideCells(void) {
00116 std::vector<bool> tmp;
00117 DivideCells(tmp);
00118 }
00119
00128 void DivideCells(std::vector<bool> which_cells);
00129
00133 int AmoebaeMove(PDE *PDEfield=0);
00134
00139 void ReadZygotePicture(void);
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149 void ConstructInitCells(Dish &beast);
00150
00152 inline int Time() const {
00153 return thetime;
00154 }
00155
00156
00157
00158
00159 inline int ZygoteArea() const {
00160 return zygote_area;
00161 }
00162
00164 inline int SizeX() const {
00165 return sizex;
00166 }
00167
00169 inline int SizeY() const {
00170 return sizey;
00171 }
00172
00176 inline int Sigma(const int x, const int y) const {
00177 return sigma[x][y];
00178 }
00179
00180
00181
00182 void Replace(Graphics *g);
00183
00189 Dir *FindCellDirections(void) const;
00190
00193 int ThrowInCells(int n, int cellsize);
00194
00202 int GrowInCells(int n_cells, int cellsize, double subfield=1.);
00203 int GrowInCells(int n_cells, int cell_size, int sx, int sy, int offset_x, int offset_y);
00204
00206 inline Cell &CellularPotts::AddCell(Dish &beast) {
00207 cell->push_back(Cell(beast));
00208 return cell->back();
00209 }
00215 void ShowDirections(Graphics &g, const Dir *celldir) const;
00216
00218 double MeanCellArea(void) const;
00219
00224 double CellDensity(void) const;
00225
00227 void ResetTargetLengths(void);
00228
00229 int spins_converted;
00230
00236 void SetRandomTypes(void);
00237
00241 void GrowAndDivideCells(int growth_rate);
00242
00243 inline Cell &getCell(int c) {
00244 return (*cell)[c];
00245 }
00246
00250 double DrawConvexHull(Graphics *g, int color=1);
00251
00256 double Compactness(double *res_compactness = 0,
00257 double *res_area = 0,
00258 double *res_cell_area = 0);
00259
00260 private:
00261 void IndexShuffle(void);
00262 int DeltaH(int x,int y, int xp, int yp, PDE *PDEfield=0);
00263 bool Probability(int DH);
00264 void ConvertSpin(int x,int y,int xp,int yp);
00265 void SprayMedium(void);
00266 int CopyvProb(int DH, double stiff);
00267 void FreezeAmoebae(void);
00268 void MeasureCellSizes(void);
00269 void MeasureCellSize(Cell &c);
00270 void CopyProb(double T);
00271 bool ConnectivityPreservedP(int x, int y);
00272
00273
00274 inline void PrintSite(int x,int y) {
00275 std::cerr << "--------\n";
00276 std::cerr << "[" << sigma[x-1][y-1] << " " << sigma[x][y-1] << " " << sigma[x+1][y-1] << "]\n";
00277 std::cerr << "[" << sigma[x-1][y] << " " << sigma[x][y] << " " << sigma[x+1][y] << "]\n";
00278 std::cerr << "[" << sigma[x-1][y+1] << " " << sigma[x][y+1] << " " << sigma[x+1][y+1] << "]\n";
00279 }
00280
00281 protected:
00282 void BaseInitialisation(std::vector<Cell> *cell);
00283
00284 protected:
00285 int **sigma;
00286 int sizex;
00287 int sizey;
00288
00289
00290 private:
00291 bool frozen;
00292 static const int nx[25], ny[25];
00293 static const int nbh_level[5];
00294 static int shuffleindex[9];
00295 std::vector<Cell> *cell;
00296 int zygote_area;
00297 int thetime;
00298 int n_nb;
00299 };
00300
00301
00302 #endif