41 #include <vtkCamera.h>
42 #include <vtkCellArray.h>
43 #include <vtkImageData.h>
44 #include <vtkImageReslice.h>
45 #include <vtkLookupTable.h>
46 #include <vtkMatrix4x4.h>
47 #include <vtkPlaneSource.h>
48 #include <vtkPoints.h>
49 #include <vtkPolyData.h>
50 #include <vtkPolyDataMapper.h>
51 #include <vtkProperty.h>
52 #include <vtkTransform.h>
56 #include <itkRGBAPixel.h>
70 return m_LSH.GetLocalStorage(renderer)->m_Actors;
76 return m_LSH.GetLocalStorage(renderer);
81 LocalStorage *localStorage = m_LSH.GetLocalStorage(renderer);
88 if ((worldGeometry == NULL) || (!worldGeometry->IsValid()) || (!worldGeometry->HasReferenceGeometry()))
97 node->
GetOpacity(opacity, renderer,
"opacity");
111 for (
int lidx = 0; lidx < numberOfLayers; ++lidx)
135 if (!RenderingGeometryIntersectsImage(worldGeometry, image->
GetSlicedGeometry()))
140 for (
int lidx = 0; lidx < numberOfLayers; ++lidx)
150 for (
int lidx = 0; lidx < numberOfLayers; ++lidx)
155 if (lidx == activeLayer)
169 bool inPlaneResampleExtentByGeometry =
false;
170 node->
GetBoolProperty(
"in plane resample extent by geometry", inPlaneResampleExtentByGeometry, renderer);
171 localStorage->
m_ReslicerVector[lidx]->SetInPlaneResampleExtentByGeometry(inPlaneResampleExtentByGeometry);
182 double sliceBounds[6];
183 sliceBounds[0] = 0.0;
184 sliceBounds[1] = 0.0;
185 sliceBounds[2] = 0.0;
186 sliceBounds[3] = 0.0;
187 sliceBounds[4] = 0.0;
188 sliceBounds[5] = 0.0;
193 this->GeneratePlane(renderer, sliceBounds);
204 double textureClippingBounds[6];
205 for (
auto &textureClippingBound : textureClippingBounds)
207 textureClippingBound = 0.0;
215 textureClippingBounds[0] =
static_cast<int>(textureClippingBounds[0] / localStorage->
m_mmPerPixel[0] + 0.5);
216 textureClippingBounds[1] =
static_cast<int>(textureClippingBounds[1] / localStorage->
m_mmPerPixel[0] + 0.5);
217 textureClippingBounds[2] =
static_cast<int>(textureClippingBounds[2] / localStorage->
m_mmPerPixel[1] + 0.5);
218 textureClippingBounds[3] =
static_cast<int>(textureClippingBounds[3] / localStorage->
m_mmPerPixel[1] + 0.5);
224 image->
GetLabelSet(lidx)->GetLookupTable()->GetVtkLookupTable());
234 bool textureInterpolation =
false;
235 node->
GetBoolProperty(
"texture interpolation", textureInterpolation, renderer);
243 this->TransformActor(renderer);
254 if (
nullptr != activeLabel)
256 bool contourActive =
false;
257 node->
GetBoolProperty(
"labelset.contour.active", contourActive, renderer);
258 if (contourActive && activeLabel->
GetVisible())
266 localStorage->
m_OutlineActor->GetProperty()->SetColor(color.GetRed(), color.GetGreen(), color.GetBlue());
269 float contourWidth(2.0);
271 localStorage->
m_OutlineActor->GetProperty()->SetLineWidth(contourWidth);
290 if (renderingGeometry == NULL || imageGeometry == NULL)
295 for (
int i = 1; i < 8; i++)
303 if (initialDistance * distance < 0)
318 LocalStorage *localStorage = this->GetLocalStorage(renderer);
321 int *extent = image->GetExtent();
322 int xMin = extent[0];
323 int xMax = extent[1];
324 int yMin = extent[2];
325 int yMax = extent[3];
327 int *dims = image->GetDimensions();
333 float depth = this->CalculateLayerDepth(renderer);
344 if ((currentPixel) && (*currentPixel == pixelValue))
351 if (y > yMin && *(currentPixel - line) != pixelValue)
359 lines->InsertNextCell(2);
360 lines->InsertCellPoint(p1);
361 lines->InsertCellPoint(p2);
365 if (y < yMax && *(currentPixel + line) != pixelValue)
369 vtkIdType p2 = points->InsertNextPoint(
371 lines->InsertNextCell(2);
372 lines->InsertCellPoint(p1);
373 lines->InsertCellPoint(p2);
377 if ((x > xMin || y > yMin) && *(currentPixel - 1) != pixelValue)
383 lines->InsertNextCell(2);
384 lines->InsertCellPoint(p1);
385 lines->InsertCellPoint(p2);
389 if ((y < yMax || (x < xMax)) && *(currentPixel + 1) != pixelValue)
393 vtkIdType p2 = points->InsertNextPoint(
395 lines->InsertNextCell(2);
396 lines->InsertCellPoint(p1);
397 lines->InsertCellPoint(p2);
409 lines->InsertNextCell(2);
410 lines->InsertCellPoint(p1);
411 lines->InsertCellPoint(p2);
419 vtkIdType p2 = points->InsertNextPoint(
421 lines->InsertNextCell(2);
422 lines->InsertCellPoint(p1);
423 lines->InsertCellPoint(p2);
433 lines->InsertNextCell(2);
434 lines->InsertCellPoint(p1);
435 lines->InsertCellPoint(p2);
443 vtkIdType p2 = points->InsertNextPoint(
445 lines->InsertNextCell(2);
446 lines->InsertCellPoint(p1);
447 lines->InsertCellPoint(p2);
468 polyData->SetPoints(points);
470 polyData->SetLines(lines);
476 LocalStorage *localStorage = this->GetLocalStorage(renderer);
477 localStorage->
m_OutlineActor->GetProperty()->SetColor(color.GetRed(), color.GetGreen(), color.GetBlue());
483 LocalStorage *localStorage = this->GetLocalStorage(renderer);
484 float opacity = 1.0f;
485 this->GetDataNode()->GetOpacity(opacity, renderer,
"opacity");
493 LocalStorage *localStorage = m_LSH.GetLocalStorage(renderer);
496 input->
GetLabelSet(layer)->GetLookupTable()->GetVtkLookupTable());
502 const DataNode *node = this->GetDataNode();
514 this->CalculateTimeStep(renderer);
518 if ((dataTimeGeometry == NULL) || (dataTimeGeometry->CountTimeSteps() == 0) ||
525 LocalStorage *localStorage = m_LSH.GetLocalStorage(renderer);
538 this->GenerateDataForRenderer(renderer);
546 LocalStorage *localStorage = m_LSH.GetLocalStorage(renderer);
548 float depth = this->CalculateLayerDepth(renderer);
551 localStorage->
m_Plane->SetOrigin(planeBounds[0], planeBounds[2], depth);
555 localStorage->
m_Plane->SetPoint1(planeBounds[1], planeBounds[2], depth);
556 localStorage->
m_Plane->SetPoint2(planeBounds[0], planeBounds[3], depth);
562 double maxRange = renderer->
GetVtkRenderer()->GetActiveCamera()->GetClippingRange()[1];
565 float depth = -maxRange * 0.01;
567 GetDataNode()->GetIntProperty(
"layer", layer, renderer);
573 MITK_WARN <<
"Layer value exceeds clipping range. Set to minimum instead.";
580 LocalStorage *localStorage = m_LSH.GetLocalStorage(renderer);
583 vtkSmartPointer<vtkMatrix4x4> matrix = localStorage->
m_ReslicerVector[0]->GetResliceAxes();
584 trans->SetMatrix(matrix);
614 node->
SetProperty(
"Image Rendering.Mode", renderingModeProperty, renderer);
619 levWinProp->SetLevelWindow(levelwindow);
620 node->
SetProperty(
"levelwindow", levWinProp, renderer);
625 Superclass::SetDefaultProperties(node, renderer, overwrite);
643 m_NumberOfLayers = 0;
645 m_OutlineActor->SetMapper(m_OutlineMapper);
646 m_OutlineShadowActor->SetMapper(m_OutlineMapper);
648 m_OutlineActor->SetVisibility(
false);
649 m_OutlineShadowActor->SetVisibility(
false);
LocalStorage()
Default constructor of the local storage.
virtual 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
Organizes the rendering process.
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)
bool RenderingGeometryIntersectsImage(const PlaneGeometry *renderingGeometry, SlicedGeometry3D *imageGeometry)
Calculates whether the given rendering geometry intersects the given SlicedGeometry3D.
virtual vtkProp * GetVtkProp(mitk::BaseRenderer *renderer) override
A data structure describing a label.
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.
std::vector< vtkSmartPointer< vtkImageData > > m_ReslicedImageVector
virtual ~LabelSetImageVtkMapper2D()
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.
virtual void Update(mitk::BaseRenderer *renderer) override
Checks whether this mapper needs to update itself and generate data.
LocalStorage * GetLocalStorage(mitk::BaseRenderer *renderer)
Get the LocalStorage corresponding to the current renderer.
~LocalStorage()
Default deconstructor of the local storage.
bool GetOpacity(float &opacity, const mitk::BaseRenderer *renderer, const char *propertyKey="opacity") const
Convenience access method for opacity properties (instances of FloatProperty)
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.
bool GetFloatProperty(const char *propertyKey, float &floatValue, const mitk::BaseRenderer *renderer=nullptr) const
Convenience access method for float properties (instances of FloatProperty)
Image class for storing images.
unsigned int GetNumberOfLayers() const
mitk::ScalarType * m_mmPerPixel
mmPerPixel relation between pixel and mm. (World spacing).
mitk::Image * GetLayerImage(unsigned int layer)
mitk::Label * GetActiveLabel(unsigned int layer=0)
Returns the active label of a specific layer.
LabelSetImageVtkMapper2D()
void TransformActor(mitk::BaseRenderer *renderer)
Transforms the actor to the actual position in 3D.
void ApplyColor(mitk::BaseRenderer *renderer, const mitk::Color &color)
Set the color of the image/polydata.
Point3D GetCornerPoint(int id) const
Get the position of the corner number id (in world coordinates)
virtual unsigned long GetMTime() const override
Get the modified time of the last change of the contents this data object or its geometry.
static void SetDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer=NULL, bool overwrite=false)
Set the default properties for general image rendering.
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.
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.
virtual bool IsInitialized() const
Check whether the data has been initialized, i.e., at least the Geometry and other header data has be...
const mitk::Color & GetColor() const
std::vector< vtkSmartPointer< vtkNeverTranslucentTexture > > m_LayerTextureVector
unsigned long GetCurrentWorldPlaneGeometryUpdateTime()
Get timestamp of last call of SetCurrentWorldPlaneGeometry.
SlicedGeometry3D * GetSlicedGeometry(unsigned int t=0) const
Convenience access method for the geometry, which is of type SlicedGeometry3D (or a sub-class of it)...
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 ...
unsigned int GetActiveLayer() const
Gets the ID of the currently active layer.
virtual void UpdateOutputInformation() override
PixelType GetValue() const
std::vector< mitk::ExtractSliceFilter::Pointer > m_ReslicerVector
vtkRenderer * GetVtkRenderer() const
mitk::BaseGeometry * GetGeometry(int t=0) const
Return the geometry, which is a TimeGeometry, of the data as non-const pointer.
std::vector< vtkSmartPointer< vtkPolyDataMapper > > m_LayerMapperVector
vtkSmartPointer< vtkPolyDataMapper > m_OutlineMapper
A mapper for the outline.
vtkSmartPointer< vtkPlaneSource > m_Plane
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< vtkPropAssembly > m_Actors
mitk::LabelSet * GetLabelSet(unsigned int layer=0)
Gets the mitk::LabelSet for the given layer.
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.
void GeneratePlane(mitk::BaseRenderer *renderer, double planeBounds[6])
Generates a plane according to the size of the resliced image in milimeters.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.