MorphoGraphX  2.0-1-227
HejnowiczSurface.hpp
Go to the documentation of this file.
1 //
2 // This file is part of MorphoGraphX - http://www.MorphoGraphX.org
3 // Copyright (C) 2012-2016 Richard S. Smith and collaborators.
4 //
5 // If you use MorphoGraphX in your work, please cite:
6 // http://dx.doi.org/10.7554/eLife.05864
7 //
8 // MorphoGraphX is free software, and is licensed under under the terms of the
9 // GNU General (GPL) Public License version 2.0, http://www.gnu.org/licenses.
10 //
11 
12 #ifndef HEJNOWICZ_SURFACE_HPP
13 #define HEJNOWICZ_SURFACE_HPP
14 
15 #include <Surface.hpp>
16 #include <Function.hpp>
17 
18 namespace mgx
19 {
28  class mgxBase_EXPORT HejnowiczSurface : public Surface
29  {
30  public:
32  enum ParmNames { puS, pvR, pA, pC, pD, pScale, pLength, pGrowthScale, pGrowthType, pGrowthFunc, pNumParms };
33 
35  struct VertexData
36  {
38  VertexData() : nrs(0,0) {}
39 
40  bool operator==(const VertexData &other) const
41  {
42  if(nrs == other.nrs)
43  return true;
44  return false;
45  }
46  };
47 
50 
52  class mgxBase_EXPORT Subdivide : virtual public mgx::Subdivide
53  {
54  public:
56  : vertexData(vData), surface(surf) {}
57 
58  virtual bool updateEdgeData(vertex l, vertex v, vertex r, double s);
59 
62  };
63 
64  // ALR: Constructor should fill in default values, like in FemMGXM
65  HejnowiczSurface() : growthType(GROWTH_HEJN) {}
67 
68  static QStringList parmNames()
69  {
70  QVector <QString> vec(pNumParms);
71 
72  vec[puS] = "uS";
73  vec[pvR] = "vR";
74  vec[pA] = "A";
75  vec[pC] = "C";
76  vec[pD] = "D";
77  vec[pScale] = "Scale";
78  vec[pLength] = "Length";
79  vec[pGrowthScale] = "Growth Scale";
80  vec[pGrowthType] = "Growth Type";
81  vec[pGrowthFunc] = "Growth Function";
82 
83  return vec.toList();
84  }
85 
86  static QStringList parmDescs()
87  {
88  QVector <QString> vec(pNumParms);
89 
90  vec[puS] = "uS";
91  vec[pvR] = "vR";
92  vec[pA] = "A";
93  vec[pC] = "C";
94  vec[pD] = "D";
95  vec[pScale] = "Surface scaling";
96  vec[pLength] = "Surface length";
97  vec[pGrowthScale] = "Growth scale";
98  vec[pGrowthType] = "Growth type";
99  vec[pGrowthFunc] = "Growth function file, clear for growth model 2 from Hejnowicz et al. 1993.";
100 
101  return vec.toList();
102  }
103 
104  static QStringList parmDefaults()
105  {
106  QVector <QString> vec(pNumParms);
107 
108  vec[puS] = "0.45";
109  vec[pvR] = "0.785398163"; // PI/4
110  vec[pA] = "0.0";
111  vec[pC] = "1.0";
112  vec[pD] = "0.3";
113  vec[pScale] = "1000.0";
114  vec[pLength] = "2000.0";
115  vec[pGrowthScale] = "1000.0";
116  vec[pGrowthType] = "Hejnowicz";
117  vec[pGrowthFunc] = "HejnowiczGrowth.func";
118 
119  return vec.toList();
120  }
121 
123  bool processParms(const QStringList &parms);
124 
127  bool setPoint(vertex p, vertex sp, Point3d cp);
128 
130  bool updatePos(vertex p);
131 
133  bool updateNormal(vertex p);
134 
136  bool initialCell(CellTissue &T,
137  const Point2d &top, const Point2d &bottom, const Point2d &middle);
138 
139  // Methods for Hejnowicz surface
140 
142  bool initialize(VertexAttr *vData, const QStringList &parms);
143 
145  bool growPoint(vertex p, double dt, double time);
146 
148  Point3d localToCartesian(const Point2d &local);
149 
151  bool cartesianToLocal(const Point3d &cartesian, Point2d &local);
152 
154  bool setGrowthMap(std::map<double, double> &growthMap);
155 
156  private:
157  enum GrowthType {GROWTH_HEJN, GROWTH_FUNC, GROWTH_MAP};
158 
159  // Integrate growth function
160  bool setupGrowth();
161  // Function interface into the growth map table, used by integrator.
162  double growthMapFunc(double s);
163 
164  // vertex attributes required for simulation
165  VertexAttr *vertexData;
166 
167  // Parameters as in Hejnowicz and Karczewski 1993
168  double uS;
169  double vR;
170  double A;
171  double C;
172  double D;
173  double scale;
174  double length;
175  double growthScale;
176  QString growthFuncFile;
177 
178  GrowthType growthType;
179  Function growthFunc;
180 
181  double nrsLength; // Length of root domain in NRS coordinates
182  std::vector<double> growthTab; // table for map (morphogen) driven growth
183  std::vector<double> velocityCart; // speed of point movement in Cartesian coordinates
184  std::vector<double> velocityNRS; // speed of point movement in NRS coordinates
185  };
186 
188  bool inline readAttr(HejnowiczSurface::VertexData &m, const QByteArray &ba, size_t &pos)
189  {
190  return readChar((char *)&m, sizeof(HejnowiczSurface::VertexData), ba, pos);
191  }
193  bool inline writeAttr(const HejnowiczSurface::VertexData &m, QByteArray &ba)
194  {
195  return writeChar((char *)&m, sizeof(HejnowiczSurface::VertexData), ba);
196  }
197 }
198 #endif
199 
mgx::HejnowiczSurface::ParmNames
ParmNames
Parameter names as in Hejnowicz and Karczewski 1993.
Definition: HejnowiczSurface.hpp:32
mgx::HejnowiczSurface::VertexAttr
AttrMap< vertex, VertexData > VertexAttr
Attribute map for vertex data required by the surface.
Definition: HejnowiczSurface.hpp:49
mgx::HejnowiczSurface
Definition: HejnowiczSurface.hpp:28
mgx::HejnowiczSurface::Subdivide::vertexData
VertexAttr * vertexData
Definition: HejnowiczSurface.hpp:60
mgx::HejnowiczSurface::parmDefaults
static QStringList parmDefaults()
Definition: HejnowiczSurface.hpp:104
mgx::CellTissue
Definition: CellTissue.hpp:46
mgx::HejnowiczSurface::HejnowiczSurface
HejnowiczSurface()
Definition: HejnowiczSurface.hpp:65
mgx::HejnowiczSurface::parmDescs
static QStringList parmDescs()
Definition: HejnowiczSurface.hpp:86
mgx
Distributed matrix library.
Definition: Assert.hpp:26
Surface.hpp
mgx::HejnowiczSurface::VertexData
Hejnowicz vertex attribute data needed for simulations.
Definition: HejnowiczSurface.hpp:35
mgx::HejnowiczSurface::VertexData::VertexData
VertexData()
Definition: HejnowiczSurface.hpp:38
mgx::HejnowiczSurface::Subdivide::Subdivide
Subdivide(VertexAttr *vData, HejnowiczSurface *surf)
Definition: HejnowiczSurface.hpp:55
mgx::HejnowiczSurface::Subdivide
Class to define methods for subdivision.
Definition: HejnowiczSurface.hpp:52
mgx::HejnowiczSurface::parmNames
static QStringList parmNames()
Definition: HejnowiczSurface.hpp:68
mgx::HejnowiczSurface::VertexData::nrs
Point2d nrs
Definition: HejnowiczSurface.hpp:37
mgx::HejnowiczSurface::~HejnowiczSurface
~HejnowiczSurface()
Definition: HejnowiczSurface.hpp:66
mgx::Vector< 2, double >
mgx::Surface
Definition: Surface.hpp:23
mgx::HejnowiczSurface::Subdivide::surface
HejnowiczSurface * surface
Definition: HejnowiczSurface.hpp:61
Function.hpp
mgx::writeAttr
bool writeAttr(const T &data, QByteArray &ba)
Write the attribute value from a QByteArray.
Definition: Attributes.hpp:510
mgx::Subdivide
Definition: Subdivide.hpp:25
mgx::readAttr
bool readAttr(T &data, const QByteArray &ba, size_t &pos)
Read the attribute value from a QByteArray.
Definition: Attributes.hpp:244
mgx::HejnowiczSurface::VertexData::operator==
bool operator==(const VertexData &other) const
Definition: HejnowiczSurface.hpp:40
mgx::AttrMap
Attribute map wraps std::map.
Definition: Attributes.hpp:686
mgx::HejnowiczSurface::pvR
@ pvR
Definition: HejnowiczSurface.hpp:32
mgx::Vertex
Definition: Vertex.hpp:58