35#include "CryptStatistics.hpp"
36#include "RandomNumberGenerator.hpp"
42bool CellsHeightComparison(
const std::pair<CellPtr, double> lhs,
const std::pair<CellPtr, double> rhs)
44 return lhs.second < rhs.second;
57 if (xBottom == DBL_MAX)
68 std::list<std::pair<CellPtr, double> > cells_list;
70 if (fabs(xTop-xBottom)<0.5*crypt_width)
87 cells_list.push_back(pair);
96 cells_list.push_back(pair);
102 cells_list.sort(CellsHeightComparison);
105 std::vector<CellPtr> ordered_cells;
106 for (std::list<std::pair<CellPtr, double> >::iterator iter = cells_list.begin();
107 iter!=cells_list.end();
110 ordered_cells.push_back(iter->first);
113 return ordered_cells;
122 c_vector<double,2> intercept;
127 intercept[1] = rCellPosition[1];
131 double m = (yTop)/(xTop-xBottom);
133 intercept[0] = (m*m*xBottom + rCellPosition[0] + m*rCellPosition[1])/(1+m*m);
134 intercept[1] = m*(intercept[0] - xBottom);
137 c_vector<double,2> vec_from_A_to_B =
mrCrypt.
rGetMesh().GetVectorFromAtoB(intercept, rCellPosition);
138 double dist = norm_2(vec_from_A_to_B);
140 return (dist <= widthOfSection);
145 bool is_in_section =
false;
147 c_vector<double,2> intercept;
155 offset = -crypt_width;
159 offset = crypt_width;
162 m = (yTop)/(xTop-xBottom+offset);
165 intercept[0] = (m*m*xBottom + rCellPosition[0] + m*rCellPosition[1])/(1+m*m);
166 intercept[1] = m*(intercept[0] - xBottom);
168 c_vector<double,2> vec_from_A_to_B =
mrCrypt.
rGetMesh().GetVectorFromAtoB(intercept, rCellPosition);
169 double dist = norm_2(vec_from_A_to_B);
171 if (dist < widthOfSection)
173 is_in_section =
true;
177 intercept[0] = (m*m*(xBottom-offset) + rCellPosition[0] + m*rCellPosition[1])/(1+m*m);
178 intercept[1] = m*(intercept[0] - (xBottom-offset));
180 vec_from_A_to_B =
mrCrypt.
rGetMesh().GetVectorFromAtoB(intercept, rCellPosition);
181 dist = norm_2(vec_from_A_to_B);
183 if (dist < widthOfSection)
185 is_in_section =
true;
188 return is_in_section;
c_vector< double, SPACE_DIM > GetLocationOfCellCentre(CellPtr pCell)
MeshBasedCellPopulation< 2 > & mrCrypt
bool CellIsInSectionPeriodic(double xBottom, double xTop, double yTop, const c_vector< double, 2 > &rCellPosition, double widthOfSection=1.0)
std::vector< CellPtr > GetCryptSectionPeriodic(double yTop, double xBottom=DBL_MAX, double xTop=DBL_MAX)
std::vector< CellPtr > GetCryptSection(double yTop, double xBottom=DBL_MAX, double xTop=DBL_MAX, bool periodic=false)
bool CellIsInSection(double xBottom, double xTop, double yTop, const c_vector< double, 2 > &rCellPosition, double widthOfSection=0.5)
CryptStatistics(MeshBasedCellPopulation< 2 > &rCrypt)
MutableMesh< ELEMENT_DIM, SPACE_DIM > & rGetMesh()
static RandomNumberGenerator * Instance()