9 #include <Base/Math/Vector3.hh>
10 #include <Base/Math/Vector4.hh>
11 #include <Base/Geometry/HomgPoint2D.hh>
12 #include <Base/Geometry/HomgPoint3D.hh>
13 #include <Base/Math/Operators.hh>
15 #include "NurbsTemplateInit.hh"
23 template <
class ControlPo
intsT>
41 template <
class ControlPo
intsT>
44 BIASASSERT(nurbsParam[0] >= 0.0 && nurbsParam[0] <= 1.0 &&
45 nurbsParam[1] >= 0.0 && nurbsParam[1] <= 1.0)
51 double weightSum = 0.0;
54 GetRelevantBaseCtrlPoints(nurbsParam, relevantBegin, relevantEnd);
55 double* baseFuncCache =
new double[degree_+1];
59 for (
int x = relevantBegin[0]; x <= relevantEnd[0]; x++)
60 for (
int y = relevantBegin[1]; y <= relevantEnd[1]; y++){
61 double weight = BaseFunc(0,x,degree_,nurbsParam[0],baseFuncCache)*
62 BaseFunc(1,y,degree_,nurbsParam[1],baseFuncCache)*
66 result += (weight * controlPoints_[x][y]);
69 result = result * weightSum;
71 delete[] baseFuncCache;
77 template <
class ControlPo
intsT>
79 const ControlPointsT** controlPoints)
const{
85 double weightSum = 0.0;
88 GetRelevantBaseCtrlPoints(nurbsParam, relevantBegin, relevantEnd);
89 double* baseFuncCache =
new double[degree_+1];
93 for (
int x = relevantBegin[0]; x <= relevantEnd[0]; x++)
94 for (
int y = relevantBegin[1]; y <= relevantEnd[1]; y++){
95 double weight = BaseFunc(0,x,degree_,nurbsParam[0],baseFuncCache)*
96 BaseFunc(1,y,degree_,nurbsParam[1],baseFuncCache)*
100 result += (weight * controlPoints[x][y]);
104 if (weightSum != 0.0)
105 result = result * (1.0 / weightSum);
107 delete[] baseFuncCache;
110 template <
class ControlPo
intsT>
112 const ControlPointsT minY,
const ControlPointsT maxY){
113 for (
int x = 0; x < numCtrlPoints_; x++)
114 for (
int y = 0; y < numCtrlPoints_; y++){
115 double ratioX = (double)x/(
double)(numCtrlPoints_-1);
116 double ratioY = (double)y/(
double)(numCtrlPoints_-1);
117 controlPoints_[x][y] = ratioX * maxX + (1.0 - ratioX) * minX
118 + ratioY * maxY + (1.0 - ratioY) * minY;
double ** weights_
The corresponding weights to the function points.
void EvalCustom(const BIAS::Vector2< double > &nurbsParam, ControlPointsT &result, const ControlPointsT **controlPoints) const
Evaluate the NURBS function at a given point in the parameter space for a certain control point vecto...
void Eval(const BIAS::Vector2< double > &nurbsParam, ControlPointsT &result) const
Evaluate the NURBS function at a given point in the parameter space.
ControlPointsT ** controlPoints_
The array of control points.
static void Init(double &value)
This class implements a NURBS-function with a two dimensional parameter space (A NURBS surface)...
Base class for NURBS classes.
void Init(const ControlPointsT minX, const ControlPointsT maxX, const ControlPointsT minY, const ControlPointsT maxY)
Very generic initialization function for the control points.
int numCtrlPoints_
The number of control points per dimension.