1 /*=========================================================================
3 Program: Visualization Toolkit
4 Module: $RCSfile: vtkProgrammableGlyphFilter.h,v $
6 Date: $Date: 2002/09/26 12:07:14 $
7 Version: $Revision: 1.20 $
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 vtkProgrammableGlyphFilter - control the generation and placement of glyphs at input points
19 // .SECTION Description
20 // vtkProgrammableGlyphFilter is a filter that allows you to place a glyph at
21 // each input point in the dataset. In addition, the filter is programmable
22 // which means the user has control over the generation of the glyph. The
23 // glyphs can be controlled via the point data attributes (e.g., scalars,
24 // vectors, etc.) or any other information in the input dataset.
26 // This is the way the filter works. You must define an input dataset which
27 // at a minimum contains points with associated attribute values. Also, the
28 // Source instance variable must be set which is of type vtkPolyData. Then,
29 // for each point in the input, the PointId is set to the current point id,
30 // and a user-defined function is called (i.e., GlyphMethod). In this method
31 // you can manipulate the Source data (including changing to a different
32 // Source object). After the GlyphMethod is called,
33 // vtkProgrammableGlyphFilter will invoke an Update() on its Source object,
34 // and then copy its data to the output of the
35 // vtkProgrammableGlyphFilter. Therefore the output of this filter is of type
38 // Another option to this filter is the way you color the glyphs. You can use
39 // the scalar data from the input or the source. The instance variable
40 // ColorMode controls this behavior.
43 // This filter operates on point data attributes. If you want to use cell
44 // data attributes, use a filter like vtkCellCenters to generate points at
45 // the centers of cells, and then use these points.
47 // Note that the data attributes (cell and point) are passed to the output of
48 // this filter from the Source object. This works well as long as you are not
49 // changing the class of the Source object during execution. However, if the
50 // class of the Source object changes, then the potential exists that the
51 // data attributes might change during execution (e.g., scalars available
52 // from one source and not the next), possibly fouling up the copying of data
53 // attributes to the output. In this case, you may have to manually set the
54 // output's copy flags (e.g., CopyScalarsOn/Off(), CopyVectorsOn/Off(), etc.)
55 // to control what's being copied.
58 // vtkGlyph3D vtkTensorGlyph vtkCellCenters
60 #ifndef __vtkProgrammableGlyphFilter_h
61 #define __vtkProgrammableGlyphFilter_h
63 #define VTK_COLOR_BY_INPUT 0
64 #define VTK_COLOR_BY_SOURCE 1
66 #include "vtkDataSetToPolyDataFilter.h"
70 class VTK_GRAPHICS_EXPORT vtkProgrammableGlyphFilter : public vtkDataSetToPolyDataFilter
73 vtkTypeRevisionMacro(vtkProgrammableGlyphFilter,vtkDataSetToPolyDataFilter);
74 void PrintSelf(ostream& os, vtkIndent indent);
77 // Construct object with NULL GlyphMethod() and no source object. The ColorMode
78 // is set to color by the input.
79 static vtkProgrammableGlyphFilter *New();
82 // Set/Get the source to use for this glyph.
83 // Note: you can change the source during execution of this filter.
84 void SetSource(vtkPolyData *source);
85 vtkPolyData *GetSource();
88 // Specify function to be called for each input point.
89 void SetGlyphMethod(void (*f)(void *), void *arg);
92 // Set the arg delete method. This is used to free user memory that might
93 // be associated with the GlyphMethod().
94 void SetGlyphMethodArgDelete(void (*f)(void *));
97 // Get the current point id during processing. Value only valid during the
98 // Execute() method of this filter. (Meant to be called by the GlyphMethod().)
99 vtkGetMacro(PointId, vtkIdType);
102 // Get the current point coordinates during processing. Value only valid during the
103 // Execute() method of this filter. (Meant to be called by the GlyphMethod().)
104 vtkGetVector3Macro(Point,float);
107 // Get the set of point data attributes for the input. A convenience to the
108 // programmer to be used in the GlyphMethod(). Only valid during the Execute()
109 // method of this filter.
110 vtkGetObjectMacro(PointData,vtkPointData);
113 // Either color by the input or source scalar data.
114 vtkSetMacro(ColorMode,int);
115 vtkGetMacro(ColorMode,int);
116 void SetColorModeToColorByInput()
117 {this->SetColorMode(VTK_COLOR_BY_INPUT);};
118 void SetColorModeToColorBySource()
119 {this->SetColorMode(VTK_COLOR_BY_SOURCE);};
120 const char *GetColorModeAsString();
123 vtkProgrammableGlyphFilter();
124 ~vtkProgrammableGlyphFilter();
128 float Point[3]; // Coordinates of point
129 vtkIdType PointId; // Current point id during processing
130 vtkPointData *PointData;
133 void (*GlyphMethod)(void *); // Support GlyphMethod
134 void (*GlyphMethodArgDelete)(void *);
135 void *GlyphMethodArg;
138 vtkProgrammableGlyphFilter(const vtkProgrammableGlyphFilter&); // Not implemented.
139 void operator=(const vtkProgrammableGlyphFilter&); // Not implemented.