33 #include <vtkArrowSource.h>
34 #include <vtkAssembly.h>
35 #include <vtkCutter.h>
36 #include <vtkGlyph3D.h>
37 #include <vtkLookupTable.h>
39 #include <vtkPointData.h>
40 #include <vtkPolyData.h>
41 #include <vtkReverseSense.h>
42 #include <vtkTransformPolyDataFilter.h>
146 if ((dataTimeGeometry == NULL) || (dataTimeGeometry->CountTimeSteps() == 0) ||
186 if (time > itk::NumericTraits<ScalarType>::NonpositiveMin())
189 vtkSmartPointer<vtkPolyData> inputPolyData = surface->
GetVtkPolyData(timestep);
190 if ((inputPolyData == NULL) || (inputPolyData->GetNumberOfPoints() < 1))
202 if (localStorage->
m_Actor->GetMapper() == NULL)
206 origin[0] = planeGeometry->
GetOrigin()[0];
207 origin[1] = planeGeometry->
GetOrigin()[1];
208 origin[2] = planeGeometry->
GetOrigin()[2];
211 normal[0] = planeGeometry->
GetNormal()[0];
212 normal[1] = planeGeometry->
GetNormal()[1];
213 normal[2] = planeGeometry->
GetNormal()[2];
221 filter->SetTransform(vtktransform);
222 filter->SetInputData(inputPolyData);
223 localStorage->
m_Cutter->SetInputConnection(filter->GetOutputPort());
226 bool generateNormals =
false;
243 bool generateInverseNormals =
false;
245 if (generateInverseNormals)
274 float lineWidth = 1.0f;
280 float color[3] = {1.0f, 1.0f, 1.0f};
281 node->
GetColor(color, renderer,
"color");
282 float opacity = 1.0f;
283 node->
GetOpacity(opacity, renderer,
"opacity");
286 localStorage->
m_Actor->GetProperty()->SetColor(color[0], color[1], color[2]);
287 localStorage->
m_Actor->GetProperty()->SetOpacity(opacity);
288 localStorage->
m_NormalActor->GetProperty()->SetOpacity(opacity);
290 localStorage->
m_Actor->GetProperty()->SetLineWidth(lineWidth);
295 localStorage->
m_Actor->GetProperty()->SetLighting(0);
300 if (transferFuncProp.IsNotNull())
302 localStorage->
m_Mapper->SetLookupTable(transferFuncProp->GetValue()->GetColorTransferFunction());
307 if (lookupTableProp.IsNotNull())
309 localStorage->
m_Mapper->SetLookupTable(lookupTableProp->GetLookupTable()->GetVtkLookupTable());
322 bool scalarVisibility =
false;
324 localStorage->
m_Mapper->SetScalarVisibility((scalarVisibility ? 1 : 0));
326 if (scalarVisibility)
329 if (this->
GetDataNode()->GetProperty(scalarMode,
"scalar mode", renderer))
332 localStorage->
m_Mapper->SetScalarModeToDefault();
334 bool colorMode =
false;
336 localStorage->
m_Mapper->SetColorMode((colorMode ? 1 : 0));
338 double scalarsMin = 0;
341 double scalarsMax = 1.0;
344 localStorage->
m_Mapper->SetScalarRange(scalarsMin, scalarsMax);
348 float inverseNormalsColor[3] = {1.0f, 0.0f, 0.0f};
349 node->
GetColor(inverseNormalsColor, renderer,
"back color");
351 inverseNormalsColor[0], inverseNormalsColor[1], inverseNormalsColor[2]);
354 float normalsColor[3] = {0.0f, 1.0f, 0.0f};
355 node->
GetColor(normalsColor, renderer,
"front color");
356 localStorage->
m_NormalActor->GetProperty()->SetColor(normalsColor[0], normalsColor[1], normalsColor[2]);
359 float normalScaleFactor = 10.0f;
360 node->
GetFloatProperty(
"front normal lenth (px)", normalScaleFactor, renderer);
361 localStorage->
m_NormalGlyph->SetScaleFactor(normalScaleFactor);
364 float inverseNormalScaleFactor = 10.0f;
365 node->
GetFloatProperty(
"back normal lenth (px)", inverseNormalScaleFactor, renderer);
373 aliases->
AddAlias(
"line width",
"Surface.2D.Line Width",
"Surface");
376 aliases->
AddAlias(
"draw normals 2D",
"Surface.2D.Normals.Draw Normals",
"Surface");
378 aliases->
AddAlias(
"invert normals",
"Surface.2D.Normals.Draw Inverse Normals",
"Surface");
380 aliases->
AddAlias(
"front color",
"Surface.2D.Normals.Normals Color",
"Surface");
382 aliases->
AddAlias(
"back color",
"Surface.2D.Normals.Inverse Normals Color",
"Surface");
384 aliases->
AddAlias(
"front normal lenth (px)",
"Surface.2D.Normals.Normals Scale Factor",
"Surface");
386 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.
const Point3D GetOrigin() const
Get the origin, e.g. the upper-left corner of the plane.
vtkSmartPointer< vtkPlane > m_CuttingPlane
m_CuttingPlane The plane where to cut off the 2D slice.
Class for storing surfaces (vtkPolyData).
mitk::PropertyList * GetPropertyList(const mitk::BaseRenderer *renderer=nullptr) const
Get the PropertyList of the renderer. If renderer is NULL, the BaseRenderer-independent PropertyList ...
Interface of property aliases service.
L * GetLocalStorage(mitk::BaseRenderer *forRenderer)
Retrieves a LocalStorage for a specific BaseRenderer.
ScalarType GetLowerWindowBound() const
LocalStorage()
Default constructor of the local storage.
virtual 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 ...
Internal class holding the mapper, actor, etc. for each of the 3 2D render windows.
virtual bool IsValid() const
Is this BaseGeometry in a state that is valid?
virtual vtkPolyData * GetVtkPolyData(unsigned int t=0) const
Organizes the rendering process.
bool GetBoolProperty(const char *propertyKey, bool &boolValue, const mitk::BaseRenderer *renderer=nullptr) const
Convenience access method for bool properties (instances of BoolProperty)
vtkSmartPointer< vtkArrowSource > m_ArrowSource
m_ArrowSource Arrow representation of the normals.
virtual void UpdateOutputInformation() override
ScalarType GetTime() const
Get the time in ms of the currently displayed content.
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.
const mitk::TimeGeometry * GetTimeGeometry() const
Return the TimeGeometry of the data as const pointer.
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...
virtual unsigned long GetMTime() const override
Get the timestamp of the last change of the contents of this node or the referenced BaseData...
bool GetDoubleProperty(const char *propertyKey, double &doubleValue, const mitk::BaseRenderer *renderer=nullptr) const
Convenience access method for double properties (instances of DoubleProperty)
Vector3D GetNormal() const
Normal of the plane.
int GetTimestep() const
Returns the current time step as calculated from the renderer.
The LevelWindow class Class to store level/window values.
vtkSmartPointer< vtkGlyph3D > m_InverseNormalGlyph
m_InverseNormalGlyph Glyph for creating inverse normals.
void Update(BaseRenderer *renderer) override
Update Check if data should be generated.
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 GetOpacity(float &opacity, const mitk::BaseRenderer *renderer, const char *propertyKey="opacity") const
Convenience access method for opacity properties (instances of FloatProperty)
virtual int GetVtkScalarMode()
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.
bool GetFloatProperty(const char *propertyKey, float &floatValue, const mitk::BaseRenderer *renderer=nullptr) const
Convenience access method for float properties (instances of FloatProperty)
virtual const mitk::Surface * GetInput() const
vtkSmartPointer< vtkPolyDataMapper > m_NormalMapper
m_NormalMapper Mapper for the normals.
vtkSmartPointer< vtkPolyDataMapper > m_InverseNormalMapper
m_InverseNormalMapper Mapper for the inverse normals.
virtual ~SurfaceVtkMapper2D()
~SurfaceVtkMapper2D default destructor.
virtual void CalculateTimeStep(BaseRenderer *renderer)
Updates the time step, which is sometimes needed in subclasses.
static void SetDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer=NULL, bool overwrite=false)
set the default properties for this mapper
vtkLinearTransform * GetVtkTransform(int t=0) const
Get the transformation applied prior to displaying the data as a vtkTransform.
bool HasReferenceGeometry() const
~LocalStorage()
Default deconstructor of the local storage.
virtual void ResetMapper(BaseRenderer *renderer) override
ResetMapper Called in mitk::Mapper::Update to hide objects. If TimeSlicedGeometry or time step is not...
vtkSmartPointer< vtkReverseSense > m_ReverseSense
m_ReverseSense Filter to invert the normals.
virtual vtkProp * GetVtkProp(mitk::BaseRenderer *renderer) override
returns the prop assembly
vtkSmartPointer< vtkActor > m_NormalActor
m_NormalActor actor for the normals.
virtual void GenerateDataForRenderer(mitk::BaseRenderer *renderer) override
GenerateDataForRenderer produces all the data.
mitk::LocalStorageHandler< LocalStorage > m_LSH
The LocalStorageHandler holds all (three) LocalStorages for the three 2D render windows.
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) ...
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.
ScalarType GetUpperWindowBound() const
virtual DataNode * GetDataNode() const
Get the DataNode containing the data to map. Method only returns valid DataNode Pointer if the mapper...
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 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...
bool GetColor(float rgb[3], const mitk::BaseRenderer *renderer=nullptr, const char *propertyKey="color") const
Convenience access method for color properties (instances of ColorProperty)
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.
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.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.
SurfaceVtkMapper2D()
SurfaceVtkMapper2D default constructor.