27 #include <vtkAssembly.h>
28 #include <vtkFollower.h>
29 #include <vtkProp3DCollection.h>
30 #include <vtkPropAssembly.h>
31 #include <vtkRenderer.h>
34 #include <vtkPolyDataMapper.h>
35 #include <vtkProperty.h>
44 return m_PropAssembly;
49 vtkLinearTransform *vtktransform = this->GetDataNode()->GetVtkTransform(this->GetTimestep());
51 m_SpheresActor->SetUserTransform(vtktransform);
52 m_ContourActor->SetUserTransform(vtktransform);
77 m_ContourActor->Delete();
78 m_SpheresActor->Delete();
79 m_ContourMapper->Delete();
80 m_SpheresMapper->Delete();
81 m_PropAssembly->Delete();
95 m_PropAssembly->VisibilityOn();
97 if (m_PropAssembly->GetParts()->IsItemPresent(m_SpheresActor))
98 m_PropAssembly->RemovePart(m_SpheresActor);
99 if (m_PropAssembly->GetParts()->IsItemPresent(m_ContourActor))
100 m_PropAssembly->RemovePart(m_ContourActor);
102 m_Spheres->RemoveAllInputs();
103 m_Contour->Initialize();
110 if (itkMesh.GetPointer() == NULL)
112 m_PropAssembly->VisibilityOff();
116 mitk::Mesh::PointsContainer::Iterator i;
120 float floatRgba[4] = {1.0f, 1.0f, 1.0f, 1.0f};
121 double doubleRgba[4] = {1.0f, 1.0f, 1.0f, 1.0f};
125 m_DataNode->GetColor(floatRgba, NULL);
127 if (dynamic_cast<mitk::ColorProperty *>(this->GetDataNode()->GetProperty(
"unselectedcolor")) != NULL)
129 tmpColor =
dynamic_cast<mitk::ColorProperty *
>(this->GetDataNode()->GetProperty(
"unselectedcolor"))->GetValue();
130 floatRgba[0] = tmpColor[0];
131 floatRgba[1] = tmpColor[1];
132 floatRgba[2] = tmpColor[2];
134 doubleRgba[0] = floatRgba[0];
135 doubleRgba[1] = floatRgba[1];
136 doubleRgba[2] = floatRgba[2];
137 doubleRgba[3] = floatRgba[3];
140 if (itkMesh->GetNumberOfPoints() > 0)
143 float pointSize = 2.0;
146 if (pointSizeProp.IsNotNull())
147 pointSize = pointSizeProp->GetValue();
149 for (j = 0, i = itkMesh->GetPoints()->Begin(); i != itkMesh->GetPoints()->End(); i++, j++)
153 sphere->SetRadius(pointSize);
154 sphere->SetCenter(i.Value()[0], i.Value()[1], i.Value()[2]);
156 m_Spheres->AddInputConnection(sphere->GetOutputPort());
161 m_SpheresMapper->SetInputConnection(m_Spheres->GetOutputPort());
162 m_SpheresActor->GetProperty()->SetColor(doubleRgba);
163 m_PropAssembly->AddPart(m_SpheresActor);
166 if (itkMesh->GetNumberOfCells() > 0)
170 itkExceptionMacro(<<
"MeshVtkMapper3D currently not working for MS Visual C++ 6.0, because MeshUtils are "
171 "currently not supported.");
177 if (m_Contour->GetNumberOfCells() > 0)
180 m_ContourMapper->SetInputData(m_Contour);
181 bool wireframe =
true;
182 GetDataNode()->GetVisibility(wireframe, NULL,
"wireframe");
184 m_ContourActor->GetProperty()->SetRepresentationToWireframe();
186 m_ContourActor->GetProperty()->SetRepresentationToSurface();
187 m_ContourActor->GetProperty()->SetColor(doubleRgba);
188 m_PropAssembly->AddPart(m_ContourActor);
193 SetVtkMapperImmediateModeRendering(m_ContourMapper);
194 SetVtkMapperImmediateModeRendering(m_SpheresMapper);
197 GetDataNode()->GetVisibility(visible, renderer,
"visible");
201 m_SpheresActor->VisibilityOff();
202 m_ContourActor->VisibilityOff();
206 bool makeContour =
false;
207 this->GetDataNode()->GetBoolProperty(
"show contour", makeContour);
211 m_ContourActor->VisibilityOn();
215 m_ContourActor->VisibilityOff();
218 bool showPoints =
true;
219 this->GetDataNode()->GetBoolProperty(
"show points", showPoints);
222 m_SpheresActor->VisibilityOn();
226 m_SpheresActor->VisibilityOff();
232 m_PropAssembly->VisibilityOff();
virtual void UpdateVtkTransform(mitk::BaseRenderer *renderer) override
Set the vtkTransform of the m_Prop3D for the current time step of renderer.
static vtkPolyData * MeshToPolyData(MeshType *mesh, bool onlyTriangles=false, bool useScalarAccessor=false, unsigned int pointDataType=0, mitk::BaseGeometry *geometryFrame=NULL, vtkPolyData *polydata=NULL)
virtual void ResetMapper(BaseRenderer *renderer) override
Reset the mapper (i.e., make sure that nothing is displayed) if no valid data is present. In most cases the reimplemented function disables the according actors (toggling visibility off)
itk::SmartPointer< Self > Pointer
Base class for mapper specific rendering ressources.
virtual vtkProp * GetVtkProp(mitk::BaseRenderer *renderer) override
vtkPropAssembly * m_PropAssembly
Organizes the rendering process.
BaseData * GetData() const
Get the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
vtkActor * m_SpheresActor
virtual const mitk::Mesh * GetInput()
The ColorProperty class RGB color property.
vtkActor * m_ContourActor
vtkPolyDataMapper * m_ContourMapper
bool IsGenerateDataRequired(mitk::BaseRenderer *renderer, mitk::Mapper *mapper, mitk::DataNode *dataNode) const
DataStructure which stores a set of points (incl. pointdata) where each point can be associated to an...
virtual ~MeshVtkMapper3D()
itk::RGBPixel< float > Color
Color Standard RGB color typedef (float)
vtkAppendPolyData * m_Spheres
void UpdateGenerateDataTime()
virtual DataNode * GetDataNode() const
Get the DataNode containing the data to map. Method only returns valid DataNode Pointer if the mapper...
vtkPolyDataMapper * m_SpheresMapper
virtual void GenerateDataForRenderer(mitk::BaseRenderer *renderer) override
Generate the data needed for rendering into renderer.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.