VPTissue Reference Manual
CellAttributes.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 "CellAttributes.h"
21 
22 #include "BoundaryType.h"
23 #include "util/misc/Exception.h"
24 #include "util/misc/log_debug.h"
25 
26 #include <iostream>
27 
28 namespace SimPT_Sim {
29 
30 using namespace std;
31 using namespace boost::property_tree;
32 using boost::optional;
33 using namespace SimPT_Sim::Util;
34 
35 CellAttributes::CellAttributes(unsigned int chem_count)
36  : m_boundary_type(BoundaryType::None), m_cell_type(0),
37  m_chem(chem_count), m_dead(false), m_div_counter(0), m_div_time(10000), m_fixed(false),
38  m_solute(0.0), m_stiffness(0.0), m_target_area(1.0), m_target_length(0.0)
39 {
40 }
41 
42 double CellAttributes::GetChemical(unsigned int c) const
43 {
44  assert( (c < m_chem.size()) && "CellAttributes::GetChemical> chemical index out of bounds!");
45  return m_chem[c];
46 }
47 
48 ostream& CellAttributes::Print(ostream& os) const
49 {
50  os << "CellAttributes: {" << endl;
51  os << "\t chemicals: [ ";
52  for (auto const& c : m_chem) {
53  os << c << " , ";
54  }
55  os << " ]" << endl;
56  os << "\t div_counter = " << m_div_counter << endl;
57  os << "\t cell_type = " << m_cell_type << endl;
58  os << "}";
59  return os;
60 }
61 
62 void CellAttributes::ReadPtree(const ptree& cell_pt)
63 {
64  try {
65  m_boundary_type = FromString<BoundaryType>(cell_pt.get<string>("boundary", "None"));
66  m_cell_type = cell_pt.get<unsigned int>("type");
67  m_dead = cell_pt.get<bool>("dead");
68  m_div_counter = cell_pt.get<unsigned int>("division_count", 0U);
69  m_fixed = cell_pt.get<bool>("fixed");
70  m_solute = cell_pt.get<double>("solute");
71  m_stiffness = cell_pt.get<double>("stiffness");
72  m_target_area = cell_pt.get<double>("target_area");
73  m_target_length = cell_pt.get<double>("target_length");
74 
75  optional<ptree const&> chemical_array_pt = cell_pt.get_child_optional("chemical_array");
76  if (chemical_array_pt) {
77  assert( (m_chem.size() == chemical_array_pt->size())
78  && "size of chemical_array in xml file does not match chemical_count");
79  unsigned int chem_i = 0;
80  for (auto const& chem_v : *chemical_array_pt) {
81  m_chem[chem_i++] = chem_v.second.get_value<double>();
82  }
83  }
84  }
85  catch(exception& e) {
86  const string here = string(VL_HERE) + " exception:\n";
87  throw Exception(here + e.what());
88  }
89 }
90 
91 void CellAttributes::SetChemical(unsigned int c, double conc)
92 {
93  assert( (c < m_chem.size()) && "CellAttributes::SetChemical> chemical index out of bounds!");
94  m_chem[c] = conc;
95 }
96 
97 void CellAttributes::SetChemicals(vector<double> const& chem)
98 {
99  assert((chem.size() == m_chem.size()) && "CellAttributes::SetChemicals> vector size inconsistent!");
100  m_chem = chem;
101 }
102 
104 {
105  ptree ret;
106  ret.put("boundary", ToString(m_boundary_type));
107  ret.put("dead", m_dead);
108  ret.put("division_count", m_div_counter);
109  ret.put("fixed", m_fixed);
110  ret.put("solute", m_solute);
111  ret.put("stiffness", m_stiffness);
112  ret.put("target_area", m_target_area);
113  ret.put("target_length", m_target_length);
114  ret.put("type", m_cell_type);
115 
116  for (const auto& chem : m_chem) {
117  ret.add("chemical_array.chemical", chem);
118  }
119 
120  return ret;
121 }
122 
123 ostream& operator<<(ostream& os, CellAttributes const& c)
124 {
125  c.Print(os);
126  return os;
127 }
128 
129 } // namespace
double m_stiffness
Stiffness like in Hogeweg (2000).
STL namespace.
Namespace for miscellaneous utilities.
Definition: PTreeFile.cpp:44
string ToString(Type w)
Converts a WallType::Type value to corresponding name.
Definition: WallType.cpp:49
bool m_dead
For future use, when apoptosis gets set up.
Extremely simple Exception root class.
Definition: Exception.h:28
Namespace for the core simulator.
int m_div_counter
Keep track of divisions in the cell ancestry.
Macro defs for debug and logging.
BoundaryType
Enumerates cell boundary types.
Definition: BoundaryType.h:34
BoundaryType enumeration class.
virtual boost::property_tree::ptree ToPtree() const
Convert the cell attributes to a ptree.
Attributes of Cell.
Interface for CellAttributes.
Header file for Exception class.