37 #include <vtkPlaneCollection.h>
38 #include <vtkPointData.h>
39 #include <vtkPolyData.h>
40 #include <vtkPolyDataMapper.h>
41 #include <vtkPolyDataNormals.h>
42 #include <vtkProperty.h>
43 #include <vtkSmartPointer.h>
52 m_GenerateNormals =
false;
64 GetDataNode()->GetVisibility(visible, renderer,
"visible");
76 vtkSmartPointer<vtkPolyData> polydata = input->GetVtkPolyData(this->GetTimestep());
82 if (m_GenerateNormals)
89 bool depthsorting =
false;
90 GetDataNode()->GetBoolProperty(
"Depth Sorting", depthsorting);
109 ApplyAllProperties(renderer, ls->
m_Actor);
122 vtkProperty *property,
128 node->
GetProperty(p,
"Backface Culling", renderer);
129 bool useCulling =
false;
131 useCulling = p->GetValue();
132 property->SetBackfaceCulling(useCulling);
137 double ambient[3] = {0.5, 0.5, 0.0};
138 double diffuse[3] = {0.5, 0.5, 0.0};
139 double specular[3] = {1.0, 1.0, 1.0};
141 float coeff_ambient = 0.5f;
142 float coeff_diffuse = 0.5f;
143 float coeff_specular = 0.5f;
144 float power_specular = 10.0f;
153 ambient[0] = c.GetRed();
154 ambient[1] = c.GetGreen();
155 ambient[2] = c.GetBlue();
156 diffuse[0] = c.GetRed();
157 diffuse[1] = c.GetGreen();
158 diffuse[2] = c.GetBlue();
161 specular[0] = c.GetRed();
162 specular[1] = c.GetGreen();
163 specular[2] = c.GetBlue();
170 node->
GetProperty(p,
"material.ambientColor", renderer);
174 ambient[0] = c.GetRed();
175 ambient[1] = c.GetGreen();
176 ambient[2] = c.GetBlue();
183 node->
GetProperty(p,
"material.diffuseColor", renderer);
187 diffuse[0] = c.GetRed();
188 diffuse[1] = c.GetGreen();
189 diffuse[2] = c.GetBlue();
196 node->
GetProperty(p,
"material.specularColor", renderer);
200 specular[0] = c.GetRed();
201 specular[1] = c.GetGreen();
202 specular[2] = c.GetBlue();
208 node->
GetFloatProperty(
"material.ambientCoefficient", coeff_ambient, renderer);
213 node->
GetFloatProperty(
"material.diffuseCoefficient", coeff_diffuse, renderer);
218 node->
GetFloatProperty(
"material.specularCoefficient", coeff_specular, renderer);
226 property->SetAmbient(coeff_ambient);
227 property->SetDiffuse(coeff_diffuse);
228 property->SetSpecular(coeff_specular);
229 property->SetSpecularPower(power_specular);
231 property->SetAmbientColor(ambient);
232 property->SetDiffuseColor(diffuse);
233 property->SetSpecularColor(specular);
240 float opacity = 1.0f;
242 property->SetOpacity(opacity);
249 property->SetLineWidth(lineWidth);
254 float pointSize = 1.0f;
256 property->SetPointSize(pointSize);
262 node->
GetProperty(p,
"material.representation", renderer);
264 property->SetRepresentation(p->GetVtkRepresentation());
270 node->
GetProperty(p,
"material.interpolation", renderer);
272 property->SetInterpolation(p->GetVtkInterpolation());
282 Superclass::ApplyColorAndOpacityProperties(renderer, ls->
m_Actor);
283 this->ApplyShaderProperties(renderer);
285 ApplyMitkPropertiesToVtkProperty(this->GetDataNode(), ls->
m_Actor->GetProperty(), renderer);
288 this->GetDataNode()->GetProperty(transferFuncProp,
"Surface.TransferFunction", renderer);
289 if (transferFuncProp.IsNotNull())
291 ls->
m_VtkPolyDataMapper->SetLookupTable(transferFuncProp->GetValue()->GetColorTransferFunction());
295 this->GetDataNode()->GetProperty(lookupTableProp,
"LookupTable", renderer);
296 if (lookupTableProp.IsNotNull())
298 ls->
m_VtkPolyDataMapper->SetLookupTable(lookupTableProp->GetLookupTable()->GetVtkLookupTable());
302 if (this->GetDataNode()->GetLevelWindow(levelWindow, renderer,
"levelWindow"))
306 else if (this->GetDataNode()->GetLevelWindow(levelWindow, renderer))
311 bool scalarVisibility =
false;
312 this->GetDataNode()->GetBoolProperty(
"scalar visibility", scalarVisibility);
315 if (scalarVisibility)
318 if (this->GetDataNode()->GetProperty(scalarMode,
"scalar mode", renderer))
323 bool colorMode =
false;
324 this->GetDataNode()->GetBoolProperty(
"color mode", colorMode);
327 double scalarsMin = 0;
328 this->GetDataNode()->GetDoubleProperty(
"ScalarsRangeMinimum", scalarsMin, renderer);
330 double scalarsMax = 1.0;
331 this->GetDataNode()->GetDoubleProperty(
"ScalarsRangeMaximum", scalarsMax, renderer);
339 if (imagetextureProp.IsNotNull())
346 MITK_WARN <<
"3D Textures are not supported by VTK and MITK. The first slice of the volume will be used instead!";
348 sliceselector->SetSliceNr(0);
349 sliceselector->SetChannelNr(0);
350 sliceselector->SetTimeNr(0);
351 sliceselector->SetInput(miktTexture);
352 sliceselector->Update();
353 vtkTxture->SetInputData(sliceselector->GetOutput()->GetVtkImageData());
360 ls->
m_Actor->SetTexture(vtkTxture);
363 MITK_ERROR <<
"Surface.Texture property was set, but there are no texture coordinates. Please provide texture "
364 "coordinates for the vtkPolyData via vtkPolyData->GetPointData()->SetTCoords().";
375 bool deprecatedUseCellData =
false;
376 this->GetDataNode()->GetBoolProperty(
"deprecated useCellDataForColouring", deprecatedUseCellData);
378 bool deprecatedUsePointData =
false;
379 this->GetDataNode()->GetBoolProperty(
"deprecated usePointDataForColouring", deprecatedUsePointData);
381 if (deprecatedUseCellData)
387 ls->
m_Actor->GetProperty()->SetSpecular(1);
388 ls->
m_Actor->GetProperty()->SetSpecularPower(50);
389 ls->
m_Actor->GetProperty()->SetInterpolationToPhong();
391 else if (deprecatedUsePointData)
393 float scalarsMin = 0;
394 if (dynamic_cast<mitk::FloatProperty *>(this->GetDataNode()->GetProperty(
"ScalarsRangeMinimum")) != NULL)
396 dynamic_cast<mitk::FloatProperty *
>(this->GetDataNode()->GetProperty(
"ScalarsRangeMinimum"))->GetValue();
398 float scalarsMax = 0.1;
399 if (dynamic_cast<mitk::FloatProperty *>(this->GetDataNode()->GetProperty(
"ScalarsRangeMaximum")) != NULL)
401 dynamic_cast<mitk::FloatProperty *>(this->GetDataNode()->GetProperty(
"ScalarsRangeMaximum"))->GetValue();
406 ls->
m_Actor->GetProperty()->SetSpecular(1);
407 ls->
m_Actor->GetProperty()->SetSpecularPower(50);
408 ls->
m_Actor->GetProperty()->SetInterpolationToPhong();
411 int deprecatedScalarMode = VTK_COLOR_MODE_DEFAULT;
412 if (this->GetDataNode()->GetIntProperty(
"deprecated scalar mode", deprecatedScalarMode, renderer))
416 ls->
m_Actor->GetProperty()->SetSpecular(1);
417 ls->
m_Actor->GetProperty()->SetSpecularPower(50);
429 PropertyList::PropertyMap::const_iterator it;
430 for (it = rendererProperties->begin(); it != rendererProperties->end(); ++it)
432 this->CheckForClippingProperty(renderer, (*it).second.GetPointer());
435 for (it = globalProperties->begin(); it != globalProperties->end(); ++it)
437 this->CheckForClippingProperty(renderer, (*it).second.GetPointer());
468 clippingPlane->SetOrigin(origin[0], origin[1], origin[2]);
469 clippingPlane->SetNormal(normal[0], normal[1], normal[2]);
512 if (surface.IsNotNull())
514 if ((surface->GetVtkPolyData() != 0) && (surface->GetVtkPolyData()->GetPointData() != NULL) &&
515 (surface->GetVtkPolyData()->GetPointData()->GetScalars() != 0))
528 "Enables correct rendering for transparent objects by ordering polygons according to the distance "
529 "to the camera. It is not recommended to enable this property for large surfaces (rendering might "
531 Superclass::SetDefaultProperties(node, renderer, overwrite);
Class for storing surfaces (vtkPolyData).
vtkSmartPointer< vtkActor > m_Actor
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.
ScalarType GetLowerWindowBound() const
Property for clipping datasets; currently only clipping planes are possible.
virtual void GenerateDataForRenderer(mitk::BaseRenderer *renderer) override
Generate the data needed for rendering into renderer.
virtual void AddDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer, bool overwrite) const =0
Adds all parsed shader uniforms to property list of the given DataNode; used by mappers.
virtual ~SurfaceVtkMapper3D()
vtkSmartPointer< vtkPlaneCollection > m_ClippingPlaneCollection
Organizes the rendering process.
static IShaderRepository * GetShaderRepository()
Get an IShaderRepository instance.
virtual vtkImageData * GetVtkImageData(int t=0, int n=0)
Get a volume at a specific time t of channel n as a vtkImageData.
BaseData * GetData() const
Get the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
mitk::BaseProperty * GetProperty(const char *propertyKey, const mitk::BaseRenderer *renderer=nullptr) const
Get the property (instance of BaseProperty) with key propertyKey from the PropertyList of the rendere...
Property containing a smart-pointer.
virtual 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.
virtual vtkProp * GetVtkProp(mitk::BaseRenderer *renderer) override
Abstract base class for properties.
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 ...
Management class for vtkShader XML descriptions.
bool GetOpacity(float &opacity, const mitk::BaseRenderer *renderer, const char *propertyKey="opacity") const
Convenience access method for opacity properties (instances of FloatProperty)
std::map< std::string, BaseProperty::Pointer > PropertyMap
virtual const mitk::Surface * GetInput()
virtual int GetVtkScalarMode()
static void SetDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer=NULL, bool overwrite=false)
static void ApplyMitkPropertiesToVtkProperty(mitk::DataNode *node, vtkProperty *property, mitk::BaseRenderer *renderer)
const Vector3D & GetNormal() const
bool GetFloatProperty(const char *propertyKey, float &floatValue, const mitk::BaseRenderer *renderer=nullptr) const
Convenience access method for float properties (instances of FloatProperty)
virtual void CheckForClippingProperty(mitk::BaseRenderer *renderer, mitk::BaseProperty *property)
Image class for storing images.
static void SetDefaultPropertiesForVtkProperty(mitk::DataNode *node, mitk::BaseRenderer *renderer, bool overwrite)
itk::RGBPixel< float > Color
Color Standard RGB color typedef (float)
const Point3D & GetOrigin() const
vtkSmartPointer< vtkPolyDataNormals > m_VtkPolyDataNormals
ScalarType GetUpperWindowBound() const
virtual DataNode * GetDataNode() const
Get the DataNode containing the data to map. Method only returns valid DataNode Pointer if the mapper...
bool GetClippingEnabled() const
unsigned int GetDimension() const
Get dimension of the image.
vtkRenderer * GetVtkRenderer() const
vtkSmartPointer< vtkPainterPolyDataMapper > m_VtkPolyDataMapper
Class for nodes of the DataTree.
virtual void ApplyAllProperties(mitk::BaseRenderer *renderer, vtkActor *actor)
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.