9 #include <Base/Math/Vector2.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>
40 double xSphere = ((double)x/((
double)numCtrlPoints_-1.0) - 0.5) * 2.0;
41 double ySphere = ((double)y/((
double)numCtrlPoints_-1.0) - 0.5) * 2.0;
42 double zSphere = ((double)z/((
double)numCtrlPoints_-1.0) - 0.5) * 2.0;
45 prm[0] = (prm[0] + 1.0) / 2.0;
46 prm[1] = (prm[1] + 1.0) / 2.0;
47 prm[2] = (prm[2] + 1.0) / 2.0;
60 template <
class ControlPo
intsT>
62 for (
int x = 0; x < numCtrlPoints_; x++){
63 for (
int y = 0; y < numCtrlPoints_; y++){
64 delete[] controlPoints_[x][y];
65 delete[] weights_[x][y];
67 delete[] controlPoints_[x];
70 delete[] controlPoints_;
77 template <
class ControlPo
intsT>
80 BIASASSERT(nurbsParam[0] >= 0.0 && nurbsParam[0] <= 1.0 &&
81 nurbsParam[1] >= 0.0 && nurbsParam[1] <= 1.0 &&
82 nurbsParam[2] >= 0.0 && nurbsParam[2] <= 1.0)
88 double weightSum = 0.0;
91 GetRelevantBaseCtrlPoints(nurbsParam, relevantBegin, relevantEnd);
92 double* baseFuncCache =
new double[degree_+1];
96 for (
int x = relevantBegin[0]; x <= relevantEnd[0]; x++)
97 for (
int y = relevantBegin[1]; y <= relevantEnd[1]; y++)
98 for (
int z = relevantBegin[2]; z <= relevantEnd[2]; z++){
99 double weight = (BaseFunc(0,x,degree_,nurbsParam[0],baseFuncCache)*
100 BaseFunc(1,y,degree_,nurbsParam[1],baseFuncCache)*
101 BaseFunc(2,z,degree_,nurbsParam[2],baseFuncCache))*
105 result += (weight * controlPoints_[x][y][z]);
108 if (weightSum != 0.0)
109 result = result * (1.0 / weightSum);
111 delete[] baseFuncCache;
114 template <
class ControlPo
intsT>
116 const ControlPointsT minY,
const ControlPointsT maxY,
117 const ControlPointsT minZ,
const ControlPointsT maxZ){
118 for (
int x = 0; x < numCtrlPoints_; x++)
119 for (
int y = 0; y < numCtrlPoints_; y++)
120 for (
int z = 0; z < numCtrlPoints_; z++){
121 double ratioX = (double)x/(
double)(numCtrlPoints_-1);
122 double ratioY = (double)y/(
double)(numCtrlPoints_-1);
123 double ratioZ = (double)z/(
double)(numCtrlPoints_-1);
124 controlPoints_[x][y][z] = ratioX * maxX + (1.0 - ratioX) * minX
125 + ratioY * maxY + (1.0 - ratioY) * minY
126 + ratioZ * maxZ + (1.0 - ratioZ) * minZ;
double Length() const
returns the Euclidean Length of the Vector
static void Init(double &value)
ControlPointsT *** controlPoints_
The array of control points.
void Init(const ControlPointsT minX, const ControlPointsT maxX, const ControlPointsT minY, const ControlPointsT maxY, const ControlPointsT minZ, const ControlPointsT maxZ)
Very generic initialization function for the control points.
std::vector< BIAS::Vector3< int > > sphereCtrlPoints_
A vector containing the control points in the vicinity of the hyper sphere.
Base class for NURBS classes.
This class implements a NURBS-function with a three dimensional parameter space (A NURBS volume)...
void Eval(const BIAS::Vector3< double > &nurbsParam, ControlPointsT &result) const
Evaluate the NURBS function at a given point in the parameter space.
void EvalBaseFunc(const int x, const int y, const int z, const BIAS::Vector3< double > &nurbsParam, double &result) const
Evaluate the base function for the control point (x,y,z) for the point nurbsParam.
Vector3< T > & Normalize()
normalize this vector to length 1
int numCtrlPoints_
The number of control points per dimension.
double *** weights_
The corresponding weights to the function points.