mbsim  4.0.0
MBSim Kernel
MBSim::NurbsSurface Class Reference

A class to represent a NURBS surface. More...

Public Types

enum  Method { equallySpaced = 0 , chordLength }
 

Public Member Functions

 NurbsSurface ()
 default constructor
 
 NurbsSurface (const NurbsSurface &nS)
 copy constructor
 
 NurbsSurface (int DegU, int DegV, const fmatvec::VecV &Uk, const fmatvec::VecV &Vk, fmatvec::GeneralMatrix< fmatvec::Vec4 > &Q)
 constructor
 
virtual ~NurbsSurface ()=default
 Empty desctructor.
 
const fmatvec::VecV & knotU () const
 A reference to the U knot vector.
 
const fmatvec::VecV & knotV () const
 A reference to the V knot vector.
 
double knotU (int i) const
 Returns the i-th knot from U.
 
double knotV (int i) const
 Returns the i-th knot from V.
 
const fmatvec::GeneralMatrix< fmatvec::Vec4 > & ctrlPnts () const
 A reference to the control points.
 
const fmatvec::Vec4 ctrlPnts (int i, int j) const
 A reference to the control point at (i,j)
 
int degreeU () const
 A reference to the degree in U of the surface.
 
int degreeV () const
 A reference to the degree in V of the surface.
 
void setKnotU (const fmatvec::VecV &U_)
 
void setKnotV (const fmatvec::VecV &V_)
 
void setCtrlPnts (const fmatvec::GeneralMatrix< fmatvec::Vec4 > &P_)
 
void setDegreeU (int degU_)
 
void setDegreeV (int degV_)
 
virtual NurbsSurfaceoperator= (const NurbsSurface &)
 NurbsSurface assignment. More...
 
void resize (int Pu, int Pv, int DegU, int DegV)
 Resize the surface. More...
 
fmatvec::HPoint< 3 > operator() (double u, double v) const
 Returns the point on the surface at u,v. More...
 
fmatvec::Point< 3 > pointAt (double u, double v) const
 rojects the point in the normal space More...
 
void deriveAt (double u, double v, int d, fmatvec::GeneralMatrix< fmatvec::Vec3 > &skl) const
 Find the non-zero basis functions in the U and V direction. More...
 
void deriveAtH (double u, double v, int d, fmatvec::GeneralMatrix< fmatvec::Vec4 > &skl) const
 computes the point and the derivatives of degree d and below at (u,v) More...
 
fmatvec::Vec3 normal (double u, double v) const
 Computes the normal of the surface at (u,v) More...
 
void globalInterp (const fmatvec::GeneralMatrix< fmatvec::Vec3 > &Q, int DegU, int DegV)
 
void globalInterp (const fmatvec::GeneralMatrix< fmatvec::Vec3 > &Q, const fmatvec::VecV &uk, const fmatvec::VecV &vk, int DegU, int DegV)
 
void globalInterpClosedU (const fmatvec::GeneralMatrix< fmatvec::Vec3 > &Q, int DegU, int DegV)
 
void globalInterpClosedU (const fmatvec::GeneralMatrix< fmatvec::Vec3 > &Q, const fmatvec::VecV &uk, const fmatvec::VecV &vk, int DegU, int DegV)
 
void globalInterpH (const fmatvec::GeneralMatrix< fmatvec::Vec4 > &Q, int DegU, int DegV, Method method=chordLength)
 
void globalInterpClosedUH (const fmatvec::GeneralMatrix< fmatvec::Vec4 > &Q, int DegU, int DegV, Method method=chordLength)
 

Protected Member Functions

void findSpan (double u, double v, int spanU, int spanV) const
 Finds the multiplicity of a knot in the U knot. More...
 
int findSpanU (double u) const
 finds the span in the U direction More...
 
int findSpanV (double v) const
 finds the span in the V direction More...
 
int findMultU (int r) const
 
int findMultV (int r) const
 

Protected Attributes

fmatvec::VecV U
 the U knot vector
 
fmatvec::VecV V
 the V knot vector
 
fmatvec::GeneralMatrix< fmatvec::Vec4 > P
 The matrix of control points.
 
