21 #include <vtkCardinalSpline.h>
22 #include <vtkCellArray.h>
23 #include <vtkPoints.h>
24 #include <vtkPolyData.h>
25 #include <vtkPolyDataMapper.h>
27 #include <vtkPropAssembly.h>
28 #include <vtkPropCollection.h>
29 #include <vtkProperty.h>
30 #include <vtkTubeFilter.h>
41 m_SplinesActor->Delete();
42 m_SplineAssembly->Delete();
47 return m_SplineAssembly;
52 vtkLinearTransform *vtktransform = this->GetDataNode()->GetVtkTransform(this->GetTimestep());
54 m_SplinesActor->SetUserTransform(vtktransform);
64 if (m_SplineUpdateTime < ls->GetLastGenerateDataTime() || m_SplineUpdateTime == 0)
67 this->ApplyAllProperties(renderer, m_SplinesActor);
70 if (m_SplinesAvailable)
72 if (!m_SplinesAddedToAssembly)
74 m_SplineAssembly->AddPart(m_SplinesActor);
75 m_SplinesAddedToAssembly =
true;
80 if (m_SplinesAddedToAssembly)
82 m_SplineAssembly->RemovePart(m_SplinesActor);
83 m_SplinesAddedToAssembly =
false;
88 GetDataNode()->GetVisibility(visible, renderer,
"visible");
92 m_SplinesActor->VisibilityOff();
93 m_SplineAssembly->VisibilityOff();
97 m_SplinesActor->VisibilityOn();
98 m_SplineAssembly->VisibilityOn();
101 if (m_SplineAssembly->GetParts()->IsItemPresent(m_PointsAssembly))
102 m_SplineAssembly->RemovePart(m_PointsAssembly);
105 if ((m_SplineUpdateTime < this->m_DataNode->GetPropertyList()->GetMTime()) ||
106 (m_SplineUpdateTime < this->m_DataNode->GetPropertyList(renderer)->GetMTime()))
107 this->ApplyAllProperties(renderer, m_SplinesActor);
112 Superclass::ApplyColorAndOpacityProperties(renderer, actor);
115 double rgba[4] = {1.0f, 1.0f, 1.0f, 1.0f};
119 this->GetDataNode()->GetColor(&temprgba[0], NULL);
121 rgba[0] = temprgba[0];
122 rgba[1] = temprgba[1];
123 rgba[2] = temprgba[2];
124 rgba[3] = temprgba[3];
126 m_SplinesActor->GetProperty()->SetColor(rgba);
129 if (dynamic_cast<mitk::IntProperty *>(this->GetDataNode()->GetProperty(
"line width")) == NULL)
132 lineWidth =
dynamic_cast<mitk::IntProperty *
>(this->GetDataNode()->GetProperty(
"line width"))->GetValue();
133 m_SplinesActor->GetProperty()->SetLineWidth(lineWidth);
135 m_SplineUpdateTime.Modified();
140 return m_SplinesAvailable;
145 if (m_SplinesAvailable)
146 return (dynamic_cast<vtkPolyDataMapper *>(m_SplinesActor->GetMapper()))->GetInput();
153 if (m_SplinesAvailable)
154 return m_SplinesActor;
165 unsigned int numberOfOutputPoints = m_SplineResolution;
166 unsigned int numberOfInputPoints = input->GetSize();
168 if (numberOfInputPoints >= 2)
170 m_SplinesAvailable =
true;
174 unsigned int index = 0;
176 for (mitk::PointSet::DataType::PointsContainer::Iterator it = pointsContainer->Begin();
177 it != pointsContainer->End();
182 splineX->AddPoint(index, point[0]);
183 splineY->AddPoint(index, point[1]);
184 splineZ->AddPoint(index, point[2]);
192 for (
unsigned int i = 0; i < numberOfOutputPoints; ++i)
194 t = ((((double)numberOfInputPoints) - 1.0f) / (((
double)numberOfOutputPoints) - 1.0f)) * ((
double)i);
195 points->InsertPoint(i, splineX->Evaluate(t), splineY->Evaluate(t), splineZ->Evaluate(t));
200 lines->InsertNextCell(numberOfOutputPoints);
201 for (
unsigned int i = 0; i < numberOfOutputPoints; ++i)
202 lines->InsertCellPoint(i);
204 profileData->SetPoints(points);
205 profileData->SetLines(lines);
214 profileMapper->SetInputData(profileData);
216 m_SplinesActor->SetMapper(profileMapper);
220 m_SplinesAvailable =
false;
222 m_SplineUpdateTime.Modified();
itk::SmartPointer< Self > Pointer
Base class for mapper specific rendering ressources.
virtual ~SplineVtkMapper3D()
vtkPolyData * GetSplinesPolyData()
vtkActor * GetSplinesActor()
vtkPropAssembly * m_SplineAssembly
Organizes the rendering process.
unsigned int m_SplineResolution
bool SplinesAreAvailable()
Data structure which stores a set of points. Superclass of mitk::Mesh.
virtual void GenerateDataForRenderer(mitk::BaseRenderer *renderer) override
Generate the data needed for rendering into renderer.
virtual void ApplyAllProperties(BaseRenderer *renderer, vtkActor *actor) override
virtual void UpdateSpline()
virtual void UpdateVtkTransform(mitk::BaseRenderer *renderer) override
Set the vtkTransform of the m_Prop3D for the current time step of renderer.
virtual vtkProp * GetVtkProp(mitk::BaseRenderer *renderer) override
vtkActor * m_SplinesActor
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.