bspline_tissue_model::TissueModel< RealModel, TissueClass > Class Template Reference

Base class for the bspline tissue model helper. More...

#include <bspline_tissue_model.h>

Inheritance diagram for bspline_tissue_model::TissueModel< RealModel, TissueClass >:
Inheritance graph
[legend]

List of all members.

Classes

struct  CompareSize
 Operator class to compare the size of cells. More...

Public Types

typedef std::set< cell,
CompareSize
ordered_cells_t
 Ordered set of vertices.

Public Member Functions

const cell & cellFromId (int i)
 Returns the cell of id i.
void draw (Viewer *viewer)
 This function should be redefined to draw the representation.
void drawWithNames ()
 Draw for cell selection.
virtual Color getCellCenterColor (const cell &c)
 Function to override to change the color used for the center of the cell.
virtual Color getCellColor (const cell &c)
 Function to override to change the color used for the cell.
 IMPORT_COMPLEX_TYPES (TissueClass)
void initDraw ()
 Convenience function used if the viewer is not necessary.
void initialize ()
 Method to override for user's initialization.
void initTissue ()
 Initialize the tissue as one single cell whose shape is the shape of the current b-spline surface.
void modifiedFiles (const std::set< std::string > &filenames)
 Keep track of the modification of the parameter file ("view.v"), and of all the files registered to the watchdog.
void postDraw ()
 Convenience function used if the viewer is not necessary.
void preDraw ()
 Convenience function used if the viewer is not necessary.
virtual void readParam (util::Parms &)
 Method to redefine to read extra parameters.
void readTissueParam ()
 Read parameters needed for the tissue and tissue growth.
void registerFiles ()
 Register the parameter file.
void SetPos (const junction &j)
 Set the position of the junction j with respect to the current time.
void SetPos (const cell &c)
 Set the position of the cell x with respect to the current time.
void step ()
 Method to override to provide the user's model.
 TissueModel (QObject *parent)
 Current time.
void updateCellsArea ()
 Update the cells area using the current positions of the vertices.
void updatePositions ()
 Update the positions of all the vertices to reflect the new b-spline surface.
Methods required by the tissue library

Point3d normal (const junction &v) const
Point3d normal (const cell &v) const
Point3d position (const junction &v) const
Point3d position (const cell &v) const
void setPosition (const junction &v, const Point3d &pos)
void setPosition (const cell &v, const Point3d &pos)
void setPositionHint (const junction &v, const junction &n1, const junction &n2, double r)
void updateFromOld (const cell &, const cell &, const cell &, const typename TissueClass::division_data &, TissueClass &)

Public Attributes

int backColor
 Initial time for the leaf description.
int cellInitWalls
 One surface of the leaf at a time.
bool drawNeighborhood
 Color of the background.
double dt
 Initial number of walls in the cell.
double growthStartTime
 Time step.
util::KeyFramer leaf
 Main tissue.
util::BSplineSurface leafs
 Description of the leaf growth.
util::Palette palette
 Watchdog for file modification.
util::WatchDog rex
TissueClass T
 Palette to retrieve colors.
double time
 Draw the neighborhood as arrows ?

Detailed Description

template<typename RealModel, typename TissueClass>
class bspline_tissue_model::TissueModel< RealModel, TissueClass >

Base class for the bspline tissue model helper.

Definition at line 216 of file bspline_tissue_model.h.


Member Typedef Documentation

template<typename RealModel , typename TissueClass >
typedef std::set<cell,CompareSize> bspline_tissue_model::TissueModel< RealModel, TissueClass >::ordered_cells_t

Ordered set of vertices.

The vertices must represent cells. They will be ordered by area.

Definition at line 236 of file bspline_tissue_model.h.


Constructor & Destructor Documentation

template<typename RealModel , typename TissueClass >
bspline_tissue_model::TissueModel< RealModel, TissueClass >::TissueModel ( QObject parent  )  [inline]

Current time.

Default constructor Creates the tissue, the aliases, the palette and the watchdog

Definition at line 258 of file bspline_tissue_model.h.

References util::WatchDog::addObject(), bspline_tissue_model::TissueModel< RealModel, TissueClass >::leaf, and bspline_tissue_model::TissueModel< RealModel, TissueClass >::palette.

