Vtk-based mapper for Splines. More...
#include <mitkSplineVtkMapper3D.h>
Public Types | |
typedef SplineVtkMapper3D | Self |
typedef PointSetVtkMapper3D | Superclass |
typedef itk::SmartPointer< Self > | Pointer |
typedef itk::SmartPointer < const Self > | ConstPointer |
Public Member Functions | |
virtual const char * | GetClassName () const |
virtual vtkProp * | GetVtkProp (mitk::BaseRenderer *renderer) |
virtual void | UpdateVtkTransform (mitk::BaseRenderer *renderer) |
Set the vtkTransform of the m_Prop3D for the current time step of renderer. | |
bool | SplinesAreAvailable () |
vtkPolyData * | GetSplinesPolyData () |
vtkActor * | GetSplinesActor () |
unsigned long | GetLastUpdateTime () const |
virtual void | UpdateSpline () |
virtual void | SetSplineResolution (unsigned int _arg) |
virtual unsigned int | GetSplineResolution () |
Static Public Member Functions | |
static Pointer | New () |
Protected Member Functions | |
SplineVtkMapper3D () | |
virtual | ~SplineVtkMapper3D () |
virtual void | GenerateData () |
Generate the data needed for rendering (independent of a specific renderer) | |
virtual void | GenerateData (mitk::BaseRenderer *renderer) |
Generate the data needed for rendering into renderer. | |
virtual void | ApplyProperties () |
Protected Attributes | |
vtkActor * | m_SplinesActor |
vtkPropAssembly * | m_SplineAssembly |
bool | m_SplinesAvailable |
bool | m_SplinesAddedToAssembly |
unsigned int | m_SplineResolution |
itk::TimeStamp | m_SplineUpdateTime |
Vtk-based mapper for Splines.
properties looked for: "line width" = with of the spline
Definition at line 43 of file mitkSplineVtkMapper3D.h.
typedef itk::SmartPointer<const Self> mitk::SplineVtkMapper3D::ConstPointer |
Reimplemented from mitk::PointSetVtkMapper3D.
Definition at line 47 of file mitkSplineVtkMapper3D.h.
typedef itk::SmartPointer<Self> mitk::SplineVtkMapper3D::Pointer |
Reimplemented from mitk::PointSetVtkMapper3D.
Definition at line 47 of file mitkSplineVtkMapper3D.h.
Reimplemented from mitk::PointSetVtkMapper3D.
Definition at line 47 of file mitkSplineVtkMapper3D.h.
Reimplemented from mitk::PointSetVtkMapper3D.
Definition at line 47 of file mitkSplineVtkMapper3D.h.
mitk::SplineVtkMapper3D::SplineVtkMapper3D | ( | ) | [protected] |
Definition at line 35 of file mitkSplineVtkMapper3D.cpp.
References m_SplineAssembly, m_SplineResolution, m_SplinesActor, and New().
: m_SplinesAvailable (false), m_SplinesAddedToAssembly(false) { m_SplinesActor = vtkActor::New(); m_SplineAssembly = vtkPropAssembly::New(); m_SplineResolution = 500; }
mitk::SplineVtkMapper3D::~SplineVtkMapper3D | ( | ) | [protected, virtual] |
Definition at line 44 of file mitkSplineVtkMapper3D.cpp.
{ m_SplinesActor->Delete(); m_SplineAssembly->Delete(); }
void mitk::SplineVtkMapper3D::ApplyProperties | ( | ) | [protected, virtual] |
Definition at line 119 of file mitkSplineVtkMapper3D.cpp.
{ //vtk changed the type of rgba during releases. Due to that, the following convert is done vtkFloatingPointType rgba[ 4 ] = {1.0f, 1.0f, 1.0f, 1.0f};//white //getting the color from DataNode float temprgba[4]; this->GetDataNode()->GetColor( &temprgba[0], NULL ); //convert to rgba, what ever type it has! rgba[0] = temprgba[0]; rgba[1] = temprgba[1]; rgba[2] = temprgba[2]; rgba[3] = temprgba[3]; //finaly set the color inside the actor m_SplinesActor->GetProperty()->SetColor( rgba ); float lineWidth; if (dynamic_cast<mitk::FloatProperty *>(this->GetDataNode()->GetProperty("line width")) == NULL) lineWidth = 1.0; else lineWidth = dynamic_cast<mitk::FloatProperty *>(this->GetDataNode()->GetProperty("line width"))->GetValue(); m_SplinesActor->GetProperty()->SetLineWidth(lineWidth); m_SplineUpdateTime.Modified(); }
void mitk::SplineVtkMapper3D::GenerateData | ( | ) | [protected, virtual] |
Generate the data needed for rendering (independent of a specific renderer)
Reimplemented from mitk::PointSetVtkMapper3D.
Definition at line 65 of file mitkSplineVtkMapper3D.cpp.
{ Superclass::GenerateData(); // only update spline if UpdateSpline has not been called from // external, e.g. by the SplineMapper2D. But call it the first time when m_SplineUpdateTime = 0 and m_LastUpdateTime = 0. if ( m_SplineUpdateTime < m_LastUpdateTime || m_SplineUpdateTime == 0) { this->UpdateSpline(); this->ApplyProperties(); } if ( m_SplinesAvailable ) { if ( ! m_SplinesAddedToAssembly ) { m_SplineAssembly->AddPart( m_SplinesActor ); m_SplinesAddedToAssembly = true; } } else { if ( m_SplinesAddedToAssembly ) { m_SplineAssembly->RemovePart( m_SplinesActor ); m_SplinesAddedToAssembly = false; } } }
void mitk::SplineVtkMapper3D::GenerateData | ( | mitk::BaseRenderer * | renderer ) | [protected, virtual] |
Generate the data needed for rendering into renderer.
Reimplemented from mitk::PointSetVtkMapper3D.
Definition at line 96 of file mitkSplineVtkMapper3D.cpp.
{ if ( IsVisible( renderer ) == false ) { m_SplinesActor->VisibilityOff(); m_SplineAssembly->VisibilityOff(); } else { m_SplinesActor->VisibilityOn(); m_SplineAssembly->VisibilityOn(); //remove the PointsAssembly if it was added in superclass. No need to display points and spline! if(m_SplineAssembly->GetParts()->IsItemPresent(m_PointsAssembly)) m_SplineAssembly->RemovePart(m_PointsAssembly); } //if the properties have been changed, then refresh the properties if ( (m_SplineUpdateTime < this->m_DataNode->GetPropertyList()->GetMTime() ) || (m_SplineUpdateTime < this->m_DataNode->GetPropertyList(renderer)->GetMTime() ) ) this->ApplyProperties(); }
virtual const char* mitk::SplineVtkMapper3D::GetClassName | ( | ) | const [virtual] |
Reimplemented from mitk::PointSetVtkMapper3D.
unsigned long mitk::SplineVtkMapper3D::GetLastUpdateTime | ( | ) | const |
Definition at line 165 of file mitkSplineVtkMapper3D.cpp.
{ return m_LastUpdateTime.GetMTime(); }
virtual unsigned int mitk::SplineVtkMapper3D::GetSplineResolution | ( | ) | [virtual] |
vtkActor * mitk::SplineVtkMapper3D::GetSplinesActor | ( | ) |
Definition at line 157 of file mitkSplineVtkMapper3D.cpp.
{ if ( m_SplinesAvailable ) return m_SplinesActor; else return vtkActor::New(); }
vtkPolyData * mitk::SplineVtkMapper3D::GetSplinesPolyData | ( | ) |
Definition at line 149 of file mitkSplineVtkMapper3D.cpp.
{ if ( m_SplinesAvailable ) return ( dynamic_cast<vtkPolyDataMapper*>( m_SplinesActor->GetMapper() ) )->GetInput(); else return NULL; }
vtkProp * mitk::SplineVtkMapper3D::GetVtkProp | ( | mitk::BaseRenderer * | renderer ) | [virtual] |
Reimplemented from mitk::PointSetVtkMapper3D.
Definition at line 51 of file mitkSplineVtkMapper3D.cpp.
{ return m_SplineAssembly; }
static Pointer mitk::SplineVtkMapper3D::New | ( | ) | [static] |
Reimplemented from mitk::PointSetVtkMapper3D.
Referenced by SplineVtkMapper3D(), and mitkDataNodeExtTestClass::TestMapperSetting().
virtual void mitk::SplineVtkMapper3D::SetSplineResolution | ( | unsigned int | _arg ) | [virtual] |
bool mitk::SplineVtkMapper3D::SplinesAreAvailable | ( | ) |
Definition at line 143 of file mitkSplineVtkMapper3D.cpp.
{ return m_SplinesAvailable; }
void mitk::SplineVtkMapper3D::UpdateSpline | ( | ) | [virtual] |
Definition at line 170 of file mitkSplineVtkMapper3D.cpp.
References mitk::PointSet::GetSize(), and QuadProgPP::t().
{ mitk::PointSet::Pointer input = const_cast<mitk::PointSet*>( this->GetInput( ) ); // input->Update();//already done in superclass // Number of points on the spline unsigned int numberOfOutputPoints = m_SplineResolution; unsigned int numberOfInputPoints = input->GetSize(); if ( numberOfInputPoints >= 2 ) { m_SplinesAvailable = true; vtkCardinalSpline* splineX = vtkCardinalSpline::New(); vtkCardinalSpline* splineY = vtkCardinalSpline::New(); vtkCardinalSpline* splineZ = vtkCardinalSpline::New(); unsigned int index = 0; mitk::PointSet::DataType::PointsContainer::Pointer pointsContainer = input->GetPointSet()->GetPoints(); for ( mitk::PointSet::DataType::PointsContainer::Iterator it = pointsContainer->Begin(); it != pointsContainer->End(); ++it, ++index ) //for ( unsigned int i = 0 ; i < numberOfInputPoints; ++i ) { mitk::PointSet::PointType point = it->Value(); splineX->AddPoint( index, point[ 0 ] ); splineY->AddPoint( index, point[ 1 ] ); splineZ->AddPoint( index, point[ 2 ] ); } vtkPoints* points = vtkPoints::New(); vtkPolyData* profileData = vtkPolyData::New(); // Interpolate x, y and z by using the three spline filters and // create new points double t = 0.0f; for ( unsigned int i = 0; i < numberOfOutputPoints; ++i ) { t = ( ( ( ( double ) numberOfInputPoints ) - 1.0f ) / ( ( ( double ) numberOfOutputPoints ) - 1.0f ) ) * ( ( double ) i ); points->InsertPoint( i, splineX->Evaluate( t ), splineY->Evaluate( t ), splineZ->Evaluate( t ) ) ; } // Create the polyline. vtkCellArray* lines = vtkCellArray::New(); lines->InsertNextCell( numberOfOutputPoints ); for ( unsigned int i = 0; i < numberOfOutputPoints; ++i ) lines->InsertCellPoint( i ); profileData->SetPoints( points ); profileData->SetLines( lines ); // Add thickness to the resulting line. //vtkTubeFilter* profileTubes = vtkTubeFilter::New(); //profileTubes->SetNumberOfSides(8); //profileTubes->SetInput(profileData); //profileTubes->SetRadius(.005); vtkPolyDataMapper* profileMapper = vtkPolyDataMapper::New(); profileMapper->SetInput( profileData ); m_SplinesActor->SetMapper( profileMapper ); } else { m_SplinesAvailable = false; } m_SplineUpdateTime.Modified(); }
void mitk::SplineVtkMapper3D::UpdateVtkTransform | ( | mitk::BaseRenderer * | renderer ) | [virtual] |
Set the vtkTransform of the m_Prop3D for the current time step of renderer.
Called by mitk::VtkPropRenderer::Update before rendering
Reimplemented from mitk::PointSetVtkMapper3D.
Definition at line 56 of file mitkSplineVtkMapper3D.cpp.
{ vtkLinearTransform * vtktransform = this->GetDataNode()->GetVtkTransform(this->GetTimestep()); m_SplinesActor->SetUserTransform(vtktransform); }
vtkPropAssembly* mitk::SplineVtkMapper3D::m_SplineAssembly [protected] |
Definition at line 82 of file mitkSplineVtkMapper3D.h.
Referenced by SplineVtkMapper3D().
unsigned int mitk::SplineVtkMapper3D::m_SplineResolution [protected] |
Definition at line 88 of file mitkSplineVtkMapper3D.h.
Referenced by SplineVtkMapper3D().
vtkActor* mitk::SplineVtkMapper3D::m_SplinesActor [protected] |
Definition at line 80 of file mitkSplineVtkMapper3D.h.
Referenced by SplineVtkMapper3D().
bool mitk::SplineVtkMapper3D::m_SplinesAddedToAssembly [protected] |
Definition at line 86 of file mitkSplineVtkMapper3D.h.
bool mitk::SplineVtkMapper3D::m_SplinesAvailable [protected] |
Definition at line 84 of file mitkSplineVtkMapper3D.h.
itk::TimeStamp mitk::SplineVtkMapper3D::m_SplineUpdateTime [protected] |
Definition at line 90 of file mitkSplineVtkMapper3D.h.