Chaste  Release::3.4
SloughingCellKiller.cpp
1 /*
2 
3 Copyright (c) 2005-2016, University of Oxford.
4 All rights reserved.
5 
6 University of Oxford means the Chancellor, Masters and Scholars of the
7 University of Oxford, having an administrative office at Wellington
8 Square, Oxford OX1 2JD, UK.
9 
10 This file is part of Chaste.
11 
12 Redistribution and use in source and binary forms, with or without
13 modification, are permitted provided that the following conditions are met:
14  * Redistributions of source code must retain the above copyright notice,
15  this list of conditions and the following disclaimer.
16  * Redistributions in binary form must reproduce the above copyright notice,
17  this list of conditions and the following disclaimer in the documentation
18  and/or other materials provided with the distribution.
19  * Neither the name of the University of Oxford nor the names of its
20  contributors may be used to endorse or promote products derived from this
21  software without specific prior written permission.
22 
23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 
34 */
35 #include "SloughingCellKiller.hpp"
36 #include "AbstractCentreBasedCellPopulation.hpp"
37 #include "Exception.hpp"
38 
39 template<unsigned DIM>
40 SloughingCellKiller<DIM>::SloughingCellKiller(AbstractCellPopulation<DIM>* pCrypt, double sloughHeight, bool sloughSides, double sloughWidth)
41  : AbstractCellKiller<DIM>(pCrypt),
42  mSloughSides(sloughSides)
43 {
44  assert(sloughHeight > 0.0);
45  mSloughHeight = sloughHeight;
46 
47  assert(sloughWidth > 0.0);
48  mSloughWidth = sloughWidth;
49 }
50 
51 template<unsigned DIM>
53 {
54  return mSloughSides;
55 }
56 
57 template<unsigned DIM>
59 {
60  return mSloughHeight;
61 }
62 
63 template<unsigned DIM>
65 {
66  return mSloughWidth;
67 }
68 
69 template<unsigned DIM>
71 {
72  switch (DIM)
73  {
74  case 1:
75  {
76  for (typename AbstractCellPopulation<DIM>::Iterator cell_iter = this->mpCellPopulation->Begin();
77  cell_iter != this->mpCellPopulation->End();
78  ++cell_iter)
79  {
80  double x = this->mpCellPopulation->GetLocationOfCellCentre(*cell_iter)[0];
81 
82  if (x > mSloughHeight)
83  {
84  cell_iter->Kill();
85  }
86  }
87  break;
88  }
89  case 2:
90  {
91  for (typename AbstractCellPopulation<DIM>::Iterator cell_iter = this->mpCellPopulation->Begin();
92  cell_iter != this->mpCellPopulation->End();
93  ++cell_iter)
94  {
95  c_vector<double, 2> location = this->mpCellPopulation->GetLocationOfCellCentre(*cell_iter);
96  double x = location[0];
97  double y = location[1];
98 
99  if ((y>mSloughHeight) || (mSloughSides && ((x<0.0) || (x>mSloughWidth))))
100  {
101  cell_iter->Kill();
102  }
103  }
104  break;
105  }
106  case 3:
107  {
108  EXCEPTION("SloughingCellKiller is not yet implemented in 3D");
109  break;
110  }
111  default:
112  // This can't happen
114  }
115 }
116 
117 template<unsigned DIM>
119 {
120  *rParamsFile << "\t\t\t<SloughLength>" << mSloughHeight << "</SloughLength>\n";
121  *rParamsFile << "\t\t\t<SloughSides>" << mSloughSides << "</SloughSides>\n";
122  *rParamsFile << "\t\t\t<SloughWidth>" << mSloughWidth << "</SloughWidth>\n";
123 
124  // Call method on direct parent class
126 }
127 
129 template class SloughingCellKiller<1>;
130 template class SloughingCellKiller<2>;
131 template class SloughingCellKiller<3>;
132 
133 // Serialization for Boost >= 1.36
void OutputCellKillerParameters(out_stream &rParamsFile)
#define EXCEPTION(message)
Definition: Exception.hpp:143
#define NEVER_REACHED
Definition: Exception.hpp:206
virtual void CheckAndLabelCellsForApoptosisOrDeath()
#define EXPORT_TEMPLATE_CLASS_SAME_DIMS(CLASS)
double GetSloughWidth() const
virtual void OutputCellKillerParameters(out_stream &rParamsFile)=0
double GetSloughHeight() const
SloughingCellKiller(AbstractCellPopulation< DIM > *pCrypt, double sloughHeight, bool sloughSides=false, double sloughWidth=10.0)