32 #include "core/common/math/WLinearAlgebraFunctions.h"
33 #include "core/common/math/WMatrix.h"
34 #include "core/common/math/WTensorFunctions.h"
40 m_numDeBoorRows( 12 ),
41 m_numDeBoorCols( 12 ),
60 std::vector< WVector3d >::iterator pointsIt;
61 for( pointsIt = points.begin(); pointsIt != points.end(); ++pointsIt )
73 for( pointsIt = points.begin(); pointsIt != points.end(); ++pointsIt )
87 result( 1, 0 ) = result( 0, 1 );
88 result( 2, 0 ) = result( 0, 2 );
89 result( 2, 1 ) = result( 1, 2 );
96 double xMin = givenPoints[0][0];
97 double xMax = givenPoints[0][0];
98 double zMin = givenPoints[0][2];
99 double zMax = givenPoints[0][2];
101 std::vector< WVector3d >::iterator givenPointsIt;
103 for( givenPointsIt = givenPoints.begin(); givenPointsIt != givenPoints.end(); ++givenPointsIt )
124 double dX = ( xMax - xMin ) / ( numCols - 1 );
125 double dZ = ( zMax - zMin ) / ( numRows - 1 );
127 deBoorPoints.reserve( numRows * numCols );
129 for(
int row = 0; row < numRows; ++row )
130 for(
int col = 0; col < numCols; ++col )
132 double x = xMin + dX * col;
133 double z = zMin + dZ * row;
136 double numerator = 0, denominator = 0;
139 for( givenPointsIt = givenPoints.begin(); givenPointsIt != givenPoints.end(); ++givenPointsIt )
142 WVector3d dmyArray( dmy1[0], dmy1[1], dmy1[2] );
148 if( length( thisPoint - dmyArray ) <
m_radius )
150 xi = 1 - length( thisPoint - dmyArray ) /
m_radius;
157 numerator += ( pow( xi,
m_mu ) * dmy1[1] );
158 denominator += ( pow( xi,
m_mu ) );
160 if( denominator == 0 )
166 y = numerator / denominator;
169 deBoorPoints.push_back(
WVector3d( x, y, z ) );
176 std::vector< WVector3d > deBoorPoints;
181 RealEigenSystem eigenSys;
183 jacobiEigenvector3D( myTensor, &eigenSys );
185 eigenSys[0].second = normalize( eigenSys[0].second );
186 eigenSys[1].second = normalize( eigenSys[1].second );
187 eigenSys[2].second = normalize( eigenSys[2].second );
190 std::map< double, WVector3d > sortedEigenSystem;
191 for(
size_t i = 0; i < 3 ; ++i )
193 sortedEigenSystem[eigenSys[i].first] = eigenSys[i].second;
198 std::map< double, WVector3d >::iterator sortedSystemIter = sortedEigenSystem.begin();
199 transMatrix( 1, 0 ) =( *sortedSystemIter ).second[0];
200 transMatrix( 1, 1 ) =( *sortedSystemIter ).second[1];
201 transMatrix( 1, 2 ) =( *sortedSystemIter ).second[2];
204 transMatrix( 0, 0 ) =( *sortedSystemIter ).second[0];
205 transMatrix( 0, 1 ) =( *sortedSystemIter ).second[1];
206 transMatrix( 0, 2 ) =( *sortedSystemIter ).second[2];
209 transMatrix( 2, 0 ) =( *sortedSystemIter ).second[0];
210 transMatrix( 2, 1 ) =( *sortedSystemIter ).second[1];
211 transMatrix( 2, 2 ) =( *sortedSystemIter ).second[2];
213 std::vector< WVector3d >::iterator pointsIt;
222 WVector3d dmy( ( *pointsIt )[0], ( *pointsIt )[1], ( *pointsIt )[2] );
225 ( *pointsIt )[0] = result[0];
226 ( *pointsIt )[1] = result[1];
227 ( *pointsIt )[2] = result[2];
234 transMatrix = invertMatrix3x3( transMatrix );
235 for( pointsIt = deBoorPoints.begin(); pointsIt != deBoorPoints.end(); ++pointsIt )
237 WVector3d dmy( ( *pointsIt )[0], ( *pointsIt )[1], ( *pointsIt )[2] );
240 ( *pointsIt )[0] = result[0];
241 ( *pointsIt )[1] = result[1];
242 ( *pointsIt )[2] = result[2];
260 newMesh->addVertex( ( *posIt )[0], ( *posIt )[1], ( *posIt )[2] );
272 newMesh->addTriangle( p0, p1, p2 );
273 newMesh->addTriangle( p2, p1, p3 );
int getNumSamplePointsT()
Returns the number of sample points in the first direction that were used for the last call to sample...
void samplePoints(std::vector< WVector3d > *points, double tResolution, double uResolution)
Compute sample points on the spline surface for a given resolution in the two directions.
int getNumSamplePointsU()
Returns the number of sample points in the second direction that were used for the last call to sampl...
std::vector< WVector3d > m_splinePoints
stores the input points ????
std::vector< WVector3d > m_supportPoints
stores the support points
int m_renderpointsPerRow
resolution of the output mesh
int m_numDeBoorCols
number of of columns for deBoor grid
void setSupportPoints(std::vector< WVector3d > supportPoints, bool forceUpdate=false)
sets the vector of support points the surface is calculated from
int m_order
order the splines
~WSurface()
Destructs this WSurface.
double m_sampleRateT
sampling rate of spline in first direction
double m_mu
parameter of local shepard with franke-little-weights
double m_zAverage
global mean of z values for covariance matrix
void setSetSampleRate(float r)
SEts the sample rate for the splines.
WTensorSym< 2, 3, double > getCovarianceMatrix(std::vector< WVector3d > points)
Calculates the covariance matrix for a given number of points inspace.
std::vector< WVector3d > getSplinePoints()
Returns a copy of the spline point vector.
double m_radius
param for the algo
std::shared_ptr< WTriangleMesh > m_tMesh
Triangle mesh of the surface.
double m_xAverage
global mean of x values for covariance matrix
void getSplineSurfaceDeBoorPoints(std::vector< WVector3d > &givenPoints, std::vector< WVector3d > &deBoorPoints, int numRows, int numCols)
Calculates numRows*numCols deBoor points from given input points.
void execute()
Runs the algo and constructs a spine surface from the given input points.
int m_numDeBoorRows
number of of rows for deBoor grid
double m_sampleRateU
sampling rate of spline in second direction
WSurface()
Constructs new WSurface.
int m_renderpointsPerCol
resolution of the output mesh
std::shared_ptr< WTriangleMesh > getTriangleMesh()
getter
double m_yAverage
global mean of y values for covariance matrix
Implements a symmetric tensor that has the same number of components in every direction.
Triangle mesh data structure allowing for convenient access of the elements.