VPTissue Reference Manual
Cell.h
Go to the documentation of this file.
1 #ifndef CELL_H_INCLUDED
2 #define CELL_H_INCLUDED
3 /*
4  * Copyright 2011-2016 Universiteit Antwerpen
5  *
6  * Licensed under the EUPL, Version 1.1 or as soon they will be approved by
7  * the European Commission - subsequent versions of the EUPL (the "Licence");
8  * You may not use this work except in compliance with the Licence.
9  * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl5
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the Licence is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the Licence for the specific language governing
15  * permissions and limitations under the Licence.
16  */
22 #include "CellAttributes.h"
23 #include "GeoData.h"
25 
26 #include <boost/property_tree/ptree.hpp>
27 #include <array>
28 #include <list>
29 #include <memory>
30 #include <vector>
31 
32 namespace SimPT_Editor {
33  class EditableMesh;
34 }
35 
36 namespace SimPT_Sim {
37 
38 using boost::property_tree::ptree;
39 class Edge;
40 class Mesh;
41 class Node;
42 class Wall;
43 
48 class Cell: public CellAttributes
49 {
50 public:
52  virtual ~Cell() {}
53 
55  void AddWall(Wall* w);
56 
58  ptree GeometryToPtree() const;
59 
61  double GetArea() const;
62 
64  double GetSignedArea() const;
65 
67  std::array<double, 3> GetCentroid() const;
68 
70  double GetCircumference() const;
71 
73  GeoData GetGeoData() const;
74 
76  int GetIndex() const { return m_index; }
77 
79  const std::vector<Node*>& GetNodes() const { return m_nodes; }
80 
82  std::vector<Node*>& GetNodes() { return m_nodes; }
83 
85  double GetSumTransporters(unsigned int ch) const;
86 
88  const std::list<Wall*>& GetWalls() const { return m_walls; }
89 
91  std::list<Wall*>& GetWalls() { return m_walls; }
92 
94  bool HasEdge(const Edge& edge) const;
95 
97  bool HasBoundaryWall() const;
98 
100  bool HasNeighborOfTypeZero() const;
101 
103  bool IsBoundaryPolygon() const { return m_index == -1; }
104 
106  bool IsWallNeighbor(Cell* cell) const;
107 
109  //bool IsWallNeighbor(Cell* cell) const { return IsWallNeighbor(cell); }
110 
112  void Move(const std::array<double, 3>& a);
113 
115  bool MoveSelfIntersects(Node* moving_node, std::array<double, 3> new_pos);
116 
118  virtual std::ostream& Print(std::ostream& os) const;
119 
121  virtual void ReadPtree(const ptree& cell_pt);
122 
124  void ReassignWall(Wall* w, Cell* to);
125 
127  void SetGeoDirty();
128 
130  void SetTransporters(unsigned int chem, double conc);
131 
133  void SetTransporters(unsigned int chem, double conc, double lat);
134 
136  void SetTransportersLight(unsigned int chem, double conc, double lat);
137 
138 
140  virtual ptree ToPtree() const;
141 
142 private:
143  friend class Mesh;
144  template<typename T, size_t N>
146  friend class SimPT_Editor::EditableMesh;
147 
148 private:
149  Cell(int index, unsigned int chem_count);
150  Cell(const Cell& src) = delete;
151  Cell& operator=(const Cell& src) = delete;
152 
153 private:
155  void CalculateArea() const;
156 
158  void CalculateCentroid() const;
159 
161  void CalculateGeoData() const;
162 
163 private:
164  int m_index;
165  std::vector<Node*> m_nodes;
166  std::list<Wall*> m_walls;
167 
168 private:
169  mutable bool m_dirty_area;
170  mutable bool m_dirty_centroid;
171  mutable bool m_dirty_geo_data;
172  mutable GeoData m_geo_data;
173 };
174 
175 std::ostream& operator<<(std::ostream& os, Cell const& v);
176 
177 } // namespace
178 
179 #endif // end_of_include_guard
std::list< Wall * > & GetWalls()
Access the cell's walls.
Definition: Cell.h:91
A cell contains walls and nodes.
Definition: Cell.h:48
Namespace for SimPT tissue editor package.
Definition: Cell.h:32
std::vector< Node * > & GetNodes()
Access the nodes of cell's polygon.
Definition: Cell.h:82
Plain data structure with cell geometric data (such as area).
Definition: GeoData.h:35
const std::list< Wall * > & GetWalls() const
Access the cell's walls.
Definition: Cell.h:88
Interface/Implementation for GeoData.
Namespace for the core simulator.
An Edge connects two nodes and is ambidextrous.
Definition: Edge.h:31
double GetCircumference() const
Return the circumference along the edges.
Definition: Cell.cpp:213
ptree GeometryToPtree() const
Convert the cell geometry to a ptree.
Definition: Cell.cpp:161
const std::vector< Node * > & GetNodes() const
Access the nodes of cell's polygon.
Definition: Cell.h:79
bool IsWallNeighbor(Cell *cell) const
Strict neighbor (you're never your own neighbor)
Definition: Cell.cpp:290
double GetSignedArea() const
Return the signed area of the cell.
Definition: Cell.cpp:186
int GetIndex() const
Return the index.
Definition: Cell.h:76
std::array< double, 3 > GetCentroid() const
Return the centroid position.
Definition: Cell.cpp:205
Interface and implementation for SegmentedVector class.
Attributes of Cell.
virtual ptree ToPtree() const
Convert the cell (geometry and attributes) to a ptree.
Definition: Cell.cpp:976
GeoData GetGeoData() const
Return GeData (area, centroid, area moment of inertia).
Definition: Cell.cpp:225
Interface for CellAttributes.
double GetSumTransporters(unsigned int ch) const
Sum transporters at this cell's side of the walls.
Definition: Cell.cpp:233
void Move(const std::array< double, 3 > &a)
Strict neighbor (you're never your own neighbor)
Definition: Cell.cpp:302
An editable mesh with actions to alter the construction of the mesh.
Definition: EditableMesh.h:35
bool MoveSelfIntersects(Node *moving_node, std::array< double, 3 > new_pos)
Check for self-intersection when moving_node gets displaced.
Definition: Cell.cpp:309
double GetArea() const
Return the area of the cell.
Definition: Cell.cpp:178
A cell wall, runs between cell corner points and consists of wall elements.
Definition: Wall.h:48
Container that stores objects "almost contiguously" and guarantees that pointers/iterators are not in...