MeVisLab Toolbox Reference
CSOFreehandProcessor.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 CSOFREEHAND_PROCESSOR_H
14 #define CSOFREEHAND_PROCESSOR_H
15 
16 
20 
21 #include "SoCSOSystem.h"
23 
24 
25 ML_START_NAMESPACE
26 
27 
29 
32 {
41 };
42 
44 
47 {
50 };
51 
54 {
57 };
58 
60 
63 {
67 };
68 
70 
75 {
76 
77 public:
78 
81 
85  bool process(CSOEvalEventView2DInfos view2DInfos, CSOEvalEventCSOInfos csoInfos) override;
86 
89  bool needsMemoryImage() override;
90 
92  virtual void setMemoryImage(float* imageData, int sizex, int sizey, int voxelPosZ,
93  float* voxelToWorldMatrix, float* worldToVoxelMatrix, View2DSliceList* slicelist);
94 
96  bool isCurrentlyGenerating() override;
98  bool isCurrentlyEditing() override;
100  bool couldCloseCSO() override;
101 
103  void resetInteractionState() override;
104 
106  void triggerSetMouseCursor(SoView2D* view2d, bool shouldSetMouseCursor) override;
107 
108 protected:
109 
112 
116  void handleNotification(Field* field) override;
117 
119  void activateAttachments() override;
120 
121 private:
122 
123  /* FIELDS */
124 
126  TypedEnumField<GENERAL_CREATION_MODE>* _creationModeFld;
127 
131  TypedEnumField<INTERPOLATION_MODES>* _interpolationModeFld;
132 
135  IntField* _minNumSeedPointsFld;
136 
140  FloatField* _minSeedPointDistanceFld;
141 
143  BoolField* _shouldCloseOnFinishFld;
145  TypedEnumField<FINISHING_MODES>* _finishingModeFld;
147  BoolField* _useFinishingDistanceFld;
150  FloatField* _finishingDistanceFld;
152  TypedEnumField<SEED_POINT_PLACEMENT>* _seedPlacementPolicyFld;
155  IntField* _numInterpolationStepsFld;
156 
159  BoolField* _showInteractivePreviewFld;
160 
161 
162  /* STATE VARIABLES */
163 
166  CSOBoundingBox _slabBB;
167 
169  CSOList* _csoList;
170 
172  int _cursorShape;
173 
175  Vector3 _moveStartPosition;
177  Vector3 _lastCurrentPosition;
178 
180  CSO* _currentlyActiveCSO;
182  CSOSeedPoint* _currentlyActiveSeedPoint;
184  CSOPathPoints* _currentlyActivePathPoints;
185 
187  bool _isMovingSeedPoint;
189  bool _isGeneratingCSO;
191  bool _isPrevCSOFinished;
193  bool _couldCloseCurrentCSO;
195  bool _hasInsertedSeedIntoPath;
196 
198  SbVec3f _sliceNormal0;
200  SbVec3f _sliceNormal1;
202  SbVec3f _sliceNormal2;
203 
205  std::string _currentSubType;
206 
207 
208  /* METHODS */
209 
212  void _interpolate();
214  void _interpolate(CSO* cso, CSOPathPoints* pPoints);
217  void _configurePresets();
219  void _finishCurrentCSO();
221  CSOSeedPoint* _getClosestSeedPoint(Vector3& hitpos, CSOPathPoints* toSplitPath);
223  float _distanceNoSqrt(float x1, float y1, float z1, float x2, float y2, float z2);
225  bool _closingDistanceCriteriaFulfilled(const Vector3& currentMousePos, View2DSliceList* slicelist);
228  bool _isWithinRangeDistance(const Vector3& startPos, const Vector3& endPos, float rangeDistance, View2DSliceList* slicelist) const;
230  void _setCurrentSubType();
231 
233 };
234 
236 
237 
238 ML_END_NAMESPACE
239 
240 #endif // __CSOFreehandProcessor_H
#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
The CSOBoundingBox defines an axis parallel bounding box with double precision.
Module which allows for an interactive generation of freehand contours with linear or spline interpol...
void handleNotification(Field *field) override
Handles field changes: here, only the creation mode field change is evaluated and leads to a setting ...
bool isCurrentlyGenerating() override
Returns whether the processor is currently generating a new contour.
~CSOFreehandProcessor() override
Destructor.
void activateAttachments() override
Method is called after module creation and after setting saved field values.
bool isCurrentlyEditing() override
Returns whether the processor is currently editing an existing contour.
void triggerSetMouseCursor(SoView2D *view2d, bool shouldSetMouseCursor) override
Triggers the setting of the processor's default mouse cursor.
bool needsMemoryImage() override
Returns whether the processor need the current memory image for interpolation.
virtual void setMemoryImage(float *imageData, int sizex, int sizey, int voxelPosZ, float *voxelToWorldMatrix, float *worldToVoxelMatrix, View2DSliceList *slicelist)
Sets an image which can be used with an image based interpolation algorithm.
void resetInteractionState() override
Sets back internal interaction state.
bool couldCloseCSO() override
Returns whether the processor could close an open CSO by the processor's rules.
bool process(CSOEvalEventView2DInfos view2DInfos, CSOEvalEventCSOInfos csoInfos) override
Evaluates the interaction events and interpolates the contours accordingly.
CSOFreehandProcessor()
Constructor.
A CSOList comprises a number of CSOs and CSOGroups and is the central object for contour segmentation...
Definition: CSOList.h:61
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
#define ML_MODULE_CLASS_HEADER(className)
Like ML_CLASS_HEADER for the usage of derived classes from Module.
FINISHING_MODES
Enumeration of the contour finishing modes.
@ FINISH_ON_RELEASE
Contour is finished on release of active mouse button (for closing: be aware of vicinity).
@ FINISH_ON_DOUBLE_CLICK
Contour is finished on double click.
INTERPOLATION_MODES
Enumeration of available interpolation modes.
@ INTERPOLATION_MODE_SPLINE_APPROXIMATION
Spline approximation (B-Spline).
@ INTERPOLATION_MODE_LINEAR_INTERPOLATION
Linear interpolation.
@ INTERPOLATION_MODE_SPLINE_INTERPOLATION
Spline interpolation (Catmull-Rom).
SEED_POINT_PLACEMENT
Enumeration of seed point placement policy.
@ PLACE_SEED_ON_CLICK
A seed point is placed on click (event start).
@ PLACE_SEED_WHILE_DRAGGING
Seed points are placed while dragging.
GENERAL_CREATION_MODE
Enumeration of the module's general creation mode.
@ CREATION_MODE_OPEN_FREEHAND
Open spline approximation: finish on release only.
@ CREATION_MODE_CLOSED_SPLINE
Closed spline interpolation: place seed on click, double click and release for closing available.
@ CREATION_MODE_OPEN_POLYLINE
Open linear interpolation: finish on double click or number of seeds available.
@ CREATION_MODE_CLOSED_POLYLINE
Closed linear interpolation: place seed on click, double click and release for closing available.
@ CREATION_MODE_CLOSED_INTERPOLATION
Closed spline interpolation: place seed continuously, release for closing only.
@ CREATION_MODE_CLOSED_FREEHAND
Closed spline approximation: place seed continuously, release for closing only.
@ CREATION_MODE_OPEN_SPLINE
Open spline interpolation: finish on double click or number of seeds available.
@ CREATION_MODE_POINT
Point: sets a single point. The resulting CSO consists of one seed point and a circular path.