vtkVisItGlyph3D.h 14.7 KB
Newer Older
hrchilds's avatar
hrchilds committed
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
/*=========================================================================

  Program:   Visualization Toolkit
  Module:    $RCSfile: vtkVisItGlyph3D.h,v $
  Language:  C++
  Date:      $Date: 2003/03/25 14:58:57 $
  Version:   $Revision: 1.57 $

  Copyright (c) 1993-2002 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.

=========================================================================*/
// .NAME vtkVisItGlyph3D - copy oriented and scaled glyph geometry to every input point
// .SECTION Description
// vtkVisItGlyph3D is a filter that copies a geometric representation (called
// a glyph) to every point in the input dataset. The glyph is defined with
// polygonal data from a source filter input. The glyph may be oriented
// along the input vectors or normals, and it may be scaled according to
// scalar data or vector magnitude. More than one glyph may be used by
// creating a table of source objects, each defining a different glyph. If a
// table of glyphs is defined, then the table can be indexed into by using
// either scalar value or vector magnitude.
// 
// To use this object you'll have to provide an input dataset and a source
// to define the glyph. Then decide whether you want to scale the glyph and
// how to scale the glyph (using scalar value or vector magnitude). Next
// decide whether you want to orient the glyph, and whether to use the
// vector data or normal data to orient it. Finally, decide whether to use a
// table of glyphs, or just a single glyph. If you use a table of glyphs,
// you'll have to decide whether to index into it with scalar value or with
// vector magnitude.
// 
// .SECTION Caveats
// The scaling of the glyphs is controlled by the ScaleFactor ivar multiplied
// by the scalar value at each point (if VTK_SCALE_BY_SCALAR is set), or
// multiplied by the vector magnitude (if VTK_SCALE_BY_VECTOR is set),
// Alternatively (if VTK_SCALE_BY_VECTORCOMPONENTS is set), the scaling
// may be specified for x,y,z using the vector components. The
// scale factor can be further controlled by enabling clamping using the
// Clamping ivar. If clamping is enabled, the scale is normalized by the
// Range ivar, and then multiplied by the scale factor. The normalization
// process includes clamping the scale value between (0,1).
// 
// Typically this object operates on input data with scalar and/or vector
// data. However, scalar and/or vector aren't necessary, and it can be used
// to copy data from a single source to each point. In this case the scale
// factor can be used to uniformly scale the glyphs.
//
// The object uses "vector" data to scale glyphs, orient glyphs, and/or index
// into a table of glyphs. You can choose to use either the vector or normal
// data at each input point. Use the method SetVectorModeToUseVector() to use 
// the vector input data, and SetVectorModeToUseNormal() to use the
// normal input data. 
//
// If you do use a table of glyphs, make sure to set the Range ivar to make
// sure the index into the glyph table is computed correctly.
//
// You can turn off scaling of the glyphs completely by using the Scaling
// ivar. You can also turn off scaling due to data (either vector or scalar)
// by using the SetScaleModeToDataScalingOff() method.

// .SECTION See Also
// vtkTensorGlyph

#ifndef __vtkVisItGlyph3D_h
#define __vtkVisItGlyph3D_h
#include <visit_vtk_exports.h>

74 75
#include <vtkPolyDataAlgorithm.h>

hrchilds's avatar
hrchilds committed
76 77
#define VTK_SCALE_BY_SCALAR 0
#define VTK_SCALE_BY_VECTOR 1
78 79 80
#define VTK_SCALE_BY_TENSOR 2
#define VTK_SCALE_BY_VECTORCOMPONENTS 3
#define VTK_DATA_SCALING_OFF 4
hrchilds's avatar
hrchilds committed
81 82 83 84

#define VTK_COLOR_BY_SCALE  0
#define VTK_COLOR_BY_SCALAR 1
#define VTK_COLOR_BY_VECTOR 2
hrchilds's avatar
hrchilds committed
85
#define VTK_COLOR_BY_SINGLE_COLOR 3
hrchilds's avatar
hrchilds committed
86 87 88 89 90 91 92 93 94

