MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
CSOInterpolate3DFunction.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2009, 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
16
17#pragma once
18
19
20#include "MLCSOIncludes.h"
21#include "CSOFunction.h"
22#include <CSOBase/CSOList.h>
23#include <CSOTools/CSOMath.h>
25
26#include <ThirdPartyWarningsDisable.h>
27#include <Eigen/Core>
28#include <ThirdPartyWarningsRestore.h>
29
30#include <Eigen/Dense>
31
33
35
38{
39public:
41 enum CodePath {
42 FPU = 0,
44 // AVX,
45 CODEPATH_NUM_OPTIONS
46 };
47
49 ADDITIONAL_POINT_INNER = 0,
50 ADDITIONAL_POINT_OUTER = 1,
51 ADDITIONAL_POINT_AUTO = 2,
52 ADDITIONAL_POINT_NUM_OPTIONS = 3
53 };
54
56 : maxNumPoints(3000)
57 , quality(0.9)
58 , useOnlySeedPoints(false)
59 , useSplineApproximationSmoothing(false)
60 , resolveIntersections(true)
61 , additionalPointLocation(ADDITIONAL_POINT_AUTO)
62 , innerPointScale(0.25)
63 , regularizationStrength(0.0)
64 , regularizationStrength2(0.0)
65 , resolveEmbeddedCSOs(false)
66 , supportOpenCSOs(false)
67 , numThreads(1)
68 , codePath(FPU)
69 , logging(false)
70 {}
71
74 unsigned int maxNumPoints;
76 double quality;
77
82
89
96
99
101 unsigned int numThreads;
102
105
108};
109
111
114{
115
116public:
117 typedef std::vector<Vector3> StartingPositions;
118 typedef std::map<unsigned int, StartingPositions> StartingPositionsMap;
119
122
124 CSOInterpolate3DFunction(const CSOList* csoList, const Matrix4& worldToVoxelMatrix, const Matrix4& voxelToWorldMatrix,
126
129
131 float evaluateAtPos(const Vector3& pos) const override;
132
134 bool shouldParallelize() const override
135 {
136 return _settings.numThreads > 1;
137 }
138
139
142 {
143 return _startingPositions;
144 }
145
148 {
149 return _settings;
150 }
151
152 // Fulfill Eigen alignment requirements.
154
155private:
156 /* STATE VARIABLES */
157
159 CSOListPtr _csoList;
160
163
165 Eigen::ArrayXd _coefficientsHead;
166 Eigen::Array4d _coefficientsTail;
168 unsigned int _numElements;
171 Eigen::Matrix4Xd _positions;
173 Eigen::Matrix4d _worldToVoxelMatrix;
175 Eigen::Matrix4d _voxelToWorldMatrix;
177 StartingPositionsMap _startingPositions;
178
179 /* METHODS */
180
182 void _computeCoefficientVector();
184 Vector3 _computeInnerPosition(const std::vector<Vector3>& allPathPointPositions, const Vector3& planeNormal,
185 unsigned int j, bool resolveIntersections, double& functionValue,
190 bool _needsHelperCSO() const;
191
193 bool _checkSelfIntersection(const std::vector<Vector3>& allPathPointPositions, unsigned int predIndex,
194 unsigned int currIndex) const;
195
198 inline double _phi(const Eigen::Vector4d& vecarg) const
199 {
200 const double sLen = vecarg.dot(vecarg);
201 {
202 return sLen * sqrt(sLen);
203 }
204 }
205};
206
208
#define MLCSO_EXPORT
Defines export symbols for classes, so they can be used in other DLLs.
Definition MLCSOSystem.h:23
Base class for distance functions for application in the marching cubes algorithm.
Definition CSOFunction.h:29
This class encapsulates the settings for CSOInterpolate3DFunction.
unsigned int maxNumPoints
The maximum number of points used for processing.
double regularizationStrength2
Regularization strength for normal constraints.
bool useOnlySeedPoints
Should only the seed points be used for interpolation?
bool resolveIntersections
If true, self-intersecting CSOs are handled correctly.
double innerPointScale
Factor used for determining the inner points.
bool useSplineApproximationSmoothing
Should the CSOs be smoothed by a spline approximation (only path points)?
CodePath
Defines the possible code paths.
double regularizationStrength
Regularization strength for surface constraints.
CodePath codePath
The code path that should be used (FPU or SSE3).
AdditionalPointLocation additionalPointLocation
Defines where the additional points should be located.
unsigned int numThreads
The number of threads used for computation.
bool resolveEmbeddedCSOs
If true, embedded CSOs invert their normals.
The CSOInterpolate3DFunction holds the interpolation function that is a smooth thin-plate spline surf...
CSOInterpolate3DFunction()
Constructor.
~CSOInterpolate3DFunction() override
Destructor.
float evaluateAtPos(const Vector3 &pos) const override
Returns a scalar for a given 3D voxel position; can be thought of as evaluating a smoothed distance f...
bool shouldParallelize() const override
Returns whether calls to evaluateAtPos should and can be done from different threads.
CSOInterpolate3DFunction(const CSOList *csoList, const Matrix4 &worldToVoxelMatrix, const Matrix4 &voxelToWorldMatrix, const CSOInterpolate3DFunctionSettings &settings)
Constructor, takes a CSOList and the voxel matrix as arguments.
StartingPositionsMap & getStartingPositions()
Returns the vector of starting positions for CSOs.
const CSOInterpolate3DFunctionSettings & getSettings() const
Returns the settings.
std::map< unsigned int, StartingPositions > StartingPositionsMap
A CSOList comprises a number of CSOs and CSOGroups and is the central object for contour segmentation...
Definition CSOList.h:61
Checks whether a point is inside a planar, closed polygon in an arbitrary plane.
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
double sqrt(T value)