MeVisLab Toolbox Reference
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 
32 ML_START_NAMESPACE
33 
35 
38 {
39 public:
40 
42  enum CodePath
43  {
44  FPU = 0,
46  //AVX,
47  CODEPATH_NUM_OPTIONS
48  };
49 
51  {
52  ADDITIONAL_POINT_INNER = 0,
53  ADDITIONAL_POINT_OUTER = 1,
54  ADDITIONAL_POINT_AUTO = 2,
55  ADDITIONAL_POINT_NUM_OPTIONS = 3
56  };
57 
59  : maxNumPoints(3000)
60  , quality(0.9)
61  , useOnlySeedPoints(false)
62  , useSplineApproximationSmoothing(false)
63  , resolveIntersections(true)
64  , additionalPointLocation(ADDITIONAL_POINT_AUTO)
65  , innerPointScale(0.25)
66  , regularizationStrength(0.0)
67  , regularizationStrength2(0.0)
68  , resolveEmbeddedCSOs(false)
69  , supportOpenCSOs(false)
70  , numThreads(1)
71  , codePath(FPU)
72  , logging(false)
73  {}
74 
77  unsigned int maxNumPoints;
79  double quality;
80 
85 
92 
99 
102 
104  unsigned int numThreads;
105 
108 
110  bool logging;
111 
112 };
113 
115 
118 {
119 
120 public:
121 
122  typedef std::vector<Vector3> StartingPositions;
123  typedef std::map<unsigned int, StartingPositions> StartingPositionsMap;
124 
127 
129  CSOInterpolate3DFunction(const CSOList* csoList, const Matrix4& worldToVoxelMatrix, const Matrix4& voxelToWorldMatrix,
130  const CSOInterpolate3DFunctionSettings& settings);
131 
134 
136  float evaluateAtPos(const Vector3& pos) const override;
137 
139  bool shouldParallelize() const override { return _settings.numThreads > 1; }
140 
141 
143  StartingPositionsMap& getStartingPositions() { return _startingPositions; }
144 
146  const CSOInterpolate3DFunctionSettings& getSettings() const { return _settings; }
147 
148  // fulfill Eigen alignment requirements
149  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
150 
151 private:
152 
153 
154  /* STATE VARIABLES */
155 
157  CSOListPtr _csoList;
158 
161 
163  Eigen::ArrayXd _coefficientsHead;
164  Eigen::Array4d _coefficientsTail;
166  unsigned int _numElements;
168  Eigen::Matrix4Xd _positions;
170  Eigen::Matrix4d _worldToVoxelMatrix;
172  Eigen::Matrix4d _voxelToWorldMatrix;
174  StartingPositionsMap _startingPositions;
175 
176  /* METHODS */
177 
179  void _computeCoefficientVector();
181  Vector3 _computeInnerPosition(const std::vector<Vector3>& allPathPointPositions, const Vector3& planeNormal, unsigned int j, bool resolveIntersections, double& functionValue, size_t csoLevelOfEmbedding, CSOPointInPolygonChecker* pointInPolygonChecker=nullptr);
185  bool _needsHelperCSO() const;
186 
188  bool _checkSelfIntersection(const std::vector<Vector3>& allPathPointPositions, unsigned int predIndex, unsigned int currIndex) const;
189 
192  inline double _phi(const Eigen::Vector4d& vecarg) const
193  {
194  const double sLen = vecarg.dot(vecarg);
195  {
196  return sLen * sqrt(sLen);
197  }
198  }
199 
200 };
201 
203 
204 ML_END_NAMESPACE
#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 which is a smooth thin-plate spline sur...
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...
std::vector< Vector3 > StartingPositions
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.
const CSOInterpolate3DFunctionSettings & getSettings() const
Returns the settings.
StartingPositionsMap & getStartingPositions()
Returns the vector of starting positions for CSOs.
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.
Tmat4< MLdouble > Matrix4d
A 4x4 matrix of type double.
Definition: mlMatrix4.h:722
Tvec4< MLdouble > Vector4d
A vector with 4 components of type double.
Definition: mlVector4.h:158