CellLabelWriter.cpp
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
00030
00031
00032
00033
00034
00035
00036 #include "CellLabelWriter.hpp"
00037 #include "AbstractCellPopulation.hpp"
00038 #include "CellLabel.hpp"
00039
00040 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00041 CellLabelWriter<ELEMENT_DIM, SPACE_DIM>::CellLabelWriter()
00042 : AbstractCellWriter<ELEMENT_DIM, SPACE_DIM>("results.vizlabels")
00043 {
00044 this->mVtkCellDataName = "Cell labels";
00045 }
00046
00047 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00048 double CellLabelWriter<ELEMENT_DIM, SPACE_DIM>::GetCellDataForVtkOutput(CellPtr pCell, AbstractCellPopulation<ELEMENT_DIM, SPACE_DIM>* pCellPopulation)
00049 {
00050 double label = 0.0;
00051 if (pCell->HasCellProperty<CellLabel>())
00052 {
00053 CellPropertyCollection collection = pCell->rGetCellPropertyCollection().GetProperties<CellLabel>();
00054 boost::shared_ptr<CellLabel> p_label = boost::static_pointer_cast<CellLabel>(collection.GetProperty());
00055 label = p_label->GetColour();
00056 }
00057 return label;
00058 }
00059
00060 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00061 void CellLabelWriter<ELEMENT_DIM, SPACE_DIM>::VisitCell(CellPtr pCell, AbstractCellPopulation<ELEMENT_DIM, SPACE_DIM>* pCellPopulation)
00062 {
00063 unsigned label = 0;
00064 if (pCell->HasCellProperty<CellLabel>())
00065 {
00066 CellPropertyCollection collection = pCell->rGetCellPropertyCollection().GetProperties<CellLabel>();
00067 boost::shared_ptr<CellLabel> p_label = boost::static_pointer_cast<CellLabel>(collection.GetProperty());
00068 label = p_label->GetColour();
00069 }
00070
00071 *this->mpOutStream << " " << label;
00072
00073 unsigned location_index = pCellPopulation->GetLocationIndexUsingCell(pCell);
00074 *this->mpOutStream << " " << location_index;
00075
00076 c_vector<double, SPACE_DIM> coords = pCellPopulation->GetLocationOfCellCentre(pCell);
00077 for (unsigned i=0; i<SPACE_DIM; i++)
00078 {
00079 *this->mpOutStream << " " << coords[i];
00080 }
00081 }
00082
00083
00084 template class CellLabelWriter<1,1>;
00085 template class CellLabelWriter<1,2>;
00086 template class CellLabelWriter<2,2>;
00087 template class CellLabelWriter<1,3>;
00088 template class CellLabelWriter<2,3>;
00089 template class CellLabelWriter<3,3>;
00090
00091 #include "SerializationExportWrapperForCpp.hpp"
00092
00093 EXPORT_TEMPLATE_CLASS_ALL_DIMS(CellLabelWriter)