40 #include <vtkProperty.h> 41 #include <vtkTransform.h> 42 #include <vtkMatrix4x4.h> 43 #include <vtkLookupTable.h> 44 #include <vtkImageData.h> 45 #include <vtkPoints.h> 46 #include <vtkGeneralTransform.h> 47 #include <vtkImageExtractComponents.h> 48 #include <vtkImageReslice.h> 49 #include <vtkImageChangeInformation.h> 50 #include <vtkPlaneSource.h> 51 #include <vtkPolyDataMapper.h> 52 #include <vtkCellArray.h> 53 #include <vtkCamera.h> 54 #include <vtkColorTransferFunction.h> 55 #include <vtkImageCheckerboard.h> 56 #include <vtkImageWeightedSum.h> 57 #include <vtkImageMathematics.h> 58 #include <vtkImageRectilinearWipe.h> 59 #include <vtkImageGradientMagnitude.h> 60 #include <vtkImageAppendComponents.h> 61 #include <vtkImageExtractComponents.h> 64 #include <itkRGBAPixel.h> 87 localStorage->
m_Plane->SetOrigin(planeBounds[0], planeBounds[2], depth);
91 localStorage->
m_Plane->SetPoint1(planeBounds[1] , planeBounds[2], depth);
92 localStorage->
m_Plane->SetPoint2(planeBounds[0], planeBounds[3], depth);
98 double maxRange = renderer->
GetVtkRenderer()->GetActiveCamera()->GetClippingRange()[1];
101 float depth = -maxRange*0.01;
108 MITK_WARN <<
"Layer value exceeds clipping range. Set to minimum instead.";
176 bool updated =
false;
182 if ( targetInput.IsNull() || targetInput->IsInitialized() == false )
189 if ( movingInput.IsNull() || movingInput->IsInitialized() == false )
207 targetInput->Update();
222 localStorage->
m_Reslicer->SetInput(targetInput);
223 localStorage->
m_Reslicer->SetWorldGeometry(worldGeometry);
228 localStorage->
m_Reslicer->SetResliceTransformByGeometry( targetInput->GetTimeGeometry()->GetGeometryForTimeStep( this->
GetTimestep() ) );
232 bool inPlaneResampleExtentByGeometry =
false;
233 datanode->
GetBoolProperty(
"in plane resample extent by geometry", inPlaneResampleExtentByGeometry, renderer);
234 localStorage->
m_Reslicer->SetInPlaneResampleExtentByGeometry(inPlaneResampleExtentByGeometry);
239 if ( (targetInput->GetDimension() >= 3) && (targetInput->GetDimension(2) > 1) )
243 resliceInterpolationProperty,
"reslice interpolation" );
245 int interpolationMode = VTK_RESLICE_NEAREST;
246 if ( resliceInterpolationProperty !=
nullptr )
251 switch ( interpolationMode )
253 case VTK_RESLICE_NEAREST:
256 case VTK_RESLICE_LINEAR:
259 case VTK_RESLICE_CUBIC:
270 localStorage->
m_Reslicer->SetOutputDimensionality( 2 );
271 localStorage->
m_Reslicer->SetOutputSpacingZDirection(1.0);
272 localStorage->
m_Reslicer->SetOutputExtentZDirection( 0, 0 );
276 localStorage->
m_Reslicer->UpdateLargestPossibleRegion();
293 double sliceBounds[6] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
301 localStorage->
m_Reslicer->GetClippedPlaneBounds(sliceBounds);
308 double textureClippingBounds[6] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
317 textureClippingBounds[0] =
static_cast<int>(textureClippingBounds[0] / localStorage->
m_mmPerPixel[0] + 0.5);
318 textureClippingBounds[1] =
static_cast<int>(textureClippingBounds[1] / localStorage->
m_mmPerPixel[0] + 0.5);
319 textureClippingBounds[2] =
static_cast<int>(textureClippingBounds[2] / localStorage->
m_mmPerPixel[1] + 0.5);
320 textureClippingBounds[3] =
static_cast<int>(textureClippingBounds[3] / localStorage->
m_mmPerPixel[1] + 0.5);
356 isWipeStyleOutdated ||
363 switch (evalStyleProp->GetValueAsId())
388 worldGeometry->
Map(currentPos3D, currentPos2D);
390 worldGeometry->
WorldToIndex(currentPos2D, currentIndex2D);
392 PrepareWipe(datanode, localStorage, currentIndex2D);
416 localStorage->
m_Texture->SetColorModeToDirectScalars();
419 bool textureInterpolation =
false;
423 localStorage->
m_Texture->SetInterpolate(textureInterpolation);
430 vtkActor* contourShadowActor =
dynamic_cast<vtkActor*
> (localStorage->
m_Actors->GetParts()->GetItemAsObject(0));
436 localStorage->
m_Mapper->SetInputConnection(localStorage->
m_Plane->GetOutputPort());
440 contourShadowActor->SetVisibility(
false );
450 bool targetContour =
true;
453 vtkSmartPointer<vtkImageGradientMagnitude> magFilter =
454 vtkSmartPointer<vtkImageGradientMagnitude>::New();
465 vtkSmartPointer<vtkImageAppendComponents> appendFilter =
466 vtkSmartPointer<vtkImageAppendComponents>::New();
468 appendFilter->AddInputConnection(magFilter->GetOutputPort());
469 appendFilter->AddInputConnection(magFilter->GetOutputPort());
478 appendFilter->Update();
485 vtkSmartPointer<vtkImageMathematics> diffFilter =
486 vtkSmartPointer<vtkImageMathematics>::New();
487 vtkSmartPointer<vtkImageMathematics> minFilter =
488 vtkSmartPointer<vtkImageMathematics>::New();
489 vtkSmartPointer<vtkImageMathematics> maxFilter =
490 vtkSmartPointer<vtkImageMathematics>::New();
494 minFilter->SetOperationToMin();
497 maxFilter->SetOperationToMax();
499 diffFilter->SetInputConnection(0, maxFilter->GetOutputPort());
500 diffFilter->SetInputConnection(1, minFilter->GetOutputPort());
501 diffFilter->SetOperationToSubtract();
502 diffFilter->Update();
511 vtkSmartPointer<vtkImageRectilinearWipe> wipedFilter =
512 vtkSmartPointer<vtkImageRectilinearWipe>::New();
515 wipedFilter->SetPosition(currentIndex2D[0], currentIndex2D[1]);
517 if (evalWipeStyleProp->GetValueAsId() == 0)
519 wipedFilter->SetWipeToQuad();
521 else if (evalWipeStyleProp->GetValueAsId() == 1)
523 wipedFilter->SetWipeToHorizontal();
525 else if (evalWipeStyleProp->GetValueAsId() == 2)
527 wipedFilter->SetWipeToVertical();
530 wipedFilter->Update();
537 int checkerCount = 5;
540 vtkSmartPointer<vtkImageCheckerboard> checkerboardFilter =
541 vtkSmartPointer<vtkImageCheckerboard>::New();
544 checkerboardFilter->SetNumberOfDivisions(checkerCount, checkerCount, 1);
545 checkerboardFilter->Update();
552 vtkSmartPointer<vtkImageAppendComponents> appendFilter =
553 vtkSmartPointer<vtkImageAppendComponents>::New();
562 appendFilter->Update();
569 int blendfactor = 50;
572 vtkSmartPointer<vtkImageWeightedSum> blendFilter =
573 vtkSmartPointer<vtkImageWeightedSum>::New();
577 blendFilter->SetWeight(0, (100 - blendfactor) / 100.);
578 blendFilter->SetWeight(1,blendfactor/100.);
579 blendFilter->Update();
591 if (dataNode->
GetLevelWindow(opacLevelWindow, renderer,
"opaclevelwindow"))
613 if (lookupTableProp.IsNotNull())
615 usedLookupTable = lookupTableProp->GetLookupTable()->GetVtkLookupTable();
630 float opacity = 1.0f;
634 localStorage->
m_Actor->GetProperty()->SetOpacity(opacity);
635 if ( localStorage->
m_Actors->GetParts()->GetNumberOfItems() > 1 )
637 dynamic_cast<vtkActor*
>( localStorage->
m_Actors->GetParts()->GetItemAsObject(0) )->GetProperty()->SetOpacity(opacity);
653 if ( data ==
nullptr )
663 if ( ( dataTimeGeometry ==
nullptr )
683 || (localStorage->
m_LastUpdateTime < this->GetTargetNode()->GetPropertyList()->GetMTime())
684 || (localStorage->
m_LastUpdateTime < this->GetTargetNode()->GetPropertyList(renderer)->GetMTime())
685 || (localStorage->
m_LastUpdateTime < this->GetMovingNode()->GetPropertyList()->GetMTime())
686 || (localStorage->
m_LastUpdateTime < this->GetMovingNode()->GetPropertyList(renderer)->GetMTime()))
714 node->
AddProperty(
"Image Rendering.Mode", renderingModeProperty);
719 mitkLutProp->SetLookupTable(mitkLut);
734 Superclass::SetDefaultProperties(node, renderer, overwrite);
746 vtkSmartPointer<vtkTransform> trans = vtkSmartPointer<vtkTransform>::New();
747 vtkSmartPointer<vtkMatrix4x4> matrix = localStorage->
m_Reslicer->GetResliceAxes();
748 trans->SetMatrix(matrix);
750 localStorage->
m_Actor->SetUserTransform(trans);
754 if ( localStorage->
m_Actors->GetNumberOfPaths() > 1 )
756 vtkActor* secondaryActor =
dynamic_cast<vtkActor*
>( localStorage->
m_Actors->GetParts()->GetItemAsObject(0) );
757 secondaryActor->SetUserTransform(trans);
766 if ( renderingGeometry ==
nullptr || imageGeometry ==
nullptr )
771 for(
int i=1; i<8; i++ )
779 if ( initialDistance * distance < 0 )
796 m_TargetLevelWindowFilter = vtkSmartPointer<vtkMitkLevelWindowFilter>::New();
797 m_MappedLevelWindowFilter = vtkSmartPointer<vtkMitkLevelWindowFilter>::New();
799 m_TargetExtractFilter = vtkSmartPointer<vtkImageExtractComponents>::New();
800 m_MappedExtractFilter = vtkSmartPointer<vtkImageExtractComponents>::New();
802 m_mmPerPixel =
nullptr;
805 m_Plane = vtkSmartPointer<vtkPlaneSource>::New();
807 m_Texture = vtkSmartPointer<vtkOpenGLTexture>::New().GetPointer();
808 m_DefaultLookupTable = vtkSmartPointer<vtkLookupTable>::New();
809 m_ColorLookupTable = vtkSmartPointer<vtkLookupTable>::New();
810 m_Mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
811 m_Actor = vtkSmartPointer<vtkActor>::New();
812 m_Actors = vtkSmartPointer<vtkPropAssembly>::New();
814 m_EvaluationImage = vtkSmartPointer<vtkImageData>::New();
815 m_EmptyPolyData = vtkSmartPointer<vtkPolyData>::New();
820 m_DefaultLookupTable = mitkLUT->GetVtkLookupTable();
823 m_ColorLookupTable = mitkLUT->GetVtkLookupTable();
826 m_Texture->RepeatOff();
829 m_Actor->SetMapper( m_Mapper );
831 vtkSmartPointer<vtkActor> outlineShadowActor = vtkSmartPointer<vtkActor>::New();
832 outlineShadowActor->SetMapper( m_Mapper );
834 m_Actors->AddPart( outlineShadowActor );
835 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::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...
virtual ScalarType SignedDistance(const Point3D &pt3d_mm) const
void Update(mitk::BaseRenderer *renderer) override
Checks whether this mapper needs to update itself and generate data.
mitk::ScalarType * m_mmPerPixel
mmPerPixel relation between pixel and mm. (World spacing).
L * GetLocalStorage(mitk::BaseRenderer *forRenderer)
Retrieves a LocalStorage for a specific BaseRenderer.
~LocalStorage() override
Default deconstructor of the local storage.
virtual TimeStepType CountTimeSteps() const =0
Returns the number of time steps.
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.
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 ...
void GenerateDataForRenderer(mitk::BaseRenderer *renderer) override
Does the actual resampling, without rendering the image yet. All the data is generated inside this me...
float CalculateLayerDepth(mitk::BaseRenderer *renderer)
This method uses the vtkCamera clipping range and the layer property to calcualte the depth of the ob...
vtkRenderer * GetVtkRenderer() const
virtual mitk::Image * GetMovingImage()
void PrepareColorBlend(LocalStorage *localStorage)
virtual DataNode * GetDataNode() const
Get the DataNode containing the data to map. Method only returns valid DataNode Pointer if the mapper...
void GeneratePlane(mitk::BaseRenderer *renderer, double planeBounds[6])
Generates a plane according to the size of the resliced image in milimeters.
mitk::LocalStorageHandler< LocalStorage > m_LSH
The LocalStorageHandler holds all (three) LocalStorages for the three 2D render windows.
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
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)
Point3D GetCornerPoint(int id) const
Get the position of the corner number id (in world coordinates)
vtkScalarsToColors * GetLookupTable()
Get the lookup table for the RGB level window.
virtual const PlaneGeometry * GetCurrentWorldPlaneGeometry()
Get the current 2D-worldgeometry (m_CurrentWorldPlaneGeometry) used for 2D-rendering.
MAPRegistrationWrapper Wrapper class to allow the handling of MatchPoint registration objects as mitk...
bool GetPropertyValue(const char *propertyKey, T &value, const mitk::BaseRenderer *renderer=nullptr) const
Convenience access method for GenericProperty<T> properties (T being the type of the second parameter...
const char *const nodeProp_RegEvalCurrentPosition
LocalStorage * GetLocalStorage(mitk::BaseRenderer *renderer)
Get the LocalStorage corresponding to the current renderer.
bool IsRotated() const
Returns true if an image is rotated, i.e. its geometry's transformation matrix has nonzero elements b...
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...
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)
virtual const mitk::DataNode * GetMovingNode()
mitk::ExtractSliceFilter::Pointer m_Reslicer
The actual reslicer (one per renderer)
bool GetIntProperty(const char *propertyKey, int &intValue, const mitk::BaseRenderer *renderer=nullptr) const
Convenience access method for int properties (instances of IntProperty)
virtual mitk::Image * GetTargetImage()
static void SetDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer=nullptr, bool overwrite=false)
Set the default properties for general image rendering.
vtkSmartPointer< vtkPolyDataMapper > m_Mapper
Mapper of a 2D render window.
vtkProp * GetVtkProp(mitk::BaseRenderer *renderer) override
The LevelWindow class Class to store level/window values.
Internal class holding the mapper, actor, etc. for each of the 3 2D render windows.
bool HasReferenceGeometry() const
void SetProperty(const std::string &propertyKey, BaseProperty *property, const std::string &contextName="", bool fallBackOnDefaultContext=false) override
Add new or change existent property.
mitk::Image::Pointer m_slicedMappedImage
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.
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.
virtual void WorldToIndex(const Point2D &pt_mm, Point2D &pt_units) const
const mitk::Image * GetMovingImage(void)
Get the moving image to map.
const mitk::Image * GetTargetImage(void)
Get the target image to map.
ScalarType GetUpperWindowBound() const
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.
~RegEvaluationMapper2D() override
const mitk::DataNode * GetTargetNode(void)
bool PropertyIsOutdated(const mitk::DataNode *regNode, const std::string &propName, const itk::TimeStamp &reference)
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...
bool RenderingGeometryIntersectsImage(const PlaneGeometry *renderingGeometry, SlicedGeometry3D *imageGeometry)
Calculates whether the given rendering geometry intersects the given SlicedGeometry3D.
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.
virtual void CalculateTimeStep(BaseRenderer *renderer)
Updates the time step, which is sometimes needed in subclasses.
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.
Describes the geometry of a data object consisting of slices.
MITKMATCHPOINTREGISTRATION_EXPORT ResultImageType::Pointer map(const InputImageType *input, const RegistrationType *registration, bool throwOnOutOfInputAreaError=false, const double &paddingValue=0, const ResultImageGeometryType *resultGeometry=nullptr, bool throwOnMappingError=true, const double &errorValue=0, mitk::ImageMappingInterpolator::Type interpolatorType=mitk::ImageMappingInterpolator::Linear)
vtkSmartPointer< vtkLookupTable > m_ColorLookupTable
The lookuptables for colors and level window.
void PrepareContour(mitk::DataNode *datanode, LocalStorage *localStorage)
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...
void ApplyOpacity(mitk::BaseRenderer *renderer)
Set the opacity of the actor.
const mitk::DataNode * GetMovingNode(void)
int GetTimestep() const
Returns the current time step as calculated from the renderer.
void TransformActor(mitk::BaseRenderer *renderer)
Transforms the actor to the actual position in 3D.
const char *const nodeProp_RegEvalStyle
unsigned long GetCurrentWorldPlaneGeometryUpdateTime()
Get timestamp of last call of SetCurrentWorldPlaneGeometry.
Describes a two-dimensional, rectangular plane.
const char *const nodeProp_RegEvalTargetContour
vtkSmartPointer< vtkPropAssembly > m_Actors
void UpdateOutputInformation() override
void PrepareCheckerBoard(mitk::DataNode *datanode, LocalStorage *localStorage)
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 mitk::MAPRegistrationWrapper * GetRegistration(void)
Get the target image to map.
vtkSmartPointer< vtkPolyData > m_EmptyPolyData
Empty vtkPolyData that is set when rendering geometry does not intersect the image geometry...
ScalarType GetLowerWindowBound() const
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.