25 #include <vtkAppendPolyData.h>
26 #include <vtkAssembly.h>
27 #pragma GCC diagnostic ignored "-Wstrict-aliasing"
28 #include <vtkCellArray.h>
29 #pragma GCC diagnostic warning "-Wstrict-aliasing"
30 #include <vtkFollower.h>
31 #include <vtkLinearTransform.h>
32 #include <vtkPolyData.h>
33 #include <vtkPolyDataMapper.h>
34 #include <vtkPolygon.h>
35 #include <vtkProp3DCollection.h>
36 #include <vtkProperty.h>
37 #include <vtkRenderer.h>
38 #include <vtkSphereSource.h>
39 #include <vtkTubeFilter.h>
53 if (m_VtkPolyDataMapper)
54 m_VtkPolyDataMapper->Delete();
57 m_TubeFilter->Delete();
60 m_VtkPointList->Delete();
77 GetDataNode()->GetVisibility(visible, renderer,
"visible");
81 m_Actor->VisibilityOff();
84 m_Actor->VisibilityOn();
89 bool makeContour =
true;
96 int numPts = input->GetNumberOfPoints();
100 mitk::Contour::PathType::InputType cstart = path->StartOfInput();
101 mitk::Contour::PathType::InputType cend = path->EndOfInput();
102 mitk::Contour::PathType::InputType cstep = (cend - cstart + 1) / numPts;
103 mitk::Contour::PathType::InputType ccur;
105 vtkIdType ptIndex = 0;
106 vtkIdType lastPointIndex = 0;
114 this->GetDataNode()->GetFloatProperty(
"spheres size", pointSize);
116 bool showPoints =
true;
117 this->GetDataNode()->GetBoolProperty(
"show points", showPoints);
122 for (i = 0, ccur = cstart; i < numPts; ++i, ccur += cstep)
124 itk2vtk(path->Evaluate(ccur), vtkpoint);
125 points->InsertPoint(ptIndex, vtkpoint);
128 vtkIdType cell[2] = {ptIndex - 1, ptIndex};
129 lines->InsertNextCell((vtkIdType)2, cell);
131 lastPointIndex = ptIndex;
138 sphere->SetRadius(pointSize);
139 sphere->SetCenter(vtkpoint);
141 m_VtkPointList->AddInputConnection(sphere->GetOutputPort());
146 if (input->GetClosed())
148 vtkIdType cell[2] = {lastPointIndex, 0};
149 lines->InsertNextCell((vtkIdType)2, cell);
152 m_Contour->SetPoints(points);
153 m_Contour->SetLines(lines);
155 m_TubeFilter->SetInputData(m_Contour);
156 m_TubeFilter->SetRadius(pointSize / 2.0f);
157 m_TubeFilter->SetNumberOfSides(8);
158 m_TubeFilter->Update();
162 m_VtkPointList->AddInputConnection(m_TubeFilter->GetOutputPort());
163 m_VtkPolyDataMapper->SetInputConnection(m_VtkPointList->GetOutputPort());
167 m_VtkPolyDataMapper->SetInputConnection(m_TubeFilter->GetOutputPort());
169 double rgba[4] = {0.0f, 1.0f, 0.0f, 0.6f};
170 m_Actor->GetProperty()->SetColor(rgba);
171 m_Actor->SetMapper(m_VtkPolyDataMapper);
174 SetVtkMapperImmediateModeRendering(m_VtkPolyDataMapper);
179 return static_cast<const mitk::Contour *
>(GetDataNode()->GetData());
Organizes the rendering process.
vtkSmartPointer< vtkPolyDataMapper > m_VtkPolyDataMapper
vtkSmartPointer< vtkActor > m_Actor
vtkSmartPointer< vtkAppendPolyData > m_VtkPointList
virtual vtkProp * GetVtkProp(mitk::BaseRenderer *renderer) override
Stores vertices for drawing a contour.
BoundingBoxType::PointsContainer::Pointer PointsContainerPointer
PathType::Pointer PathPointer
vtkSmartPointer< vtkTubeFilter > m_TubeFilter
void itk2vtk(const Tin &in, Tout &out)
virtual const mitk::Contour * GetInput()
virtual void GenerateDataForRenderer(mitk::BaseRenderer *renderer) override
Generate the data needed for rendering into renderer.
virtual ~ContourVtkMapper3D()
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.