32 #include <vtkPlaneCollection.h> 33 #include <vtkPointData.h> 34 #include <vtkPolyData.h> 35 #include <vtkPolyDataMapper.h> 36 #include <vtkPolyDataNormals.h> 37 #include <vtkProperty.h> 38 #include <vtkSmartPointer.h> 71 vtkSmartPointer<vtkPolyData> polydata = input->GetVtkPolyData(this->
GetTimestep());
72 if (polydata ==
nullptr)
84 bool depthsorting =
false;
117 vtkProperty *property,
123 node->
GetProperty(p,
"Backface Culling", renderer);
124 bool useCulling =
false;
126 useCulling = p->GetValue();
127 property->SetBackfaceCulling(useCulling);
132 double ambient[3] = {0.5, 0.5, 0.0};
133 double diffuse[3] = {0.5, 0.5, 0.0};
134 double specular[3] = {1.0, 1.0, 1.0};
136 float coeff_ambient = 0.5f;
137 float coeff_diffuse = 0.5f;
138 float coeff_specular = 0.5f;
139 float power_specular = 10.0f;
148 ambient[0] = c.GetRed();
149 ambient[1] = c.GetGreen();
150 ambient[2] = c.GetBlue();
151 diffuse[0] = c.GetRed();
152 diffuse[1] = c.GetGreen();
153 diffuse[2] = c.GetBlue();
156 specular[0] = c.GetRed();
157 specular[1] = c.GetGreen();
158 specular[2] = c.GetBlue();
165 node->
GetProperty(p,
"material.ambientColor", renderer);
169 ambient[0] = c.GetRed();
170 ambient[1] = c.GetGreen();
171 ambient[2] = c.GetBlue();
178 node->
GetProperty(p,
"material.diffuseColor", renderer);
182 diffuse[0] = c.GetRed();
183 diffuse[1] = c.GetGreen();
184 diffuse[2] = c.GetBlue();
191 node->
GetProperty(p,
"material.specularColor", renderer);
195 specular[0] = c.GetRed();
196 specular[1] = c.GetGreen();
197 specular[2] = c.GetBlue();
203 node->
GetFloatProperty(
"material.ambientCoefficient", coeff_ambient, renderer);
208 node->
GetFloatProperty(
"material.diffuseCoefficient", coeff_diffuse, renderer);
213 node->
GetFloatProperty(
"material.specularCoefficient", coeff_specular, renderer);
221 property->SetAmbient(coeff_ambient);
222 property->SetDiffuse(coeff_diffuse);
223 property->SetSpecular(coeff_specular);
224 property->SetSpecularPower(power_specular);
226 property->SetAmbientColor(ambient);
227 property->SetDiffuseColor(diffuse);
228 property->SetSpecularColor(specular);
235 float opacity = 1.0f;
237 property->SetOpacity(opacity);
244 property->SetLineWidth(lineWidth);
249 float pointSize = 1.0f;
251 property->SetPointSize(pointSize);
257 node->
GetProperty(p,
"material.representation", renderer);
259 property->SetRepresentation(p->GetVtkRepresentation());
265 node->
GetProperty(p,
"material.interpolation", renderer);
267 property->SetInterpolation(p->GetVtkInterpolation());
282 if (transferFuncProp.IsNotNull())
284 ls->
m_VtkPolyDataMapper->SetLookupTable(transferFuncProp->GetValue()->GetColorTransferFunction());
289 if (lookupTableProp.IsNotNull())
291 ls->
m_VtkPolyDataMapper->SetLookupTable(lookupTableProp->GetLookupTable()->GetVtkLookupTable());
304 bool scalarVisibility =
false;
308 if (scalarVisibility)
311 if (this->
GetDataNode()->GetProperty(scalarMode,
"scalar mode", renderer))
316 bool colorMode =
false;
320 double scalarsMin = 0;
323 double scalarsMax = 1.0;
332 if (imagetextureProp.IsNotNull())
335 vtkSmartPointer<vtkTexture> vtkTxture = vtkSmartPointer<vtkTexture>::New();
339 MITK_WARN <<
"3D Textures are not supported by VTK and MITK. The first slice of the volume will be used instead!";
341 sliceselector->SetSliceNr(0);
342 sliceselector->SetChannelNr(0);
343 sliceselector->SetTimeNr(0);
344 sliceselector->SetInput(miktTexture);
345 sliceselector->Update();
346 vtkTxture->SetInputData(sliceselector->GetOutput()->GetVtkImageData());
353 ls->
m_Actor->SetTexture(vtkTxture);
356 MITK_ERROR <<
"Surface.Texture property was set, but there are no texture coordinates. Please provide texture " 357 "coordinates for the vtkPolyData via vtkPolyData->GetPointData()->SetTCoords().";
364 ls->
m_Actor->SetTexture(
nullptr);
368 bool deprecatedUseCellData =
false;
371 bool deprecatedUsePointData =
false;
374 if (deprecatedUseCellData)
380 ls->
m_Actor->GetProperty()->SetSpecular(1);
381 ls->
m_Actor->GetProperty()->SetSpecularPower(50);
382 ls->
m_Actor->GetProperty()->SetInterpolationToPhong();
384 else if (deprecatedUsePointData)
386 float scalarsMin = 0;
387 if (dynamic_cast<mitk::FloatProperty *>(this->
GetDataNode()->GetProperty(
"ScalarsRangeMinimum")) !=
nullptr)
391 float scalarsMax = 0.1;
392 if (dynamic_cast<mitk::FloatProperty *>(this->
GetDataNode()->GetProperty(
"ScalarsRangeMaximum")) !=
nullptr)
399 ls->
m_Actor->GetProperty()->SetSpecular(1);
400 ls->
m_Actor->GetProperty()->SetSpecularPower(50);
401 ls->
m_Actor->GetProperty()->SetInterpolationToPhong();
404 int deprecatedScalarMode = VTK_COLOR_MODE_DEFAULT;
405 if (this->
GetDataNode()->GetIntProperty(
"deprecated scalar mode", deprecatedScalarMode, renderer))
409 ls->
m_Actor->GetProperty()->SetSpecular(1);
410 ls->
m_Actor->GetProperty()->SetSpecularPower(50);
422 PropertyList::PropertyMap::const_iterator it;
423 for (it = rendererProperties->begin(); it != rendererProperties->end(); ++it)
428 for (it = globalProperties->begin(); it != globalProperties->end(); ++it)
455 if ((clippingProperty !=
nullptr) && (clippingProperty->GetClippingEnabled()))
457 const Point3D &origin = clippingProperty->GetOrigin();
458 const Vector3D &normal = clippingProperty->GetNormal();
460 vtkSmartPointer<vtkPlane> clippingPlane = vtkSmartPointer<vtkPlane>::New();
461 clippingPlane->SetOrigin(origin[0], origin[1], origin[2]);
462 clippingPlane->SetNormal(normal[0], normal[1], normal[2]);
498 if (surface.IsNotNull())
500 if ((surface->GetVtkPolyData() !=
nullptr) && (surface->GetVtkPolyData()->GetPointData() !=
nullptr) &&
501 (surface->GetVtkPolyData()->GetPointData()->GetScalars() !=
nullptr))
514 "Enables correct rendering for transparent objects by ordering polygons according to the distance " 515 "to the camera. It is not recommended to enable this property for large surfaces (rendering might "
mitk::BaseProperty * GetProperty(const char *propertyKey, const mitk::BaseRenderer *renderer=nullptr, bool fallBackOnDataProperties=true) const
Get the property (instance of BaseProperty) with key propertyKey from the PropertyList of the rendere...
bool GetDoubleProperty(const char *propertyKey, double &doubleValue, const mitk::BaseRenderer *renderer=nullptr) const
Convenience access method for double properties (instances of DoubleProperty)
Class for storing surfaces (vtkPolyData).
static void SetDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer=nullptr, bool overwrite=false)
vtkSmartPointer< vtkActor > m_Actor
L * GetLocalStorage(mitk::BaseRenderer *forRenderer)
Retrieves a LocalStorage for a specific BaseRenderer.
vtkSmartPointer< vtkDepthSortPolyData > m_DepthSort
virtual bool AddDescription(const std::string &propertyName, const std::string &description, const std::string &className="", bool overwrite=false)=0
Add a description for a specific property.
Property for clipping datasets; currently only clipping planes are possible.
void GenerateDataForRenderer(mitk::BaseRenderer *renderer) override
Generate the data needed for rendering into renderer.
vtkRenderer * GetVtkRenderer() const
virtual DataNode * GetDataNode() const
Get the DataNode containing the data to map. Method only returns valid DataNode Pointer if the mapper...
mitk::LocalStorageHandler< LocalStorage > m_LSH
vtkSmartPointer< vtkPlaneCollection > m_ClippingPlaneCollection
bool GetFloatProperty(const char *propertyKey, float &floatValue, const mitk::BaseRenderer *renderer=nullptr) const
Convenience access method for float properties (instances of FloatProperty)
Organizes the rendering process.
virtual vtkImageData * GetVtkImageData(int t=0, int n=0)
Get a volume at a specific time t of channel n as a vtkImageData.
void ApplyColorAndOpacityProperties(mitk::BaseRenderer *renderer, vtkActor *actor) override
Apply color and opacity properties read from the PropertyList. Called by mapper subclasses.
Property containing a smart-pointer.
bool GetBoolProperty(const char *propertyKey, bool &boolValue, const mitk::BaseRenderer *renderer=nullptr) const
Convenience access method for bool properties (instances of BoolProperty)
bool GetOpacity(float &opacity, const mitk::BaseRenderer *renderer, const char *propertyKey="opacity") const
Convenience access method for opacity properties (instances of FloatProperty)
void ResetMapper(mitk::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)
static IPropertyDescriptions * GetPropertyDescriptions(us::ModuleContext *context=us::GetModuleContext())
Get an IPropertyDescriptions instance.
The LevelWindow class Class to store level/window values.
vtkProp * GetVtkProp(mitk::BaseRenderer *renderer) override
BaseData * GetData() const
Get the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
Abstract base class for properties.
vtkSmartPointer< vtkPolyDataMapper > m_VtkPolyDataMapper
void AddProperty(const char *propertyKey, BaseProperty *property, const mitk::BaseRenderer *renderer=nullptr, bool overwrite=false)
Add the property (instance of BaseProperty) if it does not exist (or always ifoverwrite istrue) with ...
std::map< std::string, BaseProperty::Pointer > PropertyMap
unsigned int GetDimension() const
Get dimension of the image.
virtual const mitk::Surface * GetInput()
virtual int GetVtkScalarMode()
static void ApplyMitkPropertiesToVtkProperty(mitk::DataNode *node, vtkProperty *property, mitk::BaseRenderer *renderer)
ScalarType GetUpperWindowBound() const
virtual void CheckForClippingProperty(mitk::BaseRenderer *renderer, mitk::BaseProperty *property)
Image class for storing images.
bool GetVisibility(bool &visible, const mitk::BaseRenderer *renderer, const char *propertyKey="visible") const
Convenience access method for visibility properties (instances of BoolProperty with property-key "vis...
static void SetDefaultPropertiesForVtkProperty(mitk::DataNode *node, mitk::BaseRenderer *renderer, bool overwrite)
itk::RGBPixel< float > Color
Color Standard RGB color typedef (float)
mitk::PropertyList * GetPropertyList(const mitk::BaseRenderer *renderer=nullptr) const
Get the PropertyList of the renderer. If renderer is nullptr, the BaseRenderer-independent PropertyLi...
vtkSmartPointer< vtkPolyDataNormals > m_VtkPolyDataNormals
int GetTimestep() const
Returns the current time step as calculated from the renderer.
~SurfaceVtkMapper3D() override
bool GetLevelWindow(mitk::LevelWindow &levelWindow, const mitk::BaseRenderer *renderer=nullptr, const char *propertyKey="levelwindow") const
Convenience access method for level-window properties (instances of LevelWindowProperty) ...
ScalarType GetLowerWindowBound() const
Class for nodes of the DataTree.
const PropertyMap * GetMap() const
virtual void ApplyAllProperties(mitk::BaseRenderer *renderer, vtkActor *actor)
static void SetDefaultProperties(DataNode *node, BaseRenderer *renderer=nullptr, bool overwrite=false)
Set default values of properties used by this mapper to node.