bspline_tissue_model.h File Reference

This files include the bspline tissue model helper. More...

#include <vve.h>
#include <config.h>
#include <model.h>
#include <viewer.h>
#include <util/forall.h>
#include <algorithms/tissue.h>
#include <geometry/geometry.h>
#include <util/parms.h>
#include <util/palette.h>
#include <util/vector.h>
#include <util/watchdog.h>
#include <vector>
#include <string>
#include <util/matrix.h>
#include <qgl.h>
#include <qstring.h>
#include "bsurface.h"
#include <iostream>

Go to the source code of this file.

Classes

struct  bspline_tissue_model::TissueModel< RealModel, TissueClass >::CompareSize
 Operator class to compare the size of cells. More...
class  bspline_tissue_model::TissueModel< RealModel, TissueClass >
 Base class for the bspline tissue model helper. More...

Namespaces

namespace  bspline_tissue_model
 

Namespace containing the base class for bspline tissue model helper.


Defines

#define CellAttributes
#define CellEdgeAttributes
#define CellJunctionEdgeAttributes
#define EndModel   }; DEFINE_MODEL(ModelClass);
 Macro defining the end of the model.
#define JunctionAttributes
#define JunctionCellEdgeAttributes
#define ModelInit
#define StartModel
 Macro defining the start of the model.
#define WallAttributes

Typedefs

typedef util::Palette::Color Color
 Typedef to easy the use of colors.

Variables

const double bspline_tissue_model::epsilon = 0.0001
 Relative error for geometry.

Detailed Description

This files include the bspline tissue model helper.

This helper define a tissue whose growth is driven by a set of bspline surfaces defining the geometry at key-points.

The namespace bspline_tissue_model contains the base class for this helper.

To use the helper, simply include <bspline_tissue_model.h>. Any extra attributes for vertices or edges should be defined before including this file.

Once included, the model starts with

 StartModel

and ends with

 EndModel

The tissue defined in the model uses cells which contains these attributes:

  double area;              // Area of the cell
  Point3d pos;              // Position of the cell
  Point3d normal;           // Normal to the surface
  Point2d uv;               // Local coordinate of the cell on the bspline
  double value;             // Value used to draw the cell

and junctions which contains these attributes:

  Point3d pos;              // Position of the junction
  Point3d normal;           // Normal to the surface
  Point2d uv;               // Local coordinate of the junction on the bspline

In addition, the user can add its own attributes by defining the macro VertexAttributes before including this file:

 #define CellAttribute \
   double attr1; \
   int attr2; \
   bool attr3;
 #define JunctionAttribute \
   double attr1; \
   bool attr2; \
   int attr3;

 #include <bspline_tissue_model.h>
Note:
As this is a macro, to span over many lines you need to end the inner lines with a backslash.

Similarly, the user can add attributes to the cell and tissue edges by defining the macros CellEdgeAttributes, WallAttributes, CellJunctionEdgeAttributes and JunctionCellEdgeAttributes.

Within the model class, named ModelClass, all the methods and variable of the class bspline_tissue_model::TissueModel are available. Reference to the parent class can be done using the ParentClass typedef.

For example, if yo want to augment the drawing method, you might write:

 void draw(Viewer* viewer)
 {
   ParentClass::draw(viewer);
   // my other commands
 }

As a small example, here is a code that creates a single cell and change its color when the user click on it.

 #define CellAttributes \
   bool clicked; // Is the current cell clicked?

 #include <bspline_tissue_model.h>

 StartModel

 // Define
 int clickedColor, unclickedColor;
 double dt;      // How much mecanic advance at each step
 double maxArea; // Maximum area of a cell

 // Read the extra parameter
 void readParam(util::Parms& parms)
 {
   parms("Main", "dt", dt);
   parms("Main", "MaxArea", maxArea);
   parms("View", "ClickedColor", clickedColor);
   parms("View", "UnclickedColor", unclickedColor);
 }

 // Initialize the tissue
 void initialize()
 {
   // First, create the cell
   initTissue();
   // Then, initialise the content of the cells
   forall(const cell& c, T.C)
     c->clicked = false;
 }

 // Update the status of the cell after user interaction
 void postSelection(const QPoint&, Viewer* viewer)
 {
   const cell& c = cellFromId(viewer->selectedName());
   // If a cell was selected
   if(c)
   {
     c->clicked ^= true; // Invert its state
   }
 }

 // Main loop: tissue growth and cell division
 void step()
 {
    // Change the current time, then update the vertices positions and cell areas
    time += dt;
    updatePositions();
    updateCellsArea();
    ordered_cells_t ordered_divide;

    // Find the cells to be divided, order them and divide them
    forall(const cell& c, T.C)
    {
      vvcomplex::FindCenter(c, T);
      if(c->area > maxArea)
      {
        ordered_divide.insert(c);
      }
    }

    // How to divide
    forall(const cell& c, ordered_divide)
    {
      T.divideCell(c);
    }
 }

 // Define the color depending on the clicked state
 Color getCellColor(const cell& c)
 {
   if(c->clicked)
     return palette.getColor(clickedColor);
   else
     return palette.getColor(unclickedColor);
 }

 // Define the color depending on the clicked state
 Color getCellCenterColor(const cell& c)
 {
   if(c->clicked)
     return palette.getColor(clickedColor);
   else
     return palette.getColor(unclickedColor);
 }

 // When a cell is clicked, the property is inherited by the children
 void updateFromOld(const cell& cl, const cell& cr, const cell& c,
                    const Tissue::division_data&, Tissue&)
 {
    cl->clicked = cr->clicked = c->clicked;
 }

 EndModel

Definition in file bspline_tissue_model.h.


Define Documentation

#define EndModel   }; DEFINE_MODEL(ModelClass);

Macro defining the end of the model.

Definition at line 651 of file bspline_tissue_model.h.

#define StartModel

Macro defining the start of the model.

Definition at line 593 of file bspline_tissue_model.h.


Typedef Documentation

Typedef to easy the use of colors.

Definition at line 193 of file bspline_tissue_model.h.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Fri May 31 15:37:53 2013 for VVE by  doxygen 1.6.3