#define VTK_USE_VECTOR 0
#define VTK_USE_NORMAL 1
#define VTK_VECTOR_ROTATION_OFF 2

#define VTK_INDEXING_OFF 0
#define VTK_INDEXING_BY_SCALAR 1
#define VTK_INDEXING_BY_VECTOR 2

95 96 97 98 99 100 101 102
// ***************************************************************************
//  Class: vtkVisItGlyph3D
//
//  Modifications:
//    Eric Brugger, Thu Jan 10 13:00:03 PST 2013
//    Modified to inherit from vtkPolyDataAlgorithm.
//
// ***************************************************************************
hrchilds's avatar
hrchilds committed
103

104
class VISIT_VTK_API vtkVisItGlyph3D : public vtkPolyDataAlgorithm
hrchilds's avatar
hrchilds committed
105 106
{
public:
107
  vtkTypeMacro(vtkVisItGlyph3D,vtkPolyDataAlgorithm);
hrchilds's avatar
hrchilds committed
108 109 110 111 112 113 114 115 116 117
  void PrintSelf(ostream& os, vtkIndent indent);

  // Description
  // Construct object with scaling on, scaling mode is by scalar value, 
  // scale factor = 1.0, the range is (0,1), orient geometry is on, and
  // orientation is by vector. Clamping and indexing are turned off. No
  // initial sources are defined.
  static vtkVisItGlyph3D *New();

  // Description:
118
  // Set the source to use for the glyph. Old style. See SetSourceConnection.
119
  void SetSourceData(vtkPolyData *pd) {this->SetSourceData(0,pd);};
hrchilds's avatar
hrchilds committed
120 121 122

  // Description:
  // Specify a source object at a specified table location.
123
  // Old style. See SetSourceConnection.
124
  void SetSourceData(int id, vtkPolyData *pd);
hrchilds's avatar
hrchilds committed
125

126 127 128 129 130 131 132 133 134 135
  // Description:
  // Specify a source object at a specified table location. New style.
  // Source connection is stored in port 1. This method is equivalent
  // to SetInputConnection(1, id, outputPort).
  void SetSourceConnection(int id, vtkAlgorithmOutput* algOutput);
  void SetSourceConnection(vtkAlgorithmOutput* algOutput)
    {
      this->SetSourceConnection(0, algOutput);
    }

hrchilds's avatar
hrchilds committed
136 137 138 139 140 141 142 143 144 145 146 147 148 149
  // Description:
  // Get a pointer to a source object at a specified table location.
  vtkPolyData *GetSource(int id=0);

  // Description:
  // Turn on/off scaling of source geometry.
  vtkSetMacro(Scaling,int);
  vtkBooleanMacro(Scaling,int);
  vtkGetMacro(Scaling,int);

  // Description:
  // Either scale by scalar or by vector/normal magnitude.
  vtkSetMacro(ScaleMode,int);
  vtkGetMacro(ScaleMode,int);
150
  void SetScaleModeToScaleByScalar()
hrchilds's avatar
hrchilds committed
151
    {this->SetScaleMode(VTK_SCALE_BY_SCALAR);};
152
  void SetScaleModeToScaleByVector()
hrchilds's avatar
hrchilds committed
153
    {this->SetScaleMode(VTK_SCALE_BY_VECTOR);};
154
  void SetScaleModeToScaleByTensor()
155
    {this->SetScaleMode(VTK_SCALE_BY_TENSOR);};
hrchilds's avatar
hrchilds committed
156 157 158 159 160 161 162 163 164 165
  void SetScaleModeToScaleByVectorComponents()
    {this->SetScaleMode(VTK_SCALE_BY_VECTORCOMPONENTS);};
  void SetScaleModeToDataScalingOff()
    {this->SetScaleMode(VTK_DATA_SCALING_OFF);};
  const char *GetScaleModeAsString();

  // Description:
  // Either color by scale, scalar or by vector/normal magnitude.
  vtkSetMacro(ColorMode,int);
  vtkGetMacro(ColorMode,int);
166
  void SetColorModeToColorByScale()
hrchilds's avatar
hrchilds committed
167
    {this->SetColorMode(VTK_COLOR_BY_SCALE);};
168
  void SetColorModeToColorByScalar()
hrchilds's avatar
hrchilds committed
169
    {this->SetColorMode(VTK_COLOR_BY_SCALAR);};
170
  void SetColorModeToColorByVector()
hrchilds's avatar
hrchilds committed
171
    {this->SetColorMode(VTK_COLOR_BY_VECTOR);};
172
  void SetColorModeToColorBySingleColor()
hrchilds's avatar
hrchilds committed
173
    {this->SetColorMode(VTK_COLOR_BY_SINGLE_COLOR);};
hrchilds's avatar
hrchilds committed
174 175 176 177
  const char *GetColorModeAsString();

  // Description:
  // Specify scale factor to scale object by.
178 179
  vtkSetMacro(ScaleFactor,double);
  vtkGetMacro(ScaleFactor,double);
hrchilds's avatar
hrchilds committed
180 181 182

  // Description:
  // Specify range to map scalar values into.
183 184
  vtkSetVector2Macro(Range,double);
  vtkGetVectorMacro(Range,double,2);
hrchilds's avatar
hrchilds committed
185 186 187 188 189 190 191 192

  // Description:
  // Turn on/off orienting of input geometry along vector/normal.
  vtkSetMacro(Orient,int);
  vtkBooleanMacro(Orient,int);
  vtkGetMacro(Orient,int);

  // Description:
193
  // Turn on/off clamping of "scalar" values to range. (Scalar value may be
hrchilds's avatar
hrchilds committed
194 195 196 197 198 199 200 201 202 203 204
  //  vector magnitude if ScaleByVector() is enabled.)
  vtkSetMacro(Clamping,int);
  vtkBooleanMacro(Clamping,int);
  vtkGetMacro(Clamping,int);

  // Description:
  // Specify whether to use vector or normal to perform vector operations.
  vtkSetMacro(VectorMode,int);
  vtkGetMacro(VectorMode,int);
  void SetVectorModeToUseVector() {this->SetVectorMode(VTK_USE_VECTOR);};
  void SetVectorModeToUseNormal() {this->SetVectorMode(VTK_USE_NORMAL);};
205
  void SetVectorModeToVectorRotationOff()
hrchilds's avatar
hrchilds committed
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228
    {this->SetVectorMode(VTK_VECTOR_ROTATION_OFF);};
  const char *GetVectorModeAsString();

  // Description:
  // Index into table of sources by scalar, by vector/normal magnitude, or
  // no indexing. If indexing is turned off, then the first source glyph in
  // the table of glyphs is used.
  vtkSetMacro(IndexMode,int);
  vtkGetMacro(IndexMode,int);
  void SetIndexModeToScalar() {this->SetIndexMode(VTK_INDEXING_BY_SCALAR);};
  void SetIndexModeToVector() {this->SetIndexMode(VTK_INDEXING_BY_VECTOR);};
  void SetIndexModeToOff() {this->SetIndexMode(VTK_INDEXING_OFF);};
  const char *GetIndexModeAsString();

  // Description:
  // Enable/disable the generation of point ids as part of the output. The
  // point ids are the id of the input generating point. The point ids are
  // stored in the output point field data and named "InputPointIds". Point
  // generation is useful for debugging and pick operations.
  vtkSetMacro(GeneratePointIds,int);
  vtkGetMacro(GeneratePointIds,int);
  vtkBooleanMacro(GeneratePointIds,int);

229
  // Description:
230
  // Enable/disable the 2D treatment of vectors
231 232 233 234
  vtkSetMacro(TreatVectorsAs2D,int);
  vtkGetMacro(TreatVectorsAs2D,int);
  vtkBooleanMacro(TreatVectorsAs2D,int);

hrchilds's avatar
hrchilds committed
235 236 237 238 239 240 241 242 243 244
  // Description:
  // Set/Get the name of the PointIds array if generated. By default the Ids
  // are named "InputPointIds", but this can be changed with this function.
  vtkSetStringMacro(PointIdsName);
  vtkGetStringMacro(PointIdsName);

  // Description:
  // If you want to use an arbitrary scalars array, then set its name here.
  // By default this in NULL and the filter will use the active scalar array.
  vtkGetStringMacro(InputScalarsSelection);
245
  void SelectInputScalars(const char *fieldName)
hrchilds's avatar
hrchilds committed
246 247 248 249 250 251
    {this->SetInputScalarsSelection(fieldName);}

  // Description:
  // If you want to use an arbitrary vectors array, then set its name here.
  // By default this in NULL and the filter will use the active vector array.
  vtkGetStringMacro(InputVectorsSelection);
252
  void SelectInputVectors(const char *fieldName)
hrchilds's avatar
hrchilds committed
253 254 255 256 257 258
    {this->SetInputVectorsSelection(fieldName);}

  // Description:
  // If you want to use an arbitrary normals array, then set its name here.
  // By default this in NULL and the filter will use the active normal array.
  vtkGetStringMacro(InputNormalsSelection);
259
  void SelectInputNormals(const char *fieldName)
hrchilds's avatar
hrchilds committed
260 261 262
    {this->SetInputNormalsSelection(fieldName);}

  vtkGetStringMacro(ScalarsForColoring);
263
  void SelectScalarsForColoring(const char *fieldName)
hrchilds's avatar
hrchilds committed
264 265 266
    {this->SetScalarsForColoring(fieldName);}

  vtkGetStringMacro(ScalarsForScaling);
267
  void SelectScalarsForScaling(const char *fieldName)
hrchilds's avatar
hrchilds committed
268 269 270
    {this->SetScalarsForScaling(fieldName);}

  vtkGetStringMacro(VectorsForColoring);
271
  void SelectVectorsForColoring(const char *fieldName)
hrchilds's avatar
hrchilds committed
272 273 274
    {this->SetVectorsForColoring(fieldName);}

  vtkGetStringMacro(VectorsForScaling);
275
  void SelectVectorsForScaling(const char *fieldName)
hrchilds's avatar
hrchilds committed
276 277
    {this->SetVectorsForScaling(fieldName);}

278
  vtkGetStringMacro(TensorsForScaling);
279
  void SelectTensorsForScaling(const char *fieldName)
280 281
    {this->SetTensorsForScaling(fieldName);}

hrchilds's avatar
hrchilds committed
282 283
  int SetFullFrameScaling(int useIt, const double *s);

hrchilds's avatar
hrchilds committed
284 285 286 287
protected:
  vtkVisItGlyph3D();
  ~vtkVisItGlyph3D();

288 289 290 291 292 293 294
  virtual int RequestData(vtkInformation *,
                          vtkInformationVector **,
                          vtkInformationVector *);
  virtual int RequestUpdateExtent(vtkInformation *,
                                  vtkInformationVector **,
                                  vtkInformationVector *);
  virtual int FillInputPortInformation(int port, vtkInformation *info);
hrchilds's avatar
hrchilds committed
295

bonnell's avatar
bonnell committed
296 297
  vtkPolyData* GetSource(int idx, vtkInformationVector *sourceInfo);

hrchilds's avatar
hrchilds committed
298 299 300 301
  vtkPolyData **Source; // Geometry to copy to each point
  int Scaling; // Determine whether scaling of geometry is performed
  int ScaleMode; // Scale by scalar value or vector magnitude
  int ColorMode; // new scalars based on scale, scalar or vector
302 303
  double ScaleFactor; // Scale factor to use to scale geometry
  double Range[2]; // Range to use to perform scalar scaling
hrchilds's avatar
hrchilds committed
304 305 306 307 308
  int Orient; // boolean controls whether to "orient" data
  int VectorMode; // Orient/scale via normal or via vector data
  int Clamping; // whether to clamp scale factor
  int IndexMode; // what to use to index into glyph table
  int GeneratePointIds; // produce input points ids for each output point
309
  int TreatVectorsAs2D; // glyph only the 2D portions of vectors
hrchilds's avatar
hrchilds committed
310 311 312 313 314 315 316 317 318 319 320 321 322
  char *PointIdsName;

  char *InputScalarsSelection;
  char *InputVectorsSelection;
  char *InputNormalsSelection;
  vtkSetStringMacro(InputScalarsSelection);
  vtkSetStringMacro(InputVectorsSelection);
  vtkSetStringMacro(InputNormalsSelection);

  char *ScalarsForColoring;
  char *ScalarsForScaling;
  char *VectorsForColoring;
  char *VectorsForScaling;
323
  char *TensorsForScaling;
hrchilds's avatar
hrchilds committed
324 325 326 327 328

  vtkSetStringMacro(ScalarsForColoring);
  vtkSetStringMacro(ScalarsForScaling);
  vtkSetStringMacro(VectorsForColoring);
  vtkSetStringMacro(VectorsForScaling);
329
  vtkSetStringMacro(TensorsForScaling);
hrchilds's avatar
hrchilds committed
330

hrchilds's avatar
hrchilds committed
331 332 333
  int    UseFullFrameScaling;
  double FullFrameScaling[3];

hrchilds's avatar
hrchilds committed
334 335 336 337 338 339 340 341 342 343 344 345 346
private:
  vtkVisItGlyph3D(const vtkVisItGlyph3D&);  // Not implemented.
  void operator=(const vtkVisItGlyph3D&);  // Not implemented.
};

