OpenWalnut  1.5.0dev
WSurface.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WSURFACE_H
26 #define WSURFACE_H
27 
28 #include <memory>
29 #include <vector>
30 
31 #include "WBSplineSurface.h"
32 #include "core/common/math/WTensorSym.h"
33 #include "core/graphicsEngine/WTriangleMesh.h"
34 
35 /**
36  * Constructs a triangle mesh representation of a spline surface from a given
37  * number of input points.
38  */
39 class WSurface
40 {
41 public:
42  /**
43  * Constructs new WSurface.
44  */
45  WSurface();
46 
47  /**
48  * Destructs this WSurface.
49  */
50  ~WSurface();
51 
52  /**
53  * Runs the algo and constructs a spine surface from the given input points.
54  */
55  void execute();
56 
57  /**
58  * Returns a copy of the spline point vector.
59  *
60  * \return points
61  */
62  std::vector< WVector3d > getSplinePoints();
63 
64  /**
65  * SEts the sample rate for the splines.
66  *
67  * \param r the new sample rate
68  */
69  void setSetSampleRate( float r );
70 
71  /**
72  * sets the vector of support points the surface is calculated from
73  * \param supportPoints vector of support points
74  * \param forceUpdate if true the surface will be updated with the new support points
75  */
76  void setSupportPoints( std::vector< WVector3d> supportPoints, bool forceUpdate = false );
77 
78  /**
79  * getter
80  * \return the triangle mesh representing the surface
81  */
82  std::shared_ptr< WTriangleMesh > getTriangleMesh();
83 
84 private:
85  /**
86  * Calculates the covariance matrix for a given number of points inspace.
87  *
88  * \param points vector of points
89  * \return the matrix
90  */
91  WTensorSym< 2, 3, double > getCovarianceMatrix( std::vector< WVector3d > points );
92 
93  /**
94  * Calculates numRows*numCols deBoor points from given input points.
95  *
96  * \param givenPoints the input points
97  * \param deBoorPoints reference to the output vector
98  * \param numRows number of points in first direction of spline surface
99  * \param numCols number of points in second direction of spline surface
100  */
101  void getSplineSurfaceDeBoorPoints( std::vector< WVector3d > &givenPoints, std::vector< WVector3d > &deBoorPoints, int numRows, int numCols ); // NOLINT
102 
103  std::shared_ptr< WTriangleMesh > m_tMesh; //!< Triangle mesh of the surface
104 
105  double m_radius; //!< param for the algo
106  double m_mu; //!< parameter of local shepard with franke-little-weights
107  int m_numDeBoorRows; //!< number of of rows for deBoor grid
108  int m_numDeBoorCols; //!< number of of columns for deBoor grid
109  int m_order; //!< order the splines
110  double m_sampleRateT; //!< sampling rate of spline in first direction
111  double m_sampleRateU; //!< sampling rate of spline in second direction
112  double m_xAverage; //!< global mean of x values for covariance matrix
113  double m_yAverage; //!< global mean of y values for covariance matrix
114  double m_zAverage; //!< global mean of z values for covariance matrix
115 
116  std::vector< WVector3d > m_supportPoints; //!< stores the support points
117 
118  std::vector< WVector3d > m_splinePoints; //!< stores the input points ????
119 
120  int m_renderpointsPerCol; //!< resolution of the output mesh
121  int m_renderpointsPerRow; //!< resolution of the output mesh
122 };
123 
124 #endif // WSURFACE_H
Constructs a triangle mesh representation of a spline surface from a given number of input points.
Definition: WSurface.h:40
std::vector< WVector3d > m_splinePoints
stores the input points ????
Definition: WSurface.h:118
std::vector< WVector3d > m_supportPoints
stores the support points
Definition: WSurface.h:116
int m_renderpointsPerRow
resolution of the output mesh
Definition: WSurface.h:121
int m_numDeBoorCols
number of of columns for deBoor grid
Definition: WSurface.h:108
void setSupportPoints(std::vector< WVector3d > supportPoints, bool forceUpdate=false)
sets the vector of support points the surface is calculated from
Definition: WSurface.cpp:291
int m_order
order the splines
Definition: WSurface.h:109
~WSurface()
Destructs this WSurface.
Definition: WSurface.cpp:51
double m_sampleRateT
sampling rate of spline in first direction
Definition: WSurface.h:110
double m_mu
parameter of local shepard with franke-little-weights
Definition: WSurface.h:106
double m_zAverage
global mean of z values for covariance matrix
Definition: WSurface.h:114
void setSetSampleRate(float r)
SEts the sample rate for the splines.
Definition: WSurface.cpp:285
WTensorSym< 2, 3, double > getCovarianceMatrix(std::vector< WVector3d > points)
Calculates the covariance matrix for a given number of points inspace.
Definition: WSurface.cpp:55
std::vector< WVector3d > getSplinePoints()
Returns a copy of the spline point vector.
Definition: WSurface.cpp:280
double m_radius
param for the algo
Definition: WSurface.h:105
std::shared_ptr< WTriangleMesh > m_tMesh
Triangle mesh of the surface.
Definition: WSurface.h:103
double m_xAverage
global mean of x values for covariance matrix
Definition: WSurface.h:112
void getSplineSurfaceDeBoorPoints(std::vector< WVector3d > &givenPoints, std::vector< WVector3d > &deBoorPoints, int numRows, int numCols)
Calculates numRows*numCols deBoor points from given input points.
Definition: WSurface.cpp:94
void execute()
Runs the algo and constructs a spine surface from the given input points.
Definition: WSurface.cpp:174
int m_numDeBoorRows
number of of rows for deBoor grid
Definition: WSurface.h:107
double m_sampleRateU
sampling rate of spline in second direction
Definition: WSurface.h:111
WSurface()
Constructs new WSurface.
Definition: WSurface.cpp:36
int m_renderpointsPerCol
resolution of the output mesh
Definition: WSurface.h:120
std::shared_ptr< WTriangleMesh > getTriangleMesh()
getter
Definition: WSurface.cpp:300
double m_yAverage
global mean of y values for covariance matrix
Definition: WSurface.h:113
Implements a symmetric tensor that has the same number of components in every direction.
Definition: WTensorSym.h:73