MeVisLabToolboxReference
|
00001 // **InsertLicense** code 00002 //---------------------------------------------------------------------------------- 00005 00010 //---------------------------------------------------------------------------------- 00011 00012 #ifndef __CSOInterpolate3DFunction_H 00013 #define __CSOInterpolate3DFunction_H 00014 00015 #include "MLCSOIncludes.h" 00016 #include "CSOFunction.h" 00017 #include <CSOBase/CSOList.h> 00018 #include <CSOTools/CSOMath.h> 00019 #include <CSOTools/CSOPointInPolygonChecker.h> 00020 00021 00022 ML_START_NAMESPACE 00023 00025 00027 class MLCSO_EXPORT CSOInterpolate3DFunctionSettings 00028 { 00029 public: 00030 00031 enum AdditionalPointLocation { 00032 ADDITIONAL_POINT_INNER = 0, 00033 ADDITIONAL_POINT_OUTER = 1, 00034 ADDITIONAL_POINT_AUTO = 2, 00035 ADDITIONAL_POINT_NUM_OPTIONS = 3 00036 }; 00037 00038 CSOInterpolate3DFunctionSettings() 00039 : maxNumPoints(3000) 00040 , quality(0.9) 00041 , useOnlySeedPoints(false) 00042 , useSplineApproximationSmoothing(false) 00043 , resolveIntersections(true) 00044 , additionalPointLocation(ADDITIONAL_POINT_AUTO) 00045 , innerPointScale(0.25) 00046 , regularizationStrength(0.0) 00047 , regularizationStrength2(0.0) 00048 , resolveEmbeddedCSOs(false) 00049 {} 00050 00053 unsigned int maxNumPoints; 00055 double quality; 00056 00058 bool useOnlySeedPoints; 00060 bool useSplineApproximationSmoothing; 00061 00063 bool resolveIntersections; 00065 AdditionalPointLocation additionalPointLocation; 00067 double innerPointScale; 00068 00070 double regularizationStrength; 00072 double regularizationStrength2; 00074 bool resolveEmbeddedCSOs; 00075 }; 00076 00078 00080 class MLCSO_EXPORT CSOInterpolate3DFunction : public CSOFunction 00081 { 00082 00083 public: 00084 00085 typedef std::vector<Vector3> StartingPositions; 00086 typedef std::map<unsigned int, StartingPositions> StartingPositionsMap; 00087 00089 CSOInterpolate3DFunction(); 00090 00092 CSOInterpolate3DFunction(const CSOList* csoList, const Matrix4& worldToVoxelMatrix, const Matrix4& voxelToWorldMatrix, 00093 const CSOInterpolate3DFunctionSettings& settings); 00094 00096 virtual ~CSOInterpolate3DFunction(); 00097 00099 virtual float evaluateAtPos(const Vector3& pos) const; 00100 00102 virtual bool shouldParallelize() const { return true; } 00103 00105 StartingPositionsMap& getStartingPositions() { return _startingPositions; } 00106 00108 const CSOInterpolate3DFunctionSettings& getSettings() const { return _settings; } 00109 00110 private: 00111 00112 00113 /* STATE VARIABLES */ 00114 00116 CSOListPtr _csoList; 00117 00119 CSOInterpolate3DFunctionSettings _settings; 00120 00122 double* _coefficients; 00124 long int _numElements; 00126 Vector3* _positions; 00128 Matrix4 _worldToVoxelMatrix; 00130 Matrix4 _voxelToWorldMatrix; 00132 StartingPositionsMap _startingPositions; 00133 00134 /* METHODS */ 00135 00137 void _computeCoefficientVector(); 00139 Vector3 _computeInnerPosition(const std::vector<Vector3>&allPathPointPositions, const Vector3& planeNormal, unsigned int j, bool resolveIntersections, double& functionValue, size_t levelOfEmbedding, CSOPointInPolygonChecker* pointInPolygonChecker=NULL); 00143 bool _needsHelperCSO() const; 00144 00146 bool _checkSelfIntersection(const std::vector<Vector3>& allPathPointPositions, unsigned int predIndex, unsigned int currIndex) const; 00147 00150 inline double _phi(const Vector3& vecarg) const 00151 { 00152 const double sLen = vecarg.lengthSquared(); 00153 00154 if (sLen < 10e-10) { // clamp towards 0 00155 return 0.0; 00156 } else { 00157 return (sLen) * sqrt(sLen); 00158 } 00159 } 00160 00161 }; 00162 00164 00165 00166 ML_END_NAMESPACE 00167 00168 #endif // __CSOInterpolate3DFunction_H 00169