37 #include <vtkCamera.h> 38 #include <vtkCellArray.h> 39 #include <vtkImageData.h> 40 #include <vtkImageReslice.h> 41 #include <vtkLookupTable.h> 42 #include <vtkMatrix4x4.h> 43 #include <vtkPlaneSource.h> 44 #include <vtkPoints.h> 45 #include <vtkPolyData.h> 46 #include <vtkPolyDataMapper.h> 47 #include <vtkProperty.h> 48 #include <vtkTransform.h> 52 #include <itkRGBAPixel.h> 84 if ((worldGeometry ==
nullptr) || (!worldGeometry->IsValid()) || (!worldGeometry->HasReferenceGeometry()))
89 int numberOfLayers =
image->GetNumberOfLayers();
90 int activeLayer =
image->GetActiveLayer();
93 node->
GetOpacity(opacity, renderer,
"opacity");
105 localStorage->
m_Actors = vtkSmartPointer<vtkPropAssembly>::New();
107 for (
int lidx = 0; lidx < numberOfLayers; ++lidx)
111 localStorage->
m_LayerTextureVector.push_back(vtkSmartPointer<vtkNeverTranslucentTexture>::New());
136 for (
int lidx = 0; lidx < numberOfLayers; ++lidx)
146 for (
int lidx = 0; lidx < numberOfLayers; ++lidx)
151 if (lidx == activeLayer)
154 layerImage =
image->GetLayerImage(lidx);
165 bool inPlaneResampleExtentByGeometry =
false;
166 node->
GetBoolProperty(
"in plane resample extent by geometry", inPlaneResampleExtentByGeometry, renderer);
167 localStorage->
m_ReslicerVector[lidx]->SetInPlaneResampleExtentByGeometry(inPlaneResampleExtentByGeometry);
178 double sliceBounds[6];
179 sliceBounds[0] = 0.0;
180 sliceBounds[1] = 0.0;
181 sliceBounds[2] = 0.0;
182 sliceBounds[3] = 0.0;
183 sliceBounds[4] = 0.0;
184 sliceBounds[5] = 0.0;
198 const auto *planeGeometry =
dynamic_cast<const PlaneGeometry *
>(worldGeometry);
200 double textureClippingBounds[6];
201 for (
auto &textureClippingBound : textureClippingBounds)
203 textureClippingBound = 0.0;
211 textureClippingBounds[0] =
static_cast<int>(textureClippingBounds[0] / localStorage->
m_mmPerPixel[0] + 0.5);
212 textureClippingBounds[1] =
static_cast<int>(textureClippingBounds[1] / localStorage->
m_mmPerPixel[0] + 0.5);
213 textureClippingBounds[2] =
static_cast<int>(textureClippingBounds[2] / localStorage->
m_mmPerPixel[1] + 0.5);
214 textureClippingBounds[3] =
static_cast<int>(textureClippingBounds[3] / localStorage->
m_mmPerPixel[1] + 0.5);
220 image->GetLabelSet(lidx)->GetLookupTable()->GetVtkLookupTable());
230 bool textureInterpolation =
false;
231 node->
GetBoolProperty(
"texture interpolation", textureInterpolation, renderer);
250 if (
nullptr != activeLabel)
252 bool contourActive =
false;
253 node->
GetBoolProperty(
"labelset.contour.active", contourActive, renderer);
254 if (contourActive && activeLabel->
GetVisible())
262 localStorage->
m_OutlineActor->GetProperty()->SetColor(color.GetRed(), color.GetGreen(), color.GetBlue());
265 float contourWidth(2.0);
267 localStorage->
m_OutlineActor->GetProperty()->SetLineWidth(contourWidth);
286 if (renderingGeometry ==
nullptr || imageGeometry ==
nullptr)
291 for (
int i = 1; i < 8; i++)
299 if (initialDistance * distance < 0)
317 int *extent = image->GetExtent();
318 int xMin = extent[0];
319 int xMax = extent[1];
320 int yMin = extent[2];
321 int yMax = extent[3];
323 int *dims = image->GetDimensions();
331 vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
332 vtkSmartPointer<vtkCellArray> lines = vtkSmartPointer<vtkCellArray>::New();
340 if ((currentPixel) && (*currentPixel == pixelValue))
347 if (y > yMin && *(currentPixel - line) != pixelValue)
355 lines->InsertNextCell(2);
356 lines->InsertCellPoint(p1);
357 lines->InsertCellPoint(p2);
361 if (y < yMax && *(currentPixel + line) != pixelValue)
365 vtkIdType p2 = points->InsertNextPoint(
367 lines->InsertNextCell(2);
368 lines->InsertCellPoint(p1);
369 lines->InsertCellPoint(p2);
373 if ((x > xMin || y > yMin) && *(currentPixel - 1) != pixelValue)
379 lines->InsertNextCell(2);
380 lines->InsertCellPoint(p1);
381 lines->InsertCellPoint(p2);
385 if ((y < yMax || (x < xMax)) && *(currentPixel + 1) != pixelValue)
389 vtkIdType p2 = points->InsertNextPoint(
391 lines->InsertNextCell(2);
392 lines->InsertCellPoint(p1);
393 lines->InsertCellPoint(p2);
405 lines->InsertNextCell(2);
406 lines->InsertCellPoint(p1);
407 lines->InsertCellPoint(p2);
415 vtkIdType p2 = points->InsertNextPoint(
417 lines->InsertNextCell(2);
418 lines->InsertCellPoint(p1);
419 lines->InsertCellPoint(p2);
429 lines->InsertNextCell(2);
430 lines->InsertCellPoint(p1);
431 lines->InsertCellPoint(p2);
439 vtkIdType p2 = points->InsertNextPoint(
441 lines->InsertNextCell(2);
442 lines->InsertCellPoint(p1);
443 lines->InsertCellPoint(p2);
462 vtkSmartPointer<vtkPolyData> polyData = vtkSmartPointer<vtkPolyData>::New();
464 polyData->SetPoints(points);
466 polyData->SetLines(lines);
473 localStorage->
m_OutlineActor->GetProperty()->SetColor(color.GetRed(), color.GetGreen(), color.GetBlue());
480 float opacity = 1.0f;
492 input->GetLabelSet(layer)->GetLookupTable()->GetVtkLookupTable());
506 if (
image ==
nullptr ||
image->IsInitialized() ==
false)
514 if ((dataTimeGeometry ==
nullptr) || (dataTimeGeometry->
CountTimeSteps() == 0) ||
520 image->UpdateOutputInformation();
550 localStorage->
m_Plane->SetOrigin(planeBounds[0], planeBounds[2], depth);
554 localStorage->
m_Plane->SetPoint1(planeBounds[1], planeBounds[2], depth);
555 localStorage->
m_Plane->SetPoint2(planeBounds[0], planeBounds[3], depth);
561 double maxRange = renderer->
GetVtkRenderer()->GetActiveCamera()->GetClippingRange()[1];
564 float depth = -maxRange * 0.01;
572 MITK_WARN <<
"Layer value exceeds clipping range. Set to minimum instead.";
581 vtkSmartPointer<vtkTransform> trans = vtkSmartPointer<vtkTransform>::New();
582 vtkSmartPointer<vtkMatrix4x4> matrix = localStorage->
m_ReslicerVector[0]->GetResliceAxes();
583 trans->SetMatrix(matrix);
613 node->
SetProperty(
"Image Rendering.Mode", renderingModeProperty, renderer);
618 levWinProp->SetLevelWindow(levelwindow);
619 node->
SetProperty(
"levelwindow", levWinProp, renderer);
624 Superclass::SetDefaultProperties(node, renderer, overwrite);
634 m_Plane = vtkSmartPointer<vtkPlaneSource>::New();
635 m_Actors = vtkSmartPointer<vtkPropAssembly>::New();
636 m_OutlinePolyData = vtkSmartPointer<vtkPolyData>::New();
637 m_EmptyPolyData = vtkSmartPointer<vtkPolyData>::New();
638 m_OutlineActor = vtkSmartPointer<vtkActor>::New();
639 m_OutlineMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
640 m_OutlineShadowActor = vtkSmartPointer<vtkActor>::New();
642 m_NumberOfLayers = 0;
643 m_mmPerPixel =
nullptr;
645 m_OutlineActor->SetMapper(m_OutlineMapper);
646 m_OutlineShadowActor->SetMapper(m_OutlineMapper);
648 m_OutlineActor->SetVisibility(
false);
649 m_OutlineShadowActor->SetVisibility(
false);
virtual ScalarType SignedDistance(const Point3D &pt3d_mm) const
L * GetLocalStorage(mitk::BaseRenderer *forRenderer)
Retrieves a LocalStorage for a specific BaseRenderer.
virtual TimeStepType CountTimeSteps() const =0
Returns the number of time steps.
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 ...
static void SetDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer=nullptr, bool overwrite=false)
Set the default properties for general image rendering.
vtkRenderer * GetVtkRenderer() const
LocalStorage()
Default constructor of the local storage.
virtual DataNode * GetDataNode() const
Get the DataNode containing the data to map. Method only returns valid DataNode Pointer if the mapper...
void GenerateDataForRenderer(mitk::BaseRenderer *renderer) override
Does the actual resampling, without rendering the image yet. All the data is generated inside this me...
vtkSmartPointer< vtkActor > m_OutlineActor
An actor for the outline.
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< vtkPolyData > m_OutlinePolyData
std::vector< vtkSmartPointer< vtkActor > > m_LayerActorVector
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.
bool RenderingGeometryIntersectsImage(const PlaneGeometry *renderingGeometry, SlicedGeometry3D *imageGeometry)
Calculates whether the given rendering geometry intersects the given SlicedGeometry3D.
vtkProp * GetVtkProp(mitk::BaseRenderer *renderer) override
Point3D GetCornerPoint(int id) const
Get the position of the corner number id (in world coordinates)
itk::TimeStamp m_LastPropertyUpdateTime
Timestamp of last update of a property.
A data structure describing a label.
virtual const PlaneGeometry * GetCurrentWorldPlaneGeometry()
Get the current 2D-worldgeometry (m_CurrentWorldPlaneGeometry) used for 2D-rendering.
std::vector< vtkSmartPointer< vtkImageData > > m_ReslicedImageVector
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)
bool GetIntProperty(const char *propertyKey, int &intValue, const mitk::BaseRenderer *renderer=nullptr) const
Convenience access method for int properties (instances of IntProperty)
std::vector< vtkSmartPointer< vtkMitkLevelWindowFilter > > m_LevelWindowFilterVector
This filter is used to apply the level window to Grayvalue and RBG(A) images.
float CalculateLayerDepth(mitk::BaseRenderer *renderer)
This method uses the vtkCamera clipping range and the layer property to calcualte the depth of the ob...
The LevelWindow class Class to store level/window values.
void Update(mitk::BaseRenderer *renderer) override
Checks whether this mapper needs to update itself and generate data.
~LocalStorage() override
Default deconstructor of the local storage.
void SetProperty(const std::string &propertyKey, BaseProperty *property, const std::string &contextName="", bool fallBackOnDefaultContext=false) override
Add new or change existent property.
LocalStorage * GetLocalStorage(mitk::BaseRenderer *renderer)
Get the LocalStorage corresponding to the current renderer.
mitk::LocalStorageHandler< LocalStorage > m_LSH
The LocalStorageHandler holds all (three) LocalStorages for the three 2D render windows.
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.
vtkSmartPointer< vtkPolyData > m_EmptyPolyData
void ApplyOpacity(mitk::BaseRenderer *renderer, int layer)
Set the opacity of the actor.
vtkSmartPointer< vtkActor > m_OutlineShadowActor
An actor for the outline shadow.
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...
mitk::ScalarType * m_mmPerPixel
mmPerPixel relation between pixel and mm. (World spacing).
const mitk::Color & GetColor() const
LabelSetImageVtkMapper2D()
virtual void CalculateTimeStep(BaseRenderer *renderer)
Updates the time step, which is sometimes needed in subclasses.
void TransformActor(mitk::BaseRenderer *renderer)
Transforms the actor to the actual position in 3D.
mitk::Image::Pointer image
void ApplyColor(mitk::BaseRenderer *renderer, const mitk::Color &color)
Set the color of the image/polydata.
PixelType GetValue() const
itk::RGBPixel< float > Color
Color Standard RGB color typedef (float)
Describes the geometry of a data object consisting of slices.
Internal class holding the mapper, actor, etc. for each of the 3 2D render windows.
void ApplyLookuptable(mitk::BaseRenderer *renderer, int layer)
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 nullptr, the BaseRenderer-independent PropertyLi...
virtual BaseGeometry::Pointer GetGeometryForTimeStep(TimeStepType timeStep) const =0
Returns the geometry which corresponds to the given time step.
LabelSetImage class for handling labels and layers in a segmentation session.
int GetTimestep() const
Returns the current time step as calculated from the renderer.
std::vector< vtkSmartPointer< vtkNeverTranslucentTexture > > m_LayerTextureVector
unsigned long GetCurrentWorldPlaneGeometryUpdateTime()
Get timestamp of last call of SetCurrentWorldPlaneGeometry.
Describes a two-dimensional, rectangular plane.
std::vector< mitk::ExtractSliceFilter::Pointer > m_ReslicerVector
std::vector< vtkSmartPointer< vtkPolyDataMapper > > m_LayerMapperVector
vtkSmartPointer< vtkPolyDataMapper > m_OutlineMapper
A mapper for the outline.
vtkSmartPointer< vtkPlaneSource > m_Plane
mitk::BaseGeometry * GetGeometry(int t=0) const
Return the geometry, which is a TimeGeometry, of the data as non-const pointer.
vtkSmartPointer< vtkPropAssembly > m_Actors
itk::TimeStamp m_LastDataUpdateTime
Timestamp of last update of stored data.
virtual bool IsValidTimeStep(TimeStepType timeStep) const =0
Test for the given time step if a geometry is availible.
Class for nodes of the DataTree.
vtkSmartPointer< vtkPolyData > CreateOutlinePolyData(mitk::BaseRenderer *renderer, vtkImageData *image, int pixelValue=1)
Generates a vtkPolyData object containing the outline of a given binary slice.
~LabelSetImageVtkMapper2D() override
void GeneratePlane(mitk::BaseRenderer *renderer, double planeBounds[6])
Generates a plane according to the size of the resliced image in milimeters.