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 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  1 /*=========================================================================
  2 
  3   Program:   Visualization Toolkit
  4   Module:    vtkTensorGlyphColor.h
  5 
  6   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
  7   All rights reserved.
  8   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
  9 
 10      This software is distributed WITHOUT ANY WARRANTY; without even
 11      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 12      PURPOSE.  See the above copyright notice for more information.
 13 
 14 =========================================================================*/
 15 /**
 16  * @class   vtkTensorGlyphColor
 17  * @brief   scale and orient glyph(s) according to eigenvalues and eigenvectors of symmetrical part
 18  * of tensor
 19  *
 20  * vtkTensorGlyphColor is a filter that copies a geometric representation
 21  * (specified as polygonal data) to every input point. The geometric
 22  * representation, or glyph, can be scaled and/or rotated according to
 23  * the tensor at the input point. Scaling and rotation is controlled
 24  * by the eigenvalues/eigenvectors of the symmetrical part of the tensor
 25  * as follows:
 26  * For each tensor, the eigenvalues (and associated eigenvectors) are sorted
 27  * to determine the major, medium, and minor eigenvalues/eigenvectors.
 28  * The eigenvalue decomposition only makes sense for symmetric tensors,
 29  * hence the need to only consider the symmetric part of the tensor, which is
 30  * 1/2 (T + T.transposed()).
 31  *
 32  * If the boolean variable ThreeGlyphs is not set the major eigenvalue
 33  * scales the glyph in the x-direction, the medium in the y-direction,
 34  * and the minor in the z-direction. Then, the glyph is rotated so
 35  * that the glyph's local x-axis lies along the major eigenvector,
 36  * y-axis along the medium eigenvector, and z-axis along the minor.
 37  *
 38  * If the boolean variable ThreeGlyphs is set three glyphs are produced,
 39  * each of them oriented along an eigenvector and scaled according to the
 40  * corresponding eigenvector.
 41  *
 42  * If the boolean variable Symmetric is set each glyph is mirrored (2 or 6
 43  * glyphs will be produced)
 44  *
 45  * The x-axis of the source glyph will correspond to the eigenvector
 46  * on output. Point (0,0,0) in the source will be placed in the data point.
 47  * Variable Length will normally correspond to the distance from the
 48  * origin to the tip of the source glyph along the x-axis,
 49  * but can be changed to produce other results when Symmetric is on,
 50  * e.g. glyphs that do not touch or that overlap.
 51  *
 52  * Please note that when Symmetric is false it will generally be better
 53  * to place the source glyph from (-0.5,0,0) to (0.5,0,0), i.e. centred
 54  * at the origin. When symmetric is true the placement from (0,0,0) to
 55  * (1,0,0) will generally be more convenient.
 56  *
 57  * A scale factor is provided to control the amount of scaling. Also, you
 58  * can turn off scaling completely if desired. The boolean variable
 59  * ClampScaling controls the maximum scaling (in conjunction with
 60  * MaxScaleFactor.) This is useful in certain applications where
 61  * singularities or large order of magnitude differences exist in
 62  * the eigenvalues.
 63  *
 64  * If the boolean variable ColorGlyphs is set to true the glyphs are
 65  * colored.  The glyphs can be colored using the input scalars
 66  * (SetColorModeToScalars), which is the default, or colored using the
 67  * eigenvalues (SetColorModeToEigenvalues).
 68  *
 69  * Another instance variable, ExtractEigenvalues, has been provided to
 70  * control extraction of eigenvalues/eigenvectors. If this boolean is
 71  * false, then eigenvalues/eigenvectors are not extracted, and the
 72  * columns of the tensor are taken as the eigenvectors (the norm of
 73  * column, always positive, is the eigenvalue).  This allows
 74  * additional capability over the vtkGlyph3D object. That is, the
 75  * glyph can be oriented in three directions instead of one.
 76  *
 77  * @par Thanks:
 78  * Thanks to Jose Paulo Moitinho de Almeida for enhancements.
 79  *
 80  * @sa
 81  * vtkGlyph3D vtkPointLoad vtkHyperStreamline
 82  */
 83 
 84 #ifndef vtkTensorGlyphColor_h
 85 #define vtkTensorGlyphColor_h
 86 
 87 #include <vtkPolyDataAlgorithm.h>
 88 
 89 class vtkTensorGlyphColor : public vtkPolyDataAlgorithm
 90 {
 91   public:
 92     vtkTypeMacro(vtkTensorGlyphColor,
 93                  vtkPolyDataAlgorithm) void PrintSelf(ostream& os, vtkIndent indent) override;
 94 
 95     /**
 96      * Construct object with scaling on and scale factor 1.0. Eigenvalues are
 97      * extracted, glyphs are colored with input scalar data, and logarithmic
 98      * scaling is turned off.
 99      */
100     static vtkTensorGlyphColor* New();
101 
102     //@{
103     /**
104      * Specify the geometry to copy to each point.
105      * Note that this method does not connect the pipeline. The algorithm will
106      * work on the input data as it is without updating the producer of the data.
107      * See SetSourceConnection for connecting the pipeline.
108      */
109     void SetSourceData(vtkPolyData* source);
110     vtkPolyData* GetSource();
111     //@}
112 
113     //@{
114     /**
115      * Specify a source object at a specified table location. New style.
116      * Source connection is stored in port 1. This method is equivalent
117      * to SetInputConnection(1, id, outputPort).
118      */
119     void SetSourceConnection(int id, vtkAlgorithmOutput* algOutput);
120     void SetSourceConnection(vtkAlgorithmOutput* algOutput)
121     {
122       this->SetSourceConnection(0, algOutput);
123     }
124     //@}
125 
126     //@{
127     /**
128      * Turn on/off scaling of glyph with eigenvalues.
129      */
130     vtkSetMacro(Scaling, vtkTypeBool);
131     vtkGetMacro(Scaling, vtkTypeBool);
132     vtkBooleanMacro(Scaling, vtkTypeBool);
133     //@}
134 
135     //@{
136     /**
137      * Specify scale factor to scale object by. (Scale factor always affects
138      * output even if scaling is off.)
139      */
140     vtkSetMacro(ScaleFactor, double);
141     vtkGetMacro(ScaleFactor, double);
142     //@}
143 
144     //@{
145     /**
146      * Turn on/off drawing three glyphs
147      */
148     vtkSetMacro(ThreeGlyphs, vtkTypeBool);
149     vtkGetMacro(ThreeGlyphs, vtkTypeBool);
150     vtkBooleanMacro(ThreeGlyphs, vtkTypeBool);
151     //@}
152 
153     //@{
154     /**
155      * Turn on/off drawing a mirror of each glyph
156      */
157     vtkSetMacro(Symmetric, vtkTypeBool);
158     vtkGetMacro(Symmetric, vtkTypeBool);
159     vtkBooleanMacro(Symmetric, vtkTypeBool);
160     //@}
161 
162     //@{
163     /**
164      * Set/Get the distance, along x, from the origin to the end of the
165      * source glyph. It is used to draw the symmetric glyphs.
166      */
167     vtkSetMacro(Length, double);
168     vtkGetMacro(Length, double);
169     //@}
170 
171     //@{
172     /**
173      * Turn on/off extraction of eigenvalues from tensor.
174      */
175     vtkSetMacro(ExtractEigenvalues, vtkTypeBool);
176     vtkBooleanMacro(ExtractEigenvalues, vtkTypeBool);
177     vtkGetMacro(ExtractEigenvalues, vtkTypeBool);
178     //@}
179 
180     //@{
181     /**
182      * Turn on/off coloring of glyph with input scalar data or
183      * eigenvalues. If false, or input scalar data not present, then the
184      * scalars from the source object are passed through the filter.
185      */
186     vtkSetMacro(ColorGlyphs, vtkTypeBool);
187     vtkGetMacro(ColorGlyphs, vtkTypeBool);
188     vtkBooleanMacro(ColorGlyphs, vtkTypeBool);
189     //@}
190 
191     enum
192     {
193       COLOR_BY_SCALARS,
194       COLOR_BY_EIGENVALUES
195     };
196 
197     //@{
198     /**
199      * Set the color mode to be used for the glyphs.  This can be set to
200      * use the input scalars (default) or to use the eigenvalues at the
201      * point.  If ThreeGlyphs is set and the eigenvalues are chosen for
202      * coloring then each glyph is colored by the corresponding
203      * eigenvalue and if not set the color corresponding to the largest
204      * eigenvalue is chosen.  The recognized values are:
205      * COLOR_BY_SCALARS = 0 (default)
206      * COLOR_BY_EIGENVALUES = 1
207      */
208     vtkSetClampMacro(ColorMode, int, COLOR_BY_SCALARS, COLOR_BY_EIGENVALUES);
209     vtkGetMacro(ColorMode, int);
210     void SetColorModeToScalars() { this->SetColorMode(COLOR_BY_SCALARS); };
211     void SetColorModeToEigenvalues() { this->SetColorMode(COLOR_BY_EIGENVALUES); };
212     //@}
213 
214     //@{
215     /**
216      * Turn on/off scalar clamping. If scalar clamping is on, the ivar
217      * MaxScaleFactor is used to control the maximum scale factor. (This is
218      * useful to prevent uncontrolled scaling near singularities.)
219      */
220     vtkSetMacro(ClampScaling, vtkTypeBool);
221     vtkGetMacro(ClampScaling, vtkTypeBool);
222     vtkBooleanMacro(ClampScaling, vtkTypeBool);
223     //@}
224 
225     //@{
226     /**
227      * Set/Get the maximum allowable scale factor. This value is compared to the
228      * combination of the scale factor times the eigenvalue. If less, the scale
229      * factor is reset to the MaxScaleFactor. The boolean ClampScaling has to
230      * be "on" for this to work.
231      */
232     vtkSetMacro(MaxScaleFactor, double);
233     vtkGetMacro(MaxScaleFactor, double);
234     //@}
235 
236   protected:
237     vtkTensorGlyphColor();
238     ~vtkTensorGlyphColor() override;
239     vtkTensorGlyphColor(const vtkTensorGlyphColor&) = delete;
240     void operator=(const vtkTensorGlyphColor&) = delete;
241 
242     int RequestUpdateExtent(vtkInformation*, vtkInformationVector**,
243                             vtkInformationVector*) override;
244     int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
245     int FillInputPortInformation(int port, vtkInformation* info) override;
246 
247     vtkTypeBool Scaling;  // Determine whether scaling of geometry is performed
248     double ScaleFactor;  // Scale factor to use to scale geometry
249     vtkTypeBool ExtractEigenvalues;  // Boolean controls eigenfunction extraction
250     vtkTypeBool ColorGlyphs;  // Boolean controls coloring with input scalar data
251     int ColorMode;  // The coloring mode to use for the glyphs.
252     vtkTypeBool ClampScaling;  // Boolean controls whether scaling is clamped.
253     double MaxScaleFactor;  // Maximum scale factor (ScaleFactor*eigenvalue)
254     vtkTypeBool ThreeGlyphs;  // Boolean controls drawing 1 or 3 glyphs
255     vtkTypeBool Symmetric;  // Boolean controls drawing a "mirror" of each glyph
256     double Length;  // Distance, in x, from the origin to the end of the glyph
257 };
258 
259 #endif
260