All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
nurbs_surface.h
1 #ifndef NURBS_SURFACE_FMATVEC_H_
2 #define NURBS_SURFACE_FMATVEC_H_
3 
4 #include <mbsim/numerics/nurbs/nurbs_defs.h>
5 #include "nurbs_curve.h"
6 
7 namespace fmatvec {
8  typedef Matrix<General, Fixed<4>, Var, double> Mat4xV;
9 
10  typedef Matrix<General, Var, Fixed<4>, double> MatVx4;
11 }
12 
13 namespace MBSim {
14 
15 // enum Direction { u_direction=1, v_direction=2, both_direction=3} ;
16 //
17 // template <class T, int N> class NurbsSurfaceArray ;
18 //
19 // template <class T, int N> void gordonSurface(NurbsCurveArray<T,N>& , NurbsCurveArray<T,N>& , const Matrix< Point_nD<T,N> >& , NurbsSurface<T,N>& );
20  int surfMeshParams(const GeneralMatrix<fmatvec::Vec3>& Q, Vec& uk, Vec& vl);
21 // template <class T, int N> int surfMeshParamsH(const Matrix< HPoint_nD<T,N> >& , Vector<T>& , Vector<T>& );
22 // template <class T, int N> int surfMeshParamsClosedU(const Matrix< Point_nD<T,N> >& Qw, Vector<T>& uk, Vector<T>& vl, int degU );
23  int surfMeshParamsClosedU(const GeneralMatrix<fmatvec::Vec3>& Q, Vec& uk, Vec& vl, int degU);
24 // template <class T, int N> int surfMeshParamsClosedUH(const Matrix< HPoint_nD<T,N> >& Qw, Vector<T>& uk, Vector<T>& vl, int degU );
25 //
26 // template <class T, int N> void globalSurfInterpXY(const Matrix< Point_nD<T,N> >& , int , int , NurbsSurface<T,N>& );
27 // template <class T, int N> void globalSurfInterpXY(const Matrix< Point_nD<T,N> >& , int , int , NurbsSurface<T,N>& , const Vector<T>& , const Vector<T>& );
28 // template <class T, int N> void globalSurfApprox(const Matrix< Point_nD<T,N> >& , int , int , NurbsSurface<T,N>& , double=0);
29 // template <class T, int N> void wrapPointMatrix(const Matrix< Point_nD<T,N> >& Q, int , int, Matrix< Point_nD<T,N> >& Qw);
30 
38 //template <class T, int N>
39  class NurbsSurface {
40  public:
41  NurbsSurface();
42  NurbsSurface(const NurbsSurface& nS);
43 // NurbsSurface(int DegU, int DegV, const Vector<T>& Uk, const Vector<T>& Vk, const Matrix< HPoint_nD<T,N> >& Cp) ;
44 // NurbsSurface(int DegU, int DegV, Vector<T>& Uk, Vector<T>& Vk, Matrix< Point_nD<T,N> >& Cp, Matrix<T>& W) ;
45  virtual ~NurbsSurface()
46  {
47  ;
48  }
49 
50  public:
51  // Reference to internal data
52  const Vec& knotU() const
53  {
54  return U;
55  }
56  const Vec& knotV() const
57  {
58  return V;
59  }
60  double knotU(int i) const
61  {
62  return U(i);
63  }
64  double knotV(int i) const
65  {
66  return V(i);
67  }
68  const GeneralMatrix<Vec4>& ctrlPnts() const
69  {
70  return P;
71  }
72  const fmatvec::Vec4 ctrlPnts(int i, int j) const
73  {
74  return P(i, j);
75  }
76  int degreeU() const
77  {
78  return degU;
79  }
80  int degreeV() const
81  {
82  return degV;
83  }
84 
85  // Basic operators
86  virtual NurbsSurface& operator=(const NurbsSurface&);
87  void resize(int Pu, int Pv, int DegU, int DegV);
88 // virtual void resizeKeep(int Pu, int Pv, int DegU, int DegV) ;
89 // int ok();
90 
91  // Basis functions
92  fmatvec::HPoint<3> operator()(double u, double v) const;
93  fmatvec::Point<3> pointAt(double u, double v) const;
94 // void basisFuns(T u, T v, int spanU, int spanV, Vector<T>& Nu, Vector<T>& Nv) const ;
95 // void basisFunsU(T u, int span, Vector<T>& M) const ;
96 // void basisFunsV(T u, int span, Vector<T>& M) const ;
97 // void dersBasisFuns(T u, T v, int dU, int dV,int uspan, int vspan,Matrix<T> & Niku, Matrix<T>& Njkv ) const ;
98 
99  // Derivative functions
100  void deriveAt(double u, double v, int d, GeneralMatrix<Vec3> &skl) const;
101  void deriveAtH(double u, double v, int d, GeneralMatrix<Vec4> &skl) const;
102  Vec3 normal(double u, double v) const;
103 
104  // Surface fitting functions
105 
106  void globalInterp(const GeneralMatrix<fmatvec::Vec3>& Q, int DegU, int DegV);
107  void globalInterp(const GeneralMatrix<fmatvec::Vec3>& Q, const Vec& uk, const Vec& vk, int DegU, int DegV);
108  void globalInterpClosedU(const GeneralMatrix<fmatvec::Vec3>& Q, int DegU, int DegV);
109  void globalInterpClosedU(const GeneralMatrix<fmatvec::Vec3>& Q, const Vec& uk, const Vec& vk, int DegU, int DegV);
110 // void globalInterpClosedU(const Matrix< Point_nD<T,N> >& Q,const Vector<T> &Uk, const Vector<T> &Vk, const Vector<T> &uk, const Vector<T> &vk, int pU, int pV);//testing
111 // void globalInterpClosedUH(const Matrix< HPoint_nD<T,N> >& Q, int pU, int pV);
112 // void globalInterpClosedUH(const Matrix< HPoint_nD<T,N> >& Q,const Vector<T> &Uk, const Vector<T> &Vk, const Vector<T> &uk, const Vector<T> &vk, int pU, int pV);//testing
113 // void leastSquares(const Matrix< Point_nD<T,N> >& Q, int pU, int pV, int nU, int nV) ;
114 // void leastSquaresClosedU(const Matrix< Point_nD<T,N> >& Q, int pU, int pV, int nU, int nV) ;
115 //
116 //#ifndef HAVE_ISO_FRIEND_DECL
117 // friend void gordonSurface (NurbsCurveArray<T,N>& lU, NurbsCurveArray<T,N>& lV, const Matrix< Point_nD<T,N> >& intersections, NurbsSurface<T,N>& gS);
118 // friend void globalSurfInterpXY (const Matrix< Point_nD<T,N> >& Q, int pU, int pV, NurbsSurface<T,N>& S);
119 // friend void globalSurfInterpXY (const Matrix< Point_nD<T,N> >& Q, int pU, int pV, NurbsSurface<T,N>& S, const Vector<T>& uk, const Vector<T>& vk);
120 // friend void globalSurfApprox (const Matrix< Point_nD<T,N> >& Q, int pU, int pV, NurbsSurface<T,N>& S, double error);
121 //#else
122 // friend void gordonSurface <> (NurbsCurveArray<T,N>& lU, NurbsCurveArray<T,N>& lV, const Matrix< Point_nD<T,N> >& intersections, NurbsSurface<T,N>& gS);
123 // friend void globalSurfInterpXY <> (const Matrix< Point_nD<T,N> >& Q, int pU, int pV, NurbsSurface<T,N>& S);
124 // friend void globalSurfInterpXY <> (const Matrix< Point_nD<T,N> >& Q, int pU, int pV, NurbsSurface<T,N>& S, const Vector<T>& uk, const Vector<T>& vk);
125 // friend void globalSurfApprox <> (const Matrix< Point_nD<T,N> >& Q, int pU, int pV, NurbsSurface<T,N>& S, double error);
126 //#endif
127 //
128 // // Surface generation function
129 // int skinV(NurbsCurveArray<T,N>& ca, int degV);
130 // int skinU(NurbsCurveArray<T,N>& ca, int degU);
131 // void sweep(const NurbsCurve<T,N>& t, const NurbsCurve<T,N>& C, const NurbsCurve<T,N>& Sv, int K,int useAy=0, int invAz=0) ;
132 // void sweep(const NurbsCurve<T,N>& t, const NurbsCurve<T,N>& C, int K,int useAy=0, int invAz=0) ;
133 // void makeFromRevolution(const NurbsCurve<T,N>& profile, const Point_nD<T,N>& S, const Point_nD<T,N>& Z, double theta) ;
134 // void makeFromRevolution(const NurbsCurve<T,N>& profile, const Point_nD<T,N>& S, const Point_nD<T,N>& Z) ;
135 // void makeFromRevolution(const NurbsCurve<T,N>& profile) ;
136 //
137 // void makeSphere(const Point_nD<T,N>& O, T r) ;
138 // void makeTorus(const Point_nD<T,N>& O, T R, T r);
139 //
140 //
141 // void degreeElevate(int tU, int tV) ;
142 // virtual void degreeElevateU(int tU) ;
143 // virtual void degreeElevateV(int tV) ;
144 //
145 //
146 // int decompose(NurbsSurfaceArray<T,N>& Sa) const ;
147 //
148 //
149 //
150 // virtual void refineKnots(const Vector<T>& nU, const Vector<T>& nV) ;
151 // virtual void refineKnotU(const Vector<T>& X);
152 // virtual void refineKnotV(const Vector<T>& X);
153 //
154 // virtual void mergeKnots(const Vector<T>& nU, const Vector<T>& nV) ;
155 // virtual void mergeKnotU(const Vector<T>& X);
156 // virtual void mergeKnotV(const Vector<T>& X);
157 //
158 // // Measuring functions
159 // T area(T eps=0.001,int n=100) const ;
160 // T areaIn(T us, T ue, T vs, T ve, T eps, int n) const ;
161 // T areaF(T u, T v) const ;
162 //
163 // // special functions
164 // void isoCurveU(T u, NurbsCurve<T,N>& c) const ;
165 // void isoCurveV(T v, NurbsCurve<T,N>& c) const ;
166 //
167 // // I/O functions
168 // int read(const char* filename);
169 // int write(const char* filename) const;
170 // virtual int read(ifstream &fin) ;
171 // int write(ofstream &fout) const ;
172 // int writeVRML(const char* filename,const Color& color,int Nu,int Nv, T u_s, T u_e, T v_s, T v_e) const { return ParaSurface<T,N>::writeVRML(filename,color,Nu,Nv,u_s,u_e,v_s,v_e);}
173 // int writeVRML(ostream &fout,const Color& color,int Nu,int Nv, T u_s, T u_e, T v_s, T v_e) const { return ParaSurface<T,N>::writeVRML(fout,color,Nu,Nv,u_s,u_e,v_s,v_e);}
174 // int writeVRML97(const char* filename,const Color& color,int Nu,int Nv, T u_s, T u_e, T v_s, T v_e) const { return ParaSurface<T,N>::writeVRML97(filename,color,Nu,Nv,u_s,u_e,v_s,v_e);}
175 // int writeVRML97(ostream &fout,const Color& color,int Nu,int Nv, T u_s, T u_e, T v_s, T v_e) const { return ParaSurface<T,N>::writeVRML97(fout,color,Nu,Nv,u_s,u_e,v_s,v_e);}
176 // ostream& print(ostream& os) const ;
177 //
178 // int writeVRML(const char* filename,const Color& color=whiteColor,int Nu=20,int Nv=20) const //!< Calls the ParaSurface routine with proper values
179 // { return ParaSurface<T,N>::writeVRML(filename,color,Nu,Nv,U[0],U[U.n()-1],V[0],V[V.n()-1]); }
180 // int writeVRML(ostream& fout,const Color& color=whiteColor,int Nu=20,int Nv=20) const //!< Calls the ParaSurface routine with proper values
181 // { return ParaSurface<T,N>::writeVRML(fout,color,Nu,Nv,U[0],U[U.n()-1],V[0],V[V.n()-1]); }
182 //
183 // int writeVRML97(const char* filename,const Color& color=whiteColor,int Nu=20,int Nv=20) const //!< Calls the ParaSurface routine with proper values
184 // { return ParaSurface<T,N>::writeVRML97(filename,color,Nu,Nv,U[0],U[U.n()-1],V[0],V[V.n()-1]); }
185 // int writeVRML97(ostream& fout,const Color& color=whiteColor,int Nu=20,int Nv=20) const //!< Calls the ParaSurface routine with proper values
186 // { return ParaSurface<T,N>::writeVRML97(fout,color,Nu,Nv,U[0],U[U.n()-1],V[0],V[V.n()-1]); }
187 //
188 // int writePOVRAY(ostream& povray, int patch_type=1, double flatness=0.01, int num_u_steps=8, int num_v_steps=8) const ;
189 // int writePOVRAY(T, ostream& povray, const Color& color=Color(250,250,250),int smooth=0 , T ambient=0.2, T diffuse=0.6) const ;
190 // int writePOVRAY(const char *filename, const Color& color, const Point_nD<T,N>& view, const Point_nD<T,N>& up, int patch_type=1, double flatness=0.01, int num_u_steps=8, int num_v_steps=8) const ;
191 // int writePOVRAY(T tolerance, const char *filename, const Color& color, const Point_nD<T,N>& view, const Point_nD<T,N>& up, int smooth=0, T ambient=0.2, T diffuse=0.6) const ;
192 //
193 // int writeRIB(ostream& rib) const ;
194 // int writeRIB(char* filename, const Color& color, const Point_nD<T,N>& view) const ;
195 //
196 // // tesselate is deprecated...
197 // void tesselate(T tolerance, BasicList<Point_nD<T,N> > &points, BasicList<int> &connect, BasicList<Point_nD<T,N> > *normal=0) const ;
198 //
199 // int writePS(const char*, int nu, int nv, const Point_nD<T,N>& camera, const Point_nD<T,N>& lookAt, int cp=0,T magFact=T(-1),T dash=T(5)) const ;
200 // int writePSp(const char*, int nu, int nv, const Point_nD<T,N>& camera, const Point_nD<T,N>& lookAt, const Vector< Point_nD<T,N> >&,const Vector< Point_nD<T,N> >&, int cp=0,T magFact=0.0,T dash=5.0) const ;
201 // int writeOOGL(const char* filename, T fDu, T fDv,T fBu=0.0, T fBv=0.0, T fEu=1.0, T fEv=1.0, bool bDRawCP=false) const ;
202 // int writeOOGL(const char* filename) const ;
203 //
204 // int writeDisplayQUADMESH(const char* filename, int iNu=100,int iNv=100,const Color& color=blueColor,T fA=.25, T fO=0.2) const;
205 //
206 //
207 // // Modifies the shape of the surface
208 // void transform(const MatrixRT<T>& A) ;
209 // void modCP(int i, int j, const HPoint_nD<T,N>& p) //!< Modifies a control point
210 // { P(i,j) = p ; }
211 // void modCPby(int i, int j, const HPoint_nD<T,N>& p) //!< Modifies a control point
212 // { P(i,j) += p ; }
213 //
214 // T& modU(int i) { return U[i] ; }
215 // T modU(int i) const { return U[i]; } //!< modifies a knot
216 // T& modV(int i) { return V[i] ; } //!< modifies a knot
217 // T modV(int i) const { return V[i]; } //!< modifies a knot
218 //
219 // void modKnotU(const Vector<T>& uKnot) { if(P.rows()+degU+1==uKnot.n()) U=uKnot ; } //!< modifies the U knot vector if uKnot is of a proper size
220 // void modKnotV(const Vector<T>& vKnot) { if(P.cols()+degV+1==vKnot.n()) V=vKnot ; } //!< modifies the U knot vector if uKnot is of a proper size
221 //
222 // int movePoint(T u, T v, const Point_nD<T,N>& delta);
223 // int movePoint(const Vector<T>& ur, const Vector<T>& vr, const Vector< Point_nD<T,N> >& D, const Vector_INT& Du, const Vector_INT& Dv) ;
224 // int movePoint(const Vector<T>& ur, const Vector<T>& vr, const Vector< Point_nD<T,N> >& D, const Vector_INT& Du, const Vector_INT& Dv, const Vector_INT& Dk, const Vector_INT& Dl) ;
225 // int movePoint(const Vector<T>& ur, const Vector<T>& vr, const Vector< Point_nD<T,N> >& D, const Vector_INT& Du, const Vector_INT& Dv, const Vector_INT& Dk, const Vector_INT& Dl, const BasicArray<Coordinate>& fixCP) ;
226 //
227 // NurbsSurface<T,N>& transpose(void) ;
228 
229  protected:
233  int degU;
234  int degV;
235 
236  //changed
239 
240  // Knot functions
241  void findSpan(double u, double v, int spanU, int spanV) const;
242  int findSpanU(double u) const;
243  int findSpanV(double v) const;
244 
245  int findMultU(int r) const;
246  int findMultV(int r) const;
247 
248  };
249 
250 } // end namespace
251 
253 // */
254 //namespace PLib {
255 //
257 // \class NurbsSurfaceArray nurbsS.h
258 // \brief An array of NurbsSurface
259 //
260 // This class represents an array of NurbsSurface.
261 //
262 // \author Philippe Lavoie
263 // \date 4 Oct. 1996
264 //*/
265 //template <class T, int N>
266 //class NurbsSurfaceArray {
267 //public:
268 // int n() const //!< a reference to the size of the array
269 // { return sze ; }
270 // NurbsSurfaceArray(NurbsSurface<T,N>* Sa, int size) ;
271 // NurbsSurfaceArray() { S = 0 ; sze = 0 ; rsize = 0 ;} //<! Default constructor
272 // virtual ~NurbsSurfaceArray(){ if(S){ for(int i=0;i<rsize;i++) delete S[i]; delete []S ; }}
273 //
274 // virtual NurbsSurface<T,N>& operator[](int i)
275 // { return *(S[i]) ; } //!< the ith surface
276 // virtual NurbsSurface<T,N> operator[](int i) const
277 // { return *(S[i]) ; } //!< the ith surface
278 //
279 // virtual void resize(int s) ;
280 // void init(NurbsSurface<T,N>* Sa, int size) ;
281 //
282 // NurbsSurfaceArray<T,N>& operator=(const NurbsSurfaceArray<T,N>& Sa) ;
283 //
284 //protected:
285 // int sze ; //!< the number of NURBS curves in the array
286 // int rsize ; //!< the number of space allocated for the array
287 // NurbsSurface<T,N>** S ; //!< An array of pointers to NURBS curves
288 //};
289 //
290 //}//end namespace
291 //
293 //template <class T, int N>
294 //inline void degreeElevate(const PLib::NurbsSurface<T,N>& S, int tU, int tV, PLib::NurbsSurface<T,N>& nS) { nS = S ; nS.degreeElevate(tU,tV) ; }
295 //template <class T, int N>
296 //inline void degreeElevateU(const PLib::NurbsSurface<T,N>& S, int tU, PLib::NurbsSurface<T,N>& nS) { nS = S ; nS.degreeElevateU(tU) ; }
297 //template <class T, int N>
298 //inline void degreeElevateV(const PLib::NurbsSurface<T,N>& S, int tV, PLib::NurbsSurface<T,N>& nS) { nS = S ; nS.degreeElevateV(tV) ; }
299 //
300 //
301 //#ifdef INCLUDE_TEMPLATE_SOURCE
302 //#include "nurbsS.cpp"
303 //#endif
304 
305 #endif
double knotU(int i) const
&lt; Returns the i-th knot from U
Definition: nurbs_surface.h:60
int findSpanV(double v) const
finds the span in the V direction
Definition: nurbs_surface.cc:448
Vec3 normal(double u, double v) const
Computes the normal of the surface at (u,v)
Definition: nurbs_surface.cc:672
fmatvec::Vec U
the U knot vector
Definition: nurbs_surface.h:230
void globalInterpClosedU(const GeneralMatrix< fmatvec::Vec3 > &Q, int DegU, int DegV)
Generates a closed surface using global interpolation.
Definition: nurbs_surface.cc:214
virtual NurbsSurface & operator=(const NurbsSurface &)
NurbsSurface assignment.
Definition: nurbs_surface.cc:45
GeneralMatrix< fmatvec::Vec4 > P
The matrix of control points.
Definition: nurbs_surface.h:232
const Vec & knotV() const
&lt; A reference to the V knot vector
Definition: nurbs_surface.h:56
int degreeV() const
&lt; A reference to the degree in V of the surface
Definition: nurbs_surface.h:80
NurbsSurface()
Default constructor.
Definition: nurbs_surface.cc:25
wrapper class for nurbs type HPoint
Definition: nurbs_defs.h:43
A class to represent a NURBS surface.
Definition: nurbs_surface.h:39
void findSpan(double u, double v, int spanU, int spanV) const
Finds the multiplicity of a knot in the U knot.
Definition: nurbs_surface.cc:388
void deriveAt(double u, double v, int d, GeneralMatrix< Vec3 > &skl) const
Find the non-zero basis functions in the U and V direction.
Definition: nurbs_surface.cc:574
int degV
the degree of the surface in V
Definition: nurbs_surface.h:234
Mat InverseU
The matrix for the computation of the control points in U-direction.
Definition: nurbs_surface.h:237
fmatvec::Vec V
the V knot vector
Definition: nurbs_surface.h:231
void resize(int Pu, int Pv, int DegU, int DegV)
Resize the surface.
Definition: nurbs_surface.cc:70
wrapper class for nurbs type Point
Definition: nurbs_defs.h:13
fmatvec::HPoint< 3 > operator()(double u, double v) const
Returns the point on the surface at u,v.
Definition: nurbs_surface.cc:694
double knotV(int i) const
&lt; Returns the i-th knot from V
Definition: nurbs_surface.h:64
int degreeU() const
&lt; A reference to the degree in U of the surface
Definition: nurbs_surface.h:76
int findSpanU(double u) const
finds the span in the U direction
Definition: nurbs_surface.cc:410
void deriveAtH(double u, double v, int d, GeneralMatrix< Vec4 > &skl) const
computes the point and the derivatives of degree d and below at (u,v)
Definition: nurbs_surface.cc:623
const fmatvec::Vec4 ctrlPnts(int i, int j) const
&lt; A reference to the control point at (i,j)
Definition: nurbs_surface.h:72
int degU
the degree of the surface in U
Definition: nurbs_surface.h:233
fmatvec::Point< 3 > pointAt(double u, double v) const
Projects the point in the normal space.
Definition: nurbs_surface.cc:724
const Vec & knotU() const
&lt; A reference to the U knot vector
Definition: nurbs_surface.h:52
void globalInterp(const GeneralMatrix< fmatvec::Vec3 > &Q, int DegU, int DegV)
Generates a surface using global interpolation.
Definition: nurbs_surface.cc:89
Mat InverseV
The matrix for the computation of the control points in V-direction.
Definition: nurbs_surface.h:238
const GeneralMatrix< Vec4 > & ctrlPnts() const
&lt; A reference to the control points
Definition: nurbs_surface.h:68
wrapper class for nurbs surface interpolating data point
Definition: nurbs_defs.h:105

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Valid HTML