36 #include "CellPopulationAdjacencyMatrixWriter.hpp" 38 #include "AbstractCellPopulation.hpp" 39 #include "MeshBasedCellPopulation.hpp" 40 #include "CaBasedCellPopulation.hpp" 41 #include "NodeBasedCellPopulation.hpp" 42 #include "PottsBasedCellPopulation.hpp" 43 #include "VertexBasedCellPopulation.hpp" 45 #include "CellLabel.hpp" 47 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
53 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
63 std::map<unsigned,unsigned> local_cell_id_location_index_map;
65 unsigned local_cell_id = 0;
67 cell_iter != pCellPopulation->
End();
73 assert(local_cell_id = num_cells+1);
76 std::vector<double> adjacency_matrix(num_cells*num_cells);
77 for (
unsigned i=0; i<num_cells*num_cells; i++)
79 adjacency_matrix[i] = 0;
83 cell_iter != pCellPopulation->
End();
87 bool cell_is_labelled = cell_iter->template HasCellProperty<CellLabel>();
96 if (!neighbour_indices.empty())
98 unsigned local_cell_index = local_cell_id_location_index_map[index];
100 for (std::set<unsigned>::iterator neighbour_iter = neighbour_indices.begin();
101 neighbour_iter != neighbour_indices.end();
105 unsigned type_of_link = 1;
109 bool neighbour_is_labelled = p_neighbour_cell->template HasCellProperty<CellLabel>();
111 if (cell_is_labelled != neighbour_is_labelled)
116 else if (cell_is_labelled)
122 unsigned local_neighbour_index = local_cell_id_location_index_map[*neighbour_iter];
123 adjacency_matrix[local_cell_index + num_cells*local_neighbour_index] = type_of_link;
124 adjacency_matrix[num_cells*local_cell_index + local_neighbour_index] = type_of_link;
131 for (
unsigned i=0; i<num_cells*num_cells; i++)
137 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
142 pCellPopulation->
Update();
147 std::map<unsigned,unsigned> local_cell_id_location_index_map;
149 unsigned local_cell_id = 0;
151 cell_iter != pCellPopulation->
End();
157 assert(local_cell_id = num_cells+1);
160 std::vector<double> adjacency_matrix(num_cells*num_cells);
161 for (
unsigned i=0; i<num_cells*num_cells; i++)
163 adjacency_matrix[i] = 0;
167 cell_iter != pCellPopulation->
End();
171 bool cell_is_labelled = cell_iter->template HasCellProperty<CellLabel>();
180 if (!neighbour_indices.empty())
182 unsigned local_cell_index = local_cell_id_location_index_map[index];
184 for (std::set<unsigned>::iterator neighbour_iter = neighbour_indices.begin();
185 neighbour_iter != neighbour_indices.end();
189 unsigned type_of_link = 1;
193 bool neighbour_is_labelled = p_neighbour_cell->template HasCellProperty<CellLabel>();
195 if (cell_is_labelled != neighbour_is_labelled)
200 else if (cell_is_labelled)
206 unsigned local_neighbour_index = local_cell_id_location_index_map[*neighbour_iter];
207 adjacency_matrix[local_cell_index + num_cells*local_neighbour_index] = type_of_link;
208 adjacency_matrix[num_cells*local_cell_index + local_neighbour_index] = type_of_link;
215 for (
unsigned i=0; i<num_cells*num_cells; i++)
221 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
226 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
232 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
238 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
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)