// Description:
// Return the method of scaling as a descriptive character string.
inline const char *vtkVisItGlyph3D::GetScaleModeAsString(void)
{
  if ( this->ScaleMode == VTK_SCALE_BY_SCALAR )
    {
    return "ScaleByScalar";
    }
347
  else if ( this->ScaleMode == VTK_SCALE_BY_VECTOR )
hrchilds's avatar
hrchilds committed
348 349 350
    {
    return "ScaleByVector";
    }
351
  else if ( this->ScaleMode == VTK_SCALE_BY_TENSOR )
352 353 354
    {
    return "ScaleByTensor";
    }
hrchilds's avatar
hrchilds committed
355 356 357 358 359 360 361 362 363 364 365 366 367 368
  else 
    {
    return "DataScalingOff";
    }
}

// Description:
// Return the method of coloring as a descriptive character string.
inline const char *vtkVisItGlyph3D::GetColorModeAsString(void)
{
  if ( this->ColorMode == VTK_COLOR_BY_SCALAR )
    {
    return "ColorByScalar";
    }
369
  else if ( this->ColorMode == VTK_COLOR_BY_VECTOR )
hrchilds's avatar
hrchilds committed
370 371 372
    {
    return "ColorByVector";
    }
373
  else if ( this->ColorMode == VTK_COLOR_BY_SINGLE_COLOR )
hrchilds's avatar
hrchilds committed
374 375 376
    {
    return "ColorBySingleColor";
    }
hrchilds's avatar
hrchilds committed
377 378 379 380 381 382 383 384 385 386
  else 
    {
    return "ColorByScale";
    }
}

// Description:
// Return the vector mode as a character string.
inline const char *vtkVisItGlyph3D::GetVectorModeAsString(void)
{
387
  if ( this->VectorMode == VTK_USE_VECTOR)
hrchilds's avatar
hrchilds committed
388 389 390
    {
    return "UseVector";
    }
391
  else if ( this->VectorMode == VTK_USE_NORMAL)
hrchilds's avatar
hrchilds committed
392 393 394
    {
    return "UseNormal";
    }
395
  else
hrchilds's avatar
hrchilds committed
396 397 398 399 400 401 402 403 404
    {
    return "VectorRotationOff";
    }
}

// Description:
// Return the index mode as a character string.
inline const char *vtkVisItGlyph3D::GetIndexModeAsString(void)
{
405
  if ( this->IndexMode == VTK_INDEXING_OFF)
hrchilds's avatar
hrchilds committed
406 407 408
    {
    return "IndexingOff";
    }
409
  else if ( this->IndexMode == VTK_INDEXING_BY_SCALAR)
hrchilds's avatar
hrchilds committed
410 411 412
    {
    return "IndexingByScalar";
    }
413
  else
hrchilds's avatar
hrchilds committed
414 415 416 417 418 419
    {
    return "IndexingByVector";
    }
}

#endif