36 #include "CellPopulationAdjacencyMatrixWriter.hpp"
37 #include "AbstractCellPopulation.hpp"
38 #include "MeshBasedCellPopulation.hpp"
39 #include "CaBasedCellPopulation.hpp"
40 #include "NodeBasedCellPopulation.hpp"
41 #include "PottsBasedCellPopulation.hpp"
42 #include "VertexBasedCellPopulation.hpp"
44 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
50 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
60 std::map<unsigned,unsigned> local_cell_id_location_index_map;
62 unsigned local_cell_id = 0;
64 cell_iter != pCellPopulation->
End();
70 assert(local_cell_id = num_cells+1);
73 std::vector<double> adjacency_matrix(num_cells*num_cells);
74 for (
unsigned i=0; i<num_cells*num_cells; i++)
76 adjacency_matrix[i] = 0;
80 cell_iter != pCellPopulation->
End();
84 bool cell_is_labelled = cell_iter->template HasCellProperty<CellLabel>();
93 if (!neighbour_indices.empty())
95 unsigned local_cell_index = local_cell_id_location_index_map[index];
97 for (std::set<unsigned>::iterator neighbour_iter = neighbour_indices.begin();
98 neighbour_iter != neighbour_indices.end();
102 unsigned type_of_link = 1;
106 bool neighbour_is_labelled = p_neighbour_cell->template HasCellProperty<CellLabel>();
108 if (cell_is_labelled != neighbour_is_labelled)
113 else if (cell_is_labelled)
119 unsigned local_neighbour_index = local_cell_id_location_index_map[*neighbour_iter];
120 adjacency_matrix[local_cell_index + num_cells*local_neighbour_index] = type_of_link;
121 adjacency_matrix[num_cells*local_cell_index + local_neighbour_index] = type_of_link;
127 *this->mpOutStream << num_cells <<
"\t";
128 for (
unsigned i=0; i<num_cells*num_cells; i++)
130 *this->mpOutStream << adjacency_matrix[i] <<
"\t";
134 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
139 pCellPopulation->
Update();
144 std::map<unsigned,unsigned> local_cell_id_location_index_map;
146 unsigned local_cell_id = 0;
148 cell_iter != pCellPopulation->
End();
154 assert(local_cell_id = num_cells+1);
157 std::vector<double> adjacency_matrix(num_cells*num_cells);
158 for (
unsigned i=0; i<num_cells*num_cells; i++)
160 adjacency_matrix[i] = 0;
164 cell_iter != pCellPopulation->
End();
168 bool cell_is_labelled = cell_iter->template HasCellProperty<CellLabel>();
177 if (!neighbour_indices.empty())
179 unsigned local_cell_index = local_cell_id_location_index_map[index];
181 for (std::set<unsigned>::iterator neighbour_iter = neighbour_indices.begin();
182 neighbour_iter != neighbour_indices.end();
186 unsigned type_of_link = 1;
190 bool neighbour_is_labelled = p_neighbour_cell->template HasCellProperty<CellLabel>();
192 if (cell_is_labelled != neighbour_is_labelled)
197 else if (cell_is_labelled)
203 unsigned local_neighbour_index = local_cell_id_location_index_map[*neighbour_iter];
204 adjacency_matrix[local_cell_index + num_cells*local_neighbour_index] = type_of_link;
205 adjacency_matrix[num_cells*local_cell_index + local_neighbour_index] = type_of_link;
211 *this->mpOutStream << num_cells <<
"\t";
212 for (
unsigned i=0; i<num_cells*num_cells; i++)
214 *this->mpOutStream << adjacency_matrix[i] <<
"\t";
218 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
223 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
226 VisitAnyPopulation(pCellPopulation);
229 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
232 VisitAnyPopulation(pCellPopulation);
235 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
238 VisitAnyPopulation(pCellPopulation);
virtual CellPtr GetCellUsingLocationIndex(unsigned index)
unsigned GetLocationIndexUsingCell(CellPtr pCell)
unsigned GetNumRealCells()
virtual std::set< unsigned > GetNeighbouringLocationIndices(CellPtr pCell)=0
void VisitAnyPopulation(AbstractCellPopulation< SPACE_DIM, SPACE_DIM > *pCellPopulation)
CellPopulationAdjacencyMatrixWriter()
virtual std::set< unsigned > GetNeighbouringLocationIndices(CellPtr pCell)
virtual void Update(bool hasHadBirthsOrDeaths=true)
#define EXPORT_TEMPLATE_CLASS_ALL_DIMS(CLASS)
virtual void Update(bool hasHadBirthsOrDeaths=true)=0
virtual void Visit(MeshBasedCellPopulation< ELEMENT_DIM, SPACE_DIM > *pCellPopulation)