MeVisLab Toolbox Reference
CSOIsoProcessor.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 CSOISO_PROCESSOR_H
14 #define CSOISO_PROCESSOR_H
15 
16 
19 
20 #include "SoCSOSystem.h"
22 
24 #include <mlFields.h>
25 
26 
27 ML_START_NAMESPACE
28 
29 
31 
34 {
38 };
39 
41 
42 constexpr inline const char* SUB_TYPE_ISO_FIXED_SINGLE = "SUB_TYPE_ISO_FIXED_SINGLE";
43 constexpr inline const char* SUB_TYPE_ISO_INTERACTIVE_SINGLE = "SUB_TYPE_INTERACTIVE_SINGLE";
44 constexpr inline const char* SUB_TYPE_ISO_FIXED_ALL = "SUB_TYPE_ISO_FIXED_ALL";
45 constexpr inline const char* SUB_TYPE_ISO_INTERACTIVE_ALL = "SUB_TYPE_INTERACTIVE_ALL";
46 
48 
52 {
53 
54 public:
55 
58 
60  void handleNotification(Field *field) override;
61 
65  bool process(CSOEvalEventView2DInfos view2DInfos, CSOEvalEventCSOInfos csoInfos) override;
66 
69  bool needsMemoryImage() override;
70 
72  void setMemoryImage(float* imageData, int sizex, int sizey, int voxelPosZ,
73  const Matrix4& voxelToWorldMatrix, const Matrix4& worldToVoxelMatrix,
74  View2DSliceList* slicelist) override;
75 
77  bool isCurrentlyGenerating() override;
79  bool isCurrentlyEditing() override;
80 
82  void resetInteractionState() override;
83 
85  void triggerSetMouseCursor(SoView2D* view2d, bool shouldSetMouseCursor) override;
86 
88  void activateAttachments() override;
89 
90 
91 protected:
92 
94  ~CSOIsoProcessor() override;
95 
96 private:
97 
98  /* FIELDS */
99 
104  PlaneField* _planeFld;
108  IntField* _currentSliceFld;
115  IntField* _currentLayoutFld;
117  StringField* _currentLayoutStringFld;
119  BoolField* _useInputImageFld;
121  BoolField* _shouldInterpolateFld;
123  BoolField* _useIsovalueFld;
125  BoolField* _findAllContoursFld;
127  FloatField* _isoValueFld;
129  BoolField* _shouldUpdateStartPosFld;
130 
132  TypedEnumField<CSOIsoStartCondition>* _startConditionFld;
133 
135  TypedEnumField<CSOSmoothingModes>* _smoothingModeFld;
136 
137 
138  /* STATE VARIABLES */
139 
141  CSOList* _csoList;
142 
144  View2DSliceList* _slicelist;
145 
147  float _currentHitXPos;
149  float _currentHitYPos;
151  float _currentHitZPos;
153  float _storedHitXPos;
155  float _storedHitYPos;
157  float _storedHitZPos;
159  int _timePoint;
160 
162  bool _bUseInputImage;
165  bool _bUseIsoValue;
168  bool _bUpdateStartPos;
170  float _isoValue;
172  bool _bInterpolate;
175  bool _bFindAllContours;
176 
178  CSO* _currentlyActiveCSO;
179 
181  bool _isGeneratingCSO;
182 
186  float _currentIsoValue;
187 
189  float* _imageSlice;
191  int _imageSizeX;
193  int _imageSizeY;
195  int _lastCurrentZ;
196 
197 
199  float* _view2DImg;
204  TSubImage<float> _inOptionalImg;
206  bool _optionalImgIsValid;
208  PagedImage* _pImg;
210  CSOMarchingSquares _marchingSquares;
215  std::vector<CSOMarchingSquaresCell::vecPoint2D> _vecPositions;
216 
217 
218  /* METHODS */
219 
221  void _setInternalStateVariables();
225  float _getImageValueAt(int posx, int posy);
228  bool _shouldCreateContour(float isovalue);
230  bool _findIsoContour(float isoValue);
232  void _mapVoxelToWorld(SbVec3f voxel, SbVec3f& world);
234  void _mapVoxelToWorld(Vector3 voxel, Vector3& world);
237  bool _fillCSO(CSO* cso, CSOMarchingSquaresCell::vecPoint2D& positions, float posZ);
239  CSO* _addAndInitCSO();
240 
242  void _setInputImageSlice();
243 
244 
246 };
247 
249 
250 
251 ML_END_NAMESPACE
252 
253 #endif // __CSOIsoProcessor_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 CSOIsoProcessor interactively finds an iso contour on the slice being displayed by the SoView2D m...
void resetInteractionState() override
Sets back internal interaction state.
void handleNotification(Field *field) override
Called when input changes.
bool isCurrentlyGenerating() override
Returns whether the processor is currently generating a new contour.
~CSOIsoProcessor() override
Destructor.
bool isCurrentlyEditing() override
Returns whether the processor is currently editing an existing 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.
bool process(CSOEvalEventView2DInfos view2DInfos, CSOEvalEventCSOInfos csoInfos) override
Evaluates the interaction events and interpolates the contours accordingly.
void activateAttachments() override
Sets internal state variables according to field settings.
CSOIsoProcessor()
Constructor.
void triggerSetMouseCursor(SoView2D *view2d, bool shouldSetMouseCursor) override
Triggers the setting of the processor's default mouse cursor.
A CSOList comprises a number of CSOs and CSOGroups and is the central object for contour segmentation...
Definition: CSOList.h:61
std::vector< Vector2 > vecPoint2D
Defines a 2D point vector.
This class implements the Marching Squares algorithm to find isolines on 2D image slices.
Base class for processor modules; those provide mechanisms for an interactive generation of seed poin...
Definition: CSOProcessor.h:42
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.
constexpr const char * SUB_TYPE_ISO_FIXED_SINGLE
Subtype: a single CSO at a fixed iso value.
constexpr const char * SUB_TYPE_ISO_INTERACTIVE_SINGLE
Subtype: a single CSO at some interactively chosen value.
constexpr const char * SUB_TYPE_ISO_INTERACTIVE_ALL
Subtype: all CSOs at some interactively chosen value.
constexpr const char * SUB_TYPE_ISO_FIXED_ALL
Subtype: all CSOs at a fixed value.
CSOIsoStartCondition
Enumeration of line styles (order as StylePalette::LineStyle).
@ START_HIT_GREATER_ISO_VALUE
Only start tracking an iso line when the value of the hit voxel is greater than the chosen iso value.
@ START_HIT_LOWER_ISO_VALUE
Only start tracking an iso line when the value of the hit voxel is lower than the chosen iso value.
@ START_ALWAYS
An iso line will always be tracked.