Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes

mitk::SplineMapper2D Class Reference

OpenGL-based mapper to display a spline based on a mitk::PointSet in a 2D window. More...

#include <mitkSplineMapper2D.h>

Inheritance diagram for mitk::SplineMapper2D:
Inheritance graph
[legend]
Collaboration diagram for mitk::SplineMapper2D:
Collaboration graph
[legend]

List of all members.

Public Types

typedef SplineMapper2D Self
typedef PointSetGLMapper2D Superclass
typedef itk::SmartPointer< SelfPointer
typedef itk::SmartPointer
< const Self
ConstPointer

Public Member Functions

virtual const char * GetClassName () const
virtual void Paint (mitk::BaseRenderer *renderer)
 Do the painting into the renderer.
virtual void ApplyProperties (mitk::BaseRenderer *renderer)
 Apply color and opacity read from the PropertyList.
virtual void SetMaxProjectionDistance (vtkFloatingPointType _arg)
virtual vtkFloatingPointType GetMaxProjectionDistance ()

Static Public Member Functions

static Pointer New ()

Protected Member Functions

 SplineMapper2D ()
virtual ~SplineMapper2D ()

Protected Attributes

vtkFloatingPointType m_MaxProjectionDistance

Detailed Description

OpenGL-based mapper to display a spline based on a mitk::PointSet in a 2D window.

This mapper can actually more than just draw a number of points of a mitk::PointSet. If you set the right properties of the mitk::DataNode, which contains the point set, then this mapper will also draw lines connecting the points, and calculate and display distances and angles between adjacent points. Here is a complete list of boolean properties, which might be of interest:

Definition at line 57 of file mitkSplineMapper2D.h.


Member Typedef Documentation

typedef itk::SmartPointer<const Self> mitk::SplineMapper2D::ConstPointer

Reimplemented from mitk::PointSetGLMapper2D.

Definition at line 60 of file mitkSplineMapper2D.h.

typedef itk::SmartPointer<Self> mitk::SplineMapper2D::Pointer

Reimplemented from mitk::PointSetGLMapper2D.

Definition at line 60 of file mitkSplineMapper2D.h.

Reimplemented from mitk::PointSetGLMapper2D.

Definition at line 60 of file mitkSplineMapper2D.h.

Reimplemented from mitk::PointSetGLMapper2D.

Definition at line 60 of file mitkSplineMapper2D.h.


Constructor & Destructor Documentation

mitk::SplineMapper2D::SplineMapper2D (  ) [protected]

Definition at line 182 of file mitkSplineMapper2D.cpp.

mitk::SplineMapper2D::~SplineMapper2D (  ) [protected, virtual]

Definition at line 189 of file mitkSplineMapper2D.cpp.

{}

Member Function Documentation

void mitk::SplineMapper2D::ApplyProperties ( mitk::BaseRenderer renderer ) [virtual]

Apply color and opacity read from the PropertyList.

Reimplemented from mitk::PointSetGLMapper2D.

Definition at line 177 of file mitkSplineMapper2D.cpp.

{
  Superclass::ApplyProperties ( renderer );
}
virtual const char* mitk::SplineMapper2D::GetClassName (  ) const [virtual]

Reimplemented from mitk::PointSetGLMapper2D.

virtual vtkFloatingPointType mitk::SplineMapper2D::GetMaxProjectionDistance (  ) [virtual]
static Pointer mitk::SplineMapper2D::New (  ) [static]
void mitk::SplineMapper2D::Paint ( mitk::BaseRenderer renderer ) [virtual]

Do the painting into the renderer.

!define a new ColorProp to be able to pass alpha value

!define a new ColorProp to be able to pass alpha value

Reimplemented from mitk::PointSetGLMapper2D.

Definition at line 30 of file mitkSplineMapper2D.cpp.

References mitk::DataNode::GetColor(), mitk::BaseRenderer::GetCurrentWorldGeometry2D(), mitk::DataNode::GetData(), mitk::Mapper::GetDataNode(), mitk::BaseRenderer::GetDisplayGeometry(), mitk::DataNode::GetMapper(), mitk::BaseData::GetMTime(), mitk::DataNode::GetVtkTransform(), GL_LINE_STRIP, glBegin(), glColor3f(), glEnd(), glLineWidth(), glVertex2f(), mitk::Mapper::IsVisible(), mitk::PointSetGLMapper2D::m_LineWidth, m_MaxProjectionDistance, mitk::PointSetGLMapper2D::Paint(), and mitk::DisplayGeometry::WorldToDisplay().

