Computer Assited Medical Intervention Tool Kit
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Public Member Functions | List of all members
camitk::Geometry Class Reference

A 3D representation of a vtkPointSet to be displayed in a InteractiveViewer, this class implements the InterfaceGeometry. More...

#include <Geometry.h>

+ Inheritance diagram for camitk::Geometry:

Public Member Functions

 Geometry (QString label, vtkSmartPointer< vtkPointSet > pointSet, const InterfaceGeometry::RenderingModes mode=InterfaceGeometry::Surface)
 Instanciate a Geometry using existing stuff.
virtual const QString getLabel () const
 get the label of this Geometry instance
virtual void setLabel (QString newName)
 set the label of this Geometry instance
virtual ~Geometry ()
 destructor
InterfaceGeometry Vtk related inherited methods

All the implemented InterfaceGeometry methods (Geometry is the adaptee of Component)

virtual vtkSmartPointer
< vtkPointSet > 
getPointSet ()
virtual void setPointSet (vtkSmartPointer< vtkPointSet > ds)
 set the input data of the Geometry,
virtual vtkSmartPointer
< vtkAlgorithmOutput > 
getDataPort () const
 get the custom algorithm pipeline input.
virtual void setDataConnection (vtkSmartPointer< vtkAlgorithmOutput >)
 call this method with the custom algorithm pipeline output
virtual void setPointData (vtkSmartPointer< vtkDataArray >)
 set the point data (may contains a lookup table)
virtual vtkSmartPointer< vtkActor > getActor (const RenderingModes)
 Return the actor representing this representation mode (return NULL if hightlight mode is Hidden).
virtual vtkSmartPointer< vtkProp > getProp (const QString &)
 Return the vtkProp (actors, volumes and annotations) corresponding to the given name.
virtual unsigned int getNumberOfProp () const
 return the number of additional prop
virtual vtkSmartPointer< vtkProp > getProp (unsigned int)
 return an additional prop by its index
virtual bool addProp (const QString &, vtkSmartPointer< vtkProp >)
 insert an additional prop, defining it by its name (default visibility = false)
virtual bool removeProp (const QString &)
 remove a given additional prop.
virtual void setTexture (vtkSmartPointer< vtkTexture > texture)
 Set a texture to this object.
virtual void pointPicked (vtkIdType, bool)
 a vtkPoint of the structured was picked (to be reimplemented in a Component inherited class if needed)
virtual void cellPicked (vtkIdType, bool)
 a vtkCell of the structured was picked (to be reimplemented in a Component inherited class if needed)
InterfaceGeometry Helpers inherited methods
virtual void getBounds (double bounds[6])
 compute the object's bounding box [xmin,xmax, ymin,ymax, zmin,zmax]
virtual double getBoundingRadius ()
 compute the object's bounding sphere radius
virtual void setPointPosition (const unsigned int orderNumber, const double x, const double y, const double z)
 set a given point position
InterfaceGeometry rendering mode settings inherited methods
virtual void setRenderingModes (const RenderingModes rMode)
 Set the actor associated to a rendering mode visible or not.
virtual const RenderingModes getRenderingModes () const
 Return if the actor associated to a rendering mode is currently visible or not.
virtual void setEnhancedModes (const EnhancedModes)
 set the enhanced mode
virtual const EnhancedModes getEnhancedModes () const
 get the current enhanced mode
virtual void setActorColor (const RenderingModes, double[4])
 Set the color of given representation modes.
virtual void setActorColor (const RenderingModes, const double, const double, const double)
 Set the color of given representation modes.
virtual void getActorColor (const RenderingModes, double[4])
 Get the color of given representation modes in the second parameter, i.e. double[4] (r,g,b,a)
virtual void setColor (const double, const double, const double)
 Set an (r,g,b) color to all representation modes, without changing the opacity.
virtual void setColor (const double, const double, const double, const double)
 Set an (r,g,b,a) color to all representation modes.
virtual void setActorOpacity (const RenderingModes, const double)
 Set the opacity of this representation modes. WARNING color field (surfaceColor, ...) are not modified!
