tissue_model.h File Reference

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

#include <vve.h>
#include <util/parms.h>
#include <util/palette.h>
#include <iostream>
#include <util/watchdog.h>
#include <algorithms/tissue.h>
#include <geometry/geometry.h>

Go to the source code of this file.

Classes

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

Namespaces

namespace  tissue_model
 

Namespace containing the base class for the tissue model helper.


Defines

#define CellAttributes
#define CellEdgeAttributes
#define CellJunctionEdgeAttributes
#define EndModel   }; DEFINE_MODEL(ModelClass)
#define JunctionAttributes
#define JunctionCellEdgeAttributes
#define ModelInit
#define StartModel
#define WallAttributes

Typedefs

typedef util::Palette::Color Color

Variables

const double tissue_model::epsilon = 0.0001
 Relative constant for geometrical error.

Detailed Description

This files include the tissue model helper.

This helper define a tissue that is already drawn.

The namespace tissue_model contains the base class for this helper.

To use the helper, simply include <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 if the vertex is of type
  Point3d pos;              // Position of the vertex
  Point3d normal;           // Normal to the surface
  double value;             // Value used to draw the vertex

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 <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 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 <tissue_model.h>

 StartModel

 // Define
 int clickedColor, unclickedColor;

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

 // Initialize the tissue
 void initialize()
 {
   // First, create the cell
   cell c;
   junction j1, j2, j3, j4;
   j1->pos = Point3d(-1,-1,0);
   j2->pos = Point3d(1,-1,0);
   j3->pos = Point3d(1,1,0);
   j4->pos = Point3d(-1,1,0);
   c->pos = Point3d(0,0,0);
   T.addCell(c, j1, j2, j3, j4);
   // Then, initialise the content of it
   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
   }
 }

 // 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);
 }

 // All the normals are the same and upward
 Point3d normal(const cell&)
 {
   return Point3d(0,0,1);
 }
 Point3d normal(const junction&)
 {
   return Point3d(0,0,1);
 }

 EndModel

Definition in file 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