Medical Imaging Interaction Toolkit  2023.04.00
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_h
14 #define mitkPlanarFigureMaskGenerator_h
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
mitkImage.h
mitk::Image::New
static Pointer New()
mitk::PlaneGeometry
Describes a two-dimensional, rectangular plane.
Definition: mitkPlaneGeometry.h:78
mitk::PlanarFigureMaskGenerator::PlanarFigureMaskGenerator
PlanarFigureMaskGenerator()
Definition: mitkPlanarFigureMaskGenerator.h:66
mitk::PlanarFigure
Base-class for geometric planar (2D) figures, such as lines, circles, rectangles, polygons,...
Definition: mitkPlanarFigure.h:50
itk::SmartPointer< Self >
mitkPlanarFigure.h
mitk::PlanarFigureMaskGenerator
Derived from MaskGenerator. This class is used to convert a mitk::PlanarFigure into a binary image ma...
Definition: mitkPlanarFigureMaskGenerator.h:29
mitk
DataCollection - Class to facilitate loading/accessing structured data.
Definition: RenderingTests.dox:1
mitkMaskGenerator.h
MITKIMAGESTATISTICS_EXPORT
#define MITKIMAGESTATISTICS_EXPORT
Definition: MitkImageStatisticsExports.h:15
mitk::Vector< ScalarType, 3 >
mitk::BaseGeometry
BaseGeometry Describes the geometry of a data object.
Definition: mitkBaseGeometry.h:94
mitk::PlanarFigureMaskGenerator::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: mitkPlanarFigureMaskGenerator.h:36
mitk::MaskGenerator::Superclass
itk::Object Superclass
Definition: mitkMaskGenerator.h:35
mitk::PlanarFigureMaskGenerator::Superclass
MaskGenerator Superclass
Definition: mitkPlanarFigureMaskGenerator.h:34
mitk::PlanarFigureMaskGenerator::Self
PlanarFigureMaskGenerator Self
Definition: mitkPlanarFigureMaskGenerator.h:33
MitkImageStatisticsExports.h
mitk::MaskGenerator
Base Class for all Mask Generators. Mask generators are classes that provide functionality for the cr...
Definition: mitkMaskGenerator.h:30
mitk::PlanarFigureMaskGenerator::Pointer
itk::SmartPointer< Self > Pointer
Definition: mitkPlanarFigureMaskGenerator.h:35