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

mitk::ContourVtkMapper3D Class Reference
[Mapper Classes]

Vtk-based mapper for mitk::Contour. More...

#include <mitkContourVtkMapper3D.h>

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

List of all members.

Public Types

typedef ContourVtkMapper3D Self
typedef VtkMapper3D Superclass
typedef itk::SmartPointer< SelfPointer
typedef itk::SmartPointer
< const Self
ConstPointer

Public Member Functions

virtual const char * GetClassName () const
virtual const mitk::ContourGetInput ()
virtual vtkProp * GetVtkProp (mitk::BaseRenderer *renderer)

Static Public Member Functions

static Pointer New ()

Protected Member Functions

 ContourVtkMapper3D ()
virtual ~ContourVtkMapper3D ()
virtual void GenerateData (mitk::BaseRenderer *renderer)
 Generate the data needed for rendering into renderer.

Protected Attributes

vtkSmartPointer
< vtkPolyDataMapper > 
m_VtkPolyDataMapper
vtkSmartPointer< vtkTubeFilter > m_TubeFilter
vtkSmartPointer
< vtkAppendPolyData > 
m_VtkPointList
vtkSmartPointer< vtkPolyData > m_Contour
vtkSmartPointer< vtkActor > m_Actor

Detailed Description

Vtk-based mapper for mitk::Contour.

Definition at line 41 of file mitkContourVtkMapper3D.h.


Member Typedef Documentation

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

Reimplemented from mitk::VtkMapper3D.

Definition at line 44 of file mitkContourVtkMapper3D.h.

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

Reimplemented from mitk::VtkMapper3D.

Definition at line 44 of file mitkContourVtkMapper3D.h.

Reimplemented from mitk::VtkMapper3D.

Definition at line 44 of file mitkContourVtkMapper3D.h.

Reimplemented from mitk::VtkMapper3D.

Definition at line 44 of file mitkContourVtkMapper3D.h.


Constructor & Destructor Documentation

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

Definition at line 53 of file mitkContourVtkMapper3D.cpp.

{
  if(m_VtkPolyDataMapper)
    m_VtkPolyDataMapper->Delete();

  if(m_TubeFilter)
    m_TubeFilter->Delete();

  if(m_VtkPointList)
    m_VtkPointList->Delete();

  if(m_Contour)
    m_Contour->Delete();
  
  if(m_Actor)
    m_Actor->Delete();
}

Member Function Documentation

void mitk::ContourVtkMapper3D::GenerateData ( mitk::BaseRenderer renderer ) [protected, virtual]

Generate the data needed for rendering into renderer.

Reimplemented from mitk::Mapper.

Definition at line 76 of file mitkContourVtkMapper3D.cpp.

