vtkKochanekSpline.h 3.43 KB
Newer Older
Bill Lorensen's avatar
Bill Lorensen committed
1 2 3 4 5
/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkKochanekSpline.h

6
  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 8
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
Bill Lorensen's avatar
Bill Lorensen committed
9

10 11
     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12
     PURPOSE.  See the above copyright notice for more information.
Bill Lorensen's avatar
Bill Lorensen committed
13 14 15 16

=========================================================================*/
// .NAME vtkKochanekSpline - computes an interpolating spline using a Kochanek basis.
// .SECTION Description
17
// Implements the Kochanek interpolating spline described in: Kochanek, D.,
Ken Martin's avatar
Ken Martin committed
18 19 20 21 22
// Bartels, R., "Interpolating Splines with Local Tension, Continuity, and
// Bias Control," Computer Graphics, vol. 18, no. 3, pp. 33-41, July 1984.
// These splines give the user more control over the shape of the curve than
// the cardinal splines implemented in vtkCardinalSpline. Three parameters
// can be specified. All have a range from -1 to 1.
23
//
Bill Lorensen's avatar
Bill Lorensen committed
24
// Tension controls how sharply the curve bends at an input point. A
Bill Lorensen's avatar
Bill Lorensen committed
25
// value of -1 produces more slack in the curve. A value of 1 tightens
Bill Lorensen's avatar
Bill Lorensen committed
26
// the curve.
27
//
Bill Lorensen's avatar
Bill Lorensen committed
28
// Continuity controls the continuity of the first derivative at input
29 30
// points.
//
Bill Lorensen's avatar
Bill Lorensen committed
31
// Bias controls the direction of the curve at it passes through an input
Bill Lorensen's avatar
Bill Lorensen committed
32 33
// point. A value of -1 undershoots the point while a value of 1
// overshoots the point.
34
//
Bill Lorensen's avatar
Bill Lorensen committed
35 36
// These three parameters give the user broad control over the shape of
// the interpolating spline. The original Kochanek paper describes the
37
// effects nicely and is recommended reading.
Ken Martin's avatar
Ken Martin committed
38

Bill Lorensen's avatar
Bill Lorensen committed
39
// .SECTION See Also
40
// vtkSpline vtkCardinalSpline
Bill Lorensen's avatar
Bill Lorensen committed
41 42


43 44
#ifndef vtkKochanekSpline_h
#define vtkKochanekSpline_h
Bill Lorensen's avatar
Bill Lorensen committed
45

46
#include "vtkCommonComputationalGeometryModule.h" // For export macro
Bill Lorensen's avatar
Bill Lorensen committed
47 48
#include "vtkSpline.h"

49
class VTKCOMMONCOMPUTATIONALGEOMETRY_EXPORT vtkKochanekSpline : public vtkSpline
Bill Lorensen's avatar
Bill Lorensen committed
50 51
{
public:
52
  vtkTypeMacro(vtkKochanekSpline,vtkSpline);
53
  void PrintSelf(ostream& os, vtkIndent indent);
Bill Lorensen's avatar
Bill Lorensen committed
54

Ken Martin's avatar
Ken Martin committed
55
  // Description:
Bill Lorensen's avatar
Bill Lorensen committed
56
  // Construct a KochanekSpline with the following defaults: DefaultBias = 0,
Ken Martin's avatar
Ken Martin committed
57
  // DefaultTension = 0, DefaultContinuity = 0.
58
  static vtkKochanekSpline *New();
59

Ken Martin's avatar
Ken Martin committed
60 61
  // Description:
  // Compute Kochanek Spline coefficients.
Bill Lorensen's avatar
Bill Lorensen committed
62
  void Compute ();
63

64 65
  // Description:
  // Evaluate a 1D Kochanek spline.
Ken Martin's avatar
Ken Martin committed
66
  double Evaluate (double t);
67

Bill Lorensen's avatar
Bill Lorensen committed
68 69
  // Description:
  // Set the bias for all points. Default is 0.
Ken Martin's avatar
Ken Martin committed
70 71
  vtkSetMacro(DefaultBias,double);
  vtkGetMacro(DefaultBias,double);
Bill Lorensen's avatar
Bill Lorensen committed
72 73 74

  // Description:
  // Set the tension for all points. Default is 0.
Ken Martin's avatar
Ken Martin committed
75 76
  vtkSetMacro(DefaultTension,double);
  vtkGetMacro(DefaultTension,double);
Bill Lorensen's avatar
Bill Lorensen committed
77 78 79

  // Description:
  // Set the continuity for all points. Default is 0.
Ken Martin's avatar
Ken Martin committed
80 81
  vtkSetMacro(DefaultContinuity,double);
  vtkGetMacro(DefaultContinuity,double);
Bill Lorensen's avatar
Bill Lorensen committed
82

83 84 85 86
  // Description:
  // Deep copy of cardinal spline data.
  virtual void DeepCopy(vtkSpline *s);

Bill Lorensen's avatar
Bill Lorensen committed
87
protected:
88
  vtkKochanekSpline();
89 90
  ~vtkKochanekSpline() {}

91 92
  void Fit1D (int n, double *x, double *y, double tension, double bias,
              double continuity, double coefficients[][4], int leftConstraint,
Ken Martin's avatar
Ken Martin committed
93
              double leftValue, int rightConstraint, double rightValue);
94

Ken Martin's avatar
Ken Martin committed
95 96 97
  double DefaultBias;
  double DefaultTension;
  double DefaultContinuity;
98

99
private:
100
  vtkKochanekSpline(const vtkKochanekSpline&) VTK_DELETE_FUNCTION;
101
  void operator=(const vtkKochanekSpline&) VTK_DELETE_FUNCTION;
Bill Lorensen's avatar
Bill Lorensen committed
102 103 104 105
};

#endif