MorphoGraphX  2.0-1-227
PolarSurface.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 // Surface class
13 #ifndef POLAR_SURFACE_HPP
14 #define POLAR_SURFACE_HPP
15 
16 #include <Surface.hpp>
17 #include <Attributes.hpp>
18 #include <Function.hpp>
19 
20 namespace mgx
21 {
22  // for the polar surfaces:
23  const int SAMPLES = 10000; // Sample count for function/contours in PolarSurface
24 
25  /*
26  * \class PolarSurface Surface.hpp <Surface.hpp>
27  *
28  * Growing surface using cylindrical coordinates on a contour
29  *
30  * \ingroup GrowingSurfaceProcesses
31  */
32  class mgxBase_EXPORT PolarSurface : public Surface
33  {
34  public:
35  // Parameter names
36  enum ParmNames { pGrowthType, pSurfaceContour, pArcLengthGrowth, pSurfaceScale,
37  pGrowthScaleInMult, pGrowthScaleOutMult, pGrowthScaleFunc, pRootSearchMaxSteps, pNumParms };
38 
39  // Polar vertex attribute data needed for simulations
40  struct VertexData
41  {
42  double arcLength;
43  double angle;
44  // Constructor, set initial values
45  VertexData() : arcLength(0), angle(0) {}
46 
47  bool operator==(const VertexData &other) const
48  {
49  if(arcLength == other.arcLength and angle == other.angle)
50  return true;
51  return false;
52  }
53  };
54 
55  // Define attribute map
57 
58  // Class to define methods for subdivision
59  class mgxBase_EXPORT Subdivide : virtual public mgx::Subdivide
60  {
61  public:
63  : vertexAttr(vAttr), surface(surf) {}
64 
65  protected:
66  virtual bool updateEdgeData(vertex l, vertex v, vertex r, double s);
67 
68  private:
69  VertexAttr *vertexAttr;
70  PolarSurface *surface;
71  };
72 
73  // ALR: Constructor should fill in default values, like in FemMGXM
75  // ALR: is it important to have a destructor? FemMGXM doesn't have one
77 
78  bool processParms(const QStringList &parms);
79  bool setPoint(vertex p, vertex sp, Point3d cp);
80  bool updatePos(vertex p);
81  bool updateNormal(vertex p);
82  bool initialCell(CellTissue &T, double radius, int sides);
83  bool initialize(VertexAttr *vData, const QStringList &parms);
84  bool growPoint(vertex p, double dt, double time);
85 
86  private:
87  // vertex attributes required for simulation
88  VertexAttr *vertexAttr;
89 
90  bool loadFunction(const QString &funcFile, double *v);
91  bool integrateFunction(const QString &funcFile, double *v);
92  bool arcLengthParam(const QString &contFile, Point3d *v);
93  Point3d polarToCart(double arcLength, double angle);
94 
95 
96  double dArc; // arclength diff between points in posV
97  Point3d dPos; // amount to add for next point extrapolate
98  Point3d arcLV[SAMPLES + 1]; // Pos vec, param by arclength
99  double growthVA[SAMPLES + 1]; // Growth vector, param by arclength
100 
101  // Parameters
102  int growthType;
103  double surfaceScale; // Contour scaling constant
104  Function *growthScaleFunc;
105  QString growthScaleFile; // Growth scaling function
106  double growthScaleOutMult;
107  double growthScaleInMult;
108  QString arcLengthGrowthFile; // Arc length growth function file name
109  QString surfaceContourFile; // Surface Contour file name
110  int rootSearchMaxSteps; // Max steps for closest point on surface
111  };
112 
113 
114  // Read/write Vertex data
115  bool inline readAttr(PolarSurface::VertexData &m, const QByteArray &ba, size_t &pos)
116  {
117  return readChar((char *)&m, sizeof(PolarSurface::VertexData), ba, pos);
118  }
119  bool inline writeAttr(const PolarSurface::VertexData &m, QByteArray &ba)
120  {
121  return writeChar((char *)&m, sizeof(PolarSurface::VertexData), ba);
122  }
123 
124  }
125 #endif
126 
Attributes.hpp
mgx::SAMPLES
const int SAMPLES
Definition: PolarSurface.hpp:23
mgx::PolarSurface::pSurfaceScale
@ pSurfaceScale
Definition: PolarSurface.hpp:36
mgx::PolarSurface::~PolarSurface
~PolarSurface()
Definition: PolarSurface.hpp:76
mgx::CellTissue
Definition: CellTissue.hpp:46
mgx::PolarSurface::ParmNames
ParmNames
Definition: PolarSurface.hpp:36
mgx::PolarSurface::VertexData::VertexData
VertexData()
Definition: PolarSurface.hpp:45
mgx::PolarSurface::VertexData::operator==
bool operator==(const VertexData &other) const
Definition: PolarSurface.hpp:47
mgx
Distributed matrix library.
Definition: Assert.hpp:26
Surface.hpp
mgx::PolarSurface
Definition: PolarSurface.hpp:32
mgx::PolarSurface::pRootSearchMaxSteps
@ pRootSearchMaxSteps
Definition: PolarSurface.hpp:37
mgx::PolarSurface::Subdivide::Subdivide
Subdivide(VertexAttr *vAttr, PolarSurface *surf)
Definition: PolarSurface.hpp:62
mgx::PolarSurface::VertexData::arcLength
double arcLength
Definition: PolarSurface.hpp:42
mgx::Function
A utility class for functions.
Definition: Function.hpp:26
mgx::PolarSurface::Subdivide
Definition: PolarSurface.hpp:59
mgx::Vector< 3, double >
mgx::PolarSurface::VertexAttr
AttrMap< vertex, VertexData > VertexAttr
Definition: PolarSurface.hpp:56
mgx::Surface
Definition: Surface.hpp:23
mgx::PolarSurface::VertexData
Definition: PolarSurface.hpp:40
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::PolarSurface::VertexData::angle
double angle
Definition: PolarSurface.hpp:43
mgx::PolarSurface::PolarSurface
PolarSurface()
Definition: PolarSurface.hpp:74
mgx::AttrMap
Attribute map wraps std::map.
Definition: Attributes.hpp:686
mgx::Vertex
Definition: Vertex.hpp:58