{
  if ( IsVisible(renderer)==false )
  {
    m_Actor->VisibilityOff();
    return;
  }
  m_Actor->VisibilityOn();

  m_Contour = vtkPolyData::New();

  mitk::Contour::Pointer input  = const_cast<mitk::Contour*>(this->GetInput());
  bool makeContour = true;

  if ( makeContour )
  {
    vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
    vtkSmartPointer<vtkCellArray> lines = vtkSmartPointer<vtkCellArray>::New();

    int numPts=input->GetNumberOfPoints();
    if ( numPts > 200000 )
      numPts = 200000;
    mitk::Contour::PathPointer path = input->GetContourPath();
    mitk::Contour::PathType::InputType cstart = path->StartOfInput();
    mitk::Contour::PathType::InputType cend   = path->EndOfInput();
    mitk::Contour::PathType::InputType cstep  = (cend-cstart+1)/numPts;
    mitk::Contour::PathType::InputType ccur;

    vtkIdType ptIndex = 0;
    vtkIdType lastPointIndex = 0;

    mitk::Contour::PointsContainerPointer contourPoints = input->GetPoints();
    mitk::Contour::PointsContainerIterator pointsIt = contourPoints->Begin();

    vtkFloatingPointType vtkpoint[3];

    int i;
    float pointSize = 2;
    this->GetDataNode()->GetFloatProperty("spheres size", pointSize);

    bool showPoints = true;
    this->GetDataNode()->GetBoolProperty("show points", showPoints);
    if ( showPoints )
    {
      m_VtkPointList = vtkAppendPolyData::New();
    }
    for ( i=0, ccur=cstart; i<numPts; ++i, ccur+=cstep )
    {
      itk2vtk(path->Evaluate(ccur), vtkpoint);
      points->InsertPoint(ptIndex, vtkpoint);
      if ( ptIndex > 0 )
      {
        int cell[2] = {ptIndex-1,ptIndex};
        lines->InsertNextCell((vtkIdType)2,(vtkIdType*) cell);
      }
      lastPointIndex = ptIndex;
      ++ptIndex;

      if ( showPoints )
      {
        vtkSmartPointer<vtkSphereSource> sphere = vtkSmartPointer<vtkSphereSource>::New();

        sphere->SetRadius(pointSize);
        sphere->SetCenter(vtkpoint);

        m_VtkPointList->AddInput(sphere->GetOutput());
        sphere->Update();
      }
    }

    if ( input->GetClosed() )
    {
      int cell[2] = {lastPointIndex,0};
      lines->InsertNextCell((vtkIdType)2,(vtkIdType*) cell);
    }

    m_Contour->SetPoints(points);
    m_Contour->SetLines(lines);
    m_Contour->Update();

    m_TubeFilter->SetInput(m_Contour);
    m_TubeFilter->SetRadius(pointSize / 2.0f);
    m_TubeFilter->SetNumberOfSides(8);
    m_TubeFilter->Update();

    if ( showPoints )
    {
      m_VtkPointList->AddInput(m_TubeFilter->GetOutput());
      m_VtkPolyDataMapper->SetInput(m_VtkPointList->GetOutput());
    }
    else
    {
      m_VtkPolyDataMapper->SetInput(m_TubeFilter->GetOutput());
    }
    vtkFloatingPointType rgba[4]={0.0f,1.0f,0.0f,0.6f};
    m_Actor->GetProperty()->SetColor(rgba);
    m_Actor->SetMapper(m_VtkPolyDataMapper);
  }
  
  SetVtkMapperImmediateModeRendering(m_VtkPolyDataMapper);
}
virtual const char* mitk::ContourVtkMapper3D::GetClassName (  ) const [virtual]

Reimplemented from mitk::VtkMapper3D.

const mitk::Contour * mitk::ContourVtkMapper3D::GetInput ( void   ) [virtual]

Definition at line 178 of file mitkContourVtkMapper3D.cpp.

{
  return static_cast<const mitk::Contour* > ( GetData() );
}
vtkProp * mitk::ContourVtkMapper3D::GetVtkProp ( mitk::BaseRenderer renderer ) [virtual]

Implements mitk::VtkMapper3D.

Definition at line 71 of file mitkContourVtkMapper3D.cpp.

{
  return m_Actor;
}
static Pointer mitk::ContourVtkMapper3D::New (  ) [static]

Member Data Documentation

vtkSmartPointer<vtkActor> mitk::ContourVtkMapper3D::m_Actor [protected]

Definition at line 63 of file mitkContourVtkMapper3D.h.

Referenced by ContourVtkMapper3D().

vtkSmartPointer<vtkPolyData> mitk::ContourVtkMapper3D::m_Contour [protected]

Definition at line 62 of file mitkContourVtkMapper3D.h.

vtkSmartPointer<vtkTubeFilter> mitk::ContourVtkMapper3D::m_TubeFilter [protected]

Definition at line 59 of file mitkContourVtkMapper3D.h.

Referenced by ContourVtkMapper3D().

vtkSmartPointer<vtkAppendPolyData> mitk::ContourVtkMapper3D::m_VtkPointList [protected]

Definition at line 61 of file mitkContourVtkMapper3D.h.

Referenced by ContourVtkMapper3D().

vtkSmartPointer<vtkPolyDataMapper> mitk::ContourVtkMapper3D::m_VtkPolyDataMapper [protected]

Definition at line 58 of file mitkContourVtkMapper3D.h.

Referenced by ContourVtkMapper3D().


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