Medical Imaging Interaction Toolkit  2018.4.99-a3d2e8fb
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_Included
14 #define mitkSurfaceInterpolationController_h_Included
15 
16 #include "mitkColorProperty.h"
17 #include "mitkCommon.h"
18 #include "mitkInteractionConst.h"
19 #include "mitkProperties.h"
21 #include "mitkSurface.h"
23 
27 
28 #include "mitkDataNode.h"
29 #include "mitkDataStorage.h"
30 
31 #include "vtkAppendPolyData.h"
32 #include "vtkCellArray.h"
33 #include "vtkPoints.h"
34 #include "vtkPolyData.h"
35 #include "vtkPolygon.h"
36 #include "vtkSmartPointer.h"
37 
38 #include "mitkImageTimeSelector.h"
40 #include "vtkImageData.h"
41 #include "vtkMarchingCubes.h"
42 #include "vtkProperty.h"
43 
44 #include "mitkProgressBar.h"
45 
46 namespace mitk
47 {
49  {
50  public:
52  itkFactorylessNewMacro(Self);
53  itkCloneMacro(Self);
54  itkGetMacro(DistanceImageSpacing, double);
55 
57  {
61  };
62 
63  typedef std::vector<ContourPositionInformation> ContourPositionInformationList;
64  typedef std::vector<ContourPositionInformationList> ContourPositionInformationVec2D;
65  // typedef std::map<mitk::Image*, ContourPositionInformationList> ContourListMap;
66  typedef std::map<mitk::Image *, ContourPositionInformationVec2D> ContourListMap;
67 
68  static SurfaceInterpolationController *GetInstance();
69 
70  void SetCurrentTimeStep(unsigned int ts)
71  {
72  if (m_CurrentTimeStep != ts)
73  {
74  m_CurrentTimeStep = ts;
75 
76  if (m_SelectedSegmentation)
77  {
78  this->ReinitializeInterpolation();
79  }
80  }
81  };
82 
83  unsigned int GetCurrentTimeStep() { return m_CurrentTimeStep; };
89  void AddNewContour(Surface::Pointer newContour);
90 
96  bool RemoveContour(ContourPositionInformation contourInfo);
97 
103  void AddNewContours(std::vector<Surface::Pointer> newContours);
104 
110  const mitk::Surface *GetContour(ContourPositionInformation contourInfo);
111 
116  unsigned int GetNumberOfContours();
117 
121  void Interpolate();
122 
123  mitk::Surface::Pointer GetInterpolationResult();
124 
129  void SetMinSpacing(double minSpacing);
130 
135  void SetMaxSpacing(double maxSpacing);
136 
141  void SetDistanceImageVolume(unsigned int distImageVolume);
142 
147  mitk::Image::Pointer GetCurrentSegmentation();
148 
149  Surface *GetContoursAsSurface();
150 
151  void SetDataStorage(DataStorage::Pointer ds);
152 
158  DEPRECATED(void SetCurrentSegmentationInterpolationList(mitk::Image::Pointer segmentation));
159 
164  void SetCurrentInterpolationSession(mitk::Image::Pointer currentSegmentationImage);
165 
171  DEPRECATED(void RemoveSegmentationFromContourList(mitk::Image *segmentation));
172 
177  void RemoveInterpolationSession(mitk::Image::Pointer segmentationImage);
178 
187  bool ReplaceInterpolationSession(mitk::Image::Pointer oldSession, mitk::Image::Pointer newSession);
188 
192  void RemoveAllInterpolationSessions();
193 
198  void ReinitializeInterpolation(mitk::Surface::Pointer contours);
199 
200  mitk::Image *GetImage();
201 
206  double EstimatePortionOfNeededMemory();
207 
208  unsigned int GetNumberOfInterpolationSessions();
209 
210  protected:
212 
213  ~SurfaceInterpolationController() override;
214 
215  template <typename TPixel, unsigned int VImageDimension>
216  void GetImageBase(itk::Image<TPixel, VImageDimension> *input, itk::ImageBase<3>::Pointer &result);
217 
218  private:
219  void ReinitializeInterpolation();
220 
221  void OnSegmentationDeleted(const itk::Object *caller, const itk::EventObject &event);
222 
223  void AddToInterpolationPipeline(ContourPositionInformation contourInfo);
224 
225  ReduceContourSetFilter::Pointer m_ReduceFilter;
227  CreateDistanceImageFromSurfaceFilter::Pointer m_InterpolateSurfaceFilter;
228 
229  Surface::Pointer m_Contours;
230 
231  double m_DistanceImageSpacing;
232 
233  vtkSmartPointer<vtkPolyData> m_PolyData;
234 
236 
237  ContourListMap m_ListOfInterpolationSessions;
238 
239  mitk::Surface::Pointer m_InterpolationResult;
240 
241  unsigned int m_CurrentNumberOfReducedContours;
242 
243  mitk::Image *m_SelectedSegmentation;
244 
245  std::map<mitk::Image *, unsigned long> m_SegmentationObserverTags;
246 
247  unsigned int m_CurrentTimeStep;
248  };
249 }
250 #endif
Class for storing surfaces (vtkPolyData).
Definition: mitkSurface.h:28
std::vector< ContourPositionInformationList > ContourPositionInformationVec2D
std::map< mitk::Image *, ContourPositionInformationVec2D > ContourListMap
DataCollection - Class to facilitate loading/accessing structured data.
Constants for most interaction classes, due to the generic StateMachines.
std::vector< ContourPositionInformation > ContourPositionInformationList
#define MITKSURFACEINTERPOLATION_EXPORT
#define DEPRECATED(func)
Definition: mitkCommon.h:179
mitk::DataStorage::Pointer m_DataStorage
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:49
Image class for storing images.
Definition: mitkImage.h:72