tissue_model::TissueModel< RealModel, TissueClass > Struct Template Reference

Base class for the tissue_model helper. More...

#include <tissue_model.h>

Inheritance diagram for 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

 IMPORT_COMPLEX_TYPES (TissueClass)
void initialize ()
 Function to override to initialize the model.
void modifiedFiles (const std::set< std::string > &filenames)
 This function is called anytime one or more registered files are modified.
virtual void readParam (util::Parms &)
 Function to be redefined to read extra parameters.
void readTissueParam ()
 Read the parameters for the tissue_model helper (automatically called by the helper).
void registerFiles ()
void step ()
 Default step method: do nothing.
 TissueModel (QObject *parent)
 Default constructor.
void updateCellsArea ()
 Update the area of all the cells in the tissue.
Selection methods

const cell & cellFromId (int i)
 Return a reference of the cell whose id is i.
void drawWithNames ()
 Draw for cell selection.
Drawing methods

void draw (Viewer *viewer)
 Draw the tissue using the ModelClass::getCellColor and ModelClass::getCellCenterColor methods.
virtual Color getCellCenterColor (const cell &c)
 Color using the value attribute of the cell.
virtual Color getCellColor (const cell &c)
 Color using the value attribute of the cell.
void initDraw ()
 Convenience function used if the viewer is not necessary.
void postDraw ()
 Convenience function used if the viewer is not necessary.
void preDraw ()
 Convenience function used if the viewer is not necessary.
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 setVertexPositionHint (const junction &, const junction &, const junction &, double)
void updateFromOld (const cell &, const cell &, const cell &, const typename TissueClass::division_data &, TissueClass &)

Public Attributes

int backColor
 Color of the background.
bool drawNeighborhood
 Draw the neighborhood as arrows ?
util::Palette palette
 Color palette.
util::WatchDog rex
 Watchdog object to monitor file modification.
TissueClass T
 Tissue created.

Detailed Description

template<typename RealModel, typename TissueClass>
struct tissue_model::TissueModel< RealModel, TissueClass >

Base class for the tissue_model helper.

Definition at line 180 of file tissue_model.h.


Member Typedef Documentation

template<typename RealModel , typename TissueClass >
typedef std::set<cell,CompareSize> 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 231 of file tissue_model.h.


Constructor & Destructor Documentation

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

Default constructor.

Initialise the watchdog, palette, tissue and aliases.

Definition at line 250 of file tissue_model.h.

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

00251       : Model(parent)
00252       , rex(this)
00253       , palette("pal.map")
00254       , T(palette, (RealModel*)this)
00255     {
00256       rex.addObject(&palette);
00257     }


Member Function Documentation

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

Return a reference of the cell whose id is i.

The id is the one used to name cells in drawWithNames.

Definition at line 430 of file tissue_model.h.

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

00431     {
00432       if(i == -1)
00433         return cell::null;
00434       return T.S.get_cell(i);
00435     }

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

Draw the tissue using the ModelClass::getCellColor and ModelClass::getCellCenterColor methods.

Reimplemented from Model.

Definition at line 340 of file tissue_model.h.

References QGLViewer::drawArrow(), tissue_model::TissueModel< RealModel, TissueClass >::drawNeighborhood, forall, forall_named, tissue_model::TissueModel< RealModel, TissueClass >::getCellCenterColor(), tissue_model::TissueModel< RealModel, TissueClass >::getCellColor(), QGLViewer::setSceneBoundingBox(), tissue_model::TissueModel< RealModel, TissueClass >::T, util::Vector< dim, T >::x(), util::Vector< dim, T >::y(), and util::Vector< dim, T >::z().

00341     {
00342       Vec vmin(HUGE_VAL,HUGE_VAL,HUGE_VAL), vmax(-HUGE_VAL,-HUGE_VAL,-HUGE_VAL);
00343       forall(const junction& v, T.W)
00344       {
00345         const Point3d& pos = v->pos;
00346         if(pos.x() < vmin.x)
00347           vmin.x = pos.x();
00348         if(pos.y() < vmin.y)
00349           vmin.y = pos.y();
00350         if(pos.z() < vmin.z)
00351           vmin.z = pos.z();
00352         if(pos.x() > vmax.x)
00353           vmax.x = pos.x();
00354         if(pos.y() > vmax.y)
00355           vmax.y = pos.y();
00356         if(pos.z() > vmax.z)
00357           vmax.z = pos.z();
00358       }
00359       viewer->setSceneBoundingBox(vmin, vmax);
00360 
00361       forall_named(const cell& c, T.S, cells)
00362       {
00363         Color color = getCellColor(c);
00364         Color center_color = getCellCenterColor(c);
00365         T.drawCell(c, color, center_color);
00366         glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
00367         if(drawNeighborhood)
00368         {
00369           int cnt = 3;
00370           double ds = 0.1 / (3+T.C.valence(c));
00371           glColor3f(1.0, 0, 0);
00372           Vec from(c->pos);
00373           forall(const cell& n, T.C.neighbors(c))
00374           {
00375             glColor3f(1.0, 1.0, 1.0);
00376             Vec to(n->pos);
00377             Vec u = to-from;
00378             u.normalize();
00379             to = from + cnt*ds*u;
00380             cnt++;
00381             viewer->drawArrow(from, to, -1, 6);
00382           }
00383         }
00384       }
00385     }

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

Draw for cell selection.

Reimplemented from Model.

Definition at line 411 of file tissue_model.h.

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

00412     {
00413       bool db = T.drawBorders;
00414       T.drawBorders = false;
00415       int i = 0;
00416       forall_named(const cell& c, T.S, cells)
00417       {
00418         glPushName(i++);
00419         T.drawCell(c, c->value);
00420         glPopName();
00421       }
00422       T.drawBorders = db;
00423     }

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

Color using the value attribute of the cell.

Definition at line 398 of file tissue_model.h.

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

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

00399     {
00400       return T.valueCenterColor(c->value);
00401     }

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

Color using the value attribute of the cell.

Definition at line 390 of file tissue_model.h.

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

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

00391     {
00392       return T.valueColor(c->value);
00393     }

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

Convenience function used if the viewer is not necessary.

Reimplemented from Model.

Definition at line 315 of file tissue_model.h.

00316     {
00317       glEnable(GL_NICEST);
00318       glDisable(GL_CULL_FACE);
00319     }

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

Function to override to initialize the model.

Definition at line 488 of file tissue_model.h.

00488 {}

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

This function is called anytime one or more registered files are modified.

Parameters:
files Registered files modified since last call to this function.

Reimplemented from Model.

Definition at line 259 of file tissue_model.h.

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

00260     {
00261       if(filenames.find("view.v") != filenames.end())
00262         readTissueParam();
00263       rex.watch(filenames);
00264     }

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

Convenience function used if the viewer is not necessary.

Reimplemented from Model.

Definition at line 330 of file tissue_model.h.

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

00331     {
00332       glDisable(GL_BLEND);
00333       T.postDraw();
00334     }

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

Convenience function used if the viewer is not necessary.

Reimplemented from Model.

Definition at line 321 of file tissue_model.h.

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

00322     {
00323       Color bg = palette.getColor(backColor);
00324       glClearColor(bg.r(), bg.g(), bg.b(), 1.0);
00325       T.preDraw();
00326       glEnable(GL_BLEND);
00327       glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
00328     }

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

Function to be redefined to read extra parameters.

Definition at line 269 of file tissue_model.h.

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

00269 {}

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

Read the parameters for the tissue_model helper (automatically called by the helper).

Definition at line 302 of file tissue_model.h.

References tissue_model::TissueModel< RealModel, TissueClass >::backColor, tissue_model::TissueModel< RealModel, TissueClass >::drawNeighborhood, tissue_model::TissueModel< RealModel, TissueClass >::readParam(), and tissue_model::TissueModel< RealModel, TissueClass >::T.

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

00303     {
00304       util::Parms parms("view.v");
00305       T.readViewParms(parms, "View");
00306       T.readParms(parms, "Tissue");
00307       parms("View", "BackColor", backColor);
00308       parms("View", "DrawNeighborhood", drawNeighborhood);
00309       readParam(parms);
00310     }

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

Default step method: do nothing.

Implements Model.

Definition at line 483 of file tissue_model.h.

00483 { }

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

Update the area of all the cells in the tissue.

Definition at line 274 of file tissue_model.h.

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

00275     {
00276       forall_named(const cell& c, T.S, cells)
00277       {
00278         c->area = 0.0;
00279         forall( const junction& n, T.S.neighbors(c) )
00280         {
00281           // Find area
00282           const junction& m = T.S.nextTo(c, n);
00283           c->area += geometry::triangleArea(c->pos, m->pos, n->pos);
00284         }
00285         if(c->area <= epsilon ) // Avoid inf
00286         {
00287           std::cout << "Bad area " << c->area << std::endl;
00288           c->area = 0.1;
00289         }
00290       }
00291     }


Member Data Documentation

template<typename RealModel , typename TissueClass >
int tissue_model::TissueModel< RealModel, TissueClass >::backColor
template<typename RealModel , typename TissueClass >
bool tissue_model::TissueModel< RealModel, TissueClass >::drawNeighborhood
template<typename RealModel , typename TissueClass >
util::Palette tissue_model::TissueModel< RealModel, TissueClass >::palette
template<typename RealModel , typename TissueClass >
util::WatchDog tissue_model::TissueModel< RealModel, TissueClass >::rex
template<typename RealModel , typename TissueClass >
TissueClass tissue_model::TissueModel< RealModel, TissueClass >::T

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