Medical Imaging Interaction Toolkit  2024.06.00
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 UpdateAllSurfaceInterpolations(const LabelSetImage* workingImage,
84  TimeStepType timeStep,
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  mitk::Label::PixelType activeLabelValue, bool silent = false);
187 
188 
195  bool FilterEvents(InteractionEvent *interactionEvent, DataNode *dataNode) override;
196 
203  Image::Pointer GetAffectedWorkingSlice(const InteractionPositionEvent *) const;
204 
211  Image::Pointer GetAffectedReferenceSlice(const InteractionPositionEvent *) const;
213  Image::Pointer GetAffectedReferenceSlice(const PlaneGeometry* planeGeometry, TimeStepType timeStep) const;
214 
217  void WriteBackSegmentationResult(const InteractionPositionEvent *, const Image* segmentationResult);
218 
221  void WriteBackSegmentationResult(const PlaneGeometry *planeGeometry, const Image* segmentationResult, TimeStepType timeStep);
222 
225  void WriteBackSegmentationResults(const std::vector<SliceInformation> &sliceList, bool writeSliceToVolume = true);
226 
236  static void WriteBackSegmentationResults(const DataNode* workingNode, const std::vector<SliceInformation>& sliceList, bool writeSliceToVolume = true);
237 
247  static void WriteSliceToVolume(Image* workingImage, const SliceInformation &sliceInfo, bool allowUndo);
248 
254  int AddContourmarker(const PlaneGeometry* planeGeometry, unsigned int sliceIndex);
255 
256  void InteractiveSegmentationBugMessage(const std::string &message) const;
257 
260  static bool IsPositionEventInsideImageRegion(InteractionPositionEvent* positionEvent, const BaseData* data);
261 
262  BaseRenderer *m_LastEventSender = nullptr;
263  unsigned int m_LastEventSlice = 0;
264 
265  itkGetMacro(LastTimePointTriggered, TimePointType);
266 
267  private:
271  void OnTimePointChangedInternal();
272 
273  static void RemoveContourFromInterpolator(const SliceInformation& sliceInfo, LabelSetImage::LabelValueType labelValue);
274 
275  // The prefix of the contourmarkername. Suffix is a consecutive number
276  const std::string m_Contourmarkername;
277 
278  bool m_ShowMarkerNodes = false;
279  static bool m_SurfaceInterpolationEnabled;
280 
281  bool m_IsTimePointChangeAware = true;
282 
283  TimePointType m_LastTimePointTriggered = 0.;
284  };
285 
286 } // namespace
287 
288 #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:34
mitk::Tool
Base class of all tools used by mitk::ToolManager.
Definition: mitkTool.h:83
mitk
Find image slices visible on a given plane.
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:56
mitk::TimePointType
mitk::ScalarType TimePointType
Definition: mitkTimeGeometry.h:26
MitkSegmentationExports.h
mitk::DataNode
Class for nodes of the DataTree.
Definition: mitkDataNode.h:63
mitk::LabelSetImage
LabelSetImage class for handling labels and layers in a segmentation session.
Definition: mitkLabelSetImage.h:43
mitk::LabelSetImage::LabelValueType
mitk::Label::PixelType LabelValueType
Definition: mitkLabelSetImage.h:75