VTK  9.3.20240419
vtkMapper.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
100 #ifndef vtkMapper_h
101 #define vtkMapper_h
102 
103 #include "vtkAbstractMapper3D.h"
104 #include "vtkRenderingCoreModule.h" // For export macro
105 #include "vtkSmartPointer.h" // needed for vtkSmartPointer.
106 #include "vtkSystemIncludes.h" // For VTK_COLOR_MODE_DEFAULT and _MAP_SCALARS
107 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
108 #include <vector> // for method args
109 
110 #define VTK_RESOLVE_OFF 0
111 #define VTK_RESOLVE_POLYGON_OFFSET 1
112 #define VTK_RESOLVE_SHIFT_ZBUFFER 2
113 
114 #define VTK_GET_ARRAY_BY_ID 0
115 #define VTK_GET_ARRAY_BY_NAME 1
116 
117 #define VTK_MATERIALMODE_DEFAULT 0
118 #define VTK_MATERIALMODE_AMBIENT 1
119 #define VTK_MATERIALMODE_DIFFUSE 2
120 #define VTK_MATERIALMODE_AMBIENT_AND_DIFFUSE 3
121 
122 VTK_ABI_NAMESPACE_BEGIN
123 class vtkActor;
124 class vtkDataSet;
125 class vtkDataObject;
126 class vtkFloatArray;
127 class vtkHardwareSelector;
128 class vtkImageData;
129 class vtkProp;
130 class vtkRenderer;
131 class vtkScalarsToColors;
132 class vtkSelection;
134 class vtkWindow;
135 
136 class VTKRENDERINGCORE_EXPORT VTK_MARSHALAUTO vtkMapper : public vtkAbstractMapper3D
137 {
138 public:
140  void PrintSelf(ostream& os, vtkIndent indent) override;
141 
145  void ShallowCopy(vtkAbstractMapper* m) override;
146 
151  vtkMTimeType GetMTime() override;
152 
157  virtual void Render(vtkRenderer* ren, vtkActor* a) = 0;
158 
165 
167 
173 
178  virtual void CreateDefaultLookupTable();
179 
181 
184  vtkSetMacro(ScalarVisibility, vtkTypeBool);
185  vtkGetMacro(ScalarVisibility, vtkTypeBool);
186  vtkBooleanMacro(ScalarVisibility, vtkTypeBool);
188 
190 
196  vtkSetMacro(Static, vtkTypeBool);
197  vtkGetMacro(Static, vtkTypeBool);
198  vtkBooleanMacro(Static, vtkTypeBool);
200 
202 
214  vtkSetMacro(ColorMode, int);
215  vtkGetMacro(ColorMode, int);
216  void SetColorModeToDefault() { this->SetColorMode(VTK_COLOR_MODE_DEFAULT); }
217  void SetColorModeToMapScalars() { this->SetColorMode(VTK_COLOR_MODE_MAP_SCALARS); }
220 
224  const char* GetColorModeAsString();
225 
227 
233  vtkSetMacro(InterpolateScalarsBeforeMapping, vtkTypeBool);
234  vtkGetMacro(InterpolateScalarsBeforeMapping, vtkTypeBool);
235  vtkBooleanMacro(InterpolateScalarsBeforeMapping, vtkTypeBool);
237 
239 
247  vtkSetMacro(UseLookupTableScalarRange, vtkTypeBool);
248  vtkGetMacro(UseLookupTableScalarRange, vtkTypeBool);
249  vtkBooleanMacro(UseLookupTableScalarRange, vtkTypeBool);
251 
253 
258  vtkSetVector2Macro(ScalarRange, double);
259  vtkGetVectorMacro(ScalarRange, double, 2);
261 
275  // When ScalarMode is set to use Field Data (ScalarModeToFieldData),
276  // you must call SelectColorArray to choose the field data array to
277  // be used to color cells. In this mode, the default behavior is to
278  // treat the field data tuples as being associated with cells. If
279  // the poly data contains triangle strips, the array is expected to
280  // contain the cell data for each mini-cell formed by any triangle
281  // strips in the poly data as opposed to treating them as a single
282  // tuple that applies to the entire strip. This mode can also be
283  // used to color the entire poly data by a single color obtained by
284  // mapping the tuple at a given index in the field data array
285  // through the color map. Use SetFieldDataTupleId() to specify
286  // the tuple index.
287  vtkSetMacro(ScalarMode, int);
288  vtkGetMacro(ScalarMode, int);
289  void SetScalarModeToDefault() { this->SetScalarMode(VTK_SCALAR_MODE_DEFAULT); }
293  {
294  this->SetScalarMode(VTK_SCALAR_MODE_USE_POINT_FIELD_DATA);
295  }
297  {
298  this->SetScalarMode(VTK_SCALAR_MODE_USE_CELL_FIELD_DATA);
299  }
301 
303 
308  void SelectColorArray(int arrayNum);
309  void SelectColorArray(const char* arrayName);
311 
312  // When ScalarMode is set to UseFieldData, set the index of the
313  // tuple by which to color the entire data set. By default, the
314  // index is -1, which means to treat the field data array selected
315  // with SelectColorArray as having a scalar value for each cell.
316  // Indices of 0 or higher mean to use the tuple at the given index
317  // for coloring the entire data set.
318  vtkSetMacro(FieldDataTupleId, vtkIdType);
319  vtkGetMacro(FieldDataTupleId, vtkIdType);
320 
322 
327  void ColorByArrayComponent(int arrayNum, int component);
328  void ColorByArrayComponent(const char* arrayName, int component);
330 
334  vtkGetStringMacro(ArrayName);
335  vtkSetStringMacro(ArrayName);
336  vtkGetMacro(ArrayId, int);
337  vtkSetMacro(ArrayId, int);
338  vtkGetMacro(ArrayAccessMode, int);
339  vtkSetMacro(ArrayAccessMode, int);
340  vtkGetMacro(ArrayComponent, int);
341  vtkSetMacro(ArrayComponent, int);
342 
346  const char* GetScalarModeAsString();
347 
349 
359  static void SetResolveCoincidentTopology(int val);
362  static void SetResolveCoincidentTopologyToOff() { SetResolveCoincidentTopology(VTK_RESOLVE_OFF); }
364  {
365  SetResolveCoincidentTopology(VTK_RESOLVE_POLYGON_OFFSET);
366  }
368  {
369  SetResolveCoincidentTopology(VTK_RESOLVE_SHIFT_ZBUFFER);
370  }
372 
374 
379  static void SetResolveCoincidentTopologyPolygonOffsetParameters(double factor, double units);
380  static void GetResolveCoincidentTopologyPolygonOffsetParameters(double& factor, double& units);
382 
384 
388  void SetRelativeCoincidentTopologyPolygonOffsetParameters(double factor, double units);
389  void GetRelativeCoincidentTopologyPolygonOffsetParameters(double& factor, double& units);
391 
393 
398  static void SetResolveCoincidentTopologyLineOffsetParameters(double factor, double units);
399  static void GetResolveCoincidentTopologyLineOffsetParameters(double& factor, double& units);
401 
403 
407  void SetRelativeCoincidentTopologyLineOffsetParameters(double factor, double units);
408  void GetRelativeCoincidentTopologyLineOffsetParameters(double& factor, double& units);
410 
412 
420 
422 
429 
431 
435  void GetCoincidentTopologyPolygonOffsetParameters(double& factor, double& units);
436  void GetCoincidentTopologyLineOffsetParameters(double& factor, double& units);
439 
441 
451 
453 
457  static void SetResolveCoincidentTopologyZShift(double val);
460 
465  double* GetBounds() VTK_SIZEHINT(6) override;
466  void GetBounds(double bounds[6]) override { this->vtkAbstractMapper3D::GetBounds(bounds); }
467 
473  void SetRenderTime(double time) { this->RenderTime = time; }
474  vtkGetMacro(RenderTime, double);
475 
481 
488  vtkDataSet* GetInputAsDataSet() { return this->GetInput(); }
489 
491 
499  virtual vtkUnsignedCharArray* MapScalars(double alpha, int& cellFlag);
501  virtual vtkUnsignedCharArray* MapScalars(vtkDataSet* input, double alpha, int& cellFlag);
503 
505 
510  virtual bool HasOpaqueGeometry();
513 
520  virtual bool GetSupportsSelection() { return false; }
521 
527  std::vector<unsigned int>& /* pixeloffsets */, vtkProp* /* prop */)
528  {
529  }
530 
540 
546 
551 
556 
561 
563 
567  vtkGetObjectMacro(Selection, vtkSelection);
568  virtual void SetSelection(vtkSelection*);
570 
575  vtkScalarsToColors* lkup, int colorMode);
576 
577 protected:
579  ~vtkMapper() override;
580 
581  // color mapped colors
583 
584  // Use texture coordinates for coloring.
586  // Coordinate for each point.
588  // 1D ColorMap used for the texture image.
591 
595  double ScalarRange[2];
597 
600 
601  double RenderTime;
602 
603  // for coloring by a component of a field data array
604  int ArrayId;
605  char* ArrayName;
608 
609  // If coloring by field data, which tuple to use to color the entire
610  // data set. If -1, treat array values as cell data.
612 
614 
620 
621  vtkSelection* Selection = nullptr;
622 
623 private:
624  vtkMapper(const vtkMapper&) = delete;
625  void operator=(const vtkMapper&) = delete;
626 };
627 
628 VTK_ABI_NAMESPACE_END
629 #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:151
general representation of visualization data
abstract class to specify dataset behavior
Definition: vtkDataSet.h:166
dynamic, self-adjusting array of float
topologically and geometrically regular array of data
Definition: vtkImageData.h:156
a simple class to control print indentation
Definition: vtkIndent.h:108
abstract class specifies interface to map data to graphics primitives
Definition: vtkMapper.h:137
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:292
vtkScalarsToColors * LookupTable
Definition: vtkMapper.h:592
double CoincidentPolygonFactor
Definition: vtkMapper.h:615
void SetColorModeToMapScalars()
default (ColorModeToDefault), unsigned char scalars are treated as colors, and NOT mapped through the...
Definition: vtkMapper.h:217
int ColorMode
Definition: vtkMapper.h:598
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetScalarModeToUseCellData()
Definition: vtkMapper.h:291
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:585
void SetColorModeToDefault()
default (ColorModeToDefault), unsigned char scalars are treated as colors, and NOT mapped through the...
Definition: vtkMapper.h:216
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:596
void SetScalarModeToDefault()
Definition: vtkMapper.h:289
int ScalarMode
Definition: vtkMapper.h:599
virtual bool GetSupportsSelection()
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THIS METHOD OUTSIDE OF THE RENDERI...
Definition: vtkMapper.h:520
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:601
static vtkSmartPointer< vtkImageData > BuildColorTextureImage(vtkScalarsToColors *lkup, int colorMode)
Create an image of the lookup table lkup.
void SetScalarModeToUseCellFieldData()
Definition: vtkMapper.h:296
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:589
vtkTimeStamp BuildTime
Definition: vtkMapper.h:594
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:218
vtkTypeBool Static
Definition: vtkMapper.h:613
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:300
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:607
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:604
int ArrayComponent
Definition: vtkMapper.h:606
void SetRenderTime(double time)
This instance variable is used by vtkLODActor to determine which mapper to use.
Definition: vtkMapper.h:473
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:582
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:362
virtual void Render(vtkRenderer *ren, vtkActor *a)=0
Method initiates the mapping process.
vtkTypeBool ScalarVisibility
Definition: vtkMapper.h:593
vtkMTimeType GetMTime() override
Overload standard modified time function.
vtkIdType FieldDataTupleId
Definition: vtkMapper.h:611
double CoincidentPointOffset
Definition: vtkMapper.h:619
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:363
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:367
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:526
double CoincidentLineOffset
Definition: vtkMapper.h:618
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:587
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:290
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:488
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:617
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:616
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:605
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:164
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:66
abstract specification for renderers
Definition: vtkRenderer.h:172
Superclass for mapping scalar values to colors.
data object that represents a "selection" in VTK.
Definition: vtkSelection.h:159
record modification and/or execution time
Definition: vtkTimeStamp.h:44
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:175
@ time
Definition: vtkX3D.h:497
@ alpha
Definition: vtkX3D.h:250
int vtkTypeBool
Definition: vtkABI.h:64
#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:111
#define VTK_RESOLVE_OFF
Definition: vtkMapper.h:110
#define VTK_RESOLVE_SHIFT_ZBUFFER
Definition: vtkMapper.h:112
#define VTK_COLOR_MODE_MAP_SCALARS
#define VTK_COLOR_MODE_DEFAULT
#define VTK_COLOR_MODE_DIRECT_SCALARS
int vtkIdType
Definition: vtkType.h:315
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:270
#define VTK_SIZEHINT(...)
#define VTK_MARSHALAUTO