44 #include <vtkProperty.h>
45 #include <vtkTransform.h>
46 #include <vtkMatrix4x4.h>
47 #include <vtkLookupTable.h>
48 #include <vtkImageData.h>
49 #include <vtkPoints.h>
50 #include <vtkGeneralTransform.h>
51 #include <vtkImageExtractComponents.h>
52 #include <vtkImageReslice.h>
53 #include <vtkImageChangeInformation.h>
54 #include <vtkPlaneSource.h>
55 #include <vtkPolyDataMapper.h>
56 #include <vtkCellArray.h>
57 #include <vtkCamera.h>
58 #include <vtkColorTransferFunction.h>
59 #include <vtkImageCheckerboard.h>
60 #include <vtkImageWeightedSum.h>
61 #include <vtkImageMathematics.h>
62 #include <vtkImageRectilinearWipe.h>
63 #include <vtkImageGradientMagnitude.h>
64 #include <vtkImageAppendComponents.h>
65 #include <vtkImageExtractComponents.h>
68 #include <itkRGBAPixel.h>
86 LocalStorage *localStorage = m_LSH.GetLocalStorage(renderer);
88 float depth = this->CalculateLayerDepth(renderer);
91 localStorage->
m_Plane->SetOrigin(planeBounds[0], planeBounds[2], depth);
95 localStorage->
m_Plane->SetPoint1(planeBounds[1] , planeBounds[2], depth);
96 localStorage->
m_Plane->SetPoint2(planeBounds[0], planeBounds[3], depth);
102 double maxRange = renderer->
GetVtkRenderer()->GetActiveCamera()->GetClippingRange()[1];
105 float depth = -maxRange*0.01;
107 GetDataNode()->GetIntProperty(
"layer", layer, renderer);
112 MITK_WARN <<
"Layer value exceeds clipping range. Set to minimum instead.";
175 return m_LSH.GetLocalStorage(renderer)->m_Actors;
180 bool updated =
false;
181 LocalStorage *localStorage = m_LSH.GetLocalStorage(renderer);
186 if ( targetInput.IsNull() || targetInput->IsInitialized() == false )
193 if ( movingInput.IsNull() || movingInput->IsInitialized() == false )
211 targetInput->Update();
215 if ( !RenderingGeometryIntersectsImage( worldGeometry, targetInput->GetSlicedGeometry() ) )
226 localStorage->
m_Reslicer->SetInput(targetInput);
227 localStorage->
m_Reslicer->SetWorldGeometry(worldGeometry);
228 localStorage->
m_Reslicer->SetTimeStep( this->GetTimestep() );
232 localStorage->
m_Reslicer->SetResliceTransformByGeometry( targetInput->GetTimeGeometry()->GetGeometryForTimeStep( this->GetTimestep() ) );
236 bool inPlaneResampleExtentByGeometry =
false;
237 datanode->
GetBoolProperty(
"in plane resample extent by geometry", inPlaneResampleExtentByGeometry, renderer);
238 localStorage->
m_Reslicer->SetInPlaneResampleExtentByGeometry(inPlaneResampleExtentByGeometry);
243 if ( (targetInput->GetDimension() >= 3) && (targetInput->GetDimension(2) > 1) )
247 resliceInterpolationProperty,
"reslice interpolation" );
249 int interpolationMode = VTK_RESLICE_NEAREST;
250 if ( resliceInterpolationProperty != NULL )
255 switch ( interpolationMode )
257 case VTK_RESLICE_NEAREST:
260 case VTK_RESLICE_LINEAR:
263 case VTK_RESLICE_CUBIC:
274 localStorage->
m_Reslicer->SetOutputDimensionality( 2 );
275 localStorage->
m_Reslicer->SetOutputSpacingZDirection(1.0);
276 localStorage->
m_Reslicer->SetOutputExtentZDirection( 0, 0 );
280 localStorage->
m_Reslicer->UpdateLargestPossibleRegion();
297 double sliceBounds[6] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
305 localStorage->
m_Reslicer->GetClippedPlaneBounds(sliceBounds);
312 double textureClippingBounds[6] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
321 textureClippingBounds[0] =
static_cast<int>(textureClippingBounds[0] / localStorage->
m_mmPerPixel[0] + 0.5);
322 textureClippingBounds[1] =
static_cast<int>(textureClippingBounds[1] / localStorage->
m_mmPerPixel[0] + 0.5);
323 textureClippingBounds[2] =
static_cast<int>(textureClippingBounds[2] / localStorage->
m_mmPerPixel[1] + 0.5);
324 textureClippingBounds[3] =
static_cast<int>(textureClippingBounds[3] / localStorage->
m_mmPerPixel[1] + 0.5);
360 isWipeStyleOutdated ||
367 switch (evalStyleProp->GetValueAsId())
371 PrepareBlend(datanode, localStorage);
376 PrepareColorBlend(localStorage);
381 PrepareCheckerBoard(datanode, localStorage);
392 worldGeometry->
Map(currentPos3D, currentPos2D);
394 worldGeometry->
WorldToIndex(currentPos2D, currentIndex2D);
396 PrepareWipe(datanode, localStorage, currentIndex2D);
401 PrepareDifference(localStorage);
406 PrepareContour(datanode, localStorage);
417 this->ApplyOpacity( renderer );
420 localStorage->
m_Texture->MapColorScalarsThroughLookupTableOff();
423 bool textureInterpolation =
false;
424 GetDataNode()->GetBoolProperty(
"texture interpolation", textureInterpolation, renderer );
427 localStorage->
m_Texture->SetInterpolate(textureInterpolation);
432 this->TransformActor( renderer );
434 vtkActor* contourShadowActor =
dynamic_cast<vtkActor*
> (localStorage->
m_Actors->GetParts()->GetItemAsObject(0));
438 this->GeneratePlane( renderer, sliceBounds );
440 localStorage->
m_Mapper->SetInputConnection(localStorage->
m_Plane->GetOutputPort());
444 contourShadowActor->SetVisibility(
false );
454 bool targetContour =
true;
457 vtkSmartPointer<vtkImageGradientMagnitude> magFilter =
469 vtkSmartPointer<vtkImageAppendComponents> appendFilter =
472 appendFilter->AddInputConnection(magFilter->GetOutputPort());
473 appendFilter->AddInputConnection(magFilter->GetOutputPort());
482 appendFilter->Update();
489 vtkSmartPointer<vtkImageMathematics> diffFilter =
491 vtkSmartPointer<vtkImageMathematics> minFilter =
493 vtkSmartPointer<vtkImageMathematics> maxFilter =
498 minFilter->SetOperationToMin();
501 maxFilter->SetOperationToMax();
503 diffFilter->SetInputConnection(0, maxFilter->GetOutputPort());
504 diffFilter->SetInputConnection(1, minFilter->GetOutputPort());
505 diffFilter->SetOperationToSubtract();
506 diffFilter->Update();
515 vtkSmartPointer<vtkImageRectilinearWipe> wipedFilter =
519 wipedFilter->SetPosition(currentIndex2D[0], currentIndex2D[1]);
521 if (evalWipeStyleProp->GetValueAsId() == 0)
523 wipedFilter->SetWipeToQuad();
525 else if (evalWipeStyleProp->GetValueAsId() == 1)
527 wipedFilter->SetWipeToHorizontal();
529 else if (evalWipeStyleProp->GetValueAsId() == 2)
531 wipedFilter->SetWipeToVertical();
534 wipedFilter->Update();
541 int checkerCount = 5;
544 vtkSmartPointer<vtkImageCheckerboard> checkerboardFilter =
548 checkerboardFilter->SetNumberOfDivisions(checkerCount, checkerCount, 1);
549 checkerboardFilter->Update();
556 vtkSmartPointer<vtkImageAppendComponents> appendFilter =
566 appendFilter->Update();
573 int blendfactor = 50;
576 vtkSmartPointer<vtkImageWeightedSum> blendFilter =
581 blendFilter->SetWeight(0, (100 - blendfactor) / 100.);
582 blendFilter->SetWeight(1,blendfactor/100.);
583 blendFilter->Update();
590 LocalStorage *localStorage = this->GetLocalStorage( renderer );
597 if (dataNode->
GetLevelWindow(opacLevelWindow, renderer,
"opaclevelwindow"))
613 LocalStorage* localStorage = m_LSH.GetLocalStorage(renderer);
619 if (lookupTableProp.IsNotNull())
621 usedLookupTable = lookupTableProp->GetLookupTable()->GetVtkLookupTable();
635 LocalStorage* localStorage = this->GetLocalStorage( renderer );
636 float opacity = 1.0f;
638 GetDataNode()->GetOpacity( opacity, renderer,
"opacity" );
640 localStorage->
m_Actor->GetProperty()->SetOpacity(opacity);
641 if ( localStorage->
m_Actors->GetParts()->GetNumberOfItems() > 1 )
643 dynamic_cast<vtkActor*
>( localStorage->
m_Actors->GetParts()->GetItemAsObject(0) )->GetProperty()->SetOpacity(opacity);
651 GetDataNode()->GetVisibility(visible, renderer,
"visible");
665 this->CalculateTimeStep( renderer );
669 if ( ( dataTimeGeometry == NULL )
670 || ( dataTimeGeometry->CountTimeSteps() == 0 )
676 const DataNode *node = this->GetDataNode();
678 LocalStorage *localStorage = m_LSH.GetLocalStorage(renderer);
689 || (localStorage->
m_LastUpdateTime < this->GetTargetNode()->GetPropertyList()->GetMTime())
690 || (localStorage->
m_LastUpdateTime < this->GetTargetNode()->GetPropertyList(renderer)->GetMTime())
691 || (localStorage->
m_LastUpdateTime < this->GetMovingNode()->GetPropertyList()->GetMTime())
692 || (localStorage->
m_LastUpdateTime < this->GetMovingNode()->GetPropertyList(renderer)->GetMTime()))
694 this->GenerateDataForRenderer( renderer );
720 node->
AddProperty(
"Image Rendering.Mode", renderingModeProperty);
725 mitkLutProp->SetLookupTable(mitkLut);
740 Superclass::SetDefaultProperties(node, renderer, overwrite);
745 return m_LSH.GetLocalStorage(renderer);
750 LocalStorage *localStorage = m_LSH.GetLocalStorage(renderer);
753 vtkSmartPointer<vtkMatrix4x4> matrix = localStorage->
m_Reslicer->GetResliceAxes();
754 trans->SetMatrix(matrix);
756 localStorage->
m_Actor->SetUserTransform(trans);
760 if ( localStorage->
m_Actors->GetNumberOfPaths() > 1 )
762 vtkActor* secondaryActor =
dynamic_cast<vtkActor*
>( localStorage->
m_Actors->GetParts()->GetItemAsObject(0) );
763 secondaryActor->SetUserTransform(trans);
772 if ( renderingGeometry == NULL || imageGeometry == NULL )
777 for(
int i=1; i<8; i++ )
785 if ( initialDistance * distance < 0 )
826 m_DefaultLookupTable = mitkLUT->GetVtkLookupTable();
829 m_ColorLookupTable = mitkLUT->GetVtkLookupTable();
832 m_Texture->RepeatOff();
835 m_Actor->SetMapper( m_Mapper );
838 outlineShadowActor->SetMapper( m_Mapper );
840 m_Actors->AddPart( outlineShadowActor );
841 m_Actors->AddPart( m_Actor );
vtkSmartPointer< vtkMitkLevelWindowFilter > m_MappedLevelWindowFilter
This filter is used to apply the level window to moving image.
vtkSmartPointer< vtkImageData > m_EvaluationImage
Current slice of a 2D render window.
virtual int GetInterpolation()
void ApplyLookuptable(mitk::BaseRenderer *renderer, const mitk::DataNode *dataNode, vtkMitkLevelWindowFilter *levelFilter)
This method applies (or modifies) the lookuptable for all types of images.
mitk::PropertyList * GetPropertyList(const mitk::BaseRenderer *renderer=nullptr) const
Get the PropertyList of the renderer. If renderer is NULL, the BaseRenderer-independent PropertyList ...
mitk::ScalarType * m_mmPerPixel
mmPerPixel relation between pixel and mm. (World spacing).
ScalarType GetLowerWindowBound() const
virtual vtkProp * GetVtkProp(mitk::BaseRenderer *renderer)
vtkSmartPointer< vtkMitkLevelWindowFilter > m_TargetLevelWindowFilter
This filter is used to apply the level window to target image.
vtkSmartPointer< vtkPlaneSource > m_Plane
Plane on which the slice is rendered as texture.
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 ...
float CalculateLayerDepth(mitk::BaseRenderer *renderer)
This method uses the vtkCamera clipping range and the layer property to calcualte the depth of the ob...
bool RenderingGeometryIntersectsImage(const Geometry2D *renderingGeometry, SlicedGeometry3D *imageGeometry)
Calculates whether the given rendering geometry intersects the given SlicedGeometry3D.
virtual bool Map(const mitk::Point3D &pt3d_mm, mitk::Point2D &pt2d_mm) const
Project a 3D point given in mm (pt3d_mm) onto the 2D geometry. The result is a 2D point in mm (pt2d_m...
virtual mitk::Image * GetMovingImage()
void PrepareColorBlend(LocalStorage *localStorage)
virtual bool IsValid() const
Is this BaseGeometry in a state that is valid?
virtual void GenerateDataForRenderer(mitk::BaseRenderer *renderer)
Does the actual resampling, without rendering the image yet. All the data is generated inside this me...
void GeneratePlane(mitk::BaseRenderer *renderer, double planeBounds[6])
Generates a plane according to the size of the resliced image in milimeters.
bool GetIntProperty(const char *propertyKey, int &intValue, const mitk::BaseRenderer *renderer=nullptr) const
Convenience access method for int properties (instances of IntProperty)
virtual const mitk::DataNode * GetTargetNode()
static bool CalculateClippedPlaneBounds(const BaseGeometry *boundingGeometry, const PlaneGeometry *planeGeometry, double *bounds)
Calculate the bounding box of the resliced image. This is necessary for arbitrarily rotated planes in...
vtkSmartPointer< vtkImageExtractComponents > m_MappedExtractFilter
Organizes the rendering process.
mitk::Image::Pointer m_slicedTargetImage
virtual ScalarType SignedDistance(const Point3D &pt3d_mm) const
bool GetBoolProperty(const char *propertyKey, bool &boolValue, const mitk::BaseRenderer *renderer=nullptr) const
Convenience access method for bool properties (instances of BoolProperty)
void PrepareBlend(mitk::DataNode *datanode, LocalStorage *localStorage)
const char *const nodeProp_RegEvalCheckerCount
virtual mitk::MAPRegistrationWrapper * GetRegistration()
void SetLookupTable(vtkScalarsToColors *lookupTable)
Set the lookup table for the RGB level window.
void PrepareDifference(LocalStorage *localStorage)
void PrepareWipe(mitk::DataNode *datanode, LocalStorage *localStorage, const Point2D ¤tIndex2D)
vtkScalarsToColors * GetLookupTable()
Get the lookup table for the RGB level window.
unsigned long GetCurrentWorldGeometry2DUpdateTime()
const mitk::TimeGeometry * GetTimeGeometry() const
Return the TimeGeometry of the data as const pointer.
static void SetDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer=NULL, bool overwrite=false)
Set the default properties for general image rendering.
BaseData * GetData() const
Get the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
MAPRegistrationWrapper Wrapper class to allow the handling of MatchPoint registration objects as mitk...
const char *const nodeProp_RegEvalCurrentPosition
LocalStorage * GetLocalStorage(mitk::BaseRenderer *renderer)
Get the LocalStorage corresponding to the current renderer.
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 void WorldToIndex(const Point2D &pt_mm, Point2D &pt_units) const
virtual unsigned long GetMTime() const override
Get the timestamp of the last change of the contents of this node or the referenced BaseData...
virtual const mitk::DataNode * GetMovingNode()
mitk::ExtractSliceFilter::Pointer m_Reslicer
The actual reslicer (one per renderer)
const PlaneGeometry * GetCurrentWorldGeometry2D()
virtual mitk::Image * GetTargetImage()
vtkSmartPointer< vtkPolyDataMapper > m_Mapper
Mapper of a 2D render window.
The LevelWindow class Class to store level/window values.
Internal class holding the mapper, actor, etc. for each of the 3 2D render windows.
mitk::Image::Pointer m_slicedMappedImage
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 ...
The LookupTableProperty class Property to associate mitk::LookupTable to an mitk::DataNode.
const mitk::Image * GetMovingImage(void)
Get the moving image to map.
const mitk::Image * GetTargetImage(void)
Get the target image to map.
virtual void Update(mitk::BaseRenderer *renderer)
Checks whether this mapper needs to update itself and generate data.
const char *const nodeProp_RegEvalBlendFactor
itk::TimeStamp m_LastUpdateTime
Timestamp of last update of stored data.
RegEvaluationObject Class that containes all data to realize an evaluation of registrations via image...
vtkSmartPointer< vtkActor > m_Actor
Actor of a 2D render window.
const mitk::DataNode * GetTargetNode(void)
bool PropertyIsOutdated(const mitk::DataNode *regNode, const std::string &propName, const itk::TimeStamp &reference)
Image class for storing images.
void SetMaxOpacity(double maxOpacity)
Get/Set the upper window opacity for the alpha level window.
const char *const nodeProp_RegEvalWipeStyle
vtkSmartPointer< vtkTexture > m_Texture
The texture which is used to render the current slice.
vtkSmartPointer< vtkImageExtractComponents > m_TargetExtractFilter
void ApplyLevelWindow(mitk::BaseRenderer *renderer, const mitk::DataNode *dataNode, vtkMitkLevelWindowFilter *levelFilter)
ApplyLevelWindow Apply the level window for the given renderer.
Applies the grayvalue or color/opacity level window to scalar or RGB(A) images.
bool GetPropertyValue(const char *propertyKey, T &value, const mitk::BaseRenderer *renderer=nullptr) const
Convenience access method for GenericProperty properties (T being the type of the second parameter...
Point3D GetCornerPoint(int id) const
Get the position of the corner number id (in world coordinates)
Describes the geometry of a data object consisting of slices.
vtkSmartPointer< vtkLookupTable > m_ColorLookupTable
The lookuptables for colors and level window.
void PrepareContour(mitk::DataNode *datanode, LocalStorage *localStorage)
bool IsRotated() const
Returns true if an image is rotated, i.e. its geometry's transformation matrix has nonzero elements b...
bool HasReferenceGeometry() const
void ApplyOpacity(mitk::BaseRenderer *renderer)
Set the opacity of the actor.
const mitk::DataNode * GetMovingNode(void)
void TransformActor(mitk::BaseRenderer *renderer)
Transforms the actor to the actual position in 3D.
~LocalStorage()
Default deconstructor of the local storage.
MITKMATCHPOINTREGISTRATION_EXPORT ResultImageType::Pointer map(const InputImageType *input, const RegistrationType *registration, bool throwOnOutOfInputAreaError=false, const double &paddingValue=0, const ResultImageGeometryType *resultGeometry=NULL, bool throwOnMappingError=true, const double &errorValue=0, mitk::ImageMappingInterpolator::Type interpolatorType=mitk::ImageMappingInterpolator::Linear)
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) ...
const char *const nodeProp_RegEvalStyle
Describes a two-dimensional, rectangular plane.
void SetProperty(const char *propertyKey, BaseProperty *property, const mitk::BaseRenderer *renderer=nullptr)
Set the property (instance of BaseProperty) with key propertyKey in the PropertyList of the renderer ...
const char *const nodeProp_RegEvalTargetContour
vtkSmartPointer< vtkPropAssembly > m_Actors
ScalarType GetUpperWindowBound() const
virtual void UpdateOutputInformation() override
vtkRenderer * GetVtkRenderer() const
void PrepareCheckerBoard(mitk::DataNode *datanode, LocalStorage *localStorage)
const mitk::MAPRegistrationWrapper * GetRegistration(void)
Get the target image to map.
virtual ~RegEvaluationMapper2D()
vtkSmartPointer< vtkPolyData > m_EmptyPolyData
Empty vtkPolyData that is set when rendering geometry does not intersect the image geometry...
virtual bool IsValidTimeStep(TimeStepType timeStep) const =0
Test for the given time step if a geometry is availible.
LocalStorage()
Default constructor of the local storage.
void SetMinOpacity(double minOpacity)
Get/Set the lower window opacity for the alpha level window.
Class for nodes of the DataTree.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.