MorphoGraphX  2.0-1-227
BezierSurface.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 BEZIER_SURFACE_HPP
13 #define BEZIER_SURFACE_HPP
14 
15 #include <Surface.hpp>
16 #include <Bezier.hpp>
17 
18 namespace mgx
19 {
20  /*
21  * \class BezierSurface Surface.hpp <Surface.hpp>
22  *
23  * Growing surface using Bezier key-frames
24  *
25  * \ingroup GrowingSurfaceProcesses
26  */
27  class mgxBase_EXPORT BezierSurface : public Surface
28  {
29  public:
30  // Parameter names
31  enum ParmNames { pSurface, pSurfScale, pSurfTime, pSurfMaxDist, pRootSearchMaxSteps, pNumParms };
32 
35 
36  // Bezier vertex attribute data needed for simulations
37  struct VertexData
38  {
39  double u;
40  double v;
41  // Constructor, set initial values
42  VertexData() : u(0), v(0) {}
43 
44  bool operator==(const VertexData &other) const
45  {
46  if(u == other.u and v == other.v)
47  return true;
48  return false;
49  }
50  };
51 
52  // Define attribute map
54 
55  // Class to define methods for subdivision
56  class mgxBase_EXPORT Subdivide : virtual public mgx::Subdivide
57  {
58  public:
60  : vertexAttr(vAttr), surface(surf) {}
61 
62  virtual bool updateEdgeData(vertex l, vertex v, vertex r, double s);
63 
66  };
67 
68  // Methods similar to other surfaces
69  bool processParms(const QStringList &parms);
70  bool setPoint(vertex p, vertex sp, Point3d cp);
71  bool updatePos(vertex p);
72  bool updateNormal(vertex p);
73  // Initial cell, square.
74  bool initialCell(CellTissue &T, double squareSize, int cellInitWall);
75 
76  // Methods proper to this kind of surface
77  bool initialize(VertexAttr *vData, const QStringList &parms);
78  bool growSurface(double time);
79 
80  private:
81  // vertex attributes required for simulation
82  VertexAttr *vertexAttr;
83 
84  std::vector<Bezier> surface; // Bezier surfaces
85  std::vector<double> surfScale; // Surface scaling constants
86  std::vector<double> surfTime; // Surface time scales
87  double surfMaxDist; // Max dist for closest point search
88  int rootSearchMaxSteps; // Max steps for closest point on surface
89 
90  Bezier surfCurr; // Current surface
91  };
92 
93  // Read/write Vertex data
94  bool inline readAttr(BezierSurface::VertexData &m, const QByteArray &ba, size_t &pos)
95  {
96  return readChar((char *)&m, sizeof(BezierSurface::VertexData), ba, pos);
97  }
98  bool inline writeAttr(const BezierSurface::VertexData &m, QByteArray &ba)
99  {
100  return writeChar((char *)&m, sizeof(BezierSurface::VertexData), ba);
101  }
102 }
103 #endif
mgx::BezierSurface::BezierSurface
BezierSurface()
Definition: BezierSurface.hpp:33
Bezier.hpp
mgx::Bezier
Definition: Bezier.hpp:20
mgx::CellTissue
Definition: CellTissue.hpp:46
mgx::BezierSurface::Subdivide
Definition: BezierSurface.hpp:56
mgx::BezierSurface::VertexData::u
double u
Definition: BezierSurface.hpp:39
mgx::BezierSurface::pSurfTime
@ pSurfTime
Definition: BezierSurface.hpp:31
mgx::BezierSurface
Definition: BezierSurface.hpp:27
mgx::BezierSurface::VertexData::VertexData
VertexData()
Definition: BezierSurface.hpp:42
mgx
Distributed matrix library.
Definition: Assert.hpp:26
mgx::BezierSurface::VertexAttr
AttrMap< vertex, VertexData > VertexAttr
Definition: BezierSurface.hpp:53
Surface.hpp
mgx::BezierSurface::VertexData::operator==
bool operator==(const VertexData &other) const
Definition: BezierSurface.hpp:44
mgx::BezierSurface::Subdivide::vertexAttr
VertexAttr * vertexAttr
Definition: BezierSurface.hpp:64
mgx::BezierSurface::Subdivide::surface
BezierSurface * surface
Definition: BezierSurface.hpp:65
mgx::BezierSurface::VertexData::v
double v
Definition: BezierSurface.hpp:40
mgx::BezierSurface::Subdivide::Subdivide
Subdivide(VertexAttr *vAttr, BezierSurface *surf)
Definition: BezierSurface.hpp:59
mgx::Vector< 3, double >
mgx::Surface
Definition: Surface.hpp:23
mgx::BezierSurface::ParmNames
ParmNames
Definition: BezierSurface.hpp:31
mgx::BezierSurface::VertexData
Definition: BezierSurface.hpp:37
mgx::writeAttr
bool writeAttr(const T &data, QByteArray &ba)
Write the attribute value from a QByteArray.
Definition: Attributes.hpp:510
mgx::BezierSurface::~BezierSurface
~BezierSurface()
Definition: BezierSurface.hpp:34
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::AttrMap
Attribute map wraps std::map.
Definition: Attributes.hpp:686
mgx::Vertex
Definition: Vertex.hpp:58