Medical Imaging Interaction Toolkit  2021.02.99-c7792db0
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_Included
14 #define mitkSegTool2D_h_Included
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 
168  SliceInformation() = default;
169  SliceInformation(const mitk::Image* aSlice, const mitk::PlaneGeometry* aPlane, mitk::TimeStepType aTimestep);
170  };
171 
180  static void UpdateSurfaceInterpolation(const std::vector<SliceInformation>& sliceInfos,
181  const Image* workingImage,
182  bool detectIntersection);
183 
184 
191  bool FilterEvents(InteractionEvent *interactionEvent, DataNode *dataNode) override;
192 
199  Image::Pointer GetAffectedWorkingSlice(const InteractionPositionEvent *) const;
200 
207  Image::Pointer GetAffectedReferenceSlice(const InteractionPositionEvent *) const;
209  Image::Pointer GetAffectedReferenceSlice(const PlaneGeometry* planeGeometry, TimeStepType timeStep) const;
210 
213  void WriteBackSegmentationResult(const InteractionPositionEvent *, const Image* segmentationResult);
214 
217  void WriteBackSegmentationResult(const PlaneGeometry *planeGeometry, const Image* segmentationResult, TimeStepType timeStep);
218 
221  void WriteBackSegmentationResults(const std::vector<SliceInformation> &sliceList, bool writeSliceToVolume = true);
222 
232  static void WriteBackSegmentationResults(const DataNode* workingNode, const std::vector<SliceInformation>& sliceList, bool writeSliceToVolume = true);
233 
245  static void WritePreviewOnWorkingImage(
246  Image *targetSlice, const Image *sourceSlice, const Image *workingImage, int paintingPixelValue);
247 
257  static void WriteSliceToVolume(Image* workingImage, const SliceInformation &sliceInfo, bool allowUndo);
258 
264  int AddContourmarker(const PlaneGeometry* planeGeometry, unsigned int sliceIndex);
265 
266  void InteractiveSegmentationBugMessage(const std::string &message) const;
267 
268  BaseRenderer *m_LastEventSender = nullptr;
269  unsigned int m_LastEventSlice = 0;
270 
271  itkGetMacro(LastTimePointTriggered, TimePointType);
272 
273  private:
277  void OnTimePointChangedInternal();
278 
279  static void RemoveContourFromInterpolator(const SliceInformation& sliceInfo);
280 
281  // The prefix of the contourmarkername. Suffix is a consecutive number
282  const std::string m_Contourmarkername;
283 
284  bool m_ShowMarkerNodes = false;
285  static bool m_SurfaceInterpolationEnabled;
286 
287  bool m_IsTimePointChangeAware = true;
288 
289  TimePointType m_LastTimePointTriggered = 0.;
290  };
291 
292 } // namespace
293 
294 #endif
Base class of all tools used by mitk::ToolManager.
Definition: mitkTool.h:86
Super class for all position events.
Organizes the rendering process.
#define MITKSEGMENTATION_EXPORT
DataCollection - Class to facilitate loading/accessing structured data.
Constants for most interaction classes, due to the generic StateMachines.
mitk::Image::ConstPointer slice
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:40
Image class for storing images.
Definition: mitkImage.h:73
mitk::ScalarType TimePointType
std::vcl_size_t TimeStepType
Abstract base class for segmentation tools.
Definition: mitkSegTool2D.h:54
Describes a two-dimensional, rectangular plane.
Class for nodes of the DataTree.
Definition: mitkDataNode.h:57