Medical Imaging Interaction Toolkit  2023.04.00
Medical Imaging Interaction Toolkit
mitkSurfaceInterpolationController.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef mitkSurfaceInterpolationController_h
14 #define mitkSurfaceInterpolationController_h
15 
16 #include <mitkDataStorage.h>
17 #include <mitkImage.h>
18 #include <mitkLabel.h>
19 #include <mitkSurface.h>
20 
22 
23 namespace mitk
24 {
25  class ComputeContourSetNormalsFilter;
26  class CreateDistanceImageFromSurfaceFilter;
27  class LabelSetImage;
28  class ReduceContourSetFilter;
29 
31  {
32  public:
34  itkFactorylessNewMacro(Self);
35  itkCloneMacro(Self);
36  itkGetMacro(DistanceImageSpacing, double);
37 
39  {
40  int Pos;
41  unsigned int SliceIndex;
47  unsigned int LayerValue;
48  size_t TimeStep;
49 
51  : Pos(-1),
52  SliceIndex(0),
53  Plane(nullptr),
54  LabelValue(std::numeric_limits<mitk::Label::PixelType>::max()),
55  LayerValue(std::numeric_limits<unsigned int>::max()),
56  TimeStep(std::numeric_limits<size_t>::max())
57  {
58  }
59  };
60 
61  typedef std::vector<ContourPositionInformation> ContourPositionInformationList;
62  typedef std::vector<ContourPositionInformationList> ContourPositionInformationVec2D;
63 
64  // first index is the current time step. second index is the layerID. third index is the contour index.
65  typedef std::vector<ContourPositionInformationVec2D> ContourPositionInformationVec3D;
66 
67  typedef std::map<mitk::Image *, ContourPositionInformationVec3D> ContourListMap;
68  typedef std::map<mitk::Image *, ContourPositionInformationVec2D> ContourContainer;
69 
70  static SurfaceInterpolationController *GetInstance();
71 
73  {
74  if (m_CurrentTimePoint != tp)
75  {
76  m_CurrentTimePoint = tp;
77 
78  if (m_SelectedSegmentation)
79  {
80  this->ReinitializeInterpolation();
81  }
82  }
83  };
84 
85  TimePointType GetCurrentTimePoint() const { return m_CurrentTimePoint; };
86 
92  void AddNewContour(Surface::Pointer newContour);
93 
98  void AddNewContours(const std::vector<Surface::Pointer>& newContours, std::vector<const mitk::PlaneGeometry*>& contourPlanes, bool reinitializeAction = false);
99 
105  const mitk::Surface *GetContour(const ContourPositionInformation& contourInfo);
106 
114  mitk::Point3D ComputeInteriorPointOfContour(const ContourPositionInformation& contour,
115  mitk::LabelSetImage * labelSetImage);
116 
121  void AddLabelSetConnection();
122 
127  void RemoveLabelSetConnection();
128 
129  void RemoveLabelSetConnection(mitk::LabelSetImage* labelSetImage, unsigned int layerID);
130 
131 
136  void ReinitializeInterpolation();
137 
138  void RemoveObservers();
139 
140  void AddLabelSetConnection(unsigned int layerID);
141 
143  {
144  m_SelectedSegmentation = nullptr;
145  }
146 
151  unsigned int GetNumberOfLayersInCurrentSegmentation() const;
152 
157  void SetNumberOfLayersInCurrentSegmentation(unsigned int);
158 
163  void OnRemoveLayer();
164 
169  void OnAddLayer();
170 
175  unsigned int GetNumberOfContours();
176 
181  void Interpolate();
182 
188  mitk::Surface::Pointer GetInterpolationResult();
189 
196  void SetMinSpacing(double minSpacing);
197 
203  void SetMaxSpacing(double maxSpacing);
204 
209  void SetDistanceImageVolume(unsigned int distImageVolume);
210 
215  mitk::Image::Pointer GetCurrentSegmentation();
216 
217  Surface *GetContoursAsSurface();
218 
219  void SetDataStorage(DataStorage::Pointer ds);
220 
226  DEPRECATED(void SetCurrentSegmentationInterpolationList(mitk::Image::Pointer segmentation));
227 
232  void SetCurrentInterpolationSession(mitk::Image::Pointer currentSegmentationImage);
233 
239  DEPRECATED(void RemoveSegmentationFromContourList(mitk::Image *segmentation));
240 
245  void RemoveInterpolationSession(mitk::Image::Pointer segmentationImage);
246 
255  bool ReplaceInterpolationSession(mitk::Image::Pointer oldSession, mitk::Image::Pointer newSession);
256 
260  void RemoveAllInterpolationSessions();
261 
262  mitk::Image *GetImage();
263 
271  ContourPositionInformationList* GetContours(unsigned int timeStep, unsigned int layerID);
272 
280  void CompleteReinitialization(const std::vector<mitk::Surface::Pointer>& contourList,
281  std::vector<const mitk::PlaneGeometry *>& contourPlanes);
282 
290  void RemoveContours(mitk::Label::PixelType label, unsigned int timeStep, unsigned int layerID);
291 
296  double EstimatePortionOfNeededMemory();
297 
301  void AddActiveLabelContoursForInterpolation(mitk::Label::PixelType activeLabel);
302 
303  unsigned int GetNumberOfInterpolationSessions();
304 
310  bool RemoveContour(ContourPositionInformation contourInfo);
311 
317  mitk::DataNode* GetSegmentationImageNode();
318 
319 
320 
321  protected:
323 
324  ~SurfaceInterpolationController() override;
325 
326  template <typename TPixel, unsigned int VImageDimension>
327  void GetImageBase(itk::Image<TPixel, VImageDimension> *input, itk::ImageBase<3>::Pointer &result);
328 
329  private:
330 
337  void OnSegmentationDeleted(const itk::Object *caller, const itk::EventObject &event);
338 
343  void OnRemoveLabel(mitk::Label::PixelType removedLabelValue);
344 
353  void AddPlaneGeometryNodeToDataStorage(const ContourPositionInformation& contourInfo);
354 
359  void OnActiveLabel(mitk::Label::PixelType);
360 
365  void ClearInterpolationSession();
366 
373  void AddToInterpolationPipeline(ContourPositionInformation& contourInfo, bool reinitializationAction = false);
374 
379  void OnLayerChanged();
380 
384 
385  mitk::Surface::Pointer m_Contours;
386 
387  double m_DistanceImageSpacing;
388 
389  vtkSmartPointer<vtkPolyData> m_PolyData;
390 
391  mitk::DataStorage::Pointer m_DataStorage;
392 
393  ContourContainer m_ListOfInterpolationSessions;
394  ContourListMap m_ListOfContours;
395 
396  mitk::Surface::Pointer m_InterpolationResult;
397 
398  unsigned int m_CurrentNumberOfReducedContours;
399  unsigned int m_NumberOfConnectionsAdded;
400 
401  mitk::Image *m_SelectedSegmentation;
402 
403  std::map<mitk::Image *, unsigned long> m_SegmentationObserverTags;
404 
405  mitk::TimePointType m_CurrentTimePoint;
406 
407  unsigned int m_ContourIndex;
408  unsigned int m_ContourPosIndex;
409  unsigned int m_NumberOfLayersInCurrentSegmentation;
410 
411  mitk::Label::PixelType m_PreviousActiveLabelValue;
412  mitk::Label::PixelType m_CurrentActiveLabelValue;
413 
414  unsigned int m_PreviousLayerIndex;
415  unsigned int m_CurrentLayerIndex;
416  };
417 
418  namespace ContourExt
419  {
426  size_t GetContourOrientation(const mitk::Vector3D& ContourNormal);
427 
439  template<unsigned int VImageDimension>
441  mitk::LabelSetImage * labelSetImage,
442  mitk::TimePointType currentTimePoint);
456  std::vector< mitk::Point3D > GetBoundingBoxGridPoints(size_t planeDimension,
457  double startDim1,
458  size_t numPointsToSampleDim1,
459  double deltaDim1,
460  double startDim2,
461  size_t numPointsToSampleDim2,
462  double deltaDim2,
463  double valuePlaneDim);
464  };
465 
466 }
467 
468 #endif
mitk::SurfaceInterpolationController::ContourPositionInformation::ContourPositionInformation
ContourPositionInformation()
Definition: mitkSurfaceInterpolationController.h:50
mitkLabel.h
mitk::SurfaceInterpolationController::GetCurrentTimePoint
TimePointType GetCurrentTimePoint() const
Definition: mitkSurfaceInterpolationController.h:85
mitkImage.h
mitk::SurfaceInterpolationController::ContourPositionInformation
Definition: mitkSurfaceInterpolationController.h:38
mitk::PlaneGeometry
Describes a two-dimensional, rectangular plane.
Definition: mitkPlaneGeometry.h:78
mitk::SurfaceInterpolationController::ContourPositionInformation::TimeStep
size_t TimeStep
Definition: mitkSurfaceInterpolationController.h:48
mitkDataStorage.h
MITKSURFACEINTERPOLATION_EXPORT
#define MITKSURFACEINTERPOLATION_EXPORT
Definition: MitkSurfaceInterpolationExports.h:15
mitk::ContourExt::GetBoundingBoxGridPoints
std::vector< mitk::Point3D > GetBoundingBoxGridPoints(size_t planeDimension, double startDim1, size_t numPointsToSampleDim1, double deltaDim1, double startDim2, size_t numPointsToSampleDim2, double deltaDim2, double valuePlaneDim)
Get a Grid points within the bounding box of the contour at a certain spacing.
mitk::SurfaceInterpolationController::ContourContainer
std::map< mitk::Image *, ContourPositionInformationVec2D > ContourContainer
Definition: mitkSurfaceInterpolationController.h:68
mitk::Plane
Plane surface representation.
Definition: mitkPlane.h:31
mitk::SurfaceInterpolationController::ContourPositionInformation::Plane
mitk::PlaneGeometry * Plane
Definition: mitkSurfaceInterpolationController.h:45
mitk::SurfaceInterpolationController::ContourPositionInformation::LayerValue
unsigned int LayerValue
Definition: mitkSurfaceInterpolationController.h:47
mitk::ContourExt::ComputeInteriorPointOfContour
mitk::Point3D ComputeInteriorPointOfContour(const mitk::SurfaceInterpolationController::ContourPositionInformation &contour, mitk::LabelSetImage *labelSetImage, mitk::TimePointType currentTimePoint)
Function used to compute an interior point of the contour. Used to react to the merge label and erase...
mitk::ContourExt::GetContourOrientation
size_t GetContourOrientation(const mitk::Vector3D &ContourNormal)
Returns the plane the contour belongs to.
mitk::Image
Image class for storing images.
Definition: mitkImage.h:69
DEPRECATED
#define DEPRECATED(func)
Definition: mitkCommon.h:175
itk::SmartPointer< Self >
mitk::SurfaceInterpolationController::ContourPositionInformation::ContourNormal
Vector3D ContourNormal
Definition: mitkSurfaceInterpolationController.h:43
mitk::SurfaceInterpolationController::SetCurrentTimePoint
void SetCurrentTimePoint(TimePointType tp)
Definition: mitkSurfaceInterpolationController.h:72
mitk::Label::PixelType
unsigned short PixelType
Definition: mitkLabel.h:33
mitk::Surface
Class for storing surfaces (vtkPolyData).
Definition: mitkSurface.h:28
mitkClassMacroItkParent
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:45
mitk
DataCollection - Class to facilitate loading/accessing structured data.
Definition: RenderingTests.dox:1
mitkSurface.h
mitk::Label
A data structure describing a label.
Definition: mitkLabel.h:28
mitk::SurfaceInterpolationController::ContourPositionInformation::LabelValue
mitk::Label::PixelType LabelValue
Definition: mitkSurfaceInterpolationController.h:46
mitk::SurfaceInterpolationController::ContourListMap
std::map< mitk::Image *, ContourPositionInformationVec3D > ContourListMap
Definition: mitkSurfaceInterpolationController.h:67
mitk::SurfaceInterpolationController::ContourPositionInformation::Pos
int Pos
Definition: mitkSurfaceInterpolationController.h:40
mitk::SurfaceInterpolationController::ContourPositionInformationVec2D
std::vector< ContourPositionInformationList > ContourPositionInformationVec2D
Definition: mitkSurfaceInterpolationController.h:62
mitk::Vector< ScalarType, 3 >
mitk::Point< ScalarType, 3 >
mitk::SurfaceInterpolationController::ContourPositionInformation::Contour
Surface::Pointer Contour
Definition: mitkSurfaceInterpolationController.h:42
mitk::SurfaceInterpolationController::ContourPositionInformation::SliceIndex
unsigned int SliceIndex
Definition: mitkSurfaceInterpolationController.h:41
mitk::SurfaceInterpolationController
Definition: mitkSurfaceInterpolationController.h:30
mitk::PixelType
Class for defining the data type of pixels.
Definition: mitkPixelType.h:51
MitkSurfaceInterpolationExports.h
mitk::SurfaceInterpolationController::ContourPositionInformation::ContourPoint
Point3D ContourPoint
Definition: mitkSurfaceInterpolationController.h:44
mitk::SurfaceInterpolationController::ContourPositionInformationVec3D
std::vector< ContourPositionInformationVec2D > ContourPositionInformationVec3D
Definition: mitkSurfaceInterpolationController.h:65
mitk::SurfaceInterpolationController::ContourPositionInformationList
std::vector< ContourPositionInformation > ContourPositionInformationList
Definition: mitkSurfaceInterpolationController.h:61
mitk::TimePointType
mitk::ScalarType TimePointType
Definition: mitkTimeGeometry.h:26
mitk::DataNode
Class for nodes of the DataTree.
Definition: mitkDataNode.h:63
mitk::LabelSetImage
LabelSetImage class for handling labels and layers in a segmentation session.
Definition: mitkLabelSetImage.h:29
mitk::SurfaceInterpolationController::UnsetSelectedImage
void UnsetSelectedImage()
Definition: mitkSurfaceInterpolationController.h:142