Commit bd654d44 by Bill Lorensen

### ERR: Evaluate method needed to be different for each spline

parent b6f6f366
 ... ... @@ -48,6 +48,45 @@ vtkCardinalSpline::vtkCardinalSpline () { } // Description // Evaluate a 1D Spline float vtkCardinalSpline::Evaluate (float t) { int i, index; int size = this->PiecewiseFunction->GetSize (); float *intervals; float *coefficients; // check to see if we need to recompute the spline if (this->ComputeTime < this->GetMTime ()) { this->Compute (); } intervals = this->Intervals; coefficients = this->Coefficients; // clamp the function at both ends if (t < intervals[0]) t = intervals[0]; if (t > intervals[size - 1]) t = intervals[size - 1]; // find pointer to cubic spline coefficient for (i = 1; i < size; i++) { index = i - 1; if (t < intervals[i]) break; } // calculate offset within interval t = (t - intervals[index]); // evaluate y return (t * (t * (t * *(coefficients + index * 4 + 3) + *(coefficients + index * 4 + 2)) + *(coefficients + index * 4 + 1)) + *(coefficients + index * 4)); } // Description // Compute Cardinal Splines for each dependent variable void vtkCardinalSpline::Compute () ... ...
 ... ... @@ -61,6 +61,10 @@ public: void Compute (); // Description: // Evaluate a 1D cardinal spline. float Evaluate (float t); protected: void Fit1D (int n, float *x, float *y, float *w, float coefficients[][4], int leftConstraint, float leftValue, int rightConstraint, float rightValue); ... ...
 ... ... @@ -53,6 +53,45 @@ vtkKochanekSpline::vtkKochanekSpline () this->DefaultContinuity = 0.0; } // Description // Evaluate a 1D Spline float vtkKochanekSpline::Evaluate (float t) { int i, index; int size = this->PiecewiseFunction->GetSize (); float *intervals; float *coefficients; // check to see if we need to recompute the spline if (this->ComputeTime < this->GetMTime ()) { this->Compute (); } intervals = this->Intervals; coefficients = this->Coefficients; // clamp the function at both ends if (t < intervals[0]) t = intervals[0]; if (t > intervals[size - 1]) t = intervals[size - 1]; // find pointer to cubic spline coefficient for (i = 1; i < size; i++) { index = i - 1; if (t < intervals[i]) break; } // calculate offset within interval t = (t - intervals[index]) / (intervals[index+1] - intervals[index]); // evaluate y return (t * (t * (t * *(coefficients + index * 4 + 3) + *(coefficients + index * 4 + 2)) + *(coefficients + index * 4 + 1)) + *(coefficients + index * 4)); } // Description: // Compute Kochanek Spline coefficients. void vtkKochanekSpline::Compute () ... ... @@ -154,8 +193,9 @@ void vtkKochanekSpline::Fit1D (int size, float *x, float *y, // adjust deriviatives for non uniform spacing between nodes n1 = x[i+1] - x[i]; n0 = x[i] - x[i-1]; ds *= (2 * n1 / (n0 + n1)); dd *= (2 * n0 / (n0 + n1)); ds *= (2 * n0 / (n0 + n1)); dd *= (2 * n1 / (n0 + n1)); coefficients[i][0] = y[i]; coefficients[i][1] = dd; ... ...
 ... ... @@ -82,6 +82,10 @@ public: void Compute (); // Description: // Evaluate a 1D Kochanek spline. float Evaluate (float t); // Description: // Set the bias for all points. Default is 0. vtkSetMacro(DefaultBias,float); ... ...
 ... ... @@ -78,45 +78,6 @@ void vtkSpline::RemoveAllPoints () this->PiecewiseFunction->RemoveAllPoints (); } // Description // Evaluate a 1D Spline float vtkSpline::Evaluate (float t) { int i, index; int size = this->PiecewiseFunction->GetSize (); float *intervals; float *coefficients; // check to see if we need to recompute the spline if (this->ComputeTime < this->GetMTime ()) { this->Compute (); } intervals = this->Intervals; coefficients = this->Coefficients; // clamp the function at both ends if (t < intervals[0]) t = intervals[0]; if (t > intervals[size - 1]) t = intervals[size - 1]; // find pointer to cubic spline coefficient for (i = 1; i < size; i++) { index = i - 1; if (t < intervals[i]) break; } // calculate offset within interval t = (t - intervals[index]) / (intervals[index+1] - intervals[index]); // evaluate y return (t * (t * (t * *(coefficients + index * 4 + 3) + *(coefficients + index * 4 + 2)) + *(coefficients + index * 4 + 1)) + *(coefficients + index * 4)); } // Description: // Overload standard modified time function. If data is modified, // then this object is modified as well. ... ...
 ... ... @@ -68,10 +68,6 @@ public: vtkGetMacro(ClampValue,int); vtkBooleanMacro(ClampValue,int); // Description: // Evaluate a 1D spline. float Evaluate (float t); // Description: // Compute the coefficients for the spline. virtual void Compute () = 0; ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!