int degU {0}
 the degree of the surface in U
 
int degV {0}
 the degree of the surface in V
 
fmatvec::Mat InverseU
 The matrix for the computation of the control points in U-direction.
 
fmatvec::Mat InverseV
 The matrix for the computation of the control points in V-direction.
 

Related Functions

(Note that these are not member functions.)

int surfMeshParams (const GeneralMatrix< fmatvec::Vec3 > &Q, VecV &uk, VecV &vl)
 Computes the parameters for global surface interpolation. More...
 

Detailed Description

A class to represent a NURBS surface.

The NURBS surface is composed of points in homogenous space. It can have any degree in both the u and the v direction.

Member Function Documentation

◆ deriveAt()

void MBSim::NurbsSurface::deriveAt ( double  u,
double  v,
int  d,
fmatvec::GeneralMatrix< fmatvec::Vec3 > &  skl 
) const

Find the non-zero basis functions in the U and V direction.

Parameters
uthe u parametric value
vthe v parametric value
spanUthe span of u
spanVthe span of v
Nuthe vector containing the U non-zero basis functions
Nvthe vector containing the V non-zero basis functions
Author
Philippe Lavoie
Date
24 January, 1997

Finds the non-zero basis function in the U direction

Parameters
uthe u parametric value
spanthe span of u
Nthe vector containing the basis functions
Author
Philippe Lavoie
Date
24 January, 1997 ‍/ template <class T, int nD> void NurbsSurface<T,nD>::basisFunsU(T u, int span, Vector<T>& N) const { //Vector<T> left(degU+1), right(degU+1) ; vector<T> left(degU+1) ; vector<T> right(degU+1) ; T temp,saved ;

N.resize(degU+1) ;

N(0] = 1.0 ; for(int j=1; j<= degU ; j++){ left[j] = u-U[span+1-j] ; right[j] = U[span+j]-u ; saved = 0.0 ; for(int r=0 ; r<j; r++){ temp = N[r]/(right[r+1]+left[j-r]) ; N[r] = saved+right[r+1]*temp ; saved = left[j-r]*temp ; } N[j] = saved ; }

}

