Medical Imaging Interaction Toolkit  2022.04.99-b878213f
Medical Imaging Interaction Toolkit
mitkPlanarFigureMaskGenerator.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 MITKPLANARFIGUREMASKGENERATOR
14 #define MITKPLANARFIGUREMASKGENERATOR
15 
17 #include <itkImage.h>
18 #include <mitkImage.h>
19 #include <mitkMaskGenerator.h>
20 #include <mitkPlanarFigure.h>
21 #include <vtkSmartPointer.h>
22 
23 namespace mitk
24 {
30  {
31  public:
37 
39  itkNewMacro(Self);
41 
46  mitk::Image::ConstPointer GetMask() override;
47 
48  void SetPlanarFigure(mitk::PlanarFigure* planarFigure);
49 
50  mitk::Image::ConstPointer GetReferenceImage() override;
51 
56  void SetTimeStep(unsigned int timeStep) override;
57 
58  itkGetConstMacro(PlanarFigureAxis, unsigned int);
59  itkGetConstMacro(PlanarFigureSlice, unsigned int);
60 
63  static bool CheckPlanarFigureIsNotTilted(const PlaneGeometry* planarGeometry, const BaseGeometry *geometry);
64 
65  protected:
67  : Superclass(),
68  m_ReferenceImage(nullptr),
69  m_PlanarFigureAxis(0),
70  m_InternalMaskUpdateTime(0),
71  m_PlanarFigureSlice(0)
72  {
73  m_InternalMask = mitk::Image::New();
74  }
75 
76  private:
77  void CalculateMask();
78 
79  template <typename TPixel, unsigned int VImageDimension>
80  void InternalCalculateMaskFromPlanarFigure(const itk::Image<TPixel, VImageDimension> *image, unsigned int axis);
81 
82  template <typename TPixel, unsigned int VImageDimension>
83  void InternalCalculateMaskFromOpenPlanarFigure(const itk::Image<TPixel, VImageDimension> *image, unsigned int axis);
84 
85  mitk::Image::ConstPointer extract2DImageSlice(unsigned int axis, unsigned int slice);
86 
88  static bool GetPrincipalAxis(const BaseGeometry *geometry, Vector3D vector, unsigned int &axis);
89 
91  template <typename ITK_Exporter, typename VTK_Importer>
92  void ConnectPipelines(ITK_Exporter exporter, vtkSmartPointer<VTK_Importer> importer)
93  {
94  importer->SetUpdateInformationCallback(exporter->GetUpdateInformationCallback());
95 
96  importer->SetPipelineModifiedCallback(exporter->GetPipelineModifiedCallback());
97  importer->SetWholeExtentCallback(exporter->GetWholeExtentCallback());
98  importer->SetSpacingCallback(exporter->GetSpacingCallback());
99  importer->SetOriginCallback(exporter->GetOriginCallback());
100  importer->SetScalarTypeCallback(exporter->GetScalarTypeCallback());
101 
102  importer->SetNumberOfComponentsCallback(exporter->GetNumberOfComponentsCallback());
103 
104  importer->SetPropagateUpdateExtentCallback(exporter->GetPropagateUpdateExtentCallback());
105  importer->SetUpdateDataCallback(exporter->GetUpdateDataCallback());
106  importer->SetDataExtentCallback(exporter->GetDataExtentCallback());
107  importer->SetBufferPointerCallback(exporter->GetBufferPointerCallback());
108  importer->SetCallbackUserData(exporter->GetCallbackUserData());
109  }
110 
112  template <typename VTK_Exporter, typename ITK_Importer>
113  void ConnectPipelines(vtkSmartPointer<VTK_Exporter> exporter, ITK_Importer importer)
114  {
115  importer->SetUpdateInformationCallback(exporter->GetUpdateInformationCallback());
116 
117  importer->SetPipelineModifiedCallback(exporter->GetPipelineModifiedCallback());
118  importer->SetWholeExtentCallback(exporter->GetWholeExtentCallback());
119  importer->SetSpacingCallback(exporter->GetSpacingCallback());
120  importer->SetOriginCallback(exporter->GetOriginCallback());
121  importer->SetScalarTypeCallback(exporter->GetScalarTypeCallback());
122 
123  importer->SetNumberOfComponentsCallback(exporter->GetNumberOfComponentsCallback());
124 
125  importer->SetPropagateUpdateExtentCallback(exporter->GetPropagateUpdateExtentCallback());
126  importer->SetUpdateDataCallback(exporter->GetUpdateDataCallback());
127  importer->SetDataExtentCallback(exporter->GetDataExtentCallback());
128  importer->SetBufferPointerCallback(exporter->GetBufferPointerCallback());
129  importer->SetCallbackUserData(exporter->GetCallbackUserData());
130  }
131 
132  bool IsUpdateRequired() const;
133 
134  mitk::PlanarFigure::Pointer m_PlanarFigure;
135  itk::Image<unsigned short, 2>::Pointer m_InternalITKImageMask2D;
136  mitk::Image::ConstPointer m_InternalTimeSliceImage;
137  mitk::Image::ConstPointer m_ReferenceImage;
138  unsigned int m_PlanarFigureAxis;
139  unsigned long m_InternalMaskUpdateTime;
140  unsigned int m_PlanarFigureSlice;
141  mitk::Image::Pointer m_InternalMask;
142  };
143 
144 } // namespace mitk
145 
146 #endif // MITKPLANARFIGUREMASKGENERATOR
Base Class for all Mask Generators. Mask generators are classes that provide functionality for the cr...
DataCollection - Class to facilitate loading/accessing structured data.
#define MITKIMAGESTATISTICS_EXPORT
itk::SmartPointer< const Self > ConstPointer
static Pointer New()
Base-class for geometric planar (2D) figures, such as lines, circles, rectangles, polygons...
Derived from MaskGenerator. This class is used to convert a mitk::PlanarFigure into a binary image ma...
Describes a two-dimensional, rectangular plane.
itk::SmartPointer< Self > Pointer
Definition: mitkBaseData.h:46
BaseGeometry Describes the geometry of a data object.