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) VTK_OVERRIDE;
96 
101 
106  vtkMTimeType GetMTime() VTK_OVERRIDE;
107 
112  virtual void Render(vtkRenderer *ren, vtkActor *a) = 0;
113 
119  void ReleaseGraphicsResources(vtkWindow *) VTK_OVERRIDE {}
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  vtkGetStringMacro(ArrayName);
339  vtkSetStringMacro(ArrayName);
340  vtkGetMacro(ArrayId, int);
341  vtkSetMacro(ArrayId, int);
342  vtkGetMacro(ArrayAccessMode, int);
343  vtkSetMacro(ArrayAccessMode, int);
344  vtkGetMacro(ArrayComponent, int);
345  vtkSetMacro(ArrayComponent, int);
346 
350  const char *GetScalarModeAsString();
351 
353 
365  static void SetResolveCoincidentTopology(int val);
366  static int GetResolveCoincidentTopology();
367  static void SetResolveCoincidentTopologyToDefault();
369  { SetResolveCoincidentTopology(VTK_RESOLVE_OFF) ;}
371  { SetResolveCoincidentTopology(VTK_RESOLVE_POLYGON_OFFSET); }
373  { SetResolveCoincidentTopology(VTK_RESOLVE_SHIFT_ZBUFFER); }
375 
377 
382  static void SetResolveCoincidentTopologyPolygonOffsetParameters(
383  double factor, double units);
384  static void GetResolveCoincidentTopologyPolygonOffsetParameters(
385  double& factor, double& units);
387 
389 
393  void SetRelativeCoincidentTopologyPolygonOffsetParameters(
394  double factor, double units);
395  void GetRelativeCoincidentTopologyPolygonOffsetParameters(
396  double& factor, double& units);
398 
400 
405  static void SetResolveCoincidentTopologyLineOffsetParameters(
406  double factor, double units);
407  static void GetResolveCoincidentTopologyLineOffsetParameters(
408  double& factor, double& units);
410 
412 
416  void SetRelativeCoincidentTopologyLineOffsetParameters(
417  double factor, double units);
418  void GetRelativeCoincidentTopologyLineOffsetParameters(
419  double& factor, double& units);
421 
423 
428  static void SetResolveCoincidentTopologyPointOffsetParameter(
429  double units);
430  static void GetResolveCoincidentTopologyPointOffsetParameter(
431  double& units);
433 
435 
439  void SetRelativeCoincidentTopologyPointOffsetParameter(double units);
440  void GetRelativeCoincidentTopologyPointOffsetParameter(double& units);
442 
444 
448  void GetCoincidentTopologyPolygonOffsetParameters(
449  double& factor, double& units);
450  void GetCoincidentTopologyLineOffsetParameters(
451  double& factor, double& units);
452  void GetCoincidentTopologyPointOffsetParameter(double& units);
454 
456 
463  static void SetResolveCoincidentTopologyPolygonOffsetFaces(int faces);
464  static int GetResolveCoincidentTopologyPolygonOffsetFaces();
466 
468 
472  static void SetResolveCoincidentTopologyZShift(double val);
473  static double GetResolveCoincidentTopologyZShift();
475 
480  double *GetBounds() VTK_OVERRIDE;
481  void GetBounds(double bounds[6]) VTK_OVERRIDE
482  { this->vtkAbstractMapper3D::GetBounds(bounds); }
483 
489  void SetRenderTime(double time) {this->RenderTime = time;}
490  vtkGetMacro(RenderTime, double);
491 
496  vtkDataSet *GetInput();
497 
505  { return this->GetInput(); }
506 
508 
515  virtual vtkUnsignedCharArray *MapScalars(double alpha);
516  virtual vtkUnsignedCharArray *MapScalars(double alpha,
517  int &cellFlag);
518  virtual vtkUnsignedCharArray *MapScalars(vtkDataSet *input,
519  double alpha);
520  virtual vtkUnsignedCharArray *MapScalars(vtkDataSet *input,
521  double alpha,
522  int &cellFlag);
524 
526 
529  vtkSetMacro(ScalarMaterialMode,int);
530  vtkGetMacro(ScalarMaterialMode,int);
532  { this->SetScalarMaterialMode(VTK_MATERIALMODE_DEFAULT); }
534  { this->SetScalarMaterialMode(VTK_MATERIALMODE_AMBIENT); }
536  { this->SetScalarMaterialMode(VTK_MATERIALMODE_DIFFUSE); }
538  { this->SetScalarMaterialMode(VTK_MATERIALMODE_AMBIENT_AND_DIFFUSE); }
540 
544  const char *GetScalarMaterialModeAsString();
545 
554  virtual bool GetIsOpaque();
555 
562  virtual bool GetSupportsSelection()
563  { return false; }
564 
573  virtual int CanUseTextureMapForColoring(vtkDataObject* input);
574 
579  void ClearColorArrays();
580 
584  vtkUnsignedCharArray *GetColorMapColors();
585 
589  vtkFloatArray *GetColorCoordinates();
590 
594  vtkImageData* GetColorTextureMap();
595 
596 protected:
597  vtkMapper();
598  ~vtkMapper() VTK_OVERRIDE;
599 
600  // color mapped colors
602 
603  // Use texture coordinates for coloring.
605  // Coordinate for each point.
607  // 1D ColorMap used for the texture image.
609  void MapScalarsToTexture(vtkAbstractArray* scalars, double alpha);
610 
614  double ScalarRange[2];
620 
621  double RenderTime;
622 
623  // for coloring by a component of a field data array
624  int ArrayId;
625  char* ArrayName;
628 
629  // If coloring by field data, which tuple to use to color the entire
630  // data set. If -1, treat array values as cell data.
632 
633  int Static;
634 
636 
642 
643 private:
644  vtkMapper(const vtkMapper&) VTK_DELETE_FUNCTION;
645  void operator=(const vtkMapper&) VTK_DELETE_FUNCTION;
646 };
647 
648 #endif
int ForceCompileOnly
Definition: vtkMapper.h:635
vtkIdType FieldDataTupleId
Definition: vtkMapper.h:631
#define VTK_COLOR_MODE_DIRECT_SCALARS
void SetScalarModeToUsePointData()
Definition: vtkMapper.h:294
int ScalarVisibility
Definition: vtkMapper.h:612
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:372
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:537
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:504
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:300
int ScalarMaterialMode
Definition: vtkMapper.h:619
vtkMTimeType GetMTime() override
Override Modifiedtime as we have added Clipping planes.
abstract class to specify dataset behavior
Definition: vtkDataSet.h:62
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:368
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:608
#define VTK_RESOLVE_SHIFT_ZBUFFER
Definition: vtkMapper.h:71
void SetScalarMaterialModeToDiffuse()
Set/Get the light-model color mode.
Definition: vtkMapper.h:535
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:613
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:627
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:370
void SetScalarModeToUseFieldData()
Definition: vtkMapper.h:302
int vtkIdType
Definition: vtkType.h:345
double CoincidentLineFactor
Definition: vtkMapper.h:639
vtkUnsignedCharArray * Colors
Definition: vtkMapper.h:601
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:618
#define VTK_MATERIALMODE_DIFFUSE
Definition: vtkMapper.h:78
Superclass for mapping scalar values to colors.
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
void GetBounds(double bounds[6]) override
Get the bounds for this mapper as (Xmin,Xmax,Ymin,Ymax,Zmin,Zmax).
Definition: vtkMapper.h:481
void SetScalarMaterialModeToAmbient()
Set/Get the light-model color mode.
Definition: vtkMapper.h:533
double CoincidentPointOffset
Definition: vtkMapper.h:641
void SetRenderTime(double time)
This instance variable is used by vtkLODActor to determine which mapper to use.
Definition: vtkMapper.h:489
#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:640
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:637
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:616
double CoincidentPolygonOffset
Definition: vtkMapper.h:638
vtkGetStringMacro(ExtensionsString)
Returns a string listing all available extensions.
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:604
#define VTK_COLOR_MODE_DEFAULT
#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
abstract class specifies interface to map data
int ArrayId
Definition: vtkMapper.h:624
char * ArrayName
Definition: vtkMapper.h:625
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
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:633
int ArrayComponent
Definition: vtkMapper.h:626
void ShallowCopy(vtkAbstractMapper *m)
Make a shallow copy of this mapper.
vtkFloatArray * ColorCoordinates
Definition: vtkMapper.h:606
int UseLookupTableScalarRange
Definition: vtkMapper.h:615
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:562
void SetScalarMaterialModeToDefault()
Set/Get the light-model color mode.
Definition: vtkMapper.h:531
#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:611
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:621
#define VTK_SCALAR_MODE_DEFAULT
#define VTK_RESOLVE_OFF
Definition: vtkMapper.h:69
#define VTK_MATERIALMODE_AMBIENT_AND_DIFFUSE
Definition: vtkMapper.h:79
int ColorMode
Definition: vtkMapper.h:617