/*!

Finds the non-zero basis function in the V direction

Parameters
vthe v parametric value
spanthe span of v
Nthe vector containing the basis functions
Author
Philippe Lavoie
Date
24 January, 1997 ‍/ template <class T, int nD> void NurbsSurface<T,nD>::basisFunsV(T v, int span, Vector<T>& N) const { //Vector<T> left(degV+1), right(degV+1) ; vector<T> left(degV+1) ; vector<T> right(degV+1) ; T temp,saved ;

N.resize(degV+1) ;

N[0] = 1.0 ; for(int j=1; j<= degV ; j++){ left[j] = v-V[span+1-j] ; right[j] = V[span+j]-v ; saved = 0.0 ; for(int r=0 ; r<j; r++){ temp = N[r]/(right[r+1]+left[j-r]) ; N[r] = saved+right[r+1]*temp ; saved = left[j-r]*temp ; } N[j] = saved ; }

} /*!

Computes the point and the derivatives of degree d and below at (u,v)

Computes the matrix of derivatives at u,v . The value of skl(k,l) represents the derivative of the surface S(u,v) with respect to u, k times and to v, l times.

Parameters
uthe u parametric value
vthe v parametric value
dthe derivative is computed up to and including to this value
sklthe matrix containing the derivatives
Author
Philippe Lavoie
Date
24 January, 1997

◆ deriveAtH()

void MBSim::NurbsSurface::deriveAtH ( double  u,
double  v,
int  d,
fmatvec::GeneralMatrix< fmatvec::Vec4 > &  skl 
) const

computes the point and the derivatives of degree d and below at (u,v)

Computes the matrix of derivatives at u,v . The value of skl(k,l) represents the derivative of the surface S(u,v) with respect to u k times and to $v$ $l$ times.

Parameters
uthe u parametric value
vthe v parametric value
dthe derivative is computed up to and including to this value
sklthe matrix containing the derivatives
Author
Philippe Lavoie
Date
24 January, 1997

◆ findSpan()

void MBSim::NurbsSurface::findSpan ( double  u,
double  v,
int  spanU,
int  spanV 
) const
protected

Finds the multiplicity of a knot in the U knot.

Parameters
rthe knot to observe
Returns
the multiplicity of the knot
Warning
r must be a valid U knot index
Author
Philippe Lavoie
Date
24 January, 1997

finds the multiplicity of a knot in the V knot

Parameters
rthe knot to observe
Returns
the multiplicity of the V knot
Warning
r must be a valid knot index
Author
Philippe Lavoie
Date
24 January, 1997

finds the span in the U and V direction

Finds the span in the U and V direction. The spanU is the index k for which the parameter u is valid in the [u_k,u_{k+1}] range. The spanV is the index k for which the parameter v is valid in the [v_k,v_{k+1}] range.

Parameters
ufind the U span for this parametric value
vfind the V span for this parametric value
spanUthe U span
spanVthe V span
Author
Philippe Lavoie
Date
24 January, 1997

◆ findSpanU()

int MBSim::NurbsSurface::findSpanU ( double  u) const
protected

finds the span in the U direction

Finds the span in the U direction. The span is the index k for which the parameter u is valid in the [u_k,u_{k+1}] range.

Parameters
u--> find the span for this parametric value
Returns
the span for u
Author
Philippe Lavoie
Date
24 January, 1997

\modified 20 January, 1999 (Alejandro Frangi)

◆ findSpanV()

int MBSim::NurbsSurface::findSpanV ( double  v) const
protected

finds the span in the V direction

Finds the span in the V direction. The span is the index k for which the parameter v is valid in the [v_k,v_{k+1}] range.

Parameters
vfind the span for this parametric value
Returns
the span for v
Author
Philippe Lavoie
Date
24 January, 1997 \modified 20 January, 1999 (Alejandro Frangi)

◆ normal()

Vec3 MBSim::NurbsSurface::normal ( double  u,
double  v 
) const

Computes the normal of the surface at (u,v)

Parameters
uthe u parametric value
vthe v parametric value
Returns
the normal at (u,v) .
Author
Philippe Lavoie
Date
24 January, 1997

◆ operator()()

fmatvec::HPoint< 3 > MBSim::NurbsSurface::operator() ( double  u,
double  v 
) const

Returns the point on the surface at u,v.

Returns the point on the surface at u,v

Parameters
uthe u parametric value
vthe v parametric value
Returns
The homogenous point at u,v
Author
Philippe Lavoie
Date
24 January, 1997

◆ operator=()

NurbsSurface & MBSim::NurbsSurface::operator= ( const NurbsSurface nS)
virtual

NurbsSurface assignment.

Parameters
nSthe NURBS surface to copy
Author
Philippe Lavoie
Date
24 January, 1997

◆ pointAt()

fmatvec::Point< 3 > MBSim::NurbsSurface::pointAt ( double  u,
double  v 
) const

rojects the point in the normal space

Projects the point in the normal space.

◆ resize()

void MBSim::NurbsSurface::resize ( int  Pu,
int  Pv,
int  DegU,
int  DegV 
)

Resize the surface.

Resize the surface. Proper values must be assigned once this function has been called since the resize operator is destructive.

Parameters
Puthe number of control points in the U direction
Pvthe number of control points in the V direction
DegUthe degree of the surface in the U direction
DegVthe degree of the surface in the V direction
Author
Philippe Lavoie
Date
24 January, 1997

Friends And Related Function Documentation

◆ surfMeshParams()

int surfMeshParams ( const GeneralMatrix< fmatvec::Vec3 > &  Q,
VecV &  uk,
VecV &  vl 
)
related

Computes the parameters for global surface interpolation.

Computes the parameters for global surface interpolation. For more information, see A9.3 on p377 on the NURBS book.

Parameters
Qthe matrix of 3D points
ukthe knot coefficients in the U direction
vlthe knot coefficients in the V direction
Returns
0 if an error occurs, 1 otherwise
Warning
Author
Philippe Lavoie
Date
24 January, 1997

The documentation for this class was generated from the following files: