Base class for the tissue_model helper. More...
#include <tissue_model.h>
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. |
Base class for the tissue_model helper.
Definition at line 180 of file tissue_model.h.
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.
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.
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 }
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 }
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.
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 }
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 }
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.
void tissue_model::TissueModel< RealModel, TissueClass >::initialize | ( | ) | [inline] |
Function to override to initialize the model.
Definition at line 488 of file tissue_model.h.
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.
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 }
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 }
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.
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().
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 }
void tissue_model::TissueModel< RealModel, TissueClass >::step | ( | ) | [inline, virtual] |
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 }
int tissue_model::TissueModel< RealModel, TissueClass >::backColor |
Color of the background.
Definition at line 241 of file tissue_model.h.
Referenced by tissue_model::TissueModel< RealModel, TissueClass >::preDraw(), and tissue_model::TissueModel< RealModel, TissueClass >::readTissueParam().
bool tissue_model::TissueModel< RealModel, TissueClass >::drawNeighborhood |
Draw the neighborhood as arrows ?
Definition at line 243 of file tissue_model.h.
Referenced by tissue_model::TissueModel< RealModel, TissueClass >::draw(), and tissue_model::TissueModel< RealModel, TissueClass >::readTissueParam().
util::Palette tissue_model::TissueModel< RealModel, TissueClass >::palette |
Color palette.
Definition at line 236 of file tissue_model.h.
Referenced by tissue_model::TissueModel< RealModel, TissueClass >::preDraw(), and tissue_model::TissueModel< RealModel, TissueClass >::TissueModel().
util::WatchDog tissue_model::TissueModel< RealModel, TissueClass >::rex |
Watchdog object to monitor file modification.
Definition at line 234 of file tissue_model.h.
Referenced by tissue_model::TissueModel< RealModel, TissueClass >::modifiedFiles(), and tissue_model::TissueModel< RealModel, TissueClass >::TissueModel().
TissueClass tissue_model::TissueModel< RealModel, TissueClass >::T |
Tissue created.
Definition at line 238 of file tissue_model.h.
Referenced by tissue_model::TissueModel< RealModel, TissueClass >::cellFromId(), tissue_model::TissueModel< RealModel, TissueClass >::draw(), tissue_model::TissueModel< RealModel, TissueClass >::drawWithNames(), tissue_model::TissueModel< RealModel, TissueClass >::getCellCenterColor(), tissue_model::TissueModel< RealModel, TissueClass >::getCellColor(), tissue_model::TissueModel< RealModel, TissueClass >::postDraw(), tissue_model::TissueModel< RealModel, TissueClass >::preDraw(), tissue_model::TissueModel< RealModel, TissueClass >::readTissueParam(), and tissue_model::TissueModel< RealModel, TissueClass >::updateCellsArea().