VTK  9.7.20261031
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
69
70#ifndef vtkMapper_h
71#define vtkMapper_h
72
73#include "vtkAbstractMapper3D.h"
74#include "vtkRenderingCoreModule.h" // For export macro
75#include "vtkSmartPointer.h" // needed for vtkSmartPointer.
76#include "vtkSystemIncludes.h" // For VTK_COLOR_MODE_DEFAULT and _MAP_SCALARS
77#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
78#include <vector> // for method args
79
80#define VTK_RESOLVE_OFF 0
81#define VTK_RESOLVE_POLYGON_OFFSET 1
82#define VTK_RESOLVE_SHIFT_ZBUFFER 2
83
84#define VTK_GET_ARRAY_BY_ID 0
85#define VTK_GET_ARRAY_BY_NAME 1
86
87#define VTK_MATERIALMODE_DEFAULT 0
88#define VTK_MATERIALMODE_AMBIENT 1
89#define VTK_MATERIALMODE_DIFFUSE 2
90#define VTK_MATERIALMODE_AMBIENT_AND_DIFFUSE 3
91
92VTK_ABI_NAMESPACE_BEGIN
93class vtkActor;
94class vtkDataSet;
95class vtkDataObject;
96class vtkFloatArray;
98class vtkImageData;
99class vtkProp;
100class vtkRenderer;
102class vtkSelection;
104class vtkWindow;
105
106class VTKRENDERINGCORE_EXPORT VTK_MARSHALAUTO vtkMapper : public vtkAbstractMapper3D
107{
108public:
110 void PrintSelf(ostream& os, vtkIndent indent) override;
111
116
122
127 virtual void Render(vtkRenderer* ren, vtkActor* a) = 0;
128
135
137
143
149
151
156 vtkBooleanMacro(ScalarVisibility, vtkTypeBool);
158
160
166 vtkSetMacro(Static, vtkTypeBool);
167 vtkGetMacro(Static, vtkTypeBool);
168 vtkBooleanMacro(Static, vtkTypeBool);
170
172
184 vtkSetMacro(ColorMode, int);
185 vtkGetMacro(ColorMode, int);
190
194 const char* GetColorModeAsString();
195
197
207
209
221
223
228 vtkSetVector2Macro(ScalarRange, double);
229 vtkGetVectorMacro(ScalarRange, double, 2);
231
244
245 // When ScalarMode is set to use Field Data (ScalarModeToFieldData),
246 // you must call SelectColorArray to choose the field data array to
247 // be used to color cells. In this mode, the default behavior is to
248 // treat the field data tuples as being associated with cells. If
249 // the poly data contains triangle strips, the array is expected to
250 // contain the cell data for each mini-cell formed by any triangle
251 // strips in the poly data as opposed to treating them as a single
252 // tuple that applies to the entire strip. This mode can also be
253 // used to color the entire poly data by a single color obtained by
254 // mapping the tuple at a given index in the field data array
255 // through the color map. Use SetFieldDataTupleId() to specify
256 // the tuple index.
257 vtkSetMacro(ScalarMode, int);
258 vtkGetMacro(ScalarMode, int);
271
273
278 void SelectColorArray(int arrayNum);
279 void SelectColorArray(const char* arrayName);
281
282 // When ScalarMode is set to UseFieldData, set the index of the
283 // tuple by which to color the entire data set. By default, the
284 // index is -1, which means to treat the field data array selected
285 // with SelectColorArray as having a scalar value for each cell.
286 // Indices of 0 or higher mean to use the tuple at the given index
287 // for coloring the entire data set.
290
292
297 void ColorByArrayComponent(int arrayNum, int component);
298 void ColorByArrayComponent(const char* arrayName, int component);
300
304 vtkGetStringMacro(ArrayName);
305 vtkSetStringMacro(ArrayName);
306 vtkGetMacro(ArrayId, int);
307 vtkSetMacro(ArrayId, int);
308 vtkGetMacro(ArrayAccessMode, int);
309 vtkSetMacro(ArrayAccessMode, int);
310 vtkGetMacro(ArrayComponent, int);
311 vtkSetMacro(ArrayComponent, int);
312
317
319
329 static void SetResolveCoincidentTopology(int val);
341
342
344
349 static void SetResolveCoincidentTopologyPolygonOffsetParameters(double factor, double units);
350 static void GetResolveCoincidentTopologyPolygonOffsetParameters(double& factor, double& units);
352
354
359 void GetRelativeCoincidentTopologyPolygonOffsetParameters(double& factor, double& units);
361
363
368 static void SetResolveCoincidentTopologyLineOffsetParameters(double factor, double units);
369 static void GetResolveCoincidentTopologyLineOffsetParameters(double& factor, double& units);
371
373
377 void SetRelativeCoincidentTopologyLineOffsetParameters(double factor, double units);
378 void GetRelativeCoincidentTopologyLineOffsetParameters(double& factor, double& units);
380
382
390
392
399
401
405 void GetCoincidentTopologyPolygonOffsetParameters(double& factor, double& units);
406 void GetCoincidentTopologyLineOffsetParameters(double& factor, double& units);
409
411
421
423
427 static void SetResolveCoincidentTopologyZShift(double val);
430
435 double* GetBounds() VTK_SIZEHINT(6) override;
436 void GetBounds(double bounds[6]) override { this->vtkAbstractMapper3D::GetBounds(bounds); }
437
443 void SetRenderTime(double time) { this->RenderTime = time; }
444 vtkGetMacro(RenderTime, double);
445
451
453
459 vtkDataSet* GetDataSetInput() { return this->GetInput(); }
461
463
470 virtual vtkUnsignedCharArray* MapScalars(double alpha);
471 virtual vtkUnsignedCharArray* MapScalars(double alpha, int& cellFlag);
472 virtual vtkUnsignedCharArray* MapScalars(vtkDataSet* input, double alpha);
473 virtual vtkUnsignedCharArray* MapScalars(vtkDataSet* input, double alpha, int& cellFlag);
475
477
482 virtual bool HasOpaqueGeometry();
485
492 virtual bool GetSupportsSelection() { return false; }
493
499 std::vector<unsigned int>& /* pixeloffsets */, vtkProp* /* prop */)
500 {
501 }
502
512
518
523
528
533
535
539 vtkGetObjectMacro(Selection, vtkSelection);
542
547 vtkScalarsToColors* lkup, int colorMode);
548
549protected:
551 ~vtkMapper() override;
552
553 // color mapped colors
555
556 // Use texture coordinates for coloring.
558 // Coordinate for each point.
560 // 1D ColorMap used for the texture image.
562 void MapScalarsToTexture(vtkAbstractArray* scalars, double alpha);
563
567 double ScalarRange[2];
569
572
574
575 // for coloring by a component of a field data array
580
581 // If coloring by field data, which tuple to use to color the entire
582 // data set. If -1, treat array values as cell data.
584
586
592
594
595private:
596 vtkMapper(const vtkMapper&) = delete;
597 void operator=(const vtkMapper&) = delete;
598};
599
600VTK_ABI_NAMESPACE_END
601#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:151
general representation of visualization data
abstract class to specify dataset behavior
Definition vtkDataSet.h:165
dynamic, self-adjusting array of float
topologically and geometrically regular array of data
a simple class to control print indentation
Definition vtkIndent.h:108
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:262
vtkScalarsToColors * LookupTable
Definition vtkMapper.h:564
double CoincidentPolygonFactor
Definition vtkMapper.h:587
vtkDataSet * GetDataSetInput()
Get the input to this mapper as a vtkDataSet, instead of as a more specialized data type that the sub...
Definition vtkMapper.h:459
void SetColorModeToMapScalars()
default (ColorModeToDefault), unsigned char scalars are treated as colors, and NOT mapped through the...
Definition vtkMapper.h:187
int ColorMode
Definition vtkMapper.h:570
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetScalarModeToUseCellData()
Definition vtkMapper.h:261
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:557
void SetColorModeToDefault()
default (ColorModeToDefault), unsigned char scalars are treated as colors, and NOT mapped through the...
Definition vtkMapper.h:186
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:568
void SetScalarModeToDefault()
Definition vtkMapper.h:259
int ScalarMode
Definition vtkMapper.h:571
vtkSelection * Selection
Definition vtkMapper.h:593
virtual bool GetSupportsSelection()
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THIS METHOD OUTSIDE OF THE RENDERI...
Definition vtkMapper.h:492
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:573
void SetScalarModeToUseCellFieldData()
Definition vtkMapper.h:266
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:561
vtkTimeStamp BuildTime
Definition vtkMapper.h:566
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:188
vtkTypeBool Static
Definition vtkMapper.h:585
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:270
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:579
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:576
int ArrayComponent
Definition vtkMapper.h:578
void SetRenderTime(double time)
This instance variable is used by vtkLODActor to determine which mapper to use.
Definition vtkMapper.h:443
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:554
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:332
virtual void Render(vtkRenderer *ren, vtkActor *a)=0
Method initiates the mapping process.
vtkTypeBool ScalarVisibility
Definition vtkMapper.h:565
vtkMTimeType GetMTime() override
Overload standard modified time function.
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:583
static vtkSmartPointer< vtkImageData > BuildColorTextureImage(vtkScalarsToColors *lkup, int colorMode)
Create an image of the lookup table lkup.
double CoincidentPointOffset
Definition vtkMapper.h:591
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:333
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:337
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:498
double CoincidentLineOffset
Definition vtkMapper.h:590
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:559
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:260
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:589
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:588
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:577
double ScalarRange[2]
Definition vtkMapper.h:567
void ReleaseGraphicsResources(vtkWindow *) override
Release any graphics resources that are being consumed by this mapper.
Definition vtkMapper.h:134
abstract superclass for all actors, volumes and annotations
Definition vtkProp.h:68
abstract specification for renderers
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:62
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:81
#define VTK_RESOLVE_OFF
Definition vtkMapper.h:80
#define VTK_RESOLVE_SHIFT_ZBUFFER
Definition vtkMapper.h:82
#define VTK_COLOR_MODE_MAP_SCALARS
#define VTK_COLOR_MODE_DEFAULT
#define VTK_COLOR_MODE_DIRECT_SCALARS
int vtkIdType
Definition vtkType.h:363
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:318
#define VTK_SIZEHINT(...)
#define VTK_MARSHALAUTO