MeVisLab Toolbox Reference
SoCSOEditorTools.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2012, 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 
15 
16 #pragma once
17 
18 #include "SoCSOSystem.h"
19 #include <CSOBase/CSOBoundingBox.h>
20 #include <mlLinearAlgebra.h>
21 #include <SoCSODefines.h>
22 
23 
24 class View2DSliceList;
25 class SoCSOTransform;
27 
28 namespace ml
29 {
30  class CSO;
31  class CSOVisualizationSettings;
32 }
33 
35 {
37  {
39  SLICE_IN = 1,
40  SLICE_ABOVE = 2
41  };
42 
44  {
47  };
48 
50  {
51  unsigned int csoID;
52 
62 
63  std::string imageModality;
66  };
67 
70  {
73  };
74 
77  {
78  bool operator ()(const ml::Vector2& a, const ml::Vector2& b) const
79  {
80  return a[0] < b[0];
81  }
82  };
83 
85  {
86  LineRenderSettings() : shouldUseAntiAliasing(true), stipplePattern(0xffff), width(1.0f), alpha(1.0f), outlineAlpha(1.0f) {}
87 
88  bool shouldUseStippling() const { return stipplePattern != 0xffff; }
90  unsigned short stipplePattern;
91  float width;
92 
93  SbColor color;
94  float alpha;
95 
96  SbColor outlineColor;
97  float outlineAlpha;
98  };
99 
100 
106  SOCSO_EXPORT void setStatisticsToUserData(ml::CSO* cso, const ImageStatisticsForCSO& statistics, const std::string& viewerIdentifier="");
107 
108  SOCSO_EXPORT void setUserDataWithViewerId(ml::CSO* cso, const std::string& userDataName, const std::string& viewerIdentifier, const ml::Variant& value);
109 
112  SOCSO_EXPORT void fillCrossingsVector(std::vector< std::vector< ml::Vector2 > >& crossingsVector,
113  const std::vector< ml::Vector3 >& pathPoints,
114  const ml::Vector3& minBB, const ml::Vector3& maxBB);
115 
117  SOCSO_EXPORT void retrieveDicomTagData(SoSFMLImage* image, std::string& modality, float& rescaleIntercept, float& rescaleSlope);
118 
119 
121  SOCSO_EXPORT ml::CSOBoundingBox computeSlabBoundingBox(float deviceX, float deviceY, View2DSliceList* slicelist);
123  SOCSO_EXPORT ml::CSOBoundingBox computeSlabBoundingBox(int voxelZ, View2DSliceList* slicelist, int voxelAugmentInZ=0);
125  SOCSO_EXPORT bool isOnCurrentSlice(SoView2DCSOExtensibleEditor* editor, const CSODrawCSOInfos& csoDrawInfos, const CSODrawView2DInfos& view2DInfos);
127  SOCSO_EXPORT bool isOnCurrentSlice(ml::CSO* cso, const CSODrawView2DInfos& view2DInfos);
129  SOCSO_EXPORT bool isOnCurrentSlice(ml::CSO* cso, View2DSliceList* slicelist, const ml::Vector3& sliceNormalWorld,
130  const CSODrawView2DInfos& view2DInfos);
134  SOCSO_EXPORT bool isApproximatelyParallel(ml::CSO*cso, View2DSliceList* slicelist, float epsilon=-1);
137  SOCSO_EXPORT void fillWorldSliceCrossings(const CSODrawCSOInfos& csoInfos, const CSODrawView2DInfos& view2DInfos,
138  std::vector<CSOSliceCrossing>& belowSlicePositions,
139  std::vector<CSOSliceCrossing>& inSlicePositions,
140  std::vector<CSOSliceCrossing>& aboveSlicePositions);
143  SOCSO_EXPORT void getWorldSlicePlanes(const CSODrawView2DInfos& view2DInfos, ml::Plane& topPlane, ml::Plane& bottomPlane);
144 
146  SOCSO_EXPORT void fillCrossingsOnePlaneCrossed(const ml::Plane& plane, const ml::Vector3& lastPosition, const ml::Vector3& currentPosition,
147  CSOSliceCrossing& sliceCrossings, std::vector<CSOSliceCrossing>* crossings[3],
148  int lastSlicePosition);
150  SOCSO_EXPORT void fillCrossingsBothPlanesCrossed(const ml::Plane& topPlane, const ml::Plane& bottomPlane,
151  const ml::Vector3& lastPosition, const ml::Vector3& currentPosition, int relativePosition,
152  CSOSliceCrossing &sliceCrossings, std::vector<CSOSliceCrossing>* crossings[3]);
153 
155  SOCSO_EXPORT void fillWorldToVoxelMatrix(const CSODrawView2DInfos& view2DInfos, ml::Matrix4& worldToVoxelMatrix);
157  SOCSO_EXPORT void fillWorldToVoxelMatrix(const SoPointerPosition& pos, ml::Matrix4& worldToVoxelMatrix);
159  SOCSO_EXPORT void fillWorldToVoxelMatrix(View2DSliceList* sliceList, ml::Matrix4& worldToVoxelMatrix);
161  SOCSO_EXPORT void fillWorldToVoxelMatrix(const SbMatrix& inventorMatrix, ml::Matrix4& worldToVoxelMatrix);
162 
164  SOCSO_EXPORT void fillVoxelToWorldMatrix(const CSODrawView2DInfos& view2DInfos, ml::Matrix4& voxelToWorldMatrix);
166  SOCSO_EXPORT void fillVoxelToWorldMatrix(const SoPointerPosition& pos, ml::Matrix4& voxelToWorldMatrix);
168  SOCSO_EXPORT void fillVoxelToWorldMatrix(View2DSliceList* sliceList, ml::Matrix4& voxelToWorldMatrix);
170  SOCSO_EXPORT void fillVoxelToWorldMatrix(const SbMatrix& inventorMatrix, ml::Matrix4& voxelToWorldMatrix);
171 
173  SOCSO_EXPORT bool isAbovePlane(const ml::Vector3& worldPosition, const ml::Plane& plane);
175  SOCSO_EXPORT bool evaluateHitPoint(const ml::Vector3& worldPosition, View2DSliceList* slicelist, ml::CSOList* csoList,
176  const ml::CSOBoundingBox& slabBB, const std::string& subType, SoView2DCSOExtensibleEditor* editor,
177  bool testSeedPoints,
178  ml::CSO*& localHitCSO, ml::CSOSeedPoint*& localHitSeedPoint,
179  ml::CSOPathPoints*& localHitPathPoints, float& distanceToCSO);
180 
182  SOCSO_EXPORT bool isEligibleForPicking(ml::CSO* cso, ml::CSOList* csoList, const std::string& subType, View2DSliceList* slicelist, SoView2DCSOExtensibleEditor* editor);
190  SOCSO_EXPORT float getSquaredDeviceDistance(const ml::Vector3& worldPosition, View2DSliceList* slicelist, float dMouseX, float dMouseY);
192  SOCSO_EXPORT void mapWorldToDevice(View2DSliceList* slicelist, const ml::Vector3& worldPosition, float& devX, float& devY);
194  SOCSO_EXPORT float getSquaredDeviceLineDistance(const ml::Vector3& lineWorldStart, const ml::Vector3& lineWorldEnd, View2DSliceList* slicelist, float dMouseX, float dMouseY);
198  SOCSO_EXPORT bool intersectsSlice(const ml::CSOBoundingBox& slabBB, const CSOVoxelSlab& csoBB);
200  SOCSO_EXPORT bool areOnSamePlane(ml::CSO* cso1, ml::CSO* cso2, float epsilon=0.00001f);
202  SOCSO_EXPORT bool areOnSamePlane(ml::CSO* cso, const ml::Vector3& position, const ml::Vector3& normal, float epsilon=0.00001f);
203 
206  SOCSO_EXPORT void drawLines(GLint lineMode, const std::vector<ml::Vector3>& positions,
207  const CSODrawCSOInfos& csoInfos, const CSODrawView2DInfos& view2DInfos,
208  const SbVec2f& deviceOffset);
209 
211  SOCSO_EXPORT void getRightmostSeedPointPosition(const CSODrawCSOInfos& csoInfos, const CSODrawView2DInfos& view2DInfos, float& deviceX, float& deviceY);
213  SOCSO_EXPORT void getRightMostPathPointPositionOnCurrentSlice(const CSODrawCSOInfos& csoInfos, const CSODrawView2DInfos& view2DInfos, float& deviceX, float& deviceY);
216  SOCSO_EXPORT void getRightmostSeedPointPositionAndVector(const CSODrawCSOInfos& csoInfos, const CSODrawView2DInfos& view2DInfos, float& deviceX, float& deviceY, float& deviceVX, float& deviceVY);
218  SOCSO_EXPORT SbVec2f convertDevicePositionToRelativeViewerPosition(View2DSlice* slice, const SbVec2f& deviceVector);
220  SOCSO_EXPORT SbVec2f convertRelativeViewerPositionToDevicePosition(View2DSlice* slice, const SbVec2f& relativeVector);
221 
225  const ml::Vector3& position, float& deviceX, float& deviceY);
226 
228  SOCSO_EXPORT void setupGLAntiAlias(bool shouldUseAntiAliasing);
231 
233  SOCSO_EXPORT bool enableGLStipplingIfNeeded(unsigned short pattern);
234 
236  SOCSO_EXPORT bool isNearDeviceBoundingBox(View2DSliceList* slicelist, const ml::CSOBoundingBox &box, float selectionDistance, float dMouseX, float dMouseY);
237 
239  static std::vector<float> _lineBuffer;
240 }
#define SOCSO_EXPORT
Header file for system independent resolution.
Definition: SoCSOSystem.h:21
Abstract Open Inventor base class for uniform shader parameter nodes.
SoPointerPosition manages the current position of the mouse cursor.
The SoSFMLImage field is the interface used by Inventor Nodes to access image data (in the current im...
Definition: SoSFMLImage.h:70
SoView2D is a 2D viewer for image data.
Definition: SoView2D.h:62
a list that holds all View2DSlice objects (lazily created) of a SoView2D
a single slice that is stored in a View2DSliceList, typically created by a View2DSliceList
Definition: View2DSlice.h:48
The CSOBoundingBox defines an axis parallel bounding box with double precision.
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
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
Class defining a plane in 3D.
Definition: mlPlane.h:30
The Variant class stores different data types.
Definition: mlVariant.h:36
UINT64 MLuint64
Introduce platform-independent 64-bit unsigned integer type.
Definition: mlTypeDefs.h:425
double MLdouble
Definition: mlTypeDefs.h:217
SOCSO_EXPORT bool areOnSamePlane(ml::CSO *cso1, ml::CSO *cso2, float epsilon=0.00001f)
Returns whether the two given CSOs are lying on the same plane.
SOCSO_EXPORT void drawLines(GLint lineMode, const std::vector< ml::Vector3 > &positions, const CSODrawCSOInfos &csoInfos, const CSODrawView2DInfos &view2DInfos, const SbVec2f &deviceOffset)
Draws the given points as a line strip or loop, depending on the lineMode.
SOCSO_EXPORT void setStatisticsToUserData(ml::CSO *cso, const ImageStatisticsForCSO &statistics, const std::string &viewerIdentifier="")
Sets the given statistics to the CSO as user data.
SOCSO_EXPORT SbVec2f convertRelativeViewerPositionToDevicePosition(View2DSlice *slice, const SbVec2f &relativeVector)
Converts the given position relative to the viewer's size to a device position.
SOCSO_EXPORT void setUserDataWithViewerId(ml::CSO *cso, const std::string &userDataName, const std::string &viewerIdentifier, const ml::Variant &value)
SOCSO_EXPORT bool mapWorldToDeviceViaVoxel(const CSODrawCSOInfos &csoInfos, const CSODrawView2DInfos &view2DInfos, const ml::Vector3 &position, float &deviceX, float &deviceY)
Maps the given world position to device coordinates via voxel coordinate; z in voxel space is set to ...
SOCSO_EXPORT float getParallelThicknessAbsoluteValue(View2DSliceList *slicelist, ml::CSOVisualizationSettings *vSettings)
Returns the absolute value for the parallel thickness.
SOCSO_EXPORT float getSquaredDeviceDistance(const ml::Vector3 &worldPosition, View2DSliceList *slicelist, float dMouseX, float dMouseY)
Returns the squared distance in device coordinates from the given world position to the given device ...
SOCSO_EXPORT bool isInteractionAllowedBecauseOfRegistration(ml::CSO *cso, SoView2D *viewer, SoView2DCSOExtensibleEditor *editor)
Returns whether any interaction is allowed because of registration information.
SOCSO_EXPORT ml::CSOBoundingBox computeSlabBoundingBox(float deviceX, float deviceY, View2DSliceList *slicelist)
Computes and returns the bounding box in voxel space of a slice at the given device position.
SOCSO_EXPORT void getWorldSlicePlanes(const CSODrawView2DInfos &view2DInfos, ml::Plane &topPlane, ml::Plane &bottomPlane)
Fills the given top/bottom planes with planes in world space that lies on top and on bottom of the cu...
SOCSO_EXPORT void fillWorldSliceCrossings(const CSODrawCSOInfos &csoInfos, const CSODrawView2DInfos &view2DInfos, std::vector< CSOSliceCrossing > &belowSlicePositions, std::vector< CSOSliceCrossing > &inSlicePositions, std::vector< CSOSliceCrossing > &aboveSlicePositions)
Fills the given vectors with positions below, in, and above the current slice.
SOCSO_EXPORT bool isAbovePlane(const ml::Vector3 &worldPosition, const ml::Plane &plane)
Returns whether the given point is above the given plane.
SOCSO_EXPORT bool isOnSameSlab(const ml::CSOBoundingBox &slabBB, const ml::CSOBoundingBox &csoBB)
Returns whether the two given voxel bounding boxes lie on the same slab.
SOCSO_EXPORT void fillCrossingsBothPlanesCrossed(const ml::Plane &topPlane, const ml::Plane &bottomPlane, const ml::Vector3 &lastPosition, const ml::Vector3 &currentPosition, int relativePosition, CSOSliceCrossing &sliceCrossings, std::vector< CSOSliceCrossing > *crossings[3])
Fills the crossings vector.
SOCSO_EXPORT void getRightmostSeedPointPosition(const CSODrawCSOInfos &csoInfos, const CSODrawView2DInfos &view2DInfos, float &deviceX, float &deviceY)
Fills the device coordinates with the right most seed point position of the CSO in the viewer.
SOCSO_EXPORT bool isApproximatelyParallel(ml::CSO *cso, View2DSliceList *slicelist, float epsilon=-1)
Returns whether the given CSO is parallel to the current 2D image considering the allowed thickness.
SOCSO_EXPORT bool evaluateHitPoint(const ml::Vector3 &worldPosition, View2DSliceList *slicelist, ml::CSOList *csoList, const ml::CSOBoundingBox &slabBB, const std::string &subType, SoView2DCSOExtensibleEditor *editor, bool testSeedPoints, ml::CSO *&localHitCSO, ml::CSOSeedPoint *&localHitSeedPoint, ml::CSOPathPoints *&localHitPathPoints, float &distanceToCSO)
Returns whether a CSO was hit and fills the according structures. If subType is an empty string,...
SOCSO_EXPORT void getRightMostPathPointPositionOnCurrentSlice(const CSODrawCSOInfos &csoInfos, const CSODrawView2DInfos &view2DInfos, float &deviceX, float &deviceY)
Fills the device coordinates with the right most path point position projected on the current slice o...
SOCSO_EXPORT bool isNearDeviceBoundingBox(View2DSliceList *slicelist, const ml::CSOBoundingBox &box, float selectionDistance, float dMouseX, float dMouseY)
Returns if the mouse device position is near the given voxel bounding box in device coords.
SOCSO_EXPORT SbVec2f convertDevicePositionToRelativeViewerPosition(View2DSlice *slice, const SbVec2f &deviceVector)
Converts the given device position to a position relative to the viewer's size.
SOCSO_EXPORT void retrieveDicomTagData(SoSFMLImage *image, std::string &modality, float &rescaleIntercept, float &rescaleSlope)
Fills the given variables with values obtained from DICOM tags.
SOCSO_EXPORT bool isEligibleForPicking(ml::CSO *cso, ml::CSOList *csoList, const std::string &subType, View2DSliceList *slicelist, SoView2DCSOExtensibleEditor *editor)
Returns whether the given CSO is eligible for picking.
SOCSO_EXPORT void fillCrossingsVector(std::vector< std::vector< ml::Vector2 > > &crossingsVector, const std::vector< ml::Vector3 > &pathPoints, const ml::Vector3 &minBB, const ml::Vector3 &maxBB)
Fills the given crossingsVector with crossings of rays in x-direction with the path points segments.
SOCSO_EXPORT bool intersectsSlice(const ml::CSOBoundingBox &slabBB, const CSOVoxelSlab &csoBB)
Returns whether the two given voxel bounding boxes lie on the same slab.
SOCSO_EXPORT void mapWorldToDevice(View2DSliceList *slicelist, const ml::Vector3 &worldPosition, float &devX, float &devY)
Maps the given world position to device position.
SOCSO_EXPORT void fillWorldToVoxelMatrix(const CSODrawView2DInfos &view2DInfos, ml::Matrix4 &worldToVoxelMatrix)
Fills the given matrix with the slice's worldToVoxel matrix.
static std::vector< float > _lineBuffer
Used to avoid reallocation on line rendering.
SOCSO_EXPORT ImageStatisticsForCSO performImageStatistics(ml::CSO *cso, SoSFMLImage *image)
Reads out the given image and performs image voxel value statistics for the given CSO.
SOCSO_EXPORT bool shouldRenderCSODependingOnImageCreation(ml::CSO *cso, SoView2DCSOExtensibleEditor *editor, View2DSliceList *slicelist)
Returns whether the given CSO should be rendered on the image depending whether it was created on it.
SOCSO_EXPORT bool isOnCurrentSlice(SoView2DCSOExtensibleEditor *editor, const CSODrawCSOInfos &csoDrawInfos, const CSODrawView2DInfos &view2DInfos)
Returns whether the given CSO is visible on the current slice.
SOCSO_EXPORT void restoreGLAntiAlias()
Undoes changes to OpenGL state applied by setupGLAntiAlias.
SOCSO_EXPORT void getRightmostSeedPointPositionAndVector(const CSODrawCSOInfos &csoInfos, const CSODrawView2DInfos &view2DInfos, float &deviceX, float &deviceY, float &deviceVX, float &deviceVY)
Fills the device coordinates with the right most seed point position of the CSO (assumed to be a Dist...
SOCSO_EXPORT void setupGLAntiAlias(bool shouldUseAntiAliasing)
Sets OpenGL antialiasing parameters.
SOCSO_EXPORT void fillVoxelToWorldMatrix(const CSODrawView2DInfos &view2DInfos, ml::Matrix4 &voxelToWorldMatrix)
Fills the given matrix with the slice's voxelToWorld matrix.
SOCSO_EXPORT void fillCrossingsOnePlaneCrossed(const ml::Plane &plane, const ml::Vector3 &lastPosition, const ml::Vector3 &currentPosition, CSOSliceCrossing &sliceCrossings, std::vector< CSOSliceCrossing > *crossings[3], int lastSlicePosition)
Fills the crossings vector.
SOCSO_EXPORT float getSquaredDeviceLineDistance(const ml::Vector3 &lineWorldStart, const ml::Vector3 &lineWorldEnd, View2DSliceList *slicelist, float dMouseX, float dMouseY)
Returns the squared distance in device coordinates from the given line in world positions to the give...
SOCSO_EXPORT bool hasTransformation(ml::CSO *cso, SoView2D *viewer, SoView2DCSOExtensibleEditor *editor)
Returns whether there exists a transformation between the CSO and the viewer.
SOCSO_EXPORT bool enableGLStipplingIfNeeded(unsigned short pattern)
Enables/disables GL stippling if pattern requires stippling (if pattern == 0xffff,...
Main documentation file for ML users and developers.
Definition: SoSFMLImage.h:51
Defines the z slab of a CSO bounding box in voxel coordinates.
Definition: SoCSODefines.h:123
Structure for handling path points segments.
For sorting Vector3s according to their x-component.