MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
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;
31 class CSOVisualizationSettings;
32} // namespace ml
33
35{
41
47
66
73
76 {
77 bool operator()(const ml::Vector2& a, const ml::Vector2& b) const
78 {
79 return a[0] < b[0];
80 }
81 };
82
84 {
86 : shouldUseAntiAliasing(true)
87 , stipplePattern(0xffff)
88 , width(1.0f)
89 , alpha(1.0f)
90 , outlineAlpha(1.0f)
91 {}
92
93 bool shouldUseStippling() const
94 {
95 return stipplePattern != 0xffff;
96 }
98 unsigned short stipplePattern;
99 float width;
100
102 float alpha;
103
106 };
107
108
115 const std::string& viewerIdentifier = "");
116
118 const std::string& viewerIdentifier, const ml::Variant& value);
119
122 SOCSO_EXPORT void fillCrossingsVector(std::vector<std::vector<ml::Vector2>>& crossingsVector,
123 const std::vector<ml::Vector3>& pathPoints, const ml::Vector3& minBB,
124 const ml::Vector3& maxBB);
125
127 SOCSO_EXPORT void retrieveDicomTagData(SoSFMLImage* image, std::string& modality, float& rescaleIntercept,
128 float& rescaleSlope);
129
130
135 int voxelAugmentInZ = 0);
138 const CSODrawView2DInfos& view2DInfos);
143 const CSODrawView2DInfos& view2DInfos);
148 SOCSO_EXPORT bool isApproximatelyParallel(ml::CSO* cso, View2DSliceList* slicelist, float epsilon = -1);
152 std::vector<CSOSliceCrossing>& belowSlicePositions,
153 std::vector<CSOSliceCrossing>& inSlicePositions,
154 std::vector<CSOSliceCrossing>& aboveSlicePositions);
159
163 std::vector<CSOSliceCrossing>* crossings[3], int lastSlicePosition);
167 int relativePosition, CSOSliceCrossing& sliceCrossings,
168 std::vector<CSOSliceCrossing>* crossings[3]);
169
171 SOCSO_EXPORT void fillWorldToVoxelMatrix(const CSODrawView2DInfos& view2DInfos, ml::Matrix4& worldToVoxelMatrix);
178
180 SOCSO_EXPORT void fillVoxelToWorldMatrix(const CSODrawView2DInfos& view2DInfos, ml::Matrix4& voxelToWorldMatrix);
187
189 SOCSO_EXPORT bool isAbovePlane(const ml::Vector3& worldPosition, const ml::Plane& plane);
192 SOCSO_EXPORT bool evaluateHitPoint(const ml::Vector3& worldPosition, View2DSliceList* slicelist, ml::CSOList* csoList,
193 const ml::CSOBoundingBox& slabBB, const std::string& subType,
196 float& distanceToCSO, int sliceZ = -1);
197
199 SOCSO_EXPORT bool isEligibleForPicking(ml::CSO* cso, ml::CSOList* csoList, const std::string& subType,
208 View2DSliceList* slicelist);
210 SOCSO_EXPORT bool shouldRenderCSOOnViewerWithId(ml::CSO* cso, const std::string& viewerId,
213 SOCSO_EXPORT float getSquaredDeviceDistance(const ml::Vector3& worldPosition, View2DSliceList* slicelist,
214 float dMouseX, float dMouseY);
216 SOCSO_EXPORT void mapWorldToDevice(View2DSliceList* slicelist, const ml::Vector3& worldPosition, float& devX,
217 float& devY);
221 View2DSliceList* slicelist, float dMouseX, float dMouseY,
222 int sliceZ = -1);
228 SOCSO_EXPORT bool areOnSamePlane(ml::CSO* cso1, ml::CSO* cso2, float epsilon = 0.00001f);
230 SOCSO_EXPORT bool areOnSamePlane(ml::CSO* cso, const ml::Vector3& position, const ml::Vector3& normal,
231 float epsilon = 0.00001f);
232
235 SOCSO_EXPORT void drawLines(GLint lineMode, const std::vector<ml::Vector3>& positions,
236 const CSODrawCSOInfos& csoInfos, const CSODrawView2DInfos& view2DInfos,
237 const SbVec2f& deviceOffset);
238
241 const CSODrawView2DInfos& view2DInfos, float& deviceX,
242 float& deviceY);
246 const CSODrawView2DInfos& view2DInfos, float& deviceX,
247 float& deviceY);
252 const CSODrawView2DInfos& view2DInfos, float& deviceX,
253 float& deviceY, float& deviceVX, float& deviceVY);
258
262 const ml::Vector3& position, float& deviceX, float& deviceY);
263
266 float& deviceX, float& deviceY);
267
269 SOCSO_EXPORT void setupGLAntiAlias(bool shouldUseAntiAliasing);
272
275
279 float selectionDistance, float dMouseX, float dMouseY, int sliceZ = -1);
280
286
288 static std::vector<float> _lineBuffer;
289} // namespace SoCSOEditorTools
#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:84
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 that are interpolated by a certain interpolation sch...
The CSOSeedPoint can be interactively set and modified, and is the framework for contours.
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
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
UINT64 MLuint64
Introduce platform-independent 64-bit unsigned integer type.
Definition mlTypeDefs.h:424
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 coordinates; 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 float getSquaredDeviceLineDistance(const ml::Vector3 &lineWorldStart, const ml::Vector3 &lineWorldEnd, View2DSliceList *slicelist, float dMouseX, float dMouseY, int sliceZ=-1)
Returns the squared distance in device coordinates from the given line in world positions to the give...
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 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 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 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, int sliceZ=-1)
Returns whether a CSO was hit and fills the according structures.
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 bool isNearDeviceBoundingBox(View2DSliceList *slicelist, const ml::CSOBoundingBox &box, float selectionDistance, float dMouseX, float dMouseY, int sliceZ=-1)
Returns if the mouse device position is near the given voxel bounding box in device coords.
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.
bool _isCurrentSliceForGhostedCSO(int sliceZ)
Returns whether the given sliceZ is not -1; this is used for a hit test for ghosted CSOs where we pre...
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:64
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.
bool operator()(const ml::Vector2 &a, const ml::Vector2 &b) const