VTK
vtkMapper.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkMapper.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 =========================================================================*/
61 #ifndef vtkMapper_h
62 #define vtkMapper_h
63 
64 #include "vtkRenderingCoreModule.h" // For export macro
65 #include "vtkAbstractMapper3D.h"
66 #include "vtkSystemIncludes.h" // For VTK_COLOR_MODE_DEFAULT and _MAP_SCALARS
67 #include "vtkSmartPointer.h" // needed for vtkSmartPointer.
68 
69 #define VTK_RESOLVE_OFF 0
70 #define VTK_RESOLVE_POLYGON_OFFSET 1
71 #define VTK_RESOLVE_SHIFT_ZBUFFER 2
72 
73 #define VTK_GET_ARRAY_BY_ID 0
74 #define VTK_GET_ARRAY_BY_NAME 1
75 
76 #define VTK_MATERIALMODE_DEFAULT 0
77 #define VTK_MATERIALMODE_AMBIENT 1
78 #define VTK_MATERIALMODE_DIFFUSE 2
79 #define VTK_MATERIALMODE_AMBIENT_AND_DIFFUSE 3
80 
81 class vtkWindow;
82 class vtkRenderer;
83 class vtkActor;
84 class vtkDataSet;
85 class vtkDataObject;
86 class vtkFloatArray;
87 class vtkImageData;
88 class vtkScalarsToColors;
90 
91 class VTKRENDERINGCORE_EXPORT vtkMapper : public vtkAbstractMapper3D
92 {
93 public:
95  void PrintSelf(ostream& os, vtkIndent indent);
96 
101 
107 
112  virtual void Render(vtkRenderer *ren, vtkActor *a) = 0;
113 
120 
122 
125  void SetLookupTable(vtkScalarsToColors *lut);
126  vtkScalarsToColors *GetLookupTable();
128 
133  virtual void CreateDefaultLookupTable();
134 
136 
139  vtkSetMacro(ScalarVisibility, int);
140  vtkGetMacro(ScalarVisibility, int);
141  vtkBooleanMacro(ScalarVisibility, int);
143 
145 
151  vtkSetMacro(Static, int);
152  vtkGetMacro(Static, int);
153  vtkBooleanMacro(Static, int);
155 
157 
169  vtkSetMacro(ColorMode, int);
170  vtkGetMacro(ColorMode, int);
172  { this->SetColorMode(VTK_COLOR_MODE_DEFAULT); }
174  { this->SetColorMode(VTK_COLOR_MODE_MAP_SCALARS); }
176  { this->SetColorMode(VTK_COLOR_MODE_DIRECT_SCALARS); }
178 
182  const char *GetColorModeAsString();
183 
185 
191  vtkSetMacro(InterpolateScalarsBeforeMapping, int);
192  vtkGetMacro(InterpolateScalarsBeforeMapping, int);
193  vtkBooleanMacro(InterpolateScalarsBeforeMapping, int);
195 
197 
205  vtkSetMacro(UseLookupTableScalarRange, int);
206  vtkGetMacro(UseLookupTableScalarRange, int);
207  vtkBooleanMacro(UseLookupTableScalarRange, int);
209 
211 
216  vtkSetVector2Macro(ScalarRange, double);
217  vtkGetVectorMacro(ScalarRange, double, 2);
219 
221 
229  vtkSetMacro(ImmediateModeRendering, int);
230  vtkGetMacro(ImmediateModeRendering, int);
231  vtkBooleanMacro(ImmediateModeRendering, int);
233 
235 
243  static void SetGlobalImmediateModeRendering(int val);
248  static int GetGlobalImmediateModeRendering();
250 
252 
261  vtkGetMacro(ForceCompileOnly, int);
262  void SetForceCompileOnly(int value);
264 
278  // When ScalarMode is set to use Field Data (ScalarModeToFieldData),
279  // you must call SelectColorArray to choose the field data array to
280  // be used to color cells. In this mode, the default behavior is to
281  // treat the field data tuples as being associated with cells. If
282  // the poly data contains triangle strips, the array is expected to
283  // contain the cell data for each mini-cell formed by any triangle
284  // strips in the poly data as opposed to treating them as a single
285  // tuple that applies to the entire strip. This mode can also be
286  // used to color the entire poly data by a single color obtained by
287  // mapping the tuple at a given index in the field data array
288  // through the color map. Use SetFieldDataTupleId() to specify
289  // the tuple index.
290  vtkSetMacro(ScalarMode, int);
291  vtkGetMacro(ScalarMode, int);
293  { this->SetScalarMode(VTK_SCALAR_MODE_DEFAULT); }
295  { this->SetScalarMode(VTK_SCALAR_MODE_USE_POINT_DATA); }
297  { this->SetScalarMode(VTK_SCALAR_MODE_USE_CELL_DATA); }
299  { this->SetScalarMode(VTK_SCALAR_MODE_USE_POINT_FIELD_DATA); }
301  { this->SetScalarMode(VTK_SCALAR_MODE_USE_CELL_FIELD_DATA); }
303  { this->SetScalarMode(VTK_SCALAR_MODE_USE_FIELD_DATA); }
304 
306 
311  void SelectColorArray(int arrayNum);
312  void SelectColorArray(const char* arrayName);
314 
315 
316  // When ScalarMode is set to UseFieldData, set the index of the
317  // tuple by which to color the entire data set. By default, the
318  // index is -1, which means to treat the field data array selected
319  // with SelectColorArray as having a scalar value for each cell.
320  // Indices of 0 or higher mean to use the tuple at the given index
321  // for coloring the entire data set.
322  vtkSetMacro(FieldDataTupleId, vtkIdType);
323  vtkGetMacro(FieldDataTupleId, vtkIdType);
324 
326 
331  void ColorByArrayComponent(int arrayNum, int component);
332  void ColorByArrayComponent(const char* arrayName, int component);
334 
338  char* GetArrayName() { return this->ArrayName; }
339  int GetArrayId() { return this->ArrayId; }
340  int GetArrayAccessMode() { return this->ArrayAccessMode; }
341  int GetArrayComponent() { return this->ArrayComponent; }
342 
346  const char *GetScalarModeAsString();
347 
349 
361  static void SetResolveCoincidentTopology(int val);
362  static int GetResolveCoincidentTopology();
363  static void SetResolveCoincidentTopologyToDefault();
365  { SetResolveCoincidentTopology(VTK_RESOLVE_OFF) ;}
367  { SetResolveCoincidentTopology(VTK_RESOLVE_POLYGON_OFFSET); }
369  { SetResolveCoincidentTopology(VTK_RESOLVE_SHIFT_ZBUFFER); }
371 
373 
378  static void SetResolveCoincidentTopologyPolygonOffsetParameters(
379  double factor, double units);
380  static void GetResolveCoincidentTopologyPolygonOffsetParameters(
381  double& factor, double& units);
383 
385 
389  void SetRelativeCoincidentTopologyPolygonOffsetParameters(
390  double factor, double units);
391  void GetRelativeCoincidentTopologyPolygonOffsetParameters(
392  double& factor, double& units);
394 
396 
401  static void SetResolveCoincidentTopologyLineOffsetParameters(
402  double factor, double units);
403  static void GetResolveCoincidentTopologyLineOffsetParameters(
404  double& factor, double& units);
406 
408 
412  void SetRelativeCoincidentTopologyLineOffsetParameters(
413  double factor, double units);
414  void GetRelativeCoincidentTopologyLineOffsetParameters(
415  double& factor, double& units);
417 
419 
424  static void SetResolveCoincidentTopologyPointOffsetParameter(
425  double units);
426  static void GetResolveCoincidentTopologyPointOffsetParameter(
427  double& units);
429 
431 
435  void SetRelativeCoincidentTopologyPointOffsetParameter(double units);
436  void GetRelativeCoincidentTopologyPointOffsetParameter(double& units);
438 
440 
444  void GetCoincidentTopologyPolygonOffsetParameters(
445  double& factor, double& units);
446  void GetCoincidentTopologyLineOffsetParameters(
447  double& factor, double& units);
448  void GetCoincidentTopologyPointOffsetParameter(double& units);
450 
452 
459  static void SetResolveCoincidentTopologyPolygonOffsetFaces(int faces);
460  static int GetResolveCoincidentTopologyPolygonOffsetFaces();
462 
464 
468  static void SetResolveCoincidentTopologyZShift(double val);
469  static double GetResolveCoincidentTopologyZShift();
471 
476  virtual double *GetBounds();
477  virtual void GetBounds(double bounds[6])
478  { this->vtkAbstractMapper3D::GetBounds(bounds); }
479 
485  void SetRenderTime(double time) {this->RenderTime = time;}
486  vtkGetMacro(RenderTime, double);
487 
492  vtkDataSet *GetInput();
493 
501  { return this->GetInput(); }
502 
504 
511  virtual vtkUnsignedCharArray *MapScalars(double alpha);
512  virtual vtkUnsignedCharArray *MapScalars(double alpha,
513  int &cellFlag);
514  virtual vtkUnsignedCharArray *MapScalars(vtkDataSet *input,
515  double alpha);
516  virtual vtkUnsignedCharArray *MapScalars(vtkDataSet *input,
517  double alpha,
518  int &cellFlag);
520 
522 
525  vtkSetMacro(ScalarMaterialMode,int);
526  vtkGetMacro(ScalarMaterialMode,int);
528  { this->SetScalarMaterialMode(VTK_MATERIALMODE_DEFAULT); }
530  { this->SetScalarMaterialMode(VTK_MATERIALMODE_AMBIENT); }
532  { this->SetScalarMaterialMode(VTK_MATERIALMODE_DIFFUSE); }
534  { this->SetScalarMaterialMode(VTK_MATERIALMODE_AMBIENT_AND_DIFFUSE); }
536 
540  const char *GetScalarMaterialModeAsString();
541 
550  virtual bool GetIsOpaque();
551 
558  virtual bool GetSupportsSelection()
559  { return false; }
560 
569  virtual int CanUseTextureMapForColoring(vtkDataObject* input);
570 
572 
575  void UseInvertibleColorFor(vtkDataObject *input,
576  int scalarMode,
577  int arrayAccessMode,
578  int arrayId,
579  const char *arrayName,
580  int arrayComponent,
581  double *scalarRange);
582  void UseInvertibleColorFor(int scalarMode,
583  int arrayAccessMode,
584  int arrayId,
585  const char *arrayName,
586  int arrayComponent,
587  double *scalarRange);
589 
593  void ClearInvertibleColor();
594 
598  static void ValueToColor(double value, double min, double scale,
599  unsigned char *color);
600 
604  static void ColorToValue(unsigned char *color, double min, double scale,
605  double &value);
606 
611  void ClearColorArrays();
612 
616  vtkUnsignedCharArray *GetColorMapColors();
617 
621  vtkFloatArray *GetColorCoordinates();
622 
626  vtkImageData* GetColorTextureMap();
627 
628 protected:
629  vtkMapper();
630  ~vtkMapper();
631 
632  // color mapped colors
634 
635  // Use texture coordinates for coloring.
637  // Coordinate for each point.
639  // 1D ColorMap used for the texture image.
641  void MapScalarsToTexture(vtkAbstractArray* scalars, double alpha);
642 
643  // Makes a lookup table that can be used for deferred colormaps
644  void AcquireInvertibleLookupTable();
647 
651  double ScalarRange[2];
657 
658  double RenderTime;
659 
660  // for coloring by a component of a field data array
661  int ArrayId;
662  char ArrayName[256];
665 
666  // If coloring by field data, which tuple to use to color the entire
667  // data set. If -1, treat array values as cell data.
669 
670  int Static;
671 
673 
675 
681 
682 private:
683  vtkMapper(const vtkMapper&) VTK_DELETE_FUNCTION;
684  void operator=(const vtkMapper&) VTK_DELETE_FUNCTION;
685 };
686 
687 #endif
int ForceCompileOnly
Definition: vtkMapper.h:672
vtkIdType FieldDataTupleId
Definition: vtkMapper.h:668
vtkAbstractArray * InvertibleScalars
Definition: vtkMapper.h:674
#define VTK_COLOR_MODE_DIRECT_SCALARS
void SetScalarModeToUsePointData()
Definition: vtkMapper.h:294
int ScalarVisibility
Definition: vtkMapper.h:649
void SetScalarModeToDefault()
Definition: vtkMapper.h:292
static void SetResolveCoincidentTopologyToShiftZBuffer()
Set/Get a global flag that controls whether coincident topology (e.g., a line on top of a polygon) is...
Definition: vtkMapper.h:368
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:51
#define VTK_SCALAR_MODE_USE_CELL_FIELD_DATA
void SetScalarMaterialModeToAmbientAndDiffuse()
Set/Get the light-model color mode.
Definition: vtkMapper.h:533
virtual void ReleaseGraphicsResources(vtkWindow *)
Release any graphics resources that are being consumed by this mapper.
Definition: vtkMapper.h:119
static vtkScalarsToColors * InvertibleLookupTable
Definition: vtkMapper.h:646
vtkDataSet * GetInputAsDataSet()
Get the input to this mapper as a vtkDataSet, instead of as a more specialized data type that the sub...
Definition: vtkMapper.h:500
int ScalarMaterialMode
Definition: vtkMapper.h:656
abstract class to specify dataset behavior
Definition: vtkDataSet.h:62
virtual vtkMTimeType GetMTime()
Override Modifiedtime as we have added Clipping planes.
Abstract superclass for all arrays.
static void SetResolveCoincidentTopologyToOff()
Set/Get a global flag that controls whether coincident topology (e.g., a line on top of a polygon) is...
Definition: vtkMapper.h:364
record modification and/or execution time
Definition: vtkTimeStamp.h:35
void SetScalarModeToUseCellData()
Definition: vtkMapper.h:296
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:41
vtkImageData * ColorTextureMap
Definition: vtkMapper.h:640
#define VTK_RESOLVE_SHIFT_ZBUFFER
Definition: vtkMapper.h:71
void SetScalarMaterialModeToDiffuse()
Set/Get the light-model color mode.
Definition: vtkMapper.h:531
static void GlobalImmediateModeRenderingOff()
Turn on/off flag to control whether data is rendered using immediate mode or note.
Definition: vtkMapper.h:246
vtkTimeStamp BuildTime
Definition: vtkMapper.h:650
void SetColorModeToDefault()
default (ColorModeToDefault), unsigned char scalars are treated as colors, and NOT mapped through the...
Definition: vtkMapper.h:171
abstract specification for renderers
Definition: vtkRenderer.h:63
int ArrayAccessMode
Definition: vtkMapper.h:664
static void SetResolveCoincidentTopologyToPolygonOffset()
Set/Get a global flag that controls whether coincident topology (e.g., a line on top of a polygon) is...
Definition: vtkMapper.h:366
void SetScalarModeToUseFieldData()
Definition: vtkMapper.h:302
int vtkIdType
Definition: vtkType.h:287
double CoincidentLineFactor
Definition: vtkMapper.h:678
vtkUnsignedCharArray * Colors
Definition: vtkMapper.h:633
vtkTypeUInt64 vtkMTimeType
Definition: vtkType.h:248
void SetColorModeToDirectScalars()
default (ColorModeToDefault), unsigned char scalars are treated as colors, and NOT mapped through the...
Definition: vtkMapper.h:175
int ScalarMode
Definition: vtkMapper.h:655
#define VTK_MATERIALMODE_DIFFUSE
Definition: vtkMapper.h:78
Superclass for mapping scalar values to colors.
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
void SetScalarMaterialModeToAmbient()
Set/Get the light-model color mode.
Definition: vtkMapper.h:529
double CoincidentPointOffset
Definition: vtkMapper.h:680
void SetRenderTime(double time)
This instance variable is used by vtkLODActor to determine which mapper to use.
Definition: vtkMapper.h:485
#define VTK_COLOR_MODE_MAP_SCALARS
#define VTK_SCALAR_MODE_USE_POINT_DATA
a simple class to control print indentation
Definition: vtkIndent.h:39
void SetScalarModeToUsePointFieldData()
Definition: vtkMapper.h:298
double CoincidentLineOffset
Definition: vtkMapper.h:679
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
#define VTK_SCALAR_MODE_USE_POINT_FIELD_DATA
#define VTK_MATERIALMODE_AMBIENT
Definition: vtkMapper.h:77
double CoincidentPolygonFactor
Definition: vtkMapper.h:676
static void SetGlobalImmediateModeRendering(int val)
Turn on/off flag to control whether data is rendered using immediate mode or note.
int ImmediateModeRendering
Definition: vtkMapper.h:653
double CoincidentPolygonOffset
Definition: vtkMapper.h:677
virtual double * GetBounds()=0
Return bounding box (array of six doubles) of data expressed as (xmin,xmax, ymin,ymax, zmin,zmax).
abstract class specifies interface to map 3D data
int InterpolateScalarsBeforeMapping
Definition: vtkMapper.h:636
#define VTK_COLOR_MODE_DEFAULT
bool UseInvertibleColors
Definition: vtkMapper.h:645
#define VTK_SCALAR_MODE_USE_FIELD_DATA
abstract class specifies interface to map data to graphics primitives
Definition: vtkMapper.h:91
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
dynamic, self-adjusting array of unsigned char
virtual void GetBounds(double bounds[6])
Get the bounds for this mapper as (Xmin,Xmax,Ymin,Ymax,Zmin,Zmax).
Definition: vtkMapper.h:477
abstract class specifies interface to map data
int ArrayId
Definition: vtkMapper.h:661
int GetArrayAccessMode()
Definition: vtkMapper.h:340
void SetColorModeToMapScalars()
default (ColorModeToDefault), unsigned char scalars are treated as colors, and NOT mapped through the...
Definition: vtkMapper.h:173
#define VTK_MATERIALMODE_DEFAULT
Definition: vtkMapper.h:76
int Static
Definition: vtkMapper.h:670
int ArrayComponent
Definition: vtkMapper.h:663
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
int GetArrayId()
Definition: vtkMapper.h:339
void ShallowCopy(vtkAbstractMapper *m)
Make a shallow copy of this mapper.
vtkFloatArray * ColorCoordinates
Definition: vtkMapper.h:638
int UseLookupTableScalarRange
Definition: vtkMapper.h:652
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
virtual bool GetSupportsSelection()
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THIS METHOD OUTSIDE OF THE RENDERI...
Definition: vtkMapper.h:558
void SetScalarMaterialModeToDefault()
Set/Get the light-model color mode.
Definition: vtkMapper.h:527
#define VTK_SCALAR_MODE_USE_CELL_DATA
#define VTK_RESOLVE_POLYGON_OFFSET
Definition: vtkMapper.h:70
general representation of visualization data
Definition: vtkDataObject.h:64
void SetScalarModeToUseCellFieldData()
Definition: vtkMapper.h:300
vtkScalarsToColors * LookupTable
Definition: vtkMapper.h:648
int GetArrayComponent()
Definition: vtkMapper.h:341
static void GlobalImmediateModeRenderingOn()
Turn on/off flag to control whether data is rendered using immediate mode or note.
Definition: vtkMapper.h:244
double RenderTime
Definition: vtkMapper.h:658
#define VTK_SCALAR_MODE_DEFAULT
#define VTK_RESOLVE_OFF
Definition: vtkMapper.h:69
#define VTK_MATERIALMODE_AMBIENT_AND_DIFFUSE
Definition: vtkMapper.h:79
char * GetArrayName()
Get the array name or number and component to color by.
Definition: vtkMapper.h:338
int ColorMode
Definition: vtkMapper.h:654