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
00027
00028
00029 #include "AbstractCellsGenerator.hpp"
00030
00032
00034
00035 template<unsigned DIM>
00036 bool AbstractCellsGenerator<DIM>::CellsCanDifferentiate()
00037 {
00038 return false;
00039 }
00040
00041 template<unsigned DIM>
00042 void AbstractCellsGenerator<DIM>::GenerateForCrypt(std::vector<TissueCell>& rCells,
00043 TetrahedralMesh<2,2>& rMesh,
00044 const std::vector<unsigned> locationIndices,
00045 bool randomBirthTimes,
00046 double y0,
00047 double y1,
00048 double y2,
00049 double y3,
00050 bool initialiseCells)
00051 {
00052 #define COVERAGE_IGNORE
00053 assert(DIM==2);
00054 #undef COVERAGE_IGNORE
00055
00056 RandomNumberGenerator *p_random_num_gen = RandomNumberGenerator::Instance();
00057
00058 unsigned num_cells = rMesh.GetNumNodes();
00059 if (!locationIndices.empty())
00060 {
00061 num_cells = locationIndices.size();
00062 }
00063
00064 AbstractCellCycleModel *p_cell_cycle_model = NULL;
00065 double typical_transit_cycle_time;
00066 double typical_stem_cycle_time;
00067
00068 rCells.clear();
00069 rCells.reserve(num_cells);
00070
00071 for (unsigned i=0; i<rMesh.GetNumNodes(); i++)
00072 {
00073 CellType cell_type;
00074 unsigned generation;
00075
00076 double y = 0.0;
00077 if (!locationIndices.empty())
00078 {
00079 if ( std::find(locationIndices.begin(), locationIndices.end(), i) != locationIndices.end() )
00080 {
00081 y = rMesh.GetNode(i)->GetPoint().rGetLocation()[1];
00082 }
00083 }
00084 else
00085 {
00086 y = rMesh.GetNode(i)->GetPoint().rGetLocation()[1];
00087 }
00088
00089 p_cell_cycle_model = CreateCellCycleModel();
00090 typical_transit_cycle_time = this->GetTypicalTransitCellCycleTime();
00091 typical_stem_cycle_time = GetTypicalStemCellCycleTime();
00092
00093 double birth_time = 0.0;
00094 if (randomBirthTimes)
00095 {
00096 birth_time = -p_random_num_gen->ranf();
00097 }
00098
00099 if (y <= y0)
00100 {
00101 cell_type = STEM;
00102 generation = 0;
00103 birth_time *= typical_stem_cycle_time;
00104 }
00105 else if (y < y1)
00106 {
00107 cell_type = TRANSIT;
00108 generation = 1;
00109 birth_time *= typical_transit_cycle_time;
00110 }
00111 else if (y < y2)
00112 {
00113 cell_type = TRANSIT;
00114 generation = 2;
00115 birth_time *= typical_transit_cycle_time;
00116 }
00117 else if (y < y3)
00118 {
00119 cell_type = TRANSIT;
00120 generation = 3;
00121 birth_time *= typical_transit_cycle_time;
00122 }
00123 else
00124 {
00125 cell_type = CellsCanDifferentiate() ? DIFFERENTIATED : TRANSIT;
00126 generation = 4;
00127 birth_time *= typical_transit_cycle_time;
00128 }
00129
00130 if (dynamic_cast<AbstractSimpleGenerationBasedCellCycleModel*>(p_cell_cycle_model))
00131 {
00132 static_cast<AbstractSimpleGenerationBasedCellCycleModel*>(p_cell_cycle_model)->SetGeneration(generation);
00133 }
00134
00135 TissueCell cell(cell_type, HEALTHY, p_cell_cycle_model);
00136 if (initialiseCells)
00137 {
00138 cell.InitialiseCellCycleModel();
00139 }
00140
00141 cell.SetBirthTime(birth_time);
00142
00143 if (!locationIndices.empty())
00144 {
00145 if ( std::find(locationIndices.begin(), locationIndices.end(), i) != locationIndices.end() )
00146 {
00147 rCells.push_back(cell);
00148 }
00149 }
00150 else
00151 {
00152 rCells.push_back(cell);
00153 }
00154 }
00155 }
00156
00157 template<unsigned DIM>
00158 void AbstractCellsGenerator<DIM>::GenerateBasic(std::vector<TissueCell>& rCells,
00159 const unsigned numCells)
00160 {
00161 rCells.clear();
00162 rCells.reserve(numCells);
00163
00164 for (unsigned i=0; i<numCells; i++)
00165 {
00166 AbstractCellCycleModel *p_cell_cycle_model = CreateCellCycleModel();
00167 TissueCell cell(STEM, HEALTHY, p_cell_cycle_model);
00168 double birth_time = 0.0 - i;
00169 cell.SetBirthTime(birth_time);
00170 rCells.push_back(cell);
00171 }
00172 }
00173
00175
00177
00178 template class AbstractCellsGenerator<1>;
00179 template class AbstractCellsGenerator<2>;
00180 template class AbstractCellsGenerator<3>;