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

mitk::ContourSetVtkMapper3D Class Reference
[Mapper Classes]

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

#include <mitkContourSetVtkMapper3D.h>

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

List of all members.

Public Types

typedef ContourSetVtkMapper3D 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::ContourSetGetInput ()
virtual vtkProp * GetVtkProp (mitk::BaseRenderer *renderer)

Static Public Member Functions

static Pointer New ()

Protected Member Functions

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

Protected Attributes

vtkPolyDataMapper * m_VtkPolyDataMapper
vtkTubeFilter * m_TubeFilter
vtkPolyData * m_ContourSet
vtkActor * m_Actor

Detailed Description

Vtk-based mapper for mitk::Contour.

Definition at line 40 of file mitkContourSetVtkMapper3D.h.


Member Typedef Documentation

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

Reimplemented from mitk::VtkMapper3D.

Definition at line 44 of file mitkContourSetVtkMapper3D.h.

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

Reimplemented from mitk::VtkMapper3D.

Definition at line 44 of file mitkContourSetVtkMapper3D.h.

Reimplemented from mitk::VtkMapper3D.

Definition at line 44 of file mitkContourSetVtkMapper3D.h.

Reimplemented from mitk::VtkMapper3D.

Definition at line 44 of file mitkContourSetVtkMapper3D.h.


Constructor & Destructor Documentation

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

Definition at line 56 of file mitkContourSetVtkMapper3D.cpp.

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

  if( m_TubeFilter )
    m_TubeFilter->Delete();;

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

Member Function Documentation

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

Generate the data needed for rendering into renderer.

Reimplemented from mitk::Mapper.

Definition at line 76 of file mitkContourSetVtkMapper3D.cpp.

References mitk::Contour::GetClosed(), mitk::Contour::GetContourPath(), mitk::ContourSet::GetContours(), mitk::BaseRenderer::GetDisplayGeometryUpdateTime(), and mitk::Contour::GetPoints().

{
  if(IsVisible(renderer)==false)
  {
    m_Actor->VisibilityOff();
    return;
  }
  m_Actor->VisibilityOn();
  
  mitk::ContourSet::Pointer input  = const_cast<mitk::ContourSet*>(this->GetInput());

  if ( renderer->GetDisplayGeometryUpdateTime() > this->GetInput()->GetMTime() )
  {
    m_ContourSet = vtkPolyData::New();

    vtkPoints *points = vtkPoints::New();
    vtkCellArray *lines = vtkCellArray::New();

    mitk::ContourSet::Pointer input =  const_cast<mitk::ContourSet*>(this->GetInput());
    mitk::ContourSet::ContourVectorType contourVec = input->GetContours();
    mitk::ContourSet::ContourIterator contourIt = contourVec.begin();
    
    vtkIdType firstPointIndex= 0, lastPointIndex=0;

    vtkIdType ptIndex = 0;
    while ( contourIt != contourVec.end() )
    {
      mitk::Contour* nextContour = (mitk::Contour*) (*contourIt).second;
      Contour::InputType idx = nextContour->GetContourPath()->StartOfInput();


      Contour::InputType end = nextContour->GetContourPath()->EndOfInput();
      if (end > 50000) end = 0;

      mitk::Contour::PointsContainerPointer contourPoints = nextContour->GetPoints();
      mitk::Contour::PointsContainerIterator pointsIt = contourPoints->Begin();
      unsigned int counter = 0;

      firstPointIndex=ptIndex;
      while ( pointsIt != contourPoints->End() )
      {
        if (counter %2 == 0)
        {        
          Contour::BoundingBoxType::PointType point;
          point = pointsIt.Value();
          points->InsertPoint(ptIndex, point[0],point[1],point[2]);
          if (ptIndex > firstPointIndex)
          {
            int cell[2] = {ptIndex-1,ptIndex};
            lines->InsertNextCell((vtkIdType)2,(vtkIdType*) cell);
          }
          lastPointIndex=ptIndex;
          ptIndex++;
        }
        pointsIt++;
        idx+=1;
      }

      if (nextContour->GetClosed())
      {
        int cell[2] = {lastPointIndex,firstPointIndex};
        lines->InsertNextCell((vtkIdType)2,(vtkIdType*) cell);
      }
      contourIt++;
    }

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

    m_TubeFilter->SetInput(m_ContourSet);
    m_TubeFilter->SetRadius(1);
    m_TubeFilter->Update();
    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::ContourSetVtkMapper3D::GetClassName (  ) const [virtual]

Reimplemented from mitk::VtkMapper3D.

const mitk::ContourSet * mitk::ContourSetVtkMapper3D::GetInput ( void   ) [virtual]

Definition at line 160 of file mitkContourSetVtkMapper3D.cpp.

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

Implements mitk::VtkMapper3D.

Definition at line 71 of file mitkContourSetVtkMapper3D.cpp.

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

Member Data Documentation

vtkActor* mitk::ContourSetVtkMapper3D::m_Actor [protected]

Definition at line 64 of file mitkContourSetVtkMapper3D.h.

Referenced by ContourSetVtkMapper3D().

Definition at line 63 of file mitkContourSetVtkMapper3D.h.

Referenced by ContourSetVtkMapper3D().

vtkTubeFilter* mitk::ContourSetVtkMapper3D::m_TubeFilter [protected]

Definition at line 61 of file mitkContourSetVtkMapper3D.h.

Referenced by ContourSetVtkMapper3D().

vtkPolyDataMapper* mitk::ContourSetVtkMapper3D::m_VtkPolyDataMapper [protected]

Definition at line 60 of file mitkContourSetVtkMapper3D.h.

Referenced by ContourSetVtkMapper3D().


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