virtual double getActorOpacity (const RenderingModes) const
 Return the opacity of a given renderng mode.
virtual void setOpacity (const double)
 Set the opacity of this object. WARNING color field (surfaceColor, ...) are not modified!
virtual void setGlyphType (const GlyphTypes type, const double size=0.0)
 set the glyph information
virtual void setLinesAsTubes (bool tubes=false)
 display lines as tubes (depeding of the boolean) (only work if the Geometry was defined using a vtkPolyData).
- Public Member Functions inherited from camitk::InterfaceGeometry
virtual ~InterfaceGeometry ()
 empty virtual destructor, to avoid memory leak

Private Attributes

VTK members (data, filters, actors, etc...)
vtkSmartPointer< vtkPointSet > pointSet
vtkSmartPointer
< vtkAlgorithmOutput > 
dataOutput
 to be able to set external custom pipeline
vtkSmartPointer
< vtkAlgorithmOutput > 
customPipelineOutput
 the external custom pipeline output (equals to dataOuput if no custom pipeline plugged)
vtkSmartPointer
< vtkCastToConcrete > 
concreteData
 the filter to convert the DataSet to get a correct vtkPipeline output port
vtkSmartPointer< vtkDataSetMapper > mapper
 the VTK mapper
QMap< QString, vtkSmartPointer
< vtkProp > > 
extraProp
 The additional map for prop (include at least "label" and "glyph".
vtkSmartPointer< vtkTextMapper > labelActorMapper
 the mapper to create the text
vtkSmartPointer< vtkActor > surfaceActor
 the surface actor that manages the surfacic representation
vtkSmartPointer< vtkActor > wireframeActor
 the wireframe actor that manages the representation as wireframe
vtkSmartPointer< vtkActor > pointsActor
 the point actor that manages the representation as a set of points
vtkSmartPointer< vtkTexture > texture
 texture of this object.
vtkSmartPointer< vtkTubeFilter > tube
 the tube filter (creates tubes insead of lines)
actor colors

All Colors are decribed using r, g, b, alpha (Alpha is opacity 0 = transparent, 1 = opaque)

double surfaceColor [4]
double wireframeColor [4]
double pointsColor [4]
Backup states
double oldAlphaSurface
double oldAlphaWireframe
double oldAlphaPoints
double oldPointsColor [4]

Other members

Rendering mode options for this Geometry (which actors are visible/rendered)

InterfaceGeometry::RenderingModes renderingModes
InterfaceGeometry::EnhancedModes enhancedModes
 Enhanced mode options (the way actors are rendered: normal, hidden, highlighted, shaded)
double alphaShaded
 Opacity value when this object must be shaded.
QString label
 the label
double glyphSize
 current size of glyph (0.0 means no glyph)
vtkSmartPointer< vtkSphereSource > sphereGeom
 the sphere glyph
void buildLabel ()
 build the label extra prop
void updateLabel ()
 update position and text of the label
void buildGlyph (const GlyphTypes type)
 build the glyph extra prop (sphere glyph by default)

Additional Inherited Members

- Public Types inherited from camitk::InterfaceGeometry
enum  EnhancedMode { Normal = 0x0, Hidden = 0x1, Shaded = 0x2, Highlighted = 0x4 }
 (and QFlags EnhancedModes) handle the way the rendering actors will be enhanced or not (from completely hidden to highlighted) More...
enum  GlyphType { NoGlyph = 0x0, Sphere = 0x1 }
 (and QFlags GlyphTypes) is the type of glyph attached to the geometry representation More...
enum  RenderingMode { None = 0x0, Surface = 0x1, Wireframe = 0x2, Points = 0x4 }
 (and QFlags RenderingModes) handle actor rendering options (render this InterfaceGeometry as a surface, a wireframe and set of points). More...

Detailed Description

A 3D representation of a vtkPointSet to be displayed in a InteractiveViewer, this class implements the InterfaceGeometry.

A Geometry is build out of a vtkPointSet. A single vtkDataSetMapper is created, with several associated vtkActors. Each actor has specific rendering properties: representation mode, color, ...

Available actors are: surface, wireframe and points.

An actor is visible or not according to the options of the RenderingModes associated to the Geometry as well as the highlight mode (from hidden to highlighted).

Note
when the Geometry is instanciated the Geometry TAKES CONTROL of the given vtkPointSet (hence, if you then delete the instance, the vtkDataSet will be deleted as well).

This class is used as a delegate by Component (who delegates all the InterfaceGeometry service implementation to Geometry), according to the Object Adapter Design Pattern (Component is the adaptor, Geometry is the adaptee concerning the InterfaceGeometry service).

If you need to add your own vtk filter/algorithm pipeline to pre-process the data, you need to write something like this:

vtkSomeAlgorithm *startFilter = vtkSomeAlgorithm::New();
startFilter->SetInputConnection(theAbstractGeometry->getDataPort());
...
...
theAbstractGeometry->setDataConnection(endFilter->GetOutputPort());

The complete Vtk Pipeline looks like this:

*                                               +-----> getDataPort()
*  +----------------+     +------------------+ /
*  |  vtkPointSet   |     |vtkCastToConcrete |/
*  |                |----\|                  |----\    your custom       ----\   ...
*  |   pointSet     |----/|  concreteData    |----/     pipeline         ----/
*  +----------------+     +------------------+
*     ^           |
*     |           |
* setPointSet()   |
*                 |
*                 v
*          getPointSet()
*
*
* setDataConnection(..)
*      |
*      |  +---OPTIONAL---+       +------------------+
*      +->| vtkTubeFilter|       | vtkDataSetMapper |
*... ----\|              |-----\ |                  |
*    ----/|     tube     |-----/ |     mapper       |
*         +--------------+       +------------------+
*                ^                     |
*                |                     V
*         setLinesAsTube()        +------------------+
*                                 |     3 actors:    |
*                                 |   surfaceActor   |
*                                 | wireframeActor   |
*                                 |    pointsActor   |
*                                 |                  |
*                                 +------------------+
*
* 

The other vtk (minor) ingredients not mentionned are specific vtkProp (actors, volumes and annotations) By default two props are defined: label and glyph. They can be accessed by getProp("label") and getProp("glyph"). You can also add your own additional custom props by using addProp(QString, vtkProp) and setPropVisible(QString, bool).

Constructor & Destructor Documentation

camitk::Geometry::Geometry ( QString  label,
vtkSmartPointer< vtkPointSet >  pointSet,
const InterfaceGeometry::RenderingModes  mode = InterfaceGeometry::Surface 
)

Instanciate a Geometry using existing stuff.

Note
when the Geometry is instanciated like this, the object takes CONTROL of the vtkDataSet (hence, if you then delete this instance, the vtkDataSet will be deleted as well). dataSet thus becomes owned by the Geometry and will be deleted when necessary, so do not pass the address of an object on the stack.
Parameters
labelname to display on the label
pointSetthe vtkDataSet to take as the vtk object to display
modethe default rendering mode

References alphaShaded, concreteData, customPipelineOutput, dataOutput, enhancedModes, label, mapper, camitk::InterfaceGeometry::Normal, pointsActor, pointsColor, pointSet, renderingModes, setGlyphType(), camitk::InterfaceGeometry::Sphere, surfaceActor, surfaceColor, texture, tube, wireframeActor, and wireframeColor.

camitk::Geometry::~Geometry ( )
virtual

destructor

References extraProp.

Member Function Documentation

bool camitk::Geometry::addProp ( const QString &  name,
vtkSmartPointer< vtkProp >  prop 
)
virtual

insert an additional prop, defining it by its name (default visibility = false)

Returns
true if the additional prop was added (i.e. another additional prop of the same name does not exist)

Implements camitk::InterfaceGeometry.

References extraProp.

Referenced by buildGlyph(), and buildLabel().

void camitk::Geometry::buildGlyph ( const GlyphTypes  type)
private
void camitk::Geometry::buildLabel ( )
private

build the label extra prop

References addProp(), extraProp, labelActorMapper, and updateLabel().

Referenced by getProp().

virtual void camitk::Geometry::cellPicked ( vtkIdType  ,
bool   
)
inlinevirtual

a vtkCell of the structured was picked (to be reimplemented in a Component inherited class if needed)

Implements camitk::InterfaceGeometry.

vtkSmartPointer< vtkActor > camitk::Geometry::getActor ( const RenderingModes  mode)
virtual

Return the actor representing this representation mode (return NULL if hightlight mode is Hidden).

If RenderingModes have a more than one possible representation, it returns in priority order: the surface, wireframe or points representation.

Implements camitk::InterfaceGeometry.

References enhancedModes, camitk::InterfaceGeometry::Hidden, mapper, camitk::InterfaceGeometry::Points, pointsActor, pointsColor, renderingModes, setActorColor(), camitk::InterfaceGeometry::Surface, surfaceActor, surfaceColor, texture, camitk::InterfaceGeometry::Wireframe, wireframeActor, and wireframeColor.

Referenced by AnyDecoration::show().

void camitk::Geometry::getActorColor ( const RenderingModes  mode,
double  color[4] 
)
virtual

Get the color of given representation modes in the second parameter, i.e. double[4] (r,g,b,a)

Implements camitk::InterfaceGeometry.

References camitk::InterfaceGeometry::Points, pointsColor, camitk::InterfaceGeometry::Surface, surfaceColor, camitk::InterfaceGeometry::Wireframe, and wireframeColor.

Referenced by buildGlyph().

double camitk::Geometry::getActorOpacity ( const RenderingModes  mode) const
virtual
double camitk::Geometry::getBoundingRadius ( )
virtual

compute the object's bounding sphere radius

Implements camitk::InterfaceGeometry.

References getBounds(), and pointSet.

Referenced by setGlyphType().

void camitk::Geometry::getBounds ( double  bounds[6])
virtual

compute the object's bounding box [xmin,xmax, ymin,ymax, zmin,zmax]

Implements camitk::InterfaceGeometry.

References pointSet.

Referenced by getBoundingRadius().

virtual vtkSmartPointer<vtkAlgorithmOutput> camitk::Geometry::getDataPort ( ) const
inlinevirtual

get the custom algorithm pipeline input.

Implements camitk::InterfaceGeometry.

virtual const EnhancedModes camitk::Geometry::getEnhancedModes ( ) const
inlinevirtual

get the current enhanced mode

Implements camitk::InterfaceGeometry.

virtual const QString camitk::Geometry::getLabel ( ) const
inlinevirtual

get the label of this Geometry instance

Implements camitk::InterfaceGeometry.

Referenced by VtkMeshUtil::saveGeometryToFile().

unsigned int camitk::Geometry::getNumberOfProp ( ) const
virtual

return the number of additional prop

Implements camitk::InterfaceGeometry.

References extraProp.

virtual vtkSmartPointer<vtkPointSet> camitk::Geometry::getPointSet ( )
inlinevirtual

Return the dataset associated to this object.

Implements camitk::InterfaceGeometry.

Referenced by VtkMeshUtil::saveGeometryToFile().

vtkSmartPointer< vtkProp > camitk::Geometry::getProp ( const QString &  name)
virtual

Return the vtkProp (actors, volumes and annotations) corresponding to the given name.

Implements camitk::InterfaceGeometry.

References buildGlyph(), buildLabel(), extraProp, and camitk::InterfaceGeometry::Sphere.

Referenced by setGlyphType().

vtkSmartPointer< vtkProp > camitk::Geometry::getProp ( unsigned int  index)
virtual

return an additional prop by its index

Implements camitk::InterfaceGeometry.

References extraProp.

virtual const RenderingModes camitk::Geometry::getRenderingModes ( ) const
inlinevirtual

Return if the actor associated to a rendering mode is currently visible or not.

Implements camitk::InterfaceGeometry.

Referenced by AnyDecoration::show().

virtual void camitk::Geometry::pointPicked ( vtkIdType  ,
bool   
)
inlinevirtual

a vtkPoint of the structured was picked (to be reimplemented in a Component inherited class if needed)

Implements camitk::InterfaceGeometry.

bool camitk::Geometry::removeProp ( const QString &  name)
virtual

remove a given additional prop.

Returns
true if effictively done

Implements camitk::InterfaceGeometry.

References extraProp.

void camitk::Geometry::setActorColor ( const RenderingModes  mode,
double  color[4] 
)
virtual
void camitk::Geometry::setActorColor ( const RenderingModes  mode,
const double  r,
const double  g,
const double  b 
)
virtual

Set the color of given representation modes.

Implements camitk::InterfaceGeometry.

References getActorOpacity(), and setActorColor().

void camitk::Geometry::setActorOpacity ( const RenderingModes  mode,
const double  alpha 
)
virtual

Set the opacity of this representation modes. WARNING color field (surfaceColor, ...) are not modified!

Implements camitk::InterfaceGeometry.

References camitk::InterfaceGeometry::Points, pointsActor, pointsColor, pointSet, camitk::InterfaceGeometry::Surface, surfaceActor, surfaceColor, camitk::InterfaceGeometry::Wireframe, wireframeActor, and wireframeColor.

Referenced by setEnhancedModes(), and setOpacity().

void camitk::Geometry::setColor ( const double  r,
const double  g,
const double  b 
)
virtual

Set an (r,g,b) color to all representation modes, without changing the opacity.

Implements camitk::InterfaceGeometry.

References camitk::InterfaceGeometry::Points, setActorColor(), camitk::InterfaceGeometry::Surface, and camitk::InterfaceGeometry::Wireframe.

Referenced by AnyDecoration::setColor().

void camitk::Geometry::setColor ( const double  r,
const double  g,
const double  b,
const double  a 
)
virtual
void camitk::Geometry::setDataConnection ( vtkSmartPointer< vtkAlgorithmOutput >  outputPort)
virtual

call this method with the custom algorithm pipeline output

Implements camitk::InterfaceGeometry.

References customPipelineOutput, dataOutput, mapper, and tube.

void camitk::Geometry::setEnhancedModes ( const EnhancedModes  emode)
virtual
void camitk::Geometry::setGlyphType ( const GlyphTypes  type,
const double  size = 0.0 
)
virtual
virtual void camitk::Geometry::setLabel ( QString  newName)
inlinevirtual

set the label of this Geometry instance

Implements camitk::InterfaceGeometry.

void camitk::Geometry::setLinesAsTubes ( bool  tubes = false)
virtual

display lines as tubes (depeding of the boolean) (only work if the Geometry was defined using a vtkPolyData).

Implements camitk::InterfaceGeometry.

References customPipelineOutput, mapper, pointSet, and tube.

void camitk::Geometry::setOpacity ( const double  alpha)
virtual

Set the opacity of this object. WARNING color field (surfaceColor, ...) are not modified!

Implements camitk::InterfaceGeometry.

References camitk::InterfaceGeometry::Points, setActorOpacity(), camitk::InterfaceGeometry::Surface, and camitk::InterfaceGeometry::Wireframe.

Referenced by setEnhancedModes().

void camitk::Geometry::setPointData ( vtkSmartPointer< vtkDataArray >  da)
virtual

set the point data (may contains a lookup table)

Implements camitk::InterfaceGeometry.

References mapper, and pointSet.

void camitk::Geometry::setPointPosition ( const unsigned int  orderNumber,
const double  x,
const double  y,
const double  z 
)
virtual

set a given point position

Implements camitk::InterfaceGeometry.

References pointSet.

Referenced by AnyDecoration::update().

void camitk::Geometry::setPointSet ( vtkSmartPointer< vtkPointSet >  ds)
virtual

set the input data of the Geometry,

Note
if there is already a vtkPointSet, this method calls DeepCopy(ds)

Implements camitk::InterfaceGeometry.

References pointSet, setGlyphType(), and camitk::InterfaceGeometry::Sphere.

virtual void camitk::Geometry::setRenderingModes ( const RenderingModes  rMode)
inlinevirtual

Set the actor associated to a rendering mode visible or not.

Implements camitk::InterfaceGeometry.

Referenced by AnyDecoration::AnyDecoration().

void camitk::Geometry::setTexture ( vtkSmartPointer< vtkTexture >  texture)
virtual

Set a texture to this object.

Implements camitk::InterfaceGeometry.

References mapper, surfaceActor, and texture.

void camitk::Geometry::updateLabel ( )
private

update position and text of the label

References extraProp, glyphSize, label, labelActorMapper, and pointSet.

Referenced by buildLabel().

Member Data Documentation

double camitk::Geometry::alphaShaded
private

Opacity value when this object must be shaded.

Referenced by Geometry(), and setEnhancedModes().

vtkSmartPointer<vtkCastToConcrete> camitk::Geometry::concreteData
private

the filter to convert the DataSet to get a correct vtkPipeline output port

Referenced by Geometry().

vtkSmartPointer<vtkAlgorithmOutput> camitk::Geometry::customPipelineOutput
private

the external custom pipeline output (equals to dataOuput if no custom pipeline plugged)

Referenced by buildGlyph(), Geometry(), setDataConnection(), and setLinesAsTubes().

vtkSmartPointer<vtkAlgorithmOutput> camitk::Geometry::dataOutput
private

to be able to set external custom pipeline

Referenced by Geometry(), and setDataConnection().

InterfaceGeometry::EnhancedModes camitk::Geometry::enhancedModes
private

Enhanced mode options (the way actors are rendered: normal, hidden, highlighted, shaded)

Referenced by Geometry(), getActor(), and setEnhancedModes().

QMap<QString, vtkSmartPointer<vtkProp> > camitk::Geometry::extraProp
private

The additional map for prop (include at least "label" and "glyph".

Referenced by addProp(), buildGlyph(), buildLabel(), getNumberOfProp(), getProp(), removeProp(), updateLabel(), and ~Geometry().

double camitk::Geometry::glyphSize
private

current size of glyph (0.0 means no glyph)

Referenced by buildGlyph(), setGlyphType(), and updateLabel().

QString camitk::Geometry::label
private

the label

Referenced by Geometry(), and updateLabel().

vtkSmartPointer<vtkTextMapper> camitk::Geometry::labelActorMapper
private

the mapper to create the text

Referenced by buildLabel(), and updateLabel().

vtkSmartPointer<vtkDataSetMapper> camitk::Geometry::mapper
private
double camitk::Geometry::oldAlphaPoints
private

Referenced by setEnhancedModes().

double camitk::Geometry::oldAlphaSurface
private

Referenced by setEnhancedModes().

double camitk::Geometry::oldAlphaWireframe
private

Referenced by setEnhancedModes().

double camitk::Geometry::oldPointsColor[4]
private
vtkSmartPointer<vtkActor> camitk::Geometry::pointsActor
private

the point actor that manages the representation as a set of points

Referenced by Geometry(), getActor(), setActorColor(), and setActorOpacity().

double camitk::Geometry::pointsColor[4]
private
vtkSmartPointer<vtkPointSet> camitk::Geometry::pointSet
private
InterfaceGeometry::RenderingModes camitk::Geometry::renderingModes
private
vtkSmartPointer<vtkSphereSource> camitk::Geometry::sphereGeom
private

the sphere glyph

Referenced by buildGlyph().

vtkSmartPointer<vtkActor> camitk::Geometry::surfaceActor
private

the surface actor that manages the surfacic representation

Referenced by Geometry(), getActor(), setActorColor(), setActorOpacity(), and setTexture().

double camitk::Geometry::surfaceColor[4]
private
vtkSmartPointer<vtkTexture> camitk::Geometry::texture
private

texture of this object.

Referenced by Geometry(), getActor(), and setTexture().

vtkSmartPointer<vtkTubeFilter> camitk::Geometry::tube
private

the tube filter (creates tubes insead of lines)

Referenced by buildGlyph(), Geometry(), setDataConnection(), and setLinesAsTubes().

vtkSmartPointer<vtkActor> camitk::Geometry::wireframeActor
private

the wireframe actor that manages the representation as wireframe

Referenced by Geometry(), getActor(), setActorColor(), and setActorOpacity().

double camitk::Geometry::wireframeColor[4]
private

The documentation for this class was generated from the following files: