VTK  9.2.6
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 =========================================================================*/
62 #ifndef vtkMapper_h
63 #define vtkMapper_h
64 
65 #include "vtkAbstractMapper3D.h"
66 #include "vtkRenderingCoreModule.h" // For export macro
67 #include "vtkSmartPointer.h" // needed for vtkSmartPointer.
68 #include "vtkSystemIncludes.h" // For VTK_COLOR_MODE_DEFAULT and _MAP_SCALARS
69 #include <vector> // for method args
70 
71 #define VTK_RESOLVE_OFF 0
72 #define VTK_RESOLVE_POLYGON_OFFSET 1
73 #define VTK_RESOLVE_SHIFT_ZBUFFER 2
74 
75 #define VTK_GET_ARRAY_BY_ID 0
76 #define VTK_GET_ARRAY_BY_NAME 1
77 
78 #define VTK_MATERIALMODE_DEFAULT 0
79 #define VTK_MATERIALMODE_AMBIENT 1
80 #define VTK_MATERIALMODE_DIFFUSE 2
81 #define VTK_MATERIALMODE_AMBIENT_AND_DIFFUSE 3
82 
83 class vtkActor;
84 class vtkDataSet;
85 class vtkDataObject;
86 class vtkFloatArray;
88 class vtkImageData;
89 class vtkProp;
90 class vtkRenderer;
91 class vtkScalarsToColors;
92 class vtkSelection;
94 class vtkWindow;
95 
96 class VTKRENDERINGCORE_EXPORT vtkMapper : public vtkAbstractMapper3D
97 {
98 public:
100  void PrintSelf(ostream& os, vtkIndent indent) override;
101 
105  void ShallowCopy(vtkAbstractMapper* m) override;
106 
111  vtkMTimeType GetMTime() override;
112 
117  virtual void Render(vtkRenderer* ren, vtkActor* a) = 0;
118 
125 
127 
133 
138  virtual void CreateDefaultLookupTable();
139 
141 
144  vtkSetMacro(ScalarVisibility, vtkTypeBool);
145  vtkGetMacro(ScalarVisibility, vtkTypeBool);
146  vtkBooleanMacro(ScalarVisibility, vtkTypeBool);
148 
150 
156  vtkSetMacro(Static, vtkTypeBool);
157  vtkGetMacro(Static, vtkTypeBool);
158  vtkBooleanMacro(Static, vtkTypeBool);
160 
162 
174  vtkSetMacro(ColorMode, int);
175  vtkGetMacro(ColorMode, int);
176  void SetColorModeToDefault() { this->SetColorMode(VTK_COLOR_MODE_DEFAULT); }
177  void SetColorModeToMapScalars() { this->SetColorMode(VTK_COLOR_MODE_MAP_SCALARS); }
180 
184  const char* GetColorModeAsString();
185 
187 
193  vtkSetMacro(InterpolateScalarsBeforeMapping, vtkTypeBool);
194  vtkGetMacro(InterpolateScalarsBeforeMapping, vtkTypeBool);
195  vtkBooleanMacro(InterpolateScalarsBeforeMapping, vtkTypeBool);
197 
199 
207  vtkSetMacro(UseLookupTableScalarRange, vtkTypeBool);
208  vtkGetMacro(UseLookupTableScalarRange, vtkTypeBool);
209  vtkBooleanMacro(UseLookupTableScalarRange, vtkTypeBool);
211 
213 
218  vtkSetVector2Macro(ScalarRange, double);
219  vtkGetVectorMacro(ScalarRange, double, 2);
221 
235  // When ScalarMode is set to use Field Data (ScalarModeToFieldData),
236  // you must call SelectColorArray to choose the field data array to
237  // be used to color cells. In this mode, the default behavior is to
238  // treat the field data tuples as being associated with cells. If
239  // the poly data contains triangle strips, the array is expected to
240  // contain the cell data for each mini-cell formed by any triangle
241  // strips in the poly data as opposed to treating them as a single
242  // tuple that applies to the entire strip. This mode can also be
243  // used to color the entire poly data by a single color obtained by
244  // mapping the tuple at a given index in the field data array
245  // through the color map. Use SetFieldDataTupleId() to specify
246  // the tuple index.
247  vtkSetMacro(ScalarMode, int);
248  vtkGetMacro(ScalarMode, int);
249  void SetScalarModeToDefault() { this->SetScalarMode(VTK_SCALAR_MODE_DEFAULT); }
253  {
254  this->SetScalarMode(VTK_SCALAR_MODE_USE_POINT_FIELD_DATA);
255  }
257  {
258  this->SetScalarMode(VTK_SCALAR_MODE_USE_CELL_FIELD_DATA);
259  }
261 
263 
268  void SelectColorArray(int arrayNum);
269  void SelectColorArray(const char* arrayName);
271 
272  // When ScalarMode is set to UseFieldData, set the index of the
273  // tuple by which to color the entire data set. By default, the
274  // index is -1, which means to treat the field data array selected
275  // with SelectColorArray as having a scalar value for each cell.
276  // Indices of 0 or higher mean to use the tuple at the given index
277  // for coloring the entire data set.
278  vtkSetMacro(FieldDataTupleId, vtkIdType);
279  vtkGetMacro(FieldDataTupleId, vtkIdType);
280 
282 
287  void ColorByArrayComponent(int arrayNum, int component);
288  void ColorByArrayComponent(const char* arrayName, int component);
290 
294  vtkGetStringMacro(ArrayName);
295  vtkSetStringMacro(ArrayName);
296  vtkGetMacro(ArrayId, int);
297  vtkSetMacro(ArrayId, int);
298  vtkGetMacro(ArrayAccessMode, int);
299  vtkSetMacro(ArrayAccessMode, int);
300  vtkGetMacro(ArrayComponent, int);
301  vtkSetMacro(ArrayComponent, int);
302 
306  const char* GetScalarModeAsString();
307 
309 
319  static void SetResolveCoincidentTopology(int val);
322  static void SetResolveCoincidentTopologyToOff() { SetResolveCoincidentTopology(VTK_RESOLVE_OFF); }
324  {
325  SetResolveCoincidentTopology(VTK_RESOLVE_POLYGON_OFFSET);
326  }
328  {
329  SetResolveCoincidentTopology(VTK_RESOLVE_SHIFT_ZBUFFER);
330  }
332 
334 
339  static void SetResolveCoincidentTopologyPolygonOffsetParameters(double factor, double units);
340  static void GetResolveCoincidentTopologyPolygonOffsetParameters(double& factor, double& units);
342 
344 
348  void SetRelativeCoincidentTopologyPolygonOffsetParameters(double factor, double units);
349  void GetRelativeCoincidentTopologyPolygonOffsetParameters(double& factor, double& units);
351 
353 
358  static void SetResolveCoincidentTopologyLineOffsetParameters(double factor, double units);
359  static void GetResolveCoincidentTopologyLineOffsetParameters(double& factor, double& units);
361 
363 
367  void SetRelativeCoincidentTopologyLineOffsetParameters(double factor, double units);
368  void GetRelativeCoincidentTopologyLineOffsetParameters(double& factor, double& units);
370 
372 
380 
382 
389 
391 
395  void GetCoincidentTopologyPolygonOffsetParameters(double& factor, double& units);
396  void GetCoincidentTopologyLineOffsetParameters(double& factor, double& units);
399 
401 
411 
413 
417  static void SetResolveCoincidentTopologyZShift(double val);
420 
425  double* GetBounds() VTK_SIZEHINT(6) override;
426  void GetBounds(double bounds[6]) override { this->vtkAbstractMapper3D::GetBounds(bounds); }
427 
433  void SetRenderTime(double time) { this->RenderTime = time; }
434  vtkGetMacro(RenderTime, double);
435 
441 
448  vtkDataSet* GetInputAsDataSet() { return this->GetInput(); }
449 
451 
459  virtual vtkUnsignedCharArray* MapScalars(double alpha, int& cellFlag);
461  virtual vtkUnsignedCharArray* MapScalars(vtkDataSet* input, double alpha, int& cellFlag);
463 
465 
470  virtual bool HasOpaqueGeometry();
473 
480  virtual bool GetSupportsSelection() { return false; }
481 
487  std::vector<unsigned int>& /* pixeloffsets */, vtkProp* /* prop */)
488  {
489  }
490 
500 
506 
511 
516 
521 
523 
527  vtkGetObjectMacro(Selection, vtkSelection);
528  virtual void SetSelection(vtkSelection*);
530 
531 protected:
533  ~vtkMapper() override;
534 
535  // color mapped colors
537 
538  // Use texture coordinates for coloring.
540  // Coordinate for each point.
542  // 1D ColorMap used for the texture image.
545 
549  double ScalarRange[2];
551 
554 
555  double RenderTime;
556 
557  // for coloring by a component of a field data array
558  int ArrayId;
559  char* ArrayName;
562 
563  // If coloring by field data, which tuple to use to color the entire
564  // data set. If -1, treat array values as cell data.
566 
568 
574 
575  vtkSelection* Selection = nullptr;
576 
577 private:
578  vtkMapper(const vtkMapper&) = delete;
579  void operator=(const vtkMapper&) = delete;
580 };
581 
582 #endif
Abstract superclass for all arrays.
abstract class specifies interface to map 3D data
virtual double * GetBounds()=0
Return bounding box (array of six doubles) of data expressed as (xmin,xmax, ymin,ymax,...
abstract class specifies interface to map data
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:61
general representation of visualization data
Definition: vtkDataObject.h:75
abstract class to specify dataset behavior
Definition: vtkDataSet.h:72
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:51
topologically and geometrically regular array of data
Definition: vtkImageData.h:63
a simple class to control print indentation
Definition: vtkIndent.h:49
abstract class specifies interface to map data to graphics primitives
Definition: vtkMapper.h:97
virtual bool HasOpaqueGeometry()
Some introspection on the type of data the mapper will render used by props to determine if they shou...
~vtkMapper() override
virtual int CanUseTextureMapForColoring(vtkDataObject *input)
Returns if we can use texture maps for scalar coloring.
void GetCoincidentTopologyLineOffsetParameters(double &factor, double &units)
Get the net parameters for handling coincident topology obtained by summing the global values with th...
static int GetResolveCoincidentTopology()
Set/Get a global flag that controls whether coincident topology (e.g., a line on top of a polygon) is...
void SelectColorArray(const char *arrayName)
When ScalarMode is set to UsePointFieldData or UseCellFieldData, you can specify which array to use f...
void SetScalarModeToUsePointFieldData()
Definition: vtkMapper.h:252
vtkScalarsToColors * LookupTable
Definition: vtkMapper.h:546
double CoincidentPolygonFactor
Definition: vtkMapper.h:569
void SetColorModeToMapScalars()
default (ColorModeToDefault), unsigned char scalars are treated as colors, and NOT mapped through the...
Definition: vtkMapper.h:177
int ColorMode
Definition: vtkMapper.h:552
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetScalarModeToUseCellData()
Definition: vtkMapper.h:251
vtkUnsignedCharArray * GetColorMapColors()
Provide read access to the color array.
void SetLookupTable(vtkScalarsToColors *lut)
Specify a lookup table for the mapper to use.
vtkTypeBool InterpolateScalarsBeforeMapping
Definition: vtkMapper.h:539
void SetColorModeToDefault()
default (ColorModeToDefault), unsigned char scalars are treated as colors, and NOT mapped through the...
Definition: vtkMapper.h:176
void SelectColorArray(int arrayNum)
When ScalarMode is set to UsePointFieldData or UseCellFieldData, you can specify which array to use f...
vtkTypeBool UseLookupTableScalarRange
Definition: vtkMapper.h:550
void SetScalarModeToDefault()
Definition: vtkMapper.h:249
int ScalarMode
Definition: vtkMapper.h:553
virtual bool GetSupportsSelection()
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THIS METHOD OUTSIDE OF THE RENDERI...
Definition: vtkMapper.h:480
static void GetResolveCoincidentTopologyLineOffsetParameters(double &factor, double &units)
Used to set the line offset scale factor and units.
void GetCoincidentTopologyPolygonOffsetParameters(double &factor, double &units)
Get the net parameters for handling coincident topology obtained by summing the global values with th...
virtual void CreateDefaultLookupTable()
Create default lookup table.
double RenderTime
Definition: vtkMapper.h:555
void SetScalarModeToUseCellFieldData()
Definition: vtkMapper.h:256
void MapScalarsToTexture(vtkAbstractArray *scalars, double alpha)
virtual vtkUnsignedCharArray * MapScalars(vtkDataSet *input, double alpha, int &cellFlag)
Map the scalars (if there are any scalars and ScalarVisibility is on) through the lookup table,...
static void GetResolveCoincidentTopologyPointOffsetParameter(double &units)
Used to set the point offset value Used when ResolveCoincidentTopology is set to PolygonOffset.
static void SetResolveCoincidentTopologyToDefault()
Set/Get a global flag that controls whether coincident topology (e.g., a line on top of a polygon) is...
virtual bool HasTranslucentPolygonalGeometry()
Some introspection on the type of data the mapper will render used by props to determine if they shou...
vtkImageData * ColorTextureMap
Definition: vtkMapper.h:543
vtkTimeStamp BuildTime
Definition: vtkMapper.h:548
void ColorByArrayComponent(int arrayNum, int component)
Legacy: These methods used to be used to specify the array component.
void GetRelativeCoincidentTopologyPointOffsetParameter(double &units)
Used to set the point offset value relative to the global Used when ResolveCoincidentTopology is set ...
void SetColorModeToDirectScalars()
default (ColorModeToDefault), unsigned char scalars are treated as colors, and NOT mapped through the...
Definition: vtkMapper.h:178
vtkTypeBool Static
Definition: vtkMapper.h:567
virtual vtkUnsignedCharArray * MapScalars(vtkDataSet *input, double alpha)
Map the scalars (if there are any scalars and ScalarVisibility is on) through the lookup table,...
virtual vtkUnsignedCharArray * MapScalars(double alpha)
Map the scalars (if there are any scalars and ScalarVisibility is on) through the lookup table,...
void SetScalarModeToUseFieldData()
Definition: vtkMapper.h:260
static double GetResolveCoincidentTopologyZShift()
Used to set the z-shift if ResolveCoincidentTopology is set to ShiftZBuffer.
static void SetResolveCoincidentTopologyPolygonOffsetParameters(double factor, double units)
Used to set the polygon offset scale factor and units.
int ArrayAccessMode
Definition: vtkMapper.h:561
void SetRelativeCoincidentTopologyLineOffsetParameters(double factor, double units)
Used to set the line offset values relative to the global Used when ResolveCoincidentTopology is set ...
vtkDataSet * GetInput()
Get the input as a vtkDataSet.
int ArrayId
Definition: vtkMapper.h:558
int ArrayComponent
Definition: vtkMapper.h:560
void SetRenderTime(double time)
This instance variable is used by vtkLODActor to determine which mapper to use.
Definition: vtkMapper.h:433
static void SetResolveCoincidentTopology(int val)
Set/Get a global flag that controls whether coincident topology (e.g., a line on top of a polygon) is...
void GetRelativeCoincidentTopologyLineOffsetParameters(double &factor, double &units)
Used to set the line offset values relative to the global Used when ResolveCoincidentTopology is set ...
vtkUnsignedCharArray * Colors
Definition: vtkMapper.h:536
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:322
virtual void Render(vtkRenderer *ren, vtkActor *a)=0
Method initiates the mapping process.
vtkTypeBool ScalarVisibility
Definition: vtkMapper.h:547
vtkMTimeType GetMTime() override
Overload standard modified time function.
vtkIdType FieldDataTupleId
Definition: vtkMapper.h:565
double CoincidentPointOffset
Definition: vtkMapper.h:573
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:323
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:327
void ColorByArrayComponent(const char *arrayName, int component)
Legacy: These methods used to be used to specify the array component.
void GetRelativeCoincidentTopologyPolygonOffsetParameters(double &factor, double &units)
Used to set the polygon offset values relative to the global Used when ResolveCoincidentTopology is s...
static int GetResolveCoincidentTopologyPolygonOffsetFaces()
Used when ResolveCoincidentTopology is set to PolygonOffset.
virtual void ProcessSelectorPixelBuffers(vtkHardwareSelector *, std::vector< unsigned int > &, vtkProp *)
allows a mapper to update a selections color buffers Called from a prop which in turn is called from ...
Definition: vtkMapper.h:486
double CoincidentLineOffset
Definition: vtkMapper.h:572
void SetRelativeCoincidentTopologyPointOffsetParameter(double units)
Used to set the point offset value relative to the global Used when ResolveCoincidentTopology is set ...
virtual vtkUnsignedCharArray * MapScalars(double alpha, int &cellFlag)
Map the scalars (if there are any scalars and ScalarVisibility is on) through the lookup table,...
static void SetResolveCoincidentTopologyPointOffsetParameter(double units)
Used to set the point offset value Used when ResolveCoincidentTopology is set to PolygonOffset.
vtkImageData * GetColorTextureMap()
Provide read access to the color texture array.
vtkFloatArray * ColorCoordinates
Definition: vtkMapper.h:541
void SetRelativeCoincidentTopologyPolygonOffsetParameters(double factor, double units)
Used to set the polygon offset values relative to the global Used when ResolveCoincidentTopology is s...
void ShallowCopy(vtkAbstractMapper *m) override
Make a shallow copy of this mapper.
void SetScalarModeToUsePointData()
Definition: vtkMapper.h:250
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:448
static void SetResolveCoincidentTopologyLineOffsetParameters(double factor, double units)
Used to set the line offset scale factor and units.
virtual void SetSelection(vtkSelection *)
Set/Get selection used to display particular points or cells in a second pass.
static void SetResolveCoincidentTopologyPolygonOffsetFaces(int faces)
Used when ResolveCoincidentTopology is set to PolygonOffset.
static void GetResolveCoincidentTopologyPolygonOffsetParameters(double &factor, double &units)
Used to set the polygon offset scale factor and units.
void GetCoincidentTopologyPointOffsetParameter(double &units)
Get the net parameters for handling coincident topology obtained by summing the global values with th...
double CoincidentLineFactor
Definition: vtkMapper.h:571
static void SetResolveCoincidentTopologyZShift(double val)
Used to set the z-shift if ResolveCoincidentTopology is set to ShiftZBuffer.
const char * GetScalarModeAsString()
Return the method for obtaining scalar data.
vtkScalarsToColors * GetLookupTable()
Specify a lookup table for the mapper to use.
vtkFloatArray * GetColorCoordinates()
Provide read access to the color texture coordinate array.
double CoincidentPolygonOffset
Definition: vtkMapper.h:570
double * GetBounds() override
Return bounding box (array of six doubles) of data expressed as (xmin,xmax, ymin,ymax,...
void ClearColorArrays()
Call to force a rebuild of color result arrays on next MapScalars.
char * ArrayName
Definition: vtkMapper.h:559
const char * GetColorModeAsString()
Return the method of coloring scalar data.
void ReleaseGraphicsResources(vtkWindow *) override
Release any graphics resources that are being consumed by this mapper.
Definition: vtkMapper.h:124
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:66
abstract specification for renderers
Definition: vtkRenderer.h:82
Superclass for mapping scalar values to colors.
data object that represents a "selection" in VTK.
Definition: vtkSelection.h:69
record modification and/or execution time
Definition: vtkTimeStamp.h:45
dynamic, self-adjusting array of unsigned char
window superclass for vtkRenderWindow
Definition: vtkWindow.h:48
void GetBounds(T a, double bds[6])
@ component
Definition: vtkX3D.h:181
@ time
Definition: vtkX3D.h:503
@ alpha
Definition: vtkX3D.h:256
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_SCALAR_MODE_DEFAULT
#define VTK_SCALAR_MODE_USE_POINT_DATA
#define VTK_SCALAR_MODE_USE_FIELD_DATA
#define VTK_SCALAR_MODE_USE_CELL_DATA
#define VTK_SCALAR_MODE_USE_CELL_FIELD_DATA
#define VTK_SCALAR_MODE_USE_POINT_FIELD_DATA
#define VTK_RESOLVE_POLYGON_OFFSET
Definition: vtkMapper.h:72
#define VTK_RESOLVE_OFF
Definition: vtkMapper.h:71
#define VTK_RESOLVE_SHIFT_ZBUFFER
Definition: vtkMapper.h:73
#define VTK_COLOR_MODE_MAP_SCALARS
#define VTK_COLOR_MODE_DEFAULT
#define VTK_COLOR_MODE_DIRECT_SCALARS
int vtkIdType
Definition: vtkType.h:332
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:287
#define VTK_SIZEHINT(...)