{
  Superclass::Paint ( renderer );
  if ( IsVisible ( renderer ) == false )
    return;

  //
  // get the poly data of the splines in 3D
  //
  mitk::SplineVtkMapper3D::Pointer mapper3D = dynamic_cast<mitk::SplineVtkMapper3D*> ( this->GetDataNode()->GetMapper ( 2 ) );
  if ( mapper3D.IsNull() )
  {
    itkWarningMacro ( "Mapper used for 3D mapping is not a mitk::SplineVtkMapper3D!" );
    return;
  }
  //
  // update the 3D spline, if the accoring mapper has not been updated yet
  //
  if ( mapper3D->GetLastUpdateTime() < GetDataNode()->GetData()->GetMTime() )
    mapper3D->UpdateSpline();
  vtkPolyData* spline3D = NULL;
  if ( mapper3D->SplinesAreAvailable() )
    spline3D = mapper3D->GetSplinesPolyData();
  else
    return;
  if ( spline3D == NULL )
  {
    itkWarningMacro ( "3D spline is not available!" );
    return;
  }
  //
  // get the transform associated with the data tree node
  //
  vtkLinearTransform* transform = this->GetDataNode()->GetVtkTransform();
  if ( transform == NULL )
  {
    itkWarningMacro("transfrom is NULL");  
  }

  //
  // get the plane geometry of the current renderer
  //
  mitk::Geometry2D::ConstPointer worldGeometry = renderer->GetCurrentWorldGeometry2D();
  if ( worldGeometry.IsNull() )
  {  
    itkWarningMacro("worldGeometry is NULL!");
    return;
  }
  PlaneGeometry::ConstPointer worldPlaneGeometry = dynamic_cast<const mitk::PlaneGeometry*> ( worldGeometry.GetPointer() );
  if ( worldPlaneGeometry.IsNull() )
  {  
    itkWarningMacro("worldPlaneGeometry is NULL!");
    return;
  }

  //
  // determine color of the spline
  //
  float color[3];
  this->GetDataNode()->GetColor ( color, renderer );

  //
  // iterate over the points
  //
  vtkPoints    *vpoints = spline3D->GetPoints();
  vtkCellArray *vlines  = spline3D->GetLines();
  if (vpoints == NULL)
  {
    itkWarningMacro("points are NULL!"); 
    return;
  }
  if (vlines == NULL)
  {
    itkWarningMacro("lines are NULL!"); 
    return;
  }

  mitk::Point3D currentPoint3D;
  mitk::Point2D currentPoint2D;
  vtkFloatingPointType currentPoint3DVtk[3];

  vlines->InitTraversal();
  int numberOfLines = vlines->GetNumberOfCells();
  vtkFloatingPointType currentPointDistance;
  for ( int i = 0;i < numberOfLines; ++i )
  {
    bool previousPointOnPlane = false;
    bool currentPointOnPlane = false;
    vtkIdType* cell ( NULL );
    vtkIdType cellSize ( 0 ); 
    vlines->GetNextCell ( cellSize, cell );
    for ( int j = 0 ; j < cellSize; ++j )
    {
      vpoints->GetPoint ( cell[j], currentPoint3DVtk );
      
      // take transformation via vtktransform into account
      transform->TransformPoint ( currentPoint3DVtk, currentPoint3DVtk );
      vtk2itk ( currentPoint3DVtk, currentPoint3D );

      // check if the point has a distance to the plane 
      // which is smaller than m_MaxProjectionDistance
      currentPointDistance = worldPlaneGeometry->DistanceFromPlane ( currentPoint3D );
      
      if ( currentPointDistance < m_MaxProjectionDistance )
      {
        currentPointOnPlane = true;
        //convert 3D point (in mm) to 2D point on slice (also in mm)
        worldGeometry->Map ( currentPoint3D, currentPoint2D );
        //convert point (until now mm and in worldcoordinates) to display coordinates (units )
        renderer->GetDisplayGeometry()->WorldToDisplay ( currentPoint2D, currentPoint2D );
      }
      else
        currentPointOnPlane = false;

      //
      // check if we have to begin or end a GL_LINE
      //
      if ( ( previousPointOnPlane == false ) && ( currentPointOnPlane == true ) )
      {
        glLineWidth ( m_LineWidth );
        glColor3f ( color[0], color[1], color[2] );
        glBegin ( GL_LINE_STRIP );
      }
      else if ( ( previousPointOnPlane == true ) && ( currentPointOnPlane == false ) )
      {
        glEnd ();
        glLineWidth ( 1.0 );
      }
      // the current ponit is on the plane, add it as point to the
      // line segment
      if ( currentPointOnPlane == true )
      {
        glVertex2f ( currentPoint2D[0], currentPoint2D[1] );
      }
      previousPointOnPlane = currentPointOnPlane;
    }
    // the last point of the spline segment is on the plane, thus we have to 
    // close the GL_LINE
    if ( previousPointOnPlane == true )
    {
      glEnd ();
      glLineWidth ( 1.0 );
    }
    previousPointOnPlane = false;
  }
}
virtual void mitk::SplineMapper2D::SetMaxProjectionDistance ( vtkFloatingPointType  _arg ) [virtual]

Member Data Documentation

vtkFloatingPointType mitk::SplineMapper2D::m_MaxProjectionDistance [protected]

Definition at line 77 of file mitkSplineMapper2D.h.

Referenced by Paint().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines