Medical Imaging Interaction Toolkit  2025.12.02
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 <mitkLabelSetImage.h>
18 #include <mitkLabel.h>
19 #include <mitkSurface.h>
20 
22 
23 namespace mitk
24 {
25  class ComputeContourSetNormalsFilter;
26  class CreateDistanceImageFromSurfaceFilter;
27  class MultiLabelSegmentation;
28  class ReduceContourSetFilter;
29 
31  {
32  public:
34  itkFactorylessNewMacro(Self);
35  itkCloneMacro(Self);
36 
38  {
39  Surface::ConstPointer Contour;
40  PlaneGeometry::ConstPointer Plane;
43 
45  : Plane(nullptr),
46  LabelValue(std::numeric_limits<Label::PixelType>::max()),
47  TimeStep(std::numeric_limits<TimeStepType>::max())
48  {
49  }
50 
51  ContourPositionInformation(Surface::ConstPointer contour,
52  PlaneGeometry::ConstPointer plane,
53  Label::PixelType labelValue,
54  TimeStepType timeStep)
55  :
56  Contour(contour),
57  Plane(plane),
58  LabelValue(labelValue),
59  TimeStep(timeStep)
60  {
61  }
62 
63  bool IsPlaceHolder() const
64  {
65  return Contour.IsNull();
66  }
67  };
68 
69  typedef std::vector<ContourPositionInformation> CPIVector;
70 
72 
77  void AddNewContours(const std::vector<ContourPositionInformation>& newCPIs, bool reinitializeAction = false, bool silent = false);
78 
85  bool RemoveContour(ContourPositionInformation contourInfo, bool keepPlaceholderForUndo = false);
86 
88 
93  void Interpolate(const MultiLabelSegmentation* segmentationImage, MultiLabelSegmentation::LabelValueType labelValue, TimeStepType timeStep);
94 
100  mitk::Surface::Pointer GetInterpolationResult(const MultiLabelSegmentation* segmentationImage, MultiLabelSegmentation::LabelValueType labelValue, TimeStepType timeStep);
101 
108  void SetMinSpacing(double minSpacing);
109 
115  void SetMaxSpacing(double maxSpacing);
116 
121  void SetDistanceImageVolume(unsigned int distImageVolume);
122 
128 
129  void SetDataStorage(DataStorage::Pointer ds);
130 
136 
141  void RemoveInterpolationSession(const MultiLabelSegmentation* segmentationImage);
142 
147 
156 
157  std::vector<MultiLabelSegmentation::LabelValueType> GetAffectedLabels(const MultiLabelSegmentation* seg, TimeStepType timeStep, const PlaneGeometry* plane) const;
158 
164  void CompleteReinitialization(const std::vector<ContourPositionInformation>& newCPIs);
165 
174  void RemoveContours(const MultiLabelSegmentation* segmentationImage, mitk::Label::PixelType label, TimeStepType timeStep);
175 
183  void RemoveContours(const MultiLabelSegmentation* segmentationImage, mitk::Label::PixelType label);
184 
186 
193 
194  protected:
196 
198 
199  template <typename TPixel, unsigned int VImageDimension>
200  void GetImageBase(itk::Image<TPixel, VImageDimension> *input, itk::ImageBase<3>::Pointer &result);
201 
202  private:
203 
210  void OnSegmentationDeleted(const itk::Object *caller, const itk::EventObject &event);
211 
217  void OnRemoveLabel(const itk::Object* caller, const itk::EventObject& event);
218 
227  void AddPlaneGeometryNodeToDataStorage(const ContourPositionInformation& contourInfo) const;
228 
229  DataStorage::SetOfObjects::ConstPointer GetPlaneGeometryNodeFromDataStorage(const DataNode* segNode) const;
230  DataStorage::SetOfObjects::ConstPointer GetPlaneGeometryNodeFromDataStorage(const DataNode* segNode, MultiLabelSegmentation::LabelValueType labelValue) const;
231  DataStorage::SetOfObjects::ConstPointer GetPlaneGeometryNodeFromDataStorage(const DataNode* segNode, MultiLabelSegmentation::LabelValueType labelValue, TimeStepType timeStep) const;
232 
236  void AddActiveLabelContoursForInterpolation(ReduceContourSetFilter* reduceFilter, const MultiLabelSegmentation* segmentationImage, MultiLabelSegmentation::LabelValueType labelValue, TimeStepType timeStep);
237 
242  void ClearInterpolationSession();
243 
244  void RemoveObserversInternal(const mitk::MultiLabelSegmentation* segmentationImage);
245 
252  void AddToCPIMap(ContourPositionInformation& contourInfo, bool reinitializationAction = false);
253 
254  unsigned int m_DistanceImageVolume;
255  mitk::DataStorage::Pointer m_DataStorage;
256 
257  WeakPointer<MultiLabelSegmentation> m_SelectedSegmentation;
258  };
259 }
260 
261 #endif
#define MITKSURFACEINTERPOLATION_EXPORT
Stores vertices for drawing a contour.
Definition: mitkContour.h:32
Class for nodes of the DataTree.
Definition: mitkDataNode.h:64
A data structure describing a label.
Definition: mitkLabel.h:90
unsigned short PixelType
Definition: mitkLabel.h:94
MultiLabelSegmentation class for handling labels and layers in a segmentation session.
mitk::Label::PixelType LabelValueType
Class for defining the data type of pixels.
Definition: mitkPixelType.h:52
Describes a two-dimensional, rectangular plane.
Plane surface representation.
Definition: mitkPlane.h:32
A filter that reduces the number of points of contours represented by a mitk::Surface.
void SetDistanceImageVolume(unsigned int distImageVolume)
mitk::DataNode * GetSegmentationImageNode() const
Get the Segmentation Image Node object.
unsigned int GetNumberOfInterpolationSessions()
mitkClassMacroItkParent(SurfaceInterpolationController, itk::Object)
mitk::Surface::Pointer GetInterpolationResult(const MultiLabelSegmentation *segmentationImage, MultiLabelSegmentation::LabelValueType labelValue, TimeStepType timeStep)
Get the Result of the interpolation operation.
void RemoveContours(const MultiLabelSegmentation *segmentationImage, mitk::Label::PixelType label, TimeStepType timeStep)
Removes contours of a particular label and at a given time step for the current session/segmentation.
bool RemoveContour(ContourPositionInformation contourInfo, bool keepPlaceholderForUndo=false)
Removes the contour for a given plane for the current selected segmentation.
std::vector< ContourPositionInformation > CPIVector
static SurfaceInterpolationController * GetInstance()
void CompleteReinitialization(const std::vector< ContourPositionInformation > &newCPIs)
Triggered with the "Reinit Interpolation" action. The contours are used to repopulate the.
void SetMaxSpacing(double maxSpacing)
Sets the minimum spacing of the current selected segmentation This is needed since the contour points...
void SetCurrentInterpolationSession(MultiLabelSegmentation *currentSegmentationImage)
void AddNewContours(const std::vector< ContourPositionInformation > &newCPIs, bool reinitializeAction=false, bool silent=false)
Adds new extracted contours to the list. If one or more contours at a given position already exist th...
void Interpolate(const MultiLabelSegmentation *segmentationImage, MultiLabelSegmentation::LabelValueType labelValue, TimeStepType timeStep)
Performs the interpolation.
void RemoveInterpolationSession(const MultiLabelSegmentation *segmentationImage)
Remove interpolation session.
mitk::MultiLabelSegmentation * GetCurrentSegmentation()
Get the current selected segmentation for which the interpolation is performed.
CPIVector * GetContours(MultiLabelSegmentation::LabelValueType labelValue, TimeStepType timeStep)
Get the Contours at a certain timeStep and layerID.
std::vector< MultiLabelSegmentation::LabelValueType > GetAffectedLabels(const MultiLabelSegmentation *seg, TimeStepType timeStep, const PlaneGeometry *plane) const
void SetMinSpacing(double minSpacing)
Sets the minimum spacing of the current selected segmentation This is needed since the contour points...
void RemoveAllInterpolationSessions()
Removes all sessions.
void SetDataStorage(DataStorage::Pointer ds)
void RemoveContours(const MultiLabelSegmentation *segmentationImage, mitk::Label::PixelType label)
Removes contours of a particular label and at a given time step for the current session/segmentation.
void GetImageBase(itk::Image< TPixel, VImageDimension > *input, itk::ImageBase< 3 >::Pointer &result)
Find image slices visible on a given plane.
std::size_t TimeStepType
ContourPositionInformation(Surface::ConstPointer contour, PlaneGeometry::ConstPointer plane, Label::PixelType labelValue, TimeStepType timeStep)