00259       : Model(parent)
00260       , rex(this)
00261       , palette("pal.map")
00262       , T(palette, (RealModel*)this)
00263     {
00264       rex.addObject(&palette);
00265       rex.addObject(&leaf);
00266     }


Member Function Documentation

template<typename RealModel , typename TissueClass >
const cell& bspline_tissue_model::TissueModel< RealModel, TissueClass >::cellFromId ( int  i  )  [inline]

Returns the cell of id i.

This id is the one used for OpenGL selection and is returned by QGLViewer::selectedName()

Definition at line 498 of file bspline_tissue_model.h.

References bspline_tissue_model::TissueModel< RealModel, TissueClass >::T.

00499     {
00500       if(i == -1)
00501         return cell::null;
00502       return T.S.get_cell(i);
00503     }

template<typename RealModel , typename TissueClass >
void bspline_tissue_model::TissueModel< RealModel, TissueClass >::draw ( Viewer viewer  )  [inline, virtual]

This function should be redefined to draw the representation.

Parameters:
viewer Viewer object. Useful to use the capabilities of QGLViewer object.

Reimplemented from Model.

Definition at line 426 of file bspline_tissue_model.h.

References QGLViewer::drawArrow(), bspline_tissue_model::TissueModel< RealModel, TissueClass >::drawNeighborhood, forall, forall_named, bspline_tissue_model::TissueModel< RealModel, TissueClass >::getCellCenterColor(), bspline_tissue_model::TissueModel< RealModel, TissueClass >::getCellColor(), bspline_tissue_model::TissueModel< RealModel, TissueClass >::leafs, QGLViewer::setSceneBoundingBox(), and bspline_tissue_model::TissueModel< RealModel, TissueClass >::T.

00427     {
00428       forall_named(const cell& c, T.S, cells)
00429       {
00430         Color color = getCellColor(c);
00431         Color center_color = getCellCenterColor(c);
00432         T.drawCell(c, color, center_color);
00433         glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
00434         if(drawNeighborhood)
00435         {
00436           int cnt = 3;
00437           double ds = 0.1 / (3+T.C.valence(c));
00438           glColor3f(1.0, 0, 0);
00439           Vec from(c->pos);
00440           forall(const cell& n, T.C.neighbors(c))
00441           {
00442             glColor3f(1.0, 1.0, 1.0);
00443             Vec to(n->pos);
00444             Vec u = to-from;
00445             u.normalize();
00446             to = from + cnt*ds*u;
00447             cnt++;
00448             viewer->drawArrow(from, to, -1, 6);
00449           }
00450         }
00451       }
00452 
00453       double vmin[3], vmax[3];
00454       leafs.BoundingBox(vmin[0], vmin[1], vmin[2], vmax[0], vmax[1], vmax[2]);
00455       Vec pmin(vmin), pmax(vmax);
00456       viewer->setSceneBoundingBox(pmin, pmax);
00457     }

template<typename RealModel , typename TissueClass >
void bspline_tissue_model::TissueModel< RealModel, TissueClass >::drawWithNames (  )  [inline, virtual]

Draw for cell selection.

Reimplemented from Model.

Definition at line 462 of file bspline_tissue_model.h.

References forall_named, and bspline_tissue_model::TissueModel< RealModel, TissueClass >::T.

00463     {
00464       bool db = T.drawBorders;
00465       T.drawBorders = false;
00466       int i = 0;
00467       forall_named(const cell& c, T.S, cells)
00468       {
00469         glPushName(i++);
00470         T.drawCell(c, c->value);
00471         glPopName();
00472       }
00473       T.drawBorders = db;
00474     }

template<typename RealModel , typename TissueClass >
virtual Color bspline_tissue_model::TissueModel< RealModel, TissueClass >::getCellCenterColor ( const cell &  c  )  [inline, virtual]

Function to override to change the color used for the center of the cell.

Definition at line 487 of file bspline_tissue_model.h.

References bspline_tissue_model::TissueModel< RealModel, TissueClass >::T.

Referenced by bspline_tissue_model::TissueModel< RealModel, TissueClass >::draw().

00488     {
00489       return T.valueCenterColor(c->value);
00490     }

template<typename RealModel , typename TissueClass >
virtual Color bspline_tissue_model::TissueModel< RealModel, TissueClass >::getCellColor ( const cell &  c  )  [inline, virtual]

Function to override to change the color used for the cell.

Definition at line 479 of file bspline_tissue_model.h.

References bspline_tissue_model::TissueModel< RealModel, TissueClass >::T.

Referenced by bspline_tissue_model::TissueModel< RealModel, TissueClass >::draw().

00480     {
00481       return T.valueColor(c->value);
00482     }

template<typename RealModel , typename TissueClass >
void bspline_tissue_model::TissueModel< RealModel, TissueClass >::initDraw (  )  [inline, virtual]

Convenience function used if the viewer is not necessary.

Reimplemented from Model.

Definition at line 405 of file bspline_tissue_model.h.

00406     {
00407       glEnable(GL_NICEST);
00408       glDisable(GL_CULL_FACE);
00409     }

template<typename RealModel , typename TissueClass >
void bspline_tissue_model::TissueModel< RealModel, TissueClass >::initialize (  )  [inline]

Method to override for user's initialization.

Definition at line 557 of file bspline_tissue_model.h.

00557 {}

template<typename RealModel , typename TissueClass >
void bspline_tissue_model::TissueModel< RealModel, TissueClass >::initTissue (  )  [inline]

Initialize the tissue as one single cell whose shape is the shape of the current b-spline surface.

Definition at line 306 of file bspline_tissue_model.h.

References bspline_tissue_model::TissueModel< RealModel, TissueClass >::cellInitWalls, bspline_tissue_model::TissueModel< RealModel, TissueClass >::growthStartTime, bspline_tissue_model::TissueModel< RealModel, TissueClass >::leaf, bspline_tissue_model::TissueModel< RealModel, TissueClass >::leafs, bspline_tissue_model::TissueModel< RealModel, TissueClass >::SetPos(), bspline_tissue_model::TissueModel< RealModel, TissueClass >::T, bspline_tissue_model::TissueModel< RealModel, TissueClass >::time, and bspline_tissue_model::TissueModel< RealModel, TissueClass >::updateCellsArea().

00307     {
00308       time = growthStartTime;
00309       leaf.SetTime(time);
00310       leafs = leaf.GetSurfaceTime();
00311 
00312       // Find center and set cell area and length of cell walls
00313       cell c;
00314       c->uv[0] = c->uv[1] = .5;
00315       c->value = 0.5;
00316       SetPos(c);
00317 
00318       std::vector<junction> junctions(cellInitWalls, junction(0));
00319       for(int i = 0 ; i < cellInitWalls ; i++)
00320       {
00321         double s = (double)(cellInitWalls-i)/(double)cellInitWalls;
00322         junction v;
00323         v->uv = leafs.ContourInverse(s);
00324         SetPos(v);
00325         junctions[i] = v;
00326       }
00327 
00328       T.addCell(c, junctions);
00329 
00330       updateCellsArea();
00331     }

template<typename RealModel , typename TissueClass >
void bspline_tissue_model::TissueModel< RealModel, TissueClass >::modifiedFiles ( const std::set< std::string > &  filenames  )  [inline, virtual]

Keep track of the modification of the parameter file ("view.v"), and of all the files registered to the watchdog.

Reimplemented from Model.

Definition at line 272 of file bspline_tissue_model.h.

References bspline_tissue_model::TissueModel< RealModel, TissueClass >::readTissueParam(), and util::WatchDog::watch().

00273     {
00274       if(filenames.count("view.v"))
00275         readTissueParam();
00276       rex.watch(filenames);
00277     }

template<typename RealModel , typename TissueClass >
void bspline_tissue_model::TissueModel< RealModel, TissueClass >::postDraw (  )  [inline, virtual]

Convenience function used if the viewer is not necessary.

Reimplemented from Model.

Definition at line 420 of file bspline_tissue_model.h.

References bspline_tissue_model::TissueModel< RealModel, TissueClass >::T.

00421     {
00422       glDisable(GL_BLEND);
00423       T.postDraw();
00424     }

template<typename RealModel , typename TissueClass >
void bspline_tissue_model::TissueModel< RealModel, TissueClass >::preDraw (  )  [inline, virtual]

Convenience function used if the viewer is not necessary.

Reimplemented from Model.

