MeVisLab Toolbox Reference
CSOLiveWireProcessor.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2007, MeVis Medical Solutions AG
4 **
5 ** The user may use this file in accordance with the license agreement provided with
6 ** the Software or, alternatively, in accordance with the terms contained in a
7 ** written agreement between the user and MeVis Medical Solutions AG.
8 **
9 ** For further information use the contact form at https://www.mevislab.de/contact
10 **
11 **************************************************************************************/
12 
13 #ifndef CSOLIVE_WIRE_PROCESSOR_H
14 #define CSOLIVE_WIRE_PROCESSOR_H
15 
16 
19 
20 #include "SoCSOSystem.h"
22 
23 #include <mlFields.h>
25 
26 
27 ML_START_NAMESPACE
28 
30 
33 {
36 };
37 
39 
42 {
46 };
47 
49 
53 {
54 
55 public:
56 
59 
62  bool process(CSOEvalEventView2DInfos view2DInfos, CSOEvalEventCSOInfos csoInfos) override;
63 
66  bool needsMemoryImage() override;
67 
69  void setMemoryImage(float* imageData, int sizex, int sizey, int voxelPosZ,
70  const Matrix4& voxelToWorldMatrix, const Matrix4& worldToVoxelMatrix,
71  View2DSliceList* slicelist) override;
72 
74  bool isCurrentlyGenerating() override;
76  bool isCurrentlyEditing() override;
78  bool couldCloseCSO() override;
80  void resetInteractionState() override;
82  void triggerSetMouseCursor(SoView2D* view2d, bool shouldSetMouseCursor) override;
83 
84 
85 protected:
86 
90  void activateAttachments() override;
92  void handleNotification(Field* field) override;
93 
94 private:
95 
96  /* FIELDS */
97 
102  PlaneField* _planeFld;
106  IntField* _currentSliceFld;
113  IntField* _currentLayoutFld;
115  StringField* _currentLayoutStringFld;
117  BoolField* _useInputImageFld;
119  BoolField* _useInputImageCostsFld;
121  TypedEnumField<CSOLiveWireFinishingMode>* _finishingModeFld;
124  IntField* _draggingToleranceFld;
126  BoolField* _useFinishingDistanceFld;
130  FloatField* _finishingDistanceFld;
133  BoolField* _generateClosedCSOFld;
135  TypedEnumField<SliceErrorHandlingMode>* _multipleSliceCSOErrorHandlingModeFld;
138  BoolField* _isCurrentlyGeneratingFld;
140  TypedEnumField<CSOSmoothingModes>* _smoothingModeFld;
142  IntField* _smoothingAmountFld;
143 
145  TypedEnumField<CSOLiveWireNeighborhoodMode>* _neighborhoodModeFld;
146 
147  FloatField* _weightGradientFld;
149  FloatField* _weightLaplacianFld;
151  FloatField* _weightDirectionalFld;
152 
153  /* MEMBER VARIABLES */
154 
156  CSOLiveWireGraph* _liveWireGraph;
157 
159  CSOList* _csoList;
160 
162  float _currentHitXPos;
164  float _currentHitYPos;
166  float _currentHitZPos;
168  float _lastRecentHitXPos;
170  float _lastRecentHitYPos;
172  float _lastRecentHitZPos;
174  float _startHitXPos;
176  float _startHitYPos;
178  float _startHitZPos;
179 
181  int _timePoint;
182 
184  CSO* _currentlyActiveCSO;
186  CSOSeedPoint* _currentlyActiveSeedPoint;
188  CSOPathPoints* _currentlyActivePathPoints;
189 
194  std::vector<Vector3>_draggedPositions;
195 
197  View2DSliceList* _slicelist;
198 
200  SoView2D* _lastCurrentView2D;
201 
203  int _lastCurrentZ;
204 
206  bool _isMovingSeedPoint;
208  bool _isGeneratingCSO;
210  bool _isDrawingInMotion;
212  bool _couldCloseCurrentCSO;
213 
215  bool _bUseInputImage;
216 
219  bool _bUseInputCosts;
220 
222  float* _imageSlice;
224  unsigned int _imageSizeX;
226  unsigned int _imageSizeY;
227 
229  float* _view2DImg;
230 
235  TSubImage<float> _inOptionalImg;
237  bool _optionalImgIsValid;
239  PagedImage* _pImg;
240 
242  SbVec3f _sliceNormal0;
244  SbVec3f _sliceNormal1;
246  SbVec3f _sliceNormal2;
247 
248 
249  /* METHODS */
250 
254  void _removeSeedPointFromMiddle();
255 
257  CSO* _addAndInitCSO();
259  void _interpolate(CSO* cso, CSOPathPoints* pPoints);
261  void _setInputImageSlice();
263  bool _couldCloseByDistance(const Vector3& currPos, View2DSliceList* slicelist);
265  bool _isInsideImage(VoxelPos pos);
268  void _findLiveWirePathsAroundActiveSeedPoint(const Vector3& currentHitPoint);
271  void _transformWorldToVoxel(const Vector3& worldPos, Vector3& voxelPos);
274  void _transformVoxelToWorld(const Vector3& voxelPos, Vector3& worldPos);
278  void _fillPoints(CSOPathPoints* pathPoints, const std::vector<VoxelPos>& positions);
281  bool _isWithinRangeDistance(const Vector3& startPos, const Vector3& endPos, float rangeDistance, View2DSliceList* slicelist) const;
282 
284 };
285 
287 
288 
289 ML_END_NAMESPACE
290 
291 
292 #endif //__CSOLiveWireProcessor_H
293 
#define SOCSO_EXPORT
Header file for system independent resolution.
Definition: SoCSOSystem.h:21
SoView2D is a 2D viewer for image data.
Definition: SoView2D.h:62
a list that holds all View2DSlice objects (lazily created) of a SoView2D
Field to encapsulate a boolean value.
Definition: mlFields.h:62
A CSOList comprises a number of CSOs and CSOGroups and is the central object for contour segmentation...
Definition: CSOList.h:61
The class maintains a graph for applying a shortest path algorithm on.
Module which allows for an half-automatic generation of contours along image edges,...
void activateAttachments() override
Initialize module after loading.
void handleNotification(Field *field) override
Called when input changes.
bool couldCloseCSO() override
Returns whether the processor could close an open CSO by the processor's rules.
void resetInteractionState() override
Sets back internal interaction state.
bool isCurrentlyGenerating() override
Returns whether the processor is currently generating a new contour.
bool needsMemoryImage() override
Returns whether the processor need the current memory image for interpolation.
void setMemoryImage(float *imageData, int sizex, int sizey, int voxelPosZ, const Matrix4 &voxelToWorldMatrix, const Matrix4 &worldToVoxelMatrix, View2DSliceList *slicelist) override
Sets an image which can be used with an image based interpolation algorithm.
~CSOLiveWireProcessor() override
Standard destructor.
bool process(CSOEvalEventView2DInfos view2DInfos, CSOEvalEventCSOInfos csoInfos) override
Processes the interaction events and interpolates the contours accordingly.
CSOLiveWireProcessor()
Standard constructor.
void triggerSetMouseCursor(SoView2D *view2d, bool shouldSetMouseCursor) override
Triggers the setting of the processors default mouse cursor.
bool isCurrentlyEditing() override
Returns whether the processor is currently editing an existing contour.
The CSOPathPoints is a list of world coordinates which are interpolated by a certain interpolation sc...
Definition: CSOPathPoints.h:37
Base class for processor modules; those provide mechanisms for an interactive generation of seed poin...
Definition: CSOProcessor.h:42
The CSOSeedPoint can be interactively set and modified and is the framework for contours.
Definition: CSOSeedPoint.h:35
The CSO represents a contour segmentation object.
Definition: CSO.h:44
Base class for all fields used in the ML.
Definition: mlField.h:73
Field to encapsulate a float value.
Definition: mlFields.h:627
Field to encapsulate an integer value.
Definition: mlFields.h:161
Class which represents an image, which manages properties of an image and image data which is located...
Definition: mlPagedImage.h:70
Field to encapsulate a vector of 4 double values representing a plane with all properties of Vector4F...
Definition: mlFields.h:3138
Field to encapsulate a string value.
Definition: mlFields.h:1000
#define ML_MODULE_CLASS_HEADER(className)
Like ML_CLASS_HEADER for the usage of derived classes from Module.
SliceErrorHandlingMode
Enumeration of modes to handle CSOs over more than one slice (slicing while generating).
@ CSO_SLICE_ERROR_HANDLING_REMOVE_CSO
Remove the whole CSO.
@ CSO_SLICE_ERROR_HANDLING_REMOVE_LAST_SEEDPOINT
Remove the last seedpoint which lead to this error.
@ CSO_SLICE_ERROR_HANDLING_PRINT_WARNING
Just print a warning to the console.
CSOLiveWireFinishingMode
Enumeration of finishing modes to test against.
@ CSO_LIVE_WIRE_FINISH_ON_DISTANCE
Current CSO finishes if a seed point is placed in the vicinity of its starting seed point.
@ CSO_LIVE_WIRE_FINISH_ON_DOUBLE_CLICK
Current CSO finishes on double click.
Structure holding a 2D voxel position.