1 /*=========================================================================
3 Program: Visualization Toolkit
4 Module: $RCSfile: vtkWeightedTransformFilter.h,v $
6 Date: $Date: 2002/08/07 23:12:10 $
7 Version: $Revision: 1.8 $
9 Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen
11 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notice for more information.
17 =========================================================================*/
18 // .NAME vtkWeightedTransformFilter -- transform based on per-point or per-cell weighting functions.
19 // .SECTION Description
21 // vtkWeightedTransformFilter is a filter that can be used to "skin"
22 // structures and to create new and complex shapes. Unlike a
23 // traditional transform filter (which has one transform for a data
24 // set) or an assembly (which has one transform per part or group of
25 // parts), a weighted transform produces the weighted sum of
26 // transforms on a per-point or per-cell basis.
28 // Each point or cell in the filter's input has an attached DataArray
29 // that contains tuples of weighting functions, one per point or cell.
30 // The filter also has a set of fixed transforms. When the filter
31 // executes, each input point/cell is transformed by each of the
32 // transforms. These results are weighted by the point/cell's
33 // weighting factors to produce final output data.
35 // Linear transforms are performance-optimized. Using arbitrary
36 // transforms will work, but performance may suffer.
38 // As an example of the utility of weighted transforms, here's how
39 // this filter can be used for "skinning." Skinning is the process of
40 // putting a mesh cover over an underlying structure, like skin over
41 // bone. Joints are difficult to skin because deformation is hard to
42 // do. Visualize skin over an elbow joint. Part of the skin moves
43 // with one bone, part of the skin moves with the other bone, and the
44 // skin in the middle moves a little with each.
46 // Weighted filtering can be used for a simple and efficient kind of
47 // skinning. Begin with a cylindrical mesh. Create a FloatArray with
48 // two components per tuple, and one tuple for each point in the mesh.
49 // Assign transform weights that linear interpolate the distance along
50 // the cylinder (one component is the distance along the cylinder, the
51 // other is one minus that distance). Set the filter up to use two
52 // transforms, the two used to transform the two bones. Now, when the
53 // transforms change, the mesh will deform so as to, hopefully,
54 // continue to cover the bones.
56 // vtkWeightedTransformFilter is also useful for creating "strange and
57 // complex" shapes using pinching, bending, and blending.
60 // Weighted combination of normals and vectors are probably not appropriate
61 // in many cases. Surface normals are treated somewhat specially, but
62 // in many cases you may need to regenerate the surface normals.
64 // Cell data can only be transformed if all transforms are linear.
68 // vtkAbstractTransform vtkLinearTransform vtkTransformPolyDataFilter vtkActor
70 #ifndef __vtkWeightedTransformFilter_h
71 #define __vtkWeightedTransformFilter_h
73 #include "vtkPointSetToPointSetFilter.h"
75 class vtkAbstractTransform;
77 class VTK_HYBRID_EXPORT vtkWeightedTransformFilter : public vtkPointSetToPointSetFilter
80 static vtkWeightedTransformFilter *New();
81 vtkTypeRevisionMacro(vtkWeightedTransformFilter,vtkPointSetToPointSetFilter);
82 void PrintSelf(ostream& os, vtkIndent indent);
85 // Return the MTime also considering the filter's transforms.
86 unsigned long GetMTime();
89 // WeightArray is the string name of the DataArray in the input's
90 // FieldData that holds the weighting coefficients for each point.
91 // The filter will first look for the array in the input's PointData
92 // FieldData. If the array isn't there, the filter looks in the
93 // input's FieldData. The WeightArray can have tuples of any length,
94 // but must have a tuple for every point in the input data set.
95 // This array transforms points, normals, and vectors.
96 vtkSetStringMacro(WeightArray);
97 vtkGetStringMacro(WeightArray);
100 // The CellDataWeightArray is analogous to the WeightArray, except
101 // for CellData. The array is searched for first in the CellData
102 // FieldData, then in the input's FieldData. The data array must have
103 // a tuple for each cell. This array is used to transform only normals
105 vtkSetStringMacro(CellDataWeightArray);
106 vtkGetStringMacro(CellDataWeightArray);
109 // Set or Get one of the filter's transforms. The transform number must
110 // be less than the number of transforms allocated for the object. Setting
111 // a transform slot to NULL is equivalent to assigning an overriding weight
112 // of zero to that filter slot.
113 virtual void SetTransform(vtkAbstractTransform *transform, int num);
114 virtual vtkAbstractTransform *GetTransform(int num);
117 // Set the number of transforms for the filter. References to non-existent
118 // filter numbers in the data array is equivalent to a weight of zero
119 // (i.e., no contribution of that filter or weight).
120 virtual void SetNumberOfTransforms(int num);
121 vtkGetMacro(NumberOfTransforms, int);
124 // If AddInputValues is true, the output values of this filter will be
125 // offset from the input values. The effect is exactly equivalent to
126 // having an identity transform of weight 1 added into each output point.
127 vtkBooleanMacro(AddInputValues, int);
128 vtkSetMacro(AddInputValues, int);
129 vtkGetMacro(AddInputValues, int);
132 vtkAbstractTransform **Transforms;
133 int NumberOfTransforms;
136 char *CellDataWeightArray;
139 vtkWeightedTransformFilter();
140 ~vtkWeightedTransformFilter();
144 vtkWeightedTransformFilter(const vtkWeightedTransformFilter&); // Not implemented.
145 void operator=(const vtkWeightedTransformFilter&); // Not implemented.