Definition at line 411 of file bspline_tissue_model.h.

References util::Color< T >::b(), bspline_tissue_model::TissueModel< RealModel, TissueClass >::backColor, util::Color< T >::g(), util::Palette::getColor(), bspline_tissue_model::TissueModel< RealModel, TissueClass >::palette, util::Color< T >::r(), and bspline_tissue_model::TissueModel< RealModel, TissueClass >::T.

00412     {
00413       Color bg = palette.getColor(backColor);
00414       glClearColor(bg.r(), bg.g(), bg.b(), 1.0);
00415       T.preDraw();
00416       glEnable(GL_BLEND);
00417       glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
00418     }

template<typename RealModel , typename TissueClass >
virtual void bspline_tissue_model::TissueModel< RealModel, TissueClass >::readParam ( util::Parms  )  [inline, virtual]

Method to redefine to read extra parameters.

Definition at line 282 of file bspline_tissue_model.h.

Referenced by bspline_tissue_model::TissueModel< RealModel, TissueClass >::readTissueParam().

00282 { }

template<typename RealModel , typename TissueClass >
void bspline_tissue_model::TissueModel< RealModel, TissueClass >::readTissueParam (  )  [inline]

Read parameters needed for the tissue and tissue growth.

Definition at line 384 of file bspline_tissue_model.h.

References bspline_tissue_model::TissueModel< RealModel, TissueClass >::backColor, bspline_tissue_model::TissueModel< RealModel, TissueClass >::cellInitWalls, util::WatchDog::changeFilename(), bspline_tissue_model::TissueModel< RealModel, TissueClass >::drawNeighborhood, bspline_tissue_model::TissueModel< RealModel, TissueClass >::dt, bspline_tissue_model::TissueModel< RealModel, TissueClass >::growthStartTime, bspline_tissue_model::TissueModel< RealModel, TissueClass >::leaf, bspline_tissue_model::TissueModel< RealModel, TissueClass >::readParam(), and bspline_tissue_model::TissueModel< RealModel, TissueClass >::T.

Referenced by bspline_tissue_model::TissueModel< RealModel, TissueClass >::modifiedFiles().

00385     {
00386       util::Parms parms("view.v");
00387       std::string newKeyFrameFile;
00388 
00389       parms("Main", "dt", dt);
00390       parms("Main", "KeyFrameFile", newKeyFrameFile);
00391       parms("Main", "GrowthStartTime", growthStartTime);
00392       parms("Main", "CellInitWalls", cellInitWalls);
00393 
00394       rex.changeFilename(&leaf, newKeyFrameFile);
00395 
00396       T.readViewParms(parms, "View");
00397       parms("View", "BackColor", backColor);
00398       parms("View", "DrawNeighborhood", drawNeighborhood);
00399 
00400       T.readParms(parms, "Tissue");
00401 
00402       readParam(parms);
00403     }

template<typename RealModel , typename TissueClass >
void bspline_tissue_model::TissueModel< RealModel, TissueClass >::registerFiles (  )  [inline]

Register the parameter file.

Definition at line 376 of file bspline_tissue_model.h.

References Model::registerFile().

00377     {
00378       registerFile("view.v"); 
00379     }

template<typename RealModel , typename TissueClass >
void bspline_tissue_model::TissueModel< RealModel, TissueClass >::SetPos ( const junction &  j  )  [inline]

Set the position of the junction j with respect to the current time.

Definition at line 296 of file bspline_tissue_model.h.

References bspline_tissue_model::TissueModel< RealModel, TissueClass >::leafs.

00297     {
00298       j->pos = leafs.EvalN(j->uv[0], j->uv[1]);
00299       j->normal = leafs.NormalEvalN(j->uv[0], j->uv[1]);
00300     }

template<typename RealModel , typename TissueClass >
void bspline_tissue_model::TissueModel< RealModel, TissueClass >::SetPos ( const cell &  c  )  [inline]

Set the position of the cell x with respect to the current time.

Definition at line 287 of file bspline_tissue_model.h.

References bspline_tissue_model::TissueModel< RealModel, TissueClass >::leafs.

Referenced by bspline_tissue_model::TissueModel< RealModel, TissueClass >::initTissue(), and bspline_tissue_model::TissueModel< RealModel, TissueClass >::updatePositions().

