1 /*=========================================================================
3 Program: Visualization Toolkit
4 Module: $RCSfile: vtkGlyph3D.h,v $
6 Date: $Date: 2002/02/01 06:35:48 $
7 Version: $Revision: 1.1.1.1 $
10 Copyright (c) 1993-1998 Ken Martin, Will Schroeder, Bill Lorensen.
12 This software is copyrighted by Ken Martin, Will Schroeder and Bill Lorensen.
13 The following terms apply to all files associated with the software unless
14 explicitly disclaimed in individual files. This copyright specifically does
15 not apply to the related textbook "The Visualization Toolkit" ISBN
16 013199837-4 published by Prentice Hall which is covered by its own copyright.
18 The authors hereby grant permission to use, copy, and distribute this
19 software and its documentation for any purpose, provided that existing
20 copyright notices are retained in all copies and that this notice is included
21 verbatim in any distributions. Additionally, the authors grant permission to
22 modify this software and its documentation for any purpose, provided that
23 such modifications are not distributed without the explicit consent of the
24 authors and that existing copyright notices are retained in all copies. Some
25 of the algorithms implemented by this software are patented, observe all
26 applicable patent law.
28 IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR
29 DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
30 OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF,
31 EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
34 BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
35 PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN
36 "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE
37 MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
40 =========================================================================*/
41 // .NAME vtkGlyph3D - copy oriented and scaled glyph geometry to every input point
42 // .SECTION Description
43 // vtkGlyph3D is a filter that copies a geometric representation (called
44 // a glyph) to every point in the input dataset. The glyph is defined with
45 // polygonal data from a source filter input. The glyph may be oriented
46 // along the input vectors or normals, and it may be scaled according to
47 // scalar data or vector magnitude. More than one glyph may be used by
48 // creating a table of source objects, each defining a different glyph. If a
49 // table of glyphs is defined, then the table can be indexed into by using
50 // either scalar value or vector magnitude.
52 // To use this object you'll have to provide an input dataset and a source
53 // to define the glyph. Then decide whether you want to scale the glyph and
54 // how to scale the glyph (using scalar value or vector magnitude). Next
55 // decide whether you want to orient the glyph, and whether to use the
56 // vector data or normal data to orient it. Finally, decide whether to use a
57 // table of glyphs, or just a single glyph. If you use a table of glyphs,
58 // you'll have to decide whether to index into it with scalar value or with
62 // The scaling of the glyphs is controled by the ScaleFactor ivar multiplied
63 // by the scalar value at each point (if VTK_SCALE_BY_SCALAR is set), or
64 // multiplied by the vector magnitude (if VTK_SCALE_BY_VECTOR is set). The
65 // scale factor can be further controlled by enabling clamping using the
66 // Clamping ivar. If clamping is enabled, the scale is normalized by the
67 // Range ivar, and then multiplied by the scale factor. The normalization
68 // process includes clamping the scale value between (0,1).
70 // Typically this object operates on input data with scalar and/or vector
71 // data. However, scalar and/or vector aren't necessary, and it can be used
72 // to copy data from a single source to each point. In this case the scale
73 // factor can be used to uniformly scale the glyphs.
75 // The object uses "vector" data to scale glyphs, orient glyphs, and/or index
76 // into a table of glyphs. You can choose to use either the vector or normal
77 // data at each input point. Use the method SetVectorModeToUseVector() to use
78 // the vector input data, and SetVectorModeToUseNormal() to use the
81 // If you do use a table of glyphs, make sure to set the Range ivar to make
82 // sure the index into the glyph table is computed correctly.
84 // You can turn off scaling of the glyphs completely by using the Scaling
85 // ivar. You can also turn off scaling due to data (either vector or scalar)
86 // by using the SetScaleModeToDataScalingOff() method.
91 #ifndef __vtkGlyph3D_h
92 #define __vtkGlyph3D_h
94 #include "vtkDataSetToPolyDataFilter.h"
96 #define VTK_SCALE_BY_SCALAR 0
97 #define VTK_SCALE_BY_VECTOR 1
98 #define VTK_DATA_SCALING_OFF 2
100 #define VTK_COLOR_BY_SCALE 0
101 #define VTK_COLOR_BY_SCALAR 1
102 #define VTK_COLOR_BY_VECTOR 2
104 #define VTK_USE_VECTOR 0
105 #define VTK_USE_NORMAL 1
107 #define VTK_INDEXING_OFF 0
108 #define VTK_INDEXING_BY_SCALAR 1
109 #define VTK_INDEXING_BY_VECTOR 2
111 class VTK_EXPORT vtkGlyph3D : public vtkDataSetToPolyDataFilter
116 static vtkGlyph3D *New() {return new vtkGlyph3D;};
117 const char *GetClassName() {return "vtkGlyph3D";};
118 void PrintSelf(ostream& os, vtkIndent indent);
123 // Get the number of source objects used to define the glyph
124 // table. Specify the number of sources before defining a table of glyphs.
125 vtkGetMacro(NumberOfSources,int);
126 void SetNumberOfSources(int num);
128 // These are used to load the table of sources
129 void SetSource(vtkPolyData *pd) {this->SetSource(0,pd);};
130 void SetSource(int id, vtkPolyData *pd);
131 vtkPolyData *GetSource(int id=0);
134 // Turn on/off scaling of source geometry.
135 vtkSetMacro(Scaling,int);
136 vtkBooleanMacro(Scaling,int);
137 vtkGetMacro(Scaling,int);
140 // Either scale by scalar or by vector/normal magnitude.
141 vtkSetMacro(ScaleMode,int);
142 vtkGetMacro(ScaleMode,int);
143 void SetScaleModeToScaleByScalar()
144 {this->SetScaleMode(VTK_SCALE_BY_SCALAR);};
145 void SetScaleModeToScaleByVector()
146 {this->SetScaleMode(VTK_SCALE_BY_VECTOR);};
147 void SetScaleModeToDataScalingOff()
148 {this->SetScaleMode(VTK_DATA_SCALING_OFF);};
149 char *GetScaleModeAsString();
152 // Either color by scale, scalar or by vector/normal magnitude.
153 vtkSetMacro(ColorMode,int);
154 vtkGetMacro(ColorMode,int);
155 void SetColorModeToColorByScale()
156 {this->SetColorMode(VTK_COLOR_BY_SCALE);};
157 void SetColorModeToColorByScalar()
158 {this->SetColorMode(VTK_COLOR_BY_SCALAR);};
159 void SetColorModeToColorByVector()
160 {this->SetColorMode(VTK_COLOR_BY_VECTOR);};
161 char *GetColorModeAsString();
164 // Specify scale factor to scale object by.
165 vtkSetMacro(ScaleFactor,float);
166 vtkGetMacro(ScaleFactor,float);
169 // Specify range to map scalar values into.
170 vtkSetVector2Macro(Range,float);
171 vtkGetVectorMacro(Range,float,2);
174 // Turn on/off orienting of input geometry along vector/normal.
175 vtkSetMacro(Orient,int);
176 vtkBooleanMacro(Orient,int);
177 vtkGetMacro(Orient,int);
180 // Turn on/off clamping of "scalar" values to range. (Scalar value may be
181 // vector magnitude if ScaleByVector() is enabled.)
182 vtkSetMacro(Clamping,int);
183 vtkBooleanMacro(Clamping,int);
184 vtkGetMacro(Clamping,int);
187 // Specify whether to use vector or normal to perform vector operations.
188 vtkSetMacro(VectorMode,int);
189 vtkGetMacro(VectorMode,int);
190 void SetVectorModeToUseVector() {this->SetVectorMode(VTK_USE_VECTOR);};
191 void SetVectorModeToUseNormal() {this->SetVectorMode(VTK_USE_NORMAL);};
192 char *GetVectorModeAsString();
195 // Index into table of sources by scalar, by vector/normal magnitude, or
196 // no indexing. If indexing is turned off, then the first source glyph in
197 // the table of glyphs is used.
198 vtkSetMacro(IndexMode,int);
199 vtkGetMacro(IndexMode,int);
200 void SetIndexModeToScalar() {this->SetIndexMode(VTK_INDEXING_BY_SCALAR);};
201 void SetIndexModeToVector() {this->SetIndexMode(VTK_INDEXING_BY_VECTOR);};
202 void SetIndexModeToOff() {this->SetIndexMode(VTK_INDEXING_OFF);};
203 char *GetIndexModeAsString();
208 int NumberOfSources; // Number of source objects
209 vtkPolyData **Source; // Geometry to copy to each point
210 int Scaling; // Determine whether scaling of geometry is performed
211 int ScaleMode; // Scale by scalar value or vector magnitude
212 int ColorMode; // new scalars based on scale, scalar or vector
213 float ScaleFactor; // Scale factor to use to scale geometry
214 float Range[2]; // Range to use to perform scalar scaling
215 int Orient; // boolean controls whether to "orient" data
216 int VectorMode; // Orient/scale via normal or via vector data
217 int Clamping; // whether to clamp scale factor
218 int IndexMode; // what to use to index into glyph table
222 // Return the method of scaling as a descriptive character string.
223 inline char *vtkGlyph3D::GetScaleModeAsString(void)
225 if ( this->ScaleMode == VTK_SCALE_BY_SCALAR )
227 return "ScaleByScalar";
229 else if ( this->ScaleMode == VTK_SCALE_BY_VECTOR )
231 return "ScaleByVector";
235 return "DataScalingOff";
240 // Return the method of coloring as a descriptive character string.
241 inline char *vtkGlyph3D::GetColorModeAsString(void)
243 if ( this->ColorMode == VTK_COLOR_BY_SCALAR )
245 return "ColorByScalar";
247 else if ( this->ColorMode == VTK_COLOR_BY_VECTOR )
249 return "ColorByVector";
253 return "ColorByScale";
258 // Return the vector mode as a character string.
259 inline char *vtkGlyph3D::GetVectorModeAsString(void)
261 if ( this->VectorMode == VTK_USE_VECTOR)
272 // Return the index mode as a character string.
273 inline char *vtkGlyph3D::GetIndexModeAsString(void)
275 if ( this->IndexMode == VTK_INDEXING_OFF)
277 return "IndexingOff";
279 else if ( this->IndexMode == VTK_INDEXING_BY_SCALAR)
281 return "IndexingByScalar";
285 return "IndexingByVector";