Medical Imaging Interaction Toolkit  2016.11.0
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #ifndef mitkSurfaceInterpolationController_h_Included
18 #define mitkSurfaceInterpolationController_h_Included
19 
20 #include "mitkColorProperty.h"
21 #include "mitkCommon.h"
22 #include "mitkInteractionConst.h"
23 #include "mitkProperties.h"
25 #include "mitkSurface.h"
27 
31 
32 #include "mitkDataNode.h"
33 #include "mitkDataStorage.h"
34 #include "mitkWeakPointer.h"
35 
36 #include "vtkAppendPolyData.h"
37 #include "vtkCellArray.h"
38 #include "vtkPoints.h"
39 #include "vtkPolyData.h"
40 #include "vtkPolygon.h"
41 #include "vtkSmartPointer.h"
42 
43 #include "mitkImageTimeSelector.h"
45 #include "vtkImageData.h"
46 #include "vtkMarchingCubes.h"
47 #include "vtkProperty.h"
48 
49 #include "mitkProgressBar.h"
50 
51 namespace mitk
52 {
54  {
55  public:
56  mitkClassMacroItkParent(SurfaceInterpolationController, itk::Object) itkFactorylessNewMacro(Self)
57  itkCloneMacro(Self)
58 
59  itkGetMacro(DistanceImageSpacing, double)
60 
62  {
66  };
67 
68  typedef std::vector<ContourPositionInformation> ContourPositionInformationList;
69  typedef std::vector<ContourPositionInformationList> ContourPositionInformationVec2D;
70  // typedef std::map<mitk::Image*, ContourPositionInformationList> ContourListMap;
71  typedef std::map<mitk::Image *, ContourPositionInformationVec2D> ContourListMap;
72 
73  static SurfaceInterpolationController *GetInstance();
74 
75  void SetCurrentTimeStep(unsigned int ts)
76  {
77  if (m_CurrentTimeStep != ts)
78  {
79  m_CurrentTimeStep = ts;
80 
81  if (m_SelectedSegmentation)
82  {
83  this->ReinitializeInterpolation();
84  }
85  }
86  };
87 
88  unsigned int GetCurrentTimeStep() { return m_CurrentTimeStep; };
94  void AddNewContour(Surface::Pointer newContour);
95 
101  bool RemoveContour(ContourPositionInformation contourInfo);
102 
108  void AddNewContours(std::vector<Surface::Pointer> newContours);
109 
115  const mitk::Surface *GetContour(ContourPositionInformation contourInfo);
116 
121  unsigned int GetNumberOfContours();
122 
126  void Interpolate();
127 
128  mitk::Surface::Pointer GetInterpolationResult();
129 
134  void SetMinSpacing(double minSpacing);
135 
140  void SetMaxSpacing(double maxSpacing);
141 
146  void SetDistanceImageVolume(unsigned int distImageVolume);
147 
152  mitk::Image::Pointer GetCurrentSegmentation();
153 
154  Surface *GetContoursAsSurface();
155 
156  void SetDataStorage(DataStorage::Pointer ds);
157 
163  DEPRECATED(void SetCurrentSegmentationInterpolationList(mitk::Image::Pointer segmentation));
164 
169  void SetCurrentInterpolationSession(mitk::Image::Pointer currentSegmentationImage);
170 
176  DEPRECATED(void RemoveSegmentationFromContourList(mitk::Image *segmentation));
177 
182  void RemoveInterpolationSession(mitk::Image::Pointer segmentationImage);
183 
192  bool ReplaceInterpolationSession(mitk::Image::Pointer oldSession, mitk::Image::Pointer newSession);
193 
197  void RemoveAllInterpolationSessions();
198 
203  void ReinitializeInterpolation(mitk::Surface::Pointer contours);
204 
205  mitk::Image *GetImage();
206 
211  double EstimatePortionOfNeededMemory();
212 
213  unsigned int GetNumberOfInterpolationSessions();
214 
215  protected:
217 
219 
220  template <typename TPixel, unsigned int VImageDimension>
221  void GetImageBase(itk::Image<TPixel, VImageDimension> *input, itk::ImageBase<3>::Pointer &result);
222 
223  private:
224  void ReinitializeInterpolation();
225 
226  void OnSegmentationDeleted(const itk::Object *caller, const itk::EventObject &event);
227 
228  void AddToInterpolationPipeline(ContourPositionInformation contourInfo);
229 
230  ReduceContourSetFilter::Pointer m_ReduceFilter;
232  CreateDistanceImageFromSurfaceFilter::Pointer m_InterpolateSurfaceFilter;
233 
234  Surface::Pointer m_Contours;
235 
236  double m_DistanceImageSpacing;
237 
238  vtkSmartPointer<vtkPolyData> m_PolyData;
239 
241 
242  ContourListMap m_ListOfInterpolationSessions;
243 
244  mitk::Surface::Pointer m_InterpolationResult;
245 
246  unsigned int m_CurrentNumberOfReducedContours;
247 
248  mitk::Image *m_SelectedSegmentation;
249 
250  std::map<mitk::Image *, unsigned long> m_SegmentationObserverTags;
251 
252  unsigned int m_CurrentTimeStep;
253  };
254 }
255 #endif
Class for storing surfaces (vtkPolyData).
Definition: mitkSurface.h:32
itk::SmartPointer< Self > Pointer
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:183
mitk::DataStorage::Pointer m_DataStorage
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:53
Image class for storing images.
Definition: mitkImage.h:76