29 #include <vtkArrowSource.h> 30 #include <vtkAssembly.h> 31 #include <vtkCutter.h> 32 #include <vtkGlyph3D.h> 33 #include <vtkLookupTable.h> 35 #include <vtkPointData.h> 36 #include <vtkPolyData.h> 37 #include <vtkReverseSense.h> 38 #include <vtkTransformPolyDataFilter.h> 43 m_Mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
45 m_Actor = vtkSmartPointer<vtkActor>::New();
49 m_Cutter = vtkSmartPointer<vtkCutter>::New();
134 if (surface ==
nullptr)
142 if ((dataTimeGeometry ==
nullptr) || (dataTimeGeometry->
CountTimeSteps() == 0) ||
148 surface->UpdateOutputInformation();
176 const TimeGeometry *dataTimeGeometry = surface->GetTimeGeometry();
182 if (time > itk::NumericTraits<ScalarType>::NonpositiveMin())
185 vtkSmartPointer<vtkPolyData> inputPolyData = surface->GetVtkPolyData(timestep);
186 if ((inputPolyData ==
nullptr) || (inputPolyData->GetNumberOfPoints() < 1))
198 if (localStorage->
m_Actor->GetMapper() ==
nullptr)
202 origin[0] = planeGeometry->
GetOrigin()[0];
203 origin[1] = planeGeometry->
GetOrigin()[1];
204 origin[2] = planeGeometry->
GetOrigin()[2];
207 normal[0] = planeGeometry->
GetNormal()[0];
208 normal[1] = planeGeometry->
GetNormal()[1];
209 normal[2] = planeGeometry->
GetNormal()[2];
216 vtkSmartPointer<vtkTransformPolyDataFilter> filter = vtkSmartPointer<vtkTransformPolyDataFilter>::New();
217 filter->SetTransform(vtktransform);
218 filter->SetInputData(inputPolyData);
219 localStorage->
m_Cutter->SetInputConnection(filter->GetOutputPort());
222 bool generateNormals =
false;
239 bool generateInverseNormals =
false;
241 if (generateInverseNormals)
264 float lineWidth = 1.0f;
267 int legacyLineWidth = lineWidth;
287 float lineWidth = 1.0f;
293 float color[3] = {1.0f, 1.0f, 1.0f};
294 node->
GetColor(color, renderer,
"color");
295 float opacity = 1.0f;
296 node->
GetOpacity(opacity, renderer,
"opacity");
299 localStorage->
m_Actor->GetProperty()->SetColor(color[0], color[1], color[2]);
300 localStorage->
m_Actor->GetProperty()->SetOpacity(opacity);
301 localStorage->
m_NormalActor->GetProperty()->SetOpacity(opacity);
303 localStorage->
m_Actor->GetProperty()->SetLineWidth(lineWidth);
308 localStorage->
m_Actor->GetProperty()->SetLighting(
false);
313 if (transferFuncProp.IsNotNull())
315 localStorage->
m_Mapper->SetLookupTable(transferFuncProp->GetValue()->GetColorTransferFunction());
320 if (lookupTableProp.IsNotNull())
322 localStorage->
m_Mapper->SetLookupTable(lookupTableProp->GetLookupTable()->GetVtkLookupTable());
335 bool scalarVisibility =
false;
337 localStorage->
m_Mapper->SetScalarVisibility((scalarVisibility ? 1 : 0));
339 if (scalarVisibility)
342 if (this->
GetDataNode()->GetProperty(scalarMode,
"scalar mode", renderer))
345 localStorage->
m_Mapper->SetScalarModeToDefault();
347 bool colorMode =
false;
349 localStorage->
m_Mapper->SetColorMode((colorMode ? 1 : 0));
351 double scalarsMin = 0;
354 double scalarsMax = 1.0;
357 localStorage->
m_Mapper->SetScalarRange(scalarsMin, scalarsMax);
361 float inverseNormalsColor[3] = {1.0f, 0.0f, 0.0f};
362 node->
GetColor(inverseNormalsColor, renderer,
"back color");
364 inverseNormalsColor[0], inverseNormalsColor[1], inverseNormalsColor[2]);
367 float normalsColor[3] = {0.0f, 1.0f, 0.0f};
368 node->
GetColor(normalsColor, renderer,
"front color");
369 localStorage->
m_NormalActor->GetProperty()->SetColor(normalsColor[0], normalsColor[1], normalsColor[2]);
372 float normalScaleFactor = 10.0f;
373 node->
GetFloatProperty(
"front normal lenth (px)", normalScaleFactor, renderer);
374 localStorage->
m_NormalGlyph->SetScaleFactor(normalScaleFactor);
377 float inverseNormalScaleFactor = 10.0f;
378 node->
GetFloatProperty(
"back normal lenth (px)", inverseNormalScaleFactor, renderer);
386 aliases->
AddAlias(
"line width",
"Surface.2D.Line Width",
"Surface");
389 aliases->
AddAlias(
"draw normals 2D",
"Surface.2D.Normals.Draw Normals",
"Surface");
391 aliases->
AddAlias(
"invert normals",
"Surface.2D.Normals.Draw Inverse Normals",
"Surface");
393 aliases->
AddAlias(
"front color",
"Surface.2D.Normals.Normals Color",
"Surface");
395 aliases->
AddAlias(
"back color",
"Surface.2D.Normals.Inverse Normals Color",
"Surface");
397 aliases->
AddAlias(
"front normal lenth (px)",
"Surface.2D.Normals.Normals Scale Factor",
"Surface");
399 aliases->
AddAlias(
"back normal lenth (px)",
"Surface.2D.Normals.Inverse Normals Scale Factor",
"Surface");
void ApplyAllProperties(BaseRenderer *renderer)
ApplyAllProperties Pass all the properties to VTK.
bool GetFloatProperty(const char *propertyKey, float &floatValue) const
Convenience method to access the value of a FloatProperty.
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...
ScalarType GetTime() const
Get the time in ms of the currently displayed content.
bool GetDoubleProperty(const char *propertyKey, double &doubleValue, const mitk::BaseRenderer *renderer=nullptr) const
Convenience access method for double properties (instances of DoubleProperty)
vtkSmartPointer< vtkPlane > m_CuttingPlane
m_CuttingPlane The plane where to cut off the 2D slice.
static void SetDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer=nullptr, bool overwrite=false)
set the default properties for this mapper
Class for storing surfaces (vtkPolyData).
Interface of property aliases service.
L * GetLocalStorage(mitk::BaseRenderer *forRenderer)
Retrieves a LocalStorage for a specific BaseRenderer.
virtual TimeStepType CountTimeSteps() const =0
Returns the number of time steps.
LocalStorage()
Default constructor of the local storage.
unsigned long GetMTime() const override
Get the timestamp of the last change of the map or the last change of one of the properties store in ...
bool GetIntProperty(const char *propertyKey, int &intValue) const
Convenience method to access the value of an IntProperty.
Internal class holding the mapper, actor, etc. for each of the 3 2D render windows.
virtual DataNode * GetDataNode() const
Get the DataNode containing the data to map. Method only returns valid DataNode Pointer if the mapper...
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.
~SurfaceVtkMapper2D() override
~SurfaceVtkMapper2D default destructor.
vtkSmartPointer< vtkArrowSource > m_ArrowSource
m_ArrowSource Arrow representation of the normals.
itk::TimeStamp m_LastUpdateTime
Timestamp of last update of stored data.
virtual bool AddAlias(const std::string &propertyName, const std::string &alias, const std::string &className="")=0
Add an alias for a specific property.
vtkSmartPointer< vtkActor > m_InverseNormalActor
m_InverseNormalActor actor for the inverse normals.
virtual const PlaneGeometry * GetCurrentWorldPlaneGeometry()
Get the current 2D-worldgeometry (m_CurrentWorldPlaneGeometry) used for 2D-rendering.
Key-value list holding instances of BaseProperty.
unsigned long GetMTime() const override
Get the timestamp of the last change of the contents of this node or the referenced BaseData...
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)
The LevelWindow class Class to store level/window values.
bool HasReferenceGeometry() const
vtkSmartPointer< vtkGlyph3D > m_InverseNormalGlyph
m_InverseNormalGlyph Glyph for creating inverse normals.
void Update(BaseRenderer *renderer) override
Update Check if data should be generated.
BaseData * GetData() const
Get the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
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 ...
bool GetColor(float rgb[3], const mitk::BaseRenderer *renderer=nullptr, const char *propertyKey="color") const
Convenience access method for color properties (instances of ColorProperty)
virtual int GetVtkScalarMode()
void ReplaceProperty(const std::string &propertyKey, BaseProperty *property)
Set a property object in the list/map by reference.
ScalarType GetUpperWindowBound() const
virtual TimeStepType TimePointToTimeStep(TimePointType timePoint) const =0
Converts a time point to the corresponding time step.
vtkSmartPointer< vtkGlyph3D > m_NormalGlyph
m_NormalGlyph Glyph for creating normals.
vtkSmartPointer< vtkPolyDataMapper > m_NormalMapper
m_NormalMapper Mapper for the normals.
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...
vtkSmartPointer< vtkPolyDataMapper > m_InverseNormalMapper
m_InverseNormalMapper Mapper for the inverse normals.
virtual void CalculateTimeStep(BaseRenderer *renderer)
Updates the time step, which is sometimes needed in subclasses.
vtkLinearTransform * GetVtkTransform(int t=0) const
Get the transformation applied prior to displaying the data as a vtkTransform.
const Point3D GetOrigin() const
Get the origin, e.g. the upper-left corner of the plane.
virtual bool IsValid() const
Is this BaseGeometry in a state that is valid?
mitk::PropertyList * GetPropertyList(const mitk::BaseRenderer *renderer=nullptr) const
Get the PropertyList of the renderer. If renderer is nullptr, the BaseRenderer-independent PropertyLi...
Vector3D GetNormal() const
Normal of the plane.
void ResetMapper(BaseRenderer *renderer) override
ResetMapper Called in mitk::Mapper::Update to hide objects. If TimeSlicedGeometry or time step is not...
virtual const mitk::Surface * GetInput() const
vtkSmartPointer< vtkReverseSense > m_ReverseSense
m_ReverseSense Filter to invert the normals.
vtkProp * GetVtkProp(mitk::BaseRenderer *renderer) override
returns the prop assembly
vtkSmartPointer< vtkActor > m_NormalActor
m_NormalActor actor for the normals.
void GenerateDataForRenderer(mitk::BaseRenderer *renderer) override
GenerateDataForRenderer produces all the data.
int GetTimestep() const
Returns the current time step as calculated from the renderer.
mitk::LocalStorageHandler< LocalStorage > m_LSH
The LocalStorageHandler holds all (three) LocalStorages for the three 2D render windows.
unsigned long GetCurrentWorldPlaneGeometryUpdateTime()
Get timestamp of last call of SetCurrentWorldPlaneGeometry.
vtkSmartPointer< vtkAssembly > m_PropAssembly
m_PropAssembly Contains all vtkProps for the final rendering.
Describes a two-dimensional, rectangular plane.
vtkSmartPointer< vtkPolyDataMapper > m_Mapper
m_Mapper VTK mapper for all types of 2D polydata e.g. werewolves.
static IPropertyAliases * GetPropertyAliases(us::ModuleContext *context=us::GetModuleContext())
Get an IPropertyAliases instance.
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
~LocalStorage() override
Default deconstructor of the local storage.
vtkSmartPointer< vtkActor > m_Actor
m_Actor actor for the surface cut.
virtual bool IsValidTimeStep(TimeStepType timeStep) const =0
Test for the given time step if a geometry is availible.
virtual void FixupLegacyProperties(PropertyList *properties)
Updates legacy properties to current behavior/interpretation.
Class for nodes of the DataTree.
static void SetDefaultProperties(DataNode *node, BaseRenderer *renderer=nullptr, bool overwrite=false)
Set default values of properties used by this mapper to node.
vtkSmartPointer< vtkCutter > m_Cutter
m_Cutter Filter to cut out the 2D slice.
SurfaceVtkMapper2D()
SurfaceVtkMapper2D default constructor.