VTK  9.4.20251007
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
40
41#ifndef vtkMapper_h
42#define vtkMapper_h
43
44#include "vtkAbstractMapper3D.h"
45#include "vtkRenderingCoreModule.h" // For export macro
46#include "vtkSmartPointer.h" // needed for vtkSmartPointer.
47#include "vtkSystemIncludes.h" // For VTK_COLOR_MODE_DEFAULT and _MAP_SCALARS
48#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
49#include <vector> // for method args
50
51#define VTK_RESOLVE_OFF 0
52#define VTK_RESOLVE_POLYGON_OFFSET 1
53#define VTK_RESOLVE_SHIFT_ZBUFFER 2
54
55#define VTK_GET_ARRAY_BY_ID 0
56#define VTK_GET_ARRAY_BY_NAME 1
57
58#define VTK_MATERIALMODE_DEFAULT 0
59#define VTK_MATERIALMODE_AMBIENT 1
60#define VTK_MATERIALMODE_DIFFUSE 2
61#define VTK_MATERIALMODE_AMBIENT_AND_DIFFUSE 3
62
63VTK_ABI_NAMESPACE_BEGIN
64class vtkActor;
65class vtkDataSet;
66class vtkDataObject;
67class vtkFloatArray;
69class vtkImageData;
70class vtkProp;
71class vtkRenderer;
73class vtkSelection;
75class vtkWindow;
76
77class VTKRENDERINGCORE_EXPORT VTK_MARSHALAUTO vtkMapper : public vtkAbstractMapper3D
78{
79public:
81 void PrintSelf(ostream& os, vtkIndent indent) override;
82
86 void ShallowCopy(vtkAbstractMapper* m) override;
87
93
98 virtual void Render(vtkRenderer* ren, vtkActor* a) = 0;
99
106
108
114
120
122
127 vtkBooleanMacro(ScalarVisibility, vtkTypeBool);
129
131
137 vtkSetMacro(Static, vtkTypeBool);
138 vtkGetMacro(Static, vtkTypeBool);
139 vtkBooleanMacro(Static, vtkTypeBool);
141
143
155 vtkSetMacro(ColorMode, int);
156 vtkGetMacro(ColorMode, int);
161
165 const char* GetColorModeAsString();
166
168
178
180
192
194
199 vtkSetVector2Macro(ScalarRange, double);
200 vtkGetVectorMacro(ScalarRange, double, 2);
202
215
216 // When ScalarMode is set to use Field Data (ScalarModeToFieldData),
217 // you must call SelectColorArray to choose the field data array to
218 // be used to color cells. In this mode, the default behavior is to
219 // treat the field data tuples as being associated with cells. If
220 // the poly data contains triangle strips, the array is expected to
221 // contain the cell data for each mini-cell formed by any triangle
222 // strips in the poly data as opposed to treating them as a single
223 // tuple that applies to the entire strip. This mode can also be
224 // used to color the entire poly data by a single color obtained by
225 // mapping the tuple at a given index in the field data array
226 // through the color map. Use SetFieldDataTupleId() to specify
227 // the tuple index.
228 vtkSetMacro(ScalarMode, int);
229 vtkGetMacro(ScalarMode, int);
242
244
249 void SelectColorArray(int arrayNum);
250 void SelectColorArray(const char* arrayName);
252
253 // When ScalarMode is set to UseFieldData, set the index of the
254 // tuple by which to color the entire data set. By default, the
255 // index is -1, which means to treat the field data array selected
256 // with SelectColorArray as having a scalar value for each cell.
257 // Indices of 0 or higher mean to use the tuple at the given index
258 // for coloring the entire data set.
261
263
268 void ColorByArrayComponent(int arrayNum, int component);
269 void ColorByArrayComponent(const char* arrayName, int component);
271
275 vtkGetStringMacro(ArrayName);
276 vtkSetStringMacro(ArrayName);
277 vtkGetMacro(ArrayId, int);
278 vtkSetMacro(ArrayId, int);
279 vtkGetMacro(ArrayAccessMode, int);
280 vtkSetMacro(ArrayAccessMode, int);
281 vtkGetMacro(ArrayComponent, int);
282 vtkSetMacro(ArrayComponent, int);
283
288
290
300 static void SetResolveCoincidentTopology(int val);
312
313
315
320 static void SetResolveCoincidentTopologyPolygonOffsetParameters(double factor, double units);
321 static void GetResolveCoincidentTopologyPolygonOffsetParameters(double& factor, double& units);
323
325
330 void GetRelativeCoincidentTopologyPolygonOffsetParameters(double& factor, double& units);
332
334
339 static void SetResolveCoincidentTopologyLineOffsetParameters(double factor, double units);
340 static void GetResolveCoincidentTopologyLineOffsetParameters(double& factor, double& units);
342
344
348 void SetRelativeCoincidentTopologyLineOffsetParameters(double factor, double units);
349 void GetRelativeCoincidentTopologyLineOffsetParameters(double& factor, double& units);
351
353
361
363
370
372
376 void GetCoincidentTopologyPolygonOffsetParameters(double& factor, double& units);
377 void GetCoincidentTopologyLineOffsetParameters(double& factor, double& units);
380
382
392
394
398 static void SetResolveCoincidentTopologyZShift(double val);
401
406 double* GetBounds() VTK_SIZEHINT(6) override;
407 void GetBounds(double bounds[6]) override { this->vtkAbstractMapper3D::GetBounds(bounds); }
408
414 void SetRenderTime(double time) { this->RenderTime = time; }
415 vtkGetMacro(RenderTime, double);
416
422
429 vtkDataSet* GetInputAsDataSet() { return this->GetInput(); }
430
432
439 virtual vtkUnsignedCharArray* MapScalars(double alpha);
440 virtual vtkUnsignedCharArray* MapScalars(double alpha, int& cellFlag);
441 virtual vtkUnsignedCharArray* MapScalars(vtkDataSet* input, double alpha);
442 virtual vtkUnsignedCharArray* MapScalars(vtkDataSet* input, double alpha, int& cellFlag);
444
446
451 virtual bool HasOpaqueGeometry();
454
461 virtual bool GetSupportsSelection() { return false; }
462
468 std::vector<unsigned int>& /* pixeloffsets */, vtkProp* /* prop */)
469 {
470 }
471
481
487
492
497
502
504
508 vtkGetObjectMacro(Selection, vtkSelection);
511
516 vtkScalarsToColors* lkup, int colorMode);
517
518protected:
520 ~vtkMapper() override;
521
522 // color mapped colors
524
525 // Use texture coordinates for coloring.
527 // Coordinate for each point.
529 // 1D ColorMap used for the texture image.
531 void MapScalarsToTexture(vtkAbstractArray* scalars, double alpha);
532
536 double ScalarRange[2];
538
541
543
544 // for coloring by a component of a field data array
549
550 // If coloring by field data, which tuple to use to color the entire
551 // data set. If -1, treat array values as cell data.
553
555
561
563
564private:
565 vtkMapper(const vtkMapper&) = delete;
566 void operator=(const vtkMapper&) = delete;
567};
568
569VTK_ABI_NAMESPACE_END
570#endif
Abstract superclass for all arrays.
virtual double * GetBounds()=0
Return bounding box (array of six doubles) of data expressed as (xmin,xmax, ymin,ymax,...
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:42
general representation of visualization data
abstract class to specify dataset behavior
Definition vtkDataSet.h:57
dynamic, self-adjusting array of float
topologically and geometrically regular array of data
a simple class to control print indentation
Definition vtkIndent.h:29
virtual bool HasOpaqueGeometry()
Some introspection on the type of data the mapper will render used by props to determine if they shou...
const char * GetScalarModeAsString()
Return the method for obtaining scalar data.
~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:233
vtkScalarsToColors * LookupTable
Definition vtkMapper.h:533
double CoincidentPolygonFactor
Definition vtkMapper.h:556
void SetColorModeToMapScalars()
default (ColorModeToDefault), unsigned char scalars are treated as colors, and NOT mapped through the...
Definition vtkMapper.h:158
int ColorMode
Definition vtkMapper.h:539
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetScalarModeToUseCellData()
Definition vtkMapper.h:232
void SetLookupTable(vtkScalarsToColors *lut)
Specify a lookup table for the mapper to use.
virtual vtkUnsignedCharArray * MapScalars(double alpha)
Map the scalars (if there are any scalars and ScalarVisibility is on) through the lookup table,...
vtkTypeBool InterpolateScalarsBeforeMapping
Definition vtkMapper.h:526
void SetColorModeToDefault()
default (ColorModeToDefault), unsigned char scalars are treated as colors, and NOT mapped through the...
Definition vtkMapper.h:157
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:537
void SetScalarModeToDefault()
Definition vtkMapper.h:230
int ScalarMode
Definition vtkMapper.h:540
vtkSelection * Selection
Definition vtkMapper.h:562
virtual bool GetSupportsSelection()
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THIS METHOD OUTSIDE OF THE RENDERI...
Definition vtkMapper.h:461
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:542
void SetScalarModeToUseCellFieldData()
Definition vtkMapper.h:237
void MapScalarsToTexture(vtkAbstractArray *scalars, double alpha)
vtkImageData * GetColorTextureMap()
Provide read access to the color texture array.
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:530
vtkTimeStamp BuildTime
Definition vtkMapper.h:535
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:159
vtkTypeBool Static
Definition vtkMapper.h:554
virtual vtkUnsignedCharArray * MapScalars(double alpha, int &cellFlag)
Map the scalars (if there are any scalars and ScalarVisibility is on) through the lookup table,...
void SetScalarModeToUseFieldData()
Definition vtkMapper.h:241
static double GetResolveCoincidentTopologyZShift()
Used to set the z-shift if ResolveCoincidentTopology is set to ShiftZBuffer.
virtual void SetColorMode(int)
default (ColorModeToDefault), unsigned char scalars are treated as colors, and NOT mapped through the...
static void SetResolveCoincidentTopologyPolygonOffsetParameters(double factor, double units)
Used to set the polygon offset scale factor and units.
int ArrayAccessMode
Definition vtkMapper.h:548
void SetRelativeCoincidentTopologyLineOffsetParameters(double factor, double units)
Used to set the line offset values relative to the global Used when ResolveCoincidentTopology is set ...
int ArrayId
Definition vtkMapper.h:545
int ArrayComponent
Definition vtkMapper.h:547
void SetRenderTime(double time)
This instance variable is used by vtkLODActor to determine which mapper to use.
Definition vtkMapper.h:414
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:523
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:303
virtual void Render(vtkRenderer *ren, vtkActor *a)=0
Method initiates the mapping process.
vtkTypeBool ScalarVisibility
Definition vtkMapper.h:534
vtkMTimeType GetMTime() override
Overload standard modified time function.
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:429
vtkScalarsToColors * GetLookupTable()
Specify a lookup table for the mapper to use.
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,...
vtkIdType FieldDataTupleId
Definition vtkMapper.h:552
static vtkSmartPointer< vtkImageData > BuildColorTextureImage(vtkScalarsToColors *lkup, int colorMode)
Create an image of the lookup table lkup.
double CoincidentPointOffset
Definition vtkMapper.h:560
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:304
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:308
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.
vtkFloatArray * GetColorCoordinates()
Provide read access to the color texture coordinate array.
double * GetBounds() override
Return bounding box (array of six doubles) of data expressed as (xmin,xmax, ymin,ymax,...
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:467
double CoincidentLineOffset
Definition vtkMapper.h:559
void SetRelativeCoincidentTopologyPointOffsetParameter(double units)
Used to set the point offset value relative to the global Used when ResolveCoincidentTopology is set ...
static void SetResolveCoincidentTopologyPointOffsetParameter(double units)
Used to set the point offset value Used when ResolveCoincidentTopology is set to PolygonOffset.
vtkFloatArray * ColorCoordinates
Definition vtkMapper.h:528
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:231
vtkUnsignedCharArray * GetColorMapColors()
Provide read access to the color array.
static void SetResolveCoincidentTopologyLineOffsetParameters(double factor, double units)
Used to set the line offset scale factor and units.
vtkDataSet * GetInput()
Get the input as a vtkDataSet.
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:558
const char * GetColorModeAsString()
Return the method of coloring scalar data.
static void SetResolveCoincidentTopologyZShift(double val)
Used to set the z-shift if ResolveCoincidentTopology is set to ShiftZBuffer.
virtual vtkUnsignedCharArray * MapScalars(vtkDataSet *input, double alpha)
Map the scalars (if there are any scalars and ScalarVisibility is on) through the lookup table,...
double CoincidentPolygonOffset
Definition vtkMapper.h:557
virtual void SetScalarMode(int)
Control how the filter works with scalar point data and cell attribute data.
void ClearColorArrays()
Call to force a rebuild of color result arrays on next MapScalars.
char * ArrayName
Definition vtkMapper.h:546
double ScalarRange[2]
Definition vtkMapper.h:536
void ReleaseGraphicsResources(vtkWindow *) override
Release any graphics resources that are being consumed by this mapper.
Definition vtkMapper.h:105
abstract superclass for all actors, volumes and annotations
Definition vtkProp.h:47
abstract specification for renderers
Definition vtkRenderer.h:63
Superclass for mapping scalar values to colors.
data object that represents a "selection" in VTK.
Hold a reference to a vtkObjectBase instance.
record modification and/or execution time
dynamic, self-adjusting array of unsigned char
window superclass for vtkRenderWindow
Definition vtkWindow.h:29
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:52
#define VTK_RESOLVE_OFF
Definition vtkMapper.h:51
#define VTK_RESOLVE_SHIFT_ZBUFFER
Definition vtkMapper.h:53
#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