VPTissue Reference Manual
Perimeter.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2011-2016 Universiteit Antwerpen
3  *
4  * Licensed under the EUPL, Version 1.1 or as soon they will be approved by
5  * the European Commission - subsequent versions of the EUPL (the "Licence");
6  * You may not use this work except in compliance with the Licence.
7  * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl5
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the Licence is distributed on an "AS IS" basis,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the Licence for the specific language governing
13  * permissions and limitations under the Licence.
14  */
20 #include "Perimeter.h"
21 
22 #include "bio/Cell.h"
23 #include "bio/Mesh.h"
24 #include "math/RandomEngine.h"
25 
26 #include <trng/uniform01_dist.hpp>
27 #include <cmath>
28 
29 using namespace std;
30 using namespace boost::property_tree;
31 
32 namespace SimPT_Default {
33 namespace CellDaughters {
34 
35 Perimeter::Perimeter(const CoreData& cd)
36 {
37  Initialize(cd);
38 }
39 
40 void Perimeter::Initialize(const CoreData& cd)
41 {
42  m_cd = cd;
43 
44  const trng::uniform01_dist<double> dist;
45  m_uniform_generator = m_cd.m_random_engine->GetGenerator(dist);
46 }
47 
48 void Perimeter::operator()(Cell* daughter1, Cell* daughter2)
49 {
50  // set one cell to source after first division
51  const unsigned int cell_count = m_cd.m_mesh->GetCells().size();
52  if (cell_count == 2) {
53  daughter1->SetCellType(1);
54  daughter2->SetCellType(0);
55  }
56 
57  // if a source cell has divided, one of the daughters becomes the new source
58  if (daughter1->GetCellType() == 1) {
59  // if both cells are at the tissue perimeter, choose at random
60  if (daughter1->HasBoundaryWall() && daughter2->HasBoundaryWall()) {
61  if (m_uniform_generator() < 0.5) {
62  daughter1->SetCellType(1);
63  daughter2->SetCellType(0);
64  } else {
65  daughter1->SetCellType(0);
66  daughter2->SetCellType(1);
67  }
68  } else {
69  // otherwise choose the one that is still at the perimeter
70  if (daughter1->HasBoundaryWall()) {
71  daughter1->SetCellType(1);
72  daughter2->SetCellType(0);
73  } else {
74  daughter1->SetCellType(0);
75  daughter2->SetCellType(1);
76  }
77  }
78  }
79 }
80 
81 } // namespace
82 } // namespace
Core data with mesh, parameters, random engine and time data.
Definition: CoreData.h:38
STL namespace.
A cell contains walls and nodes.
Definition: Cell.h:48
Interface of RandomEngine.
Namespace for components of the Default model group.
Interface for Cell.
CellDaughters::Perimeter header file.
Interface for Mesh.