00288     {
00289       c->pos = leafs.EvalN(c->uv[0], c->uv[1]);
00290       c->normal = leafs.NormalEvalN(c->uv[0], c->uv[1]);
00291     }

template<typename RealModel , typename TissueClass >
void bspline_tissue_model::TissueModel< RealModel, TissueClass >::step (  )  [inline, virtual]

Method to override to provide the user's model.

Implements Model.

Definition at line 552 of file bspline_tissue_model.h.

00552 { }

template<typename RealModel , typename TissueClass >
void bspline_tissue_model::TissueModel< RealModel, TissueClass >::updateCellsArea (  )  [inline]

Update the cells area using the current positions of the vertices.

Definition at line 354 of file bspline_tissue_model.h.

References bspline_tissue_model::epsilon, forall, forall_named, bspline_tissue_model::TissueModel< RealModel, TissueClass >::T, and geometry::triangleArea().

Referenced by bspline_tissue_model::TissueModel< RealModel, TissueClass >::initTissue().

00355     {
00356       forall_named( const cell& c, T.S, cells )
00357       {
00358         c->area = 0.0;
00359         forall( const junction& n, T.S.neighbors(c) )
00360         {
00361           // Find area
00362           const junction& m = T.S.nextTo(c, n);
00363           c->area += geometry::triangleArea(c->pos, m->pos, n->pos);
00364         }
00365         if(c->area <= epsilon ) // Avoid inf
00366         {
00367           cout << "Bad area " << c->area << endl;
00368           c->area = 0.1;
00369         }
00370       }
00371     }

template<typename RealModel , typename TissueClass >
void bspline_tissue_model::TissueModel< RealModel, TissueClass >::updatePositions (  )  [inline]

Update the positions of all the vertices to reflect the new b-spline surface.

Definition at line 337 of file bspline_tissue_model.h.

References forall, bspline_tissue_model::TissueModel< RealModel, TissueClass >::leaf, bspline_tissue_model::TissueModel< RealModel, TissueClass >::leafs, bspline_tissue_model::TissueModel< RealModel, TissueClass >::SetPos(), bspline_tissue_model::TissueModel< RealModel, TissueClass >::T, and bspline_tissue_model::TissueModel< RealModel, TissueClass >::time.

00338     {
00339       leaf.SetTime(time);
00340       leafs = leaf.GetSurfaceTime();
00341       forall(const cell& c, T.C)
00342       {
00343         SetPos(c);
00344       }
00345       forall(const junction& j, T.W)
00346       {
00347         SetPos(j);
00348       }
00349     }


Member Data Documentation

template<typename RealModel , typename TissueClass >
int bspline_tissue_model::TissueModel< RealModel, TissueClass >::backColor
template<typename RealModel , typename TissueClass >
int bspline_tissue_model::TissueModel< RealModel, TissueClass >::cellInitWalls
template<typename RealModel , typename TissueClass >
bool bspline_tissue_model::TissueModel< RealModel, TissueClass >::drawNeighborhood
template<typename RealModel , typename TissueClass >
double bspline_tissue_model::TissueModel< RealModel, TissueClass >::dt

Initial number of walls in the cell.

Definition at line 246 of file bspline_tissue_model.h.

Referenced by bspline_tissue_model::TissueModel< RealModel, TissueClass >::readTissueParam().

template<typename RealModel , typename TissueClass >
double bspline_tissue_model::TissueModel< RealModel, TissueClass >::growthStartTime
template<typename RealModel , typename TissueClass >
util::KeyFramer bspline_tissue_model::TissueModel< RealModel, TissueClass >::leaf
template<typename RealModel , typename TissueClass >
util::BSplineSurface bspline_tissue_model::TissueModel< RealModel, TissueClass >::leafs
template<typename RealModel , typename TissueClass >
util::Palette bspline_tissue_model::TissueModel< RealModel, TissueClass >::palette
template<typename RealModel , typename TissueClass >
TissueClass bspline_tissue_model::TissueModel< RealModel, TissueClass >::T
template<typename RealModel , typename TissueClass >
double bspline_tissue_model::TissueModel< RealModel, TissueClass >::time

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Fri May 31 15:38:05 2013 for VVE by  doxygen 1.6.3