VTK  9.3.0
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
50#ifndef vtkMapper_h
51#define vtkMapper_h
52
53#include "vtkAbstractMapper3D.h"
54#include "vtkRenderingCoreModule.h" // For export macro
55#include "vtkSmartPointer.h" // needed for vtkSmartPointer.
56#include "vtkSystemIncludes.h" // For VTK_COLOR_MODE_DEFAULT and _MAP_SCALARS
57#include <vector> // for method args
58
59#define VTK_RESOLVE_OFF 0
60#define VTK_RESOLVE_POLYGON_OFFSET 1
61#define VTK_RESOLVE_SHIFT_ZBUFFER 2
62
63#define VTK_GET_ARRAY_BY_ID 0
64#define VTK_GET_ARRAY_BY_NAME 1
65
66#define VTK_MATERIALMODE_DEFAULT 0
67#define VTK_MATERIALMODE_AMBIENT 1
68#define VTK_MATERIALMODE_DIFFUSE 2
69#define VTK_MATERIALMODE_AMBIENT_AND_DIFFUSE 3
70
71VTK_ABI_NAMESPACE_BEGIN
72class vtkActor;
73class vtkDataSet;
74class vtkDataObject;
75class vtkFloatArray;
77class vtkImageData;
78class vtkProp;
79class vtkRenderer;
81class vtkSelection;
83class vtkWindow;
84
85class VTKRENDERINGCORE_EXPORT vtkMapper : public vtkAbstractMapper3D
86{
87public:
89 void PrintSelf(ostream& os, vtkIndent indent) override;
90
94 void ShallowCopy(vtkAbstractMapper* m) override;
95
101
106 virtual void Render(vtkRenderer* ren, vtkActor* a) = 0;
107
114
116
122
128
130
133 vtkSetMacro(ScalarVisibility, vtkTypeBool);
134 vtkGetMacro(ScalarVisibility, vtkTypeBool);
135 vtkBooleanMacro(ScalarVisibility, vtkTypeBool);
137
139
145 vtkSetMacro(Static, vtkTypeBool);
146 vtkGetMacro(Static, vtkTypeBool);
147 vtkBooleanMacro(Static, vtkTypeBool);
149
151
163 vtkSetMacro(ColorMode, int);
164 vtkGetMacro(ColorMode, int);
165 void SetColorModeToDefault() { this->SetColorMode(VTK_COLOR_MODE_DEFAULT); }
169
173 const char* GetColorModeAsString();
174
176
182 vtkSetMacro(InterpolateScalarsBeforeMapping, vtkTypeBool);
183 vtkGetMacro(InterpolateScalarsBeforeMapping, vtkTypeBool);
184 vtkBooleanMacro(InterpolateScalarsBeforeMapping, vtkTypeBool);
186
188
196 vtkSetMacro(UseLookupTableScalarRange, vtkTypeBool);
197 vtkGetMacro(UseLookupTableScalarRange, vtkTypeBool);
198 vtkBooleanMacro(UseLookupTableScalarRange, vtkTypeBool);
200
202
207 vtkSetVector2Macro(ScalarRange, double);
208 vtkGetVectorMacro(ScalarRange, double, 2);
210
224 // When ScalarMode is set to use Field Data (ScalarModeToFieldData),
225 // you must call SelectColorArray to choose the field data array to
226 // be used to color cells. In this mode, the default behavior is to
227 // treat the field data tuples as being associated with cells. If
228 // the poly data contains triangle strips, the array is expected to
229 // contain the cell data for each mini-cell formed by any triangle
230 // strips in the poly data as opposed to treating them as a single
231 // tuple that applies to the entire strip. This mode can also be
232 // used to color the entire poly data by a single color obtained by
233 // mapping the tuple at a given index in the field data array
234 // through the color map. Use SetFieldDataTupleId() to specify
235 // the tuple index.
236 vtkSetMacro(ScalarMode, int);
237 vtkGetMacro(ScalarMode, int);
238 void SetScalarModeToDefault() { this->SetScalarMode(VTK_SCALAR_MODE_DEFAULT); }
242 {
243 this->SetScalarMode(VTK_SCALAR_MODE_USE_POINT_FIELD_DATA);
244 }
246 {
247 this->SetScalarMode(VTK_SCALAR_MODE_USE_CELL_FIELD_DATA);
248 }
250
252
257 void SelectColorArray(int arrayNum);
258 void SelectColorArray(const char* arrayName);
260
261 // When ScalarMode is set to UseFieldData, set the index of the
262 // tuple by which to color the entire data set. By default, the
263 // index is -1, which means to treat the field data array selected
264 // with SelectColorArray as having a scalar value for each cell.
265 // Indices of 0 or higher mean to use the tuple at the given index
266 // for coloring the entire data set.
267 vtkSetMacro(FieldDataTupleId, vtkIdType);
268 vtkGetMacro(FieldDataTupleId, vtkIdType);
269
271
276 void ColorByArrayComponent(int arrayNum, int component);
277 void ColorByArrayComponent(const char* arrayName, int component);
279
283 vtkGetStringMacro(ArrayName);
284 vtkSetStringMacro(ArrayName);
285 vtkGetMacro(ArrayId, int);
286 vtkSetMacro(ArrayId, int);
287 vtkGetMacro(ArrayAccessMode, int);
288 vtkSetMacro(ArrayAccessMode, int);
289 vtkGetMacro(ArrayComponent, int);
290 vtkSetMacro(ArrayComponent, int);
291
296
298
308 static void SetResolveCoincidentTopology(int val);
311 static void SetResolveCoincidentTopologyToOff() { SetResolveCoincidentTopology(VTK_RESOLVE_OFF); }
313 {
314 SetResolveCoincidentTopology(VTK_RESOLVE_POLYGON_OFFSET);
315 }
317 {
318 SetResolveCoincidentTopology(VTK_RESOLVE_SHIFT_ZBUFFER);
319 }
321
323
328 static void SetResolveCoincidentTopologyPolygonOffsetParameters(double factor, double units);
329 static void GetResolveCoincidentTopologyPolygonOffsetParameters(double& factor, double& units);
331
333
338 void GetRelativeCoincidentTopologyPolygonOffsetParameters(double& factor, double& units);
340
342
347 static void SetResolveCoincidentTopologyLineOffsetParameters(double factor, double units);
348 static void GetResolveCoincidentTopologyLineOffsetParameters(double& factor, double& units);
350
352
356 void SetRelativeCoincidentTopologyLineOffsetParameters(double factor, double units);
357 void GetRelativeCoincidentTopologyLineOffsetParameters(double& factor, double& units);
359
361
369
371
378
380
384 void GetCoincidentTopologyPolygonOffsetParameters(double& factor, double& units);
385 void GetCoincidentTopologyLineOffsetParameters(double& factor, double& units);
388
390
400
402
406 static void SetResolveCoincidentTopologyZShift(double val);
409
414 double* GetBounds() VTK_SIZEHINT(6) override;
415 void GetBounds(double bounds[6]) override { this->vtkAbstractMapper3D::GetBounds(bounds); }
416
422 void SetRenderTime(double time) { this->RenderTime = time; }
423 vtkGetMacro(RenderTime, double);
424
430
437 vtkDataSet* GetInputAsDataSet() { return this->GetInput(); }
438
440
447 virtual vtkUnsignedCharArray* MapScalars(double alpha);
448 virtual vtkUnsignedCharArray* MapScalars(double alpha, int& cellFlag);
449 virtual vtkUnsignedCharArray* MapScalars(vtkDataSet* input, double alpha);
450 virtual vtkUnsignedCharArray* MapScalars(vtkDataSet* input, double alpha, int& cellFlag);
452
454
459 virtual bool HasOpaqueGeometry();
462
469 virtual bool GetSupportsSelection() { return false; }
470
476 std::vector<unsigned int>& /* pixeloffsets */, vtkProp* /* prop */)
477 {
478 }
479
489
495
500
505
510
512
516 vtkGetObjectMacro(Selection, vtkSelection);
519
520protected:
522 ~vtkMapper() override;
523
524 // color mapped colors
526
527 // Use texture coordinates for coloring.
529 // Coordinate for each point.
531 // 1D ColorMap used for the texture image.
533 void MapScalarsToTexture(vtkAbstractArray* scalars, double alpha);
534
538 double ScalarRange[2];
540
543
545
546 // for coloring by a component of a field data array
551
552 // If coloring by field data, which tuple to use to color the entire
553 // data set. If -1, treat array values as cell data.
555
557
563
564 vtkSelection* Selection = nullptr;
565
566private:
567 vtkMapper(const vtkMapper&) = delete;
568 void operator=(const vtkMapper&) = delete;
569};
570
571VTK_ABI_NAMESPACE_END
572#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:50
general representation of visualization data
abstract class to specify dataset behavior
Definition vtkDataSet.h:62
dynamic, self-adjusting array of float
topologically and geometrically regular array of data
a simple class to control print indentation
Definition vtkIndent.h:38
abstract class specifies interface to map data to graphics primitives
Definition vtkMapper.h:86
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:241
vtkScalarsToColors * LookupTable
Definition vtkMapper.h:535
double CoincidentPolygonFactor
Definition vtkMapper.h:558
void SetColorModeToMapScalars()
default (ColorModeToDefault), unsigned char scalars are treated as colors, and NOT mapped through the...
Definition vtkMapper.h:166
int ColorMode
Definition vtkMapper.h:541
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetScalarModeToUseCellData()
Definition vtkMapper.h:240
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:528
void SetColorModeToDefault()
default (ColorModeToDefault), unsigned char scalars are treated as colors, and NOT mapped through the...
Definition vtkMapper.h:165
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:539
void SetScalarModeToDefault()
Definition vtkMapper.h:238
int ScalarMode
Definition vtkMapper.h:542
virtual bool GetSupportsSelection()
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THIS METHOD OUTSIDE OF THE RENDERI...
Definition vtkMapper.h:469
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:544
void SetScalarModeToUseCellFieldData()
Definition vtkMapper.h:245
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:532
vtkTimeStamp BuildTime
Definition vtkMapper.h:537
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:167
vtkTypeBool Static
Definition vtkMapper.h:556
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:249
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:550
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:547
int ArrayComponent
Definition vtkMapper.h:549
void SetRenderTime(double time)
This instance variable is used by vtkLODActor to determine which mapper to use.
Definition vtkMapper.h:422
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:525
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:311
virtual void Render(vtkRenderer *ren, vtkActor *a)=0
Method initiates the mapping process.
vtkTypeBool ScalarVisibility
Definition vtkMapper.h:536
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:437
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:554
double CoincidentPointOffset
Definition vtkMapper.h:562
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:312
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:316
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:475
double CoincidentLineOffset
Definition vtkMapper.h:561
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:530
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:239
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:560
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:559
void ClearColorArrays()
Call to force a rebuild of color result arrays on next MapScalars.
char * ArrayName
Definition vtkMapper.h:548
void ReleaseGraphicsResources(vtkWindow *) override
Release any graphics resources that are being consumed by this mapper.
Definition vtkMapper.h:113
abstract superclass for all actors, volumes and annotations
Definition vtkProp.h:52
abstract specification for renderers
Definition vtkRenderer.h:68
Superclass for mapping scalar values to colors.
data object that represents a "selection" in VTK.
record modification and/or execution time
dynamic, self-adjusting array of unsigned char
window superclass for vtkRenderWindow
Definition vtkWindow.h:34
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:60
#define VTK_RESOLVE_OFF
Definition vtkMapper.h:59
#define VTK_RESOLVE_SHIFT_ZBUFFER
Definition vtkMapper.h:61
#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(...)