File: vtkSplineFilter.h

package info (click to toggle)
vtk7 7.1.1%2Bdfsg1-12
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 125,776 kB
  • sloc: cpp: 1,539,582; ansic: 106,521; python: 78,038; tcl: 47,013; xml: 8,142; yacc: 5,040; java: 4,439; perl: 3,132; lex: 1,926; sh: 1,500; makefile: 122; objc: 83
file content (188 lines) | stat: -rw-r--r-- 6,345 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkSplineFilter.h

  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/
/**
 * @class   vtkSplineFilter
 * @brief   generate uniformly subdivided polylines from a set of input polyline using a vtkSpline
 *
 * vtkSplineFilter is a filter that generates an output polylines from an
 * input set of polylines. The polylines are uniformly subdivided and produced
 * with the help of a vtkSpline class that the user can specify (by default a
 * vtkCardinalSpline is used). The number of subdivisions of the line can be
 * controlled in several ways. The user can either specify the number of
 * subdivisions or a length of each subdivision can be provided (and the
 * class will figure out how many subdivisions is required over the whole
 * polyline). The maximum number of subdivisions can also be set.
 *
 * The output of this filter is a polyline per input polyline (or line). New
 * points and texture coordinates are created. Point data is interpolated and
 * cell data passed on. Any polylines with less than two points, or who have
 * coincident points, are ignored.
 *
 * @sa
 * vtkRibbonFilter vtkTubeFilter
*/

#ifndef vtkSplineFilter_h
#define vtkSplineFilter_h

#include "vtkFiltersGeneralModule.h" // For export macro
#include "vtkPolyDataAlgorithm.h"

#define VTK_SUBDIVIDE_SPECIFIED 0
#define VTK_SUBDIVIDE_LENGTH    1

#define VTK_TCOORDS_OFF                    0
#define VTK_TCOORDS_FROM_NORMALIZED_LENGTH 1
#define VTK_TCOORDS_FROM_LENGTH            2
#define VTK_TCOORDS_FROM_SCALARS           3

class vtkCellArray;
class vtkCellData;
class vtkFloatArray;
class vtkPointData;
class vtkPoints;
class vtkSpline;

class VTKFILTERSGENERAL_EXPORT vtkSplineFilter : public vtkPolyDataAlgorithm
{
public:
  vtkTypeMacro(vtkSplineFilter,vtkPolyDataAlgorithm);
  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;

  /**
   * Construct the class with no limit on the number of subdivisions
   * and using an instance of vtkCardinalSpline to perform interpolation.
   */
  static vtkSplineFilter *New();

  //@{
  /**
   * Set the maximum number of subdivisions that are created for each
   * polyline.
   */
  vtkSetClampMacro(MaximumNumberOfSubdivisions,int,1,VTK_INT_MAX);
  vtkGetMacro(MaximumNumberOfSubdivisions,int);
  //@}

  //@{
  /**
   * Specify how the number of subdivisions is determined.
   */
  vtkSetClampMacro(Subdivide,int,VTK_SUBDIVIDE_SPECIFIED,VTK_SUBDIVIDE_LENGTH);
  vtkGetMacro(Subdivide,int);
  void SetSubdivideToSpecified()
    {this->SetSubdivide(VTK_SUBDIVIDE_SPECIFIED);}
  void SetSubdivideToLength()
    {this->SetSubdivide(VTK_SUBDIVIDE_LENGTH);}
  const char *GetSubdivideAsString();
  //@}

  //@{
  /**
   * Set the number of subdivisions that are created for the
   * polyline. This method only has effect if Subdivisions is set
   * to SetSubdivisionsToSpecify().
   */
  vtkSetClampMacro(NumberOfSubdivisions,int,1,VTK_INT_MAX);
  vtkGetMacro(NumberOfSubdivisions,int);
  //@}

  //@{
  /**
   * Control the number of subdivisions that are created for the
   * polyline based on an absolute length. The length of the spline
   * is divided by this length to determine the number of subdivisions.
   */
  vtkSetClampMacro(Length,double,0.0000001,VTK_DOUBLE_MAX);
  vtkGetMacro(Length,double);
  //@}

  //@{
  /**
   * Specify an instance of vtkSpline to use to perform the interpolation.
   */
  virtual void SetSpline(vtkSpline*);
  vtkGetObjectMacro(Spline,vtkSpline);
  //@}

  //@{
  /**
   * Control whether and how texture coordinates are produced. This is
   * useful for striping the output polyline. The texture coordinates
   * can be generated in three ways: a normalized (0,1) generation;
   * based on the length (divided by the texture length); and by using
   * the input scalar values.
   */
  vtkSetClampMacro(GenerateTCoords,int,VTK_TCOORDS_OFF,
                   VTK_TCOORDS_FROM_SCALARS);
  vtkGetMacro(GenerateTCoords,int);
  void SetGenerateTCoordsToOff()
    {this->SetGenerateTCoords(VTK_TCOORDS_OFF);}
  void SetGenerateTCoordsToNormalizedLength()
    {this->SetGenerateTCoords(VTK_TCOORDS_FROM_NORMALIZED_LENGTH);}
  void SetGenerateTCoordsToUseLength()
    {this->SetGenerateTCoords(VTK_TCOORDS_FROM_LENGTH);}
  void SetGenerateTCoordsToUseScalars()
    {this->SetGenerateTCoords(VTK_TCOORDS_FROM_SCALARS);}
  const char *GetGenerateTCoordsAsString();
  //@}

  //@{
  /**
   * Control the conversion of units during the texture coordinates
   * calculation. The TextureLength indicates what length (whether
   * calculated from scalars or length) is mapped to the [0,1)
   * texture space.
   */
  vtkSetClampMacro(TextureLength,double,0.000001,VTK_INT_MAX);
  vtkGetMacro(TextureLength,double);
  //@}

protected:
  vtkSplineFilter();
  ~vtkSplineFilter() VTK_OVERRIDE;

  // Usual data generation method
  int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) VTK_OVERRIDE;

  int       MaximumNumberOfSubdivisions;
  int       Subdivide;
  int       NumberOfSubdivisions;
  double     Length;
  vtkSpline *Spline;
  vtkSpline *XSpline;
  vtkSpline *YSpline;
  vtkSpline *ZSpline;
  int       GenerateTCoords;
  double     TextureLength; //this length is mapped to [0,1) texture space

  //helper methods
  int GeneratePoints(vtkIdType offset, vtkIdType npts, vtkIdType *pts,
                     vtkPoints *inPts, vtkPoints *newPts, vtkPointData *pd,
                     vtkPointData *outPD, int genTCoords,
                     vtkFloatArray *newTCoords);

  void GenerateLine(vtkIdType offset, vtkIdType numGenPts, vtkIdType inCellId,
                    vtkCellData *cd, vtkCellData *outCD, vtkCellArray *newLines);

  //helper members
  vtkFloatArray *TCoordMap;

private:
  vtkSplineFilter(const vtkSplineFilter&) VTK_DELETE_FUNCTION;
  void operator=(const vtkSplineFilter&) VTK_DELETE_FUNCTION;
};

#endif