Medical Imaging Interaction Toolkit  2024.06.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 
42  unsigned int GetNumberOfMasks() const override;
43 
44  void SetPlanarFigure(mitk::PlanarFigure* planarFigure);
45 
46  mitk::Image::ConstPointer GetReferenceImage() override;
47 
48  itkGetConstMacro(PlanarFigureAxis, unsigned int);
49  itkGetConstMacro(PlanarFigureSlice, unsigned int);
50 
53  static bool CheckPlanarFigureIsNotTilted(const PlaneGeometry* planarGeometry, const BaseGeometry *geometry);
54 
55  protected:
57  : Superclass(),
58  m_ReferenceImage(nullptr),
59  m_PlanarFigureAxis(0),
60  m_InternalMaskUpdateTime(0),
61  m_PlanarFigureSlice(0)
62  {
63  m_InternalMask = mitk::Image::New();
64  }
65 
66  Image::ConstPointer DoGetMask(unsigned int) override;
67 
68  private:
69  void CalculateMask();
70 
71  template <typename TPixel, unsigned int VImageDimension>
72  void InternalCalculateMaskFromClosedPlanarFigure(const itk::Image<TPixel, VImageDimension> *image, unsigned int axis);
73 
74  template <typename TPixel, unsigned int VImageDimension>
75  void InternalCalculateMaskFromOpenPlanarFigure(const itk::Image<TPixel, VImageDimension> *image, unsigned int axis);
76 
77  mitk::Image::ConstPointer Extract2DImageSlice(const Image* input, unsigned int axis, unsigned int slice) const;
78 
80  static bool GetPrincipalAxis(const BaseGeometry *geometry, Vector3D vector, unsigned int &axis);
81 
83  template <typename ITK_Exporter, typename VTK_Importer>
84  void ConnectPipelines(ITK_Exporter exporter, vtkSmartPointer<VTK_Importer> importer)
85  {
86  importer->SetUpdateInformationCallback(exporter->GetUpdateInformationCallback());
87 
88  importer->SetPipelineModifiedCallback(exporter->GetPipelineModifiedCallback());
89  importer->SetWholeExtentCallback(exporter->GetWholeExtentCallback());
90  importer->SetSpacingCallback(exporter->GetSpacingCallback());
91  importer->SetOriginCallback(exporter->GetOriginCallback());
92  importer->SetScalarTypeCallback(exporter->GetScalarTypeCallback());
93 
94  importer->SetNumberOfComponentsCallback(exporter->GetNumberOfComponentsCallback());
95 
96  importer->SetPropagateUpdateExtentCallback(exporter->GetPropagateUpdateExtentCallback());
97  importer->SetUpdateDataCallback(exporter->GetUpdateDataCallback());
98  importer->SetDataExtentCallback(exporter->GetDataExtentCallback());
99  importer->SetBufferPointerCallback(exporter->GetBufferPointerCallback());
100  importer->SetCallbackUserData(exporter->GetCallbackUserData());
101  }
102 
104  template <typename VTK_Exporter, typename ITK_Importer>
105  void ConnectPipelines(vtkSmartPointer<VTK_Exporter> exporter, ITK_Importer importer)
106  {
107  importer->SetUpdateInformationCallback(exporter->GetUpdateInformationCallback());
108 
109  importer->SetPipelineModifiedCallback(exporter->GetPipelineModifiedCallback());
110  importer->SetWholeExtentCallback(exporter->GetWholeExtentCallback());
111  importer->SetSpacingCallback(exporter->GetSpacingCallback());
112  importer->SetOriginCallback(exporter->GetOriginCallback());
113  importer->SetScalarTypeCallback(exporter->GetScalarTypeCallback());
114 
115  importer->SetNumberOfComponentsCallback(exporter->GetNumberOfComponentsCallback());
116 
117  importer->SetPropagateUpdateExtentCallback(exporter->GetPropagateUpdateExtentCallback());
118  importer->SetUpdateDataCallback(exporter->GetUpdateDataCallback());
119  importer->SetDataExtentCallback(exporter->GetDataExtentCallback());
120  importer->SetBufferPointerCallback(exporter->GetBufferPointerCallback());
121  importer->SetCallbackUserData(exporter->GetCallbackUserData());
122  }
123 
124  bool IsUpdateRequired() const;
125 
126  mitk::PlanarFigure::Pointer m_PlanarFigure;
127  itk::Image<unsigned short, 2>::Pointer m_InternalITKImageMask2D;
128  mitk::Image::ConstPointer m_ReferenceImage;
129  unsigned int m_PlanarFigureAxis;
130  unsigned long m_InternalMaskUpdateTime;
131  unsigned int m_PlanarFigureSlice;
132  mitk::Image::Pointer m_InternalMask;
133  };
134 
135 } // namespace mitk
136 
137 #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:56
mitk::PlanarFigure
Base-class for geometric planar (2D) figures, such as lines, circles, rectangles, polygons,...
Definition: mitkPlanarFigure.h:50
vtkSmartPointer
Definition: mitkROIMapperLocalStorage.h:19
mitk::Image
Image class for storing images.
Definition: mitkImage.h:69
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
Find image slices visible on a given plane.
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::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