Medical Imaging Interaction Toolkit  2023.04.00
Medical Imaging Interaction Toolkit
mitkSegTool2D.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 mitkSegTool2D_h
14 #define mitkSegTool2D_h
15 
16 #include <mitkCommon.h>
17 #include <mitkImage.h>
18 #include <mitkTool.h>
20 
22 
23 #include <mitkInteractionConst.h>
26 
27 #include <mitkDiffSliceOperation.h>
28 
29 namespace mitk
30 {
31  class BaseRenderer;
32 
55  {
56  public:
58 
69  static bool DetermineAffectedImageSlice(const Image *image,
70  const PlaneGeometry *plane,
71  int &affectedDimension,
72  int &affectedSlice);
73 
83  static void UpdateSurfaceInterpolation(const Image *slice,
84  const Image *workingImage,
85  const PlaneGeometry *plane,
86  bool detectIntersection);
87 
98  static Image::Pointer GetAffectedImageSliceAs2DImage(const InteractionPositionEvent* positionEvent, const Image* image, unsigned int component = 0);
99 
111  static Image::Pointer GetAffectedImageSliceAs2DImage(const PlaneGeometry* planeGeometry,
112  const Image* image,
113  TimeStepType timeStep,
114  unsigned int component = 0);
115  static Image::Pointer GetAffectedImageSliceAs2DImageByTimePoint(const PlaneGeometry* planeGeometry,
116  const Image* image,
117  TimePointType timePoint,
118  unsigned int component = 0);
119 
122  static void WriteBackSegmentationResult(const DataNode* workingNode, const PlaneGeometry* planeGeometry, const Image* segmentationResult, TimeStepType timeStep);
123 
126  static void WriteSliceToVolume(Image* workingImage, const PlaneGeometry* planeGeometry, const Image* slice, TimeStepType timeStep, bool allowUndo);
127 
128  void SetShowMarkerNodes(bool);
129 
134  void SetEnable3DInterpolation(bool);
135 
136  void Activated() override;
137  void Deactivated() override;
138 
139  itkSetMacro(IsTimePointChangeAware, bool);
140  itkGetMacro(IsTimePointChangeAware, bool);
141  itkBooleanMacro(IsTimePointChangeAware);
142 
143  protected:
144  SegTool2D(); // purposely hidden
145  SegTool2D(const char *, const us::Module *interactorModule = nullptr); // purposely hidden
146  ~SegTool2D() override;
147 
151  DataNode* GetWorkingDataNode() const;
152  Image* GetWorkingData() const;
153 
154  DataNode* GetReferenceDataNode() const;
155  Image* GetReferenceData() const;
156 
160  virtual void OnTimePointChanged();
161 
163  {
165  const mitk::PlaneGeometry *plane = nullptr;
166  mitk::TimeStepType timestep = 0;
167  unsigned int slicePosition;
168 
169  SliceInformation() = default;
170  SliceInformation(const mitk::Image* aSlice, const mitk::PlaneGeometry* aPlane, mitk::TimeStepType aTimestep);
171  };
172 
183  static void UpdateSurfaceInterpolation(const std::vector<SliceInformation>& sliceInfos,
184  const Image* workingImage,
185  bool detectIntersection,
186  unsigned int activeLayerID,
187  mitk::Label::PixelType activeLabelValue);
188 
189 
196  bool FilterEvents(InteractionEvent *interactionEvent, DataNode *dataNode) override;
197 
204  Image::Pointer GetAffectedWorkingSlice(const InteractionPositionEvent *) const;
205 
212  Image::Pointer GetAffectedReferenceSlice(const InteractionPositionEvent *) const;
214  Image::Pointer GetAffectedReferenceSlice(const PlaneGeometry* planeGeometry, TimeStepType timeStep) const;
215 
218  void WriteBackSegmentationResult(const InteractionPositionEvent *, const Image* segmentationResult);
219 
222  void WriteBackSegmentationResult(const PlaneGeometry *planeGeometry, const Image* segmentationResult, TimeStepType timeStep);
223 
226  void WriteBackSegmentationResults(const std::vector<SliceInformation> &sliceList, bool writeSliceToVolume = true);
227 
237  static void WriteBackSegmentationResults(const DataNode* workingNode, const std::vector<SliceInformation>& sliceList, bool writeSliceToVolume = true);
238 
250  static void WritePreviewOnWorkingImage(
251  Image *targetSlice, const Image *sourceSlice, const Image *workingImage, int paintingPixelValue);
252 
262  static void WriteSliceToVolume(Image* workingImage, const SliceInformation &sliceInfo, bool allowUndo);
263 
269  int AddContourmarker(const PlaneGeometry* planeGeometry, unsigned int sliceIndex);
270 
271  void InteractiveSegmentationBugMessage(const std::string &message) const;
272 
275  static bool IsPositionEventInsideImageRegion(InteractionPositionEvent* positionEvent, const BaseData* data);
276 
277  BaseRenderer *m_LastEventSender = nullptr;
278  unsigned int m_LastEventSlice = 0;
279 
280  itkGetMacro(LastTimePointTriggered, TimePointType);
281 
282  private:
286  void OnTimePointChangedInternal();
287 
288  static void RemoveContourFromInterpolator(const SliceInformation& sliceInfo);
289 
290  // The prefix of the contourmarkername. Suffix is a consecutive number
291  const std::string m_Contourmarkername;
292 
293  bool m_ShowMarkerNodes = false;
294  static bool m_SurfaceInterpolationEnabled;
295 
296  bool m_IsTimePointChangeAware = true;
297 
298  TimePointType m_LastTimePointTriggered = 0.;
299  };
300 
301 } // namespace
302 
303 #endif
mitkTool.h
mitkInteractionConst.h
Constants for most interaction classes, due to the generic StateMachines.
mitk::InteractionEvent
Definition: mitkInteractionEvent.h:26
mitkImage.h
mitk::PlaneGeometry
Describes a two-dimensional, rectangular plane.
Definition: mitkPlaneGeometry.h:78
mitk::SegTool2D::SliceInformation::slice
mitk::Image::ConstPointer slice
Definition: mitkSegTool2D.h:164
mitk::Image
Image class for storing images.
Definition: mitkImage.h:69
mitkRestorePlanePositionOperation.h
mitk::SegTool2D::SliceInformation::slicePosition
unsigned int slicePosition
Definition: mitkSegTool2D.h:167
itk::SmartPointer< Self >
mitkPlanePositionManager.h
mitk::Label::PixelType
unsigned short PixelType
Definition: mitkLabel.h:33
mitk::Tool
Base class of all tools used by mitk::ToolManager.
Definition: mitkTool.h:83
mitk
DataCollection - Class to facilitate loading/accessing structured data.
Definition: RenderingTests.dox:1
mitk::SegTool2D::SliceInformation
Definition: mitkSegTool2D.h:162
mitk::SegTool2D
Abstract base class for segmentation tools.
Definition: mitkSegTool2D.h:54
mitk::InteractionPositionEvent
Super class for all position events.
Definition: mitkInteractionPositionEvent.h:36
mitkInteractionPositionEvent.h
mitkDiffSliceOperation.h
us::Module
Definition: usModule.h:78
mitkCommon.h
MITKSEGMENTATION_EXPORT
#define MITKSEGMENTATION_EXPORT
Definition: MitkSegmentationExports.h:15
mitk::BaseData
Base of all data objects.
Definition: mitkBaseData.h:42
mitk::TimeStepType
std::size_t TimeStepType
Definition: mitkTimeGeometry.h:27
mitkClassMacro
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:36
mitk::BaseRenderer
Definition: mitkBaseRenderer.h:55
mitk::TimePointType
mitk::ScalarType TimePointType
Definition: mitkTimeGeometry.h:26
MitkSegmentationExports.h
mitk::DataNode
Class for nodes of the DataTree.
Definition: mitkDataNode.h:63