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"
20#include <mlLinearAlgebra.h>
21#include <SoCSODefines.h>
22
23
24class View2DSliceList;
25class SoCSOTransform;
27
28namespace ml
29{
30 class CSO;
32}
33
35{
42
48
67
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 {
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;
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
123 SOCSO_EXPORT ml::CSOBoundingBox computeSlabBoundingBox(int voxelZ, View2DSliceList* slicelist, int voxelAugmentInZ=0);
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);
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);
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);
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 bool shouldRenderCSOOnViewerWithId(ml::CSO* cso, const std::string& viewerId, SoView2DCSOExtensibleEditor* editor);
192 SOCSO_EXPORT float getSquaredDeviceDistance(const ml::Vector3& worldPosition, View2DSliceList* slicelist, float dMouseX, float dMouseY);
194 SOCSO_EXPORT void mapWorldToDevice(View2DSliceList* slicelist, const ml::Vector3& worldPosition, float& devX, float& devY);
196 SOCSO_EXPORT float getSquaredDeviceLineDistance(const ml::Vector3& lineWorldStart, const ml::Vector3& lineWorldEnd, View2DSliceList* slicelist, float dMouseX, float dMouseY);
202 SOCSO_EXPORT bool areOnSamePlane(ml::CSO* cso1, ml::CSO* cso2, float epsilon=0.00001f);
204 SOCSO_EXPORT bool areOnSamePlane(ml::CSO* cso, const ml::Vector3& position, const ml::Vector3& normal, float epsilon=0.00001f);
205
208 SOCSO_EXPORT void drawLines(GLint lineMode, const std::vector<ml::Vector3>& positions,
209 const CSODrawCSOInfos& csoInfos, const CSODrawView2DInfos& view2DInfos,
210 const SbVec2f& deviceOffset);
211
213 SOCSO_EXPORT void getRightmostSeedPointPosition(const CSODrawCSOInfos& csoInfos, const CSODrawView2DInfos& view2DInfos, float& deviceX, float& deviceY);
215 SOCSO_EXPORT void getRightMostPathPointPositionOnCurrentSlice(const CSODrawCSOInfos& csoInfos, const CSODrawView2DInfos& view2DInfos, float& deviceX, float& deviceY);
218 SOCSO_EXPORT void getRightmostSeedPointPositionAndVector(const CSODrawCSOInfos& csoInfos, const CSODrawView2DInfos& view2DInfos, float& deviceX, float& deviceY, float& deviceVX, float& deviceVY);
220 SOCSO_EXPORT SbVec2f convertDevicePositionToRelativeViewerPosition(View2DSlice* slice, const SbVec2f& deviceVector);
222 SOCSO_EXPORT SbVec2f convertRelativeViewerPositionToDevicePosition(View2DSlice* slice, const SbVec2f& relativeVector);
223
227 const ml::Vector3& position, float& deviceX, float& deviceY);
228
230 SOCSO_EXPORT void setupGLAntiAlias(bool shouldUseAntiAliasing);
233
235 SOCSO_EXPORT bool enableGLStipplingIfNeeded(unsigned short pattern);
236
238 SOCSO_EXPORT bool isNearDeviceBoundingBox(View2DSliceList* slicelist, const ml::CSOBoundingBox &box, float selectionDistance, float dMouseX, float dMouseY);
239
241 static std::vector<float> _lineBuffer;
242}
#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.
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.
Definition CSO.h:44
Class defining a plane in 3D.
Definition mlPlane.h:30
UINT64 MLuint64
Introduce platform-independent 64-bit unsigned integer type.
Definition mlTypeDefs.h:424
double MLdouble
Definition mlTypeDefs.h:216
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)
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)
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)
SOCSO_EXPORT void fillWorldSliceCrossings(const CSODrawCSOInfos &csoInfos, const CSODrawView2DInfos &view2DInfos, std::vector< CSOSliceCrossing > &belowSlicePositions, std::vector< CSOSliceCrossing > &inSlicePositions, std::vector< CSOSliceCrossing > &aboveSlicePositions)
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 bool shouldRenderCSOOnViewerWithId(ml::CSO *cso, const std::string &viewerId, SoView2DCSOExtensibleEditor *editor)
Returns whether the given CSO should be rendered on a viewer with the given viewer ID.
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)
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)
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)
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,...
Defines the class GetTileJob.
Definition SoSFMLImage.h:51
Tmat4< MLdouble > Matrix4
The standard 4x4 matrix of type double.
Definition mlMatrix4.h:713
Tvec3< MLdouble > Vector3
A vector with three components of type double.
Definition mlVector3.h:286
Tvec2< MLdouble > Vector2
A vector with two components of type double.
Definition mlVector2.h:159
Defines the z slab of a CSO bounding box in voxel coordinates.
Structure for handling path points segments.
For sorting Vector3s according to their x-component.