VTK  9.2.20220926
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 =========================================================================*/
142 #ifndef vtkMapper_h
143 #define vtkMapper_h
144 
145 #include "vtkAbstractMapper3D.h"
146 #include "vtkRenderingCoreModule.h" // For export macro
147 #include "vtkSmartPointer.h" // needed for vtkSmartPointer.
148 #include "vtkSystemIncludes.h" // For VTK_COLOR_MODE_DEFAULT and _MAP_SCALARS
149 #include <vector> // for method args
150 
151 #define VTK_RESOLVE_OFF 0
152 #define VTK_RESOLVE_POLYGON_OFFSET 1
153 #define VTK_RESOLVE_SHIFT_ZBUFFER 2
154 
155 #define VTK_GET_ARRAY_BY_ID 0
156 #define VTK_GET_ARRAY_BY_NAME 1
157 
158 #define VTK_MATERIALMODE_DEFAULT 0
159 #define VTK_MATERIALMODE_AMBIENT 1
160 #define VTK_MATERIALMODE_DIFFUSE 2
161 #define VTK_MATERIALMODE_AMBIENT_AND_DIFFUSE 3
162 
163 VTK_ABI_NAMESPACE_BEGIN
164 class vtkActor;
165 class vtkDataSet;
166 class vtkDataObject;
167 class vtkFloatArray;
168 class vtkHardwareSelector;
169 class vtkImageData;
170 class vtkProp;
171 class vtkRenderer;
172 class vtkScalarsToColors;
173 class vtkSelection;
175 class vtkWindow;
176 
177 class VTKRENDERINGCORE_EXPORT vtkMapper : public vtkAbstractMapper3D
178 {
179 public:
181  void PrintSelf(ostream& os, vtkIndent indent) override;
182 
186  void ShallowCopy(vtkAbstractMapper* m) override;
187 
192  vtkMTimeType GetMTime() override;
193 
198  virtual void Render(vtkRenderer* ren, vtkActor* a) = 0;
199 
206 
208 
214 
219  virtual void CreateDefaultLookupTable();
220 
222 
225  vtkSetMacro(ScalarVisibility, vtkTypeBool);
226  vtkGetMacro(ScalarVisibility, vtkTypeBool);
227  vtkBooleanMacro(ScalarVisibility, vtkTypeBool);
229 
231 
237  vtkSetMacro(Static, vtkTypeBool);
238  vtkGetMacro(Static, vtkTypeBool);
239  vtkBooleanMacro(Static, vtkTypeBool);
241 
243 
255  vtkSetMacro(ColorMode, int);
256  vtkGetMacro(ColorMode, int);
257  void SetColorModeToDefault() { this->SetColorMode(VTK_COLOR_MODE_DEFAULT); }
258  void SetColorModeToMapScalars() { this->SetColorMode(VTK_COLOR_MODE_MAP_SCALARS); }
261 
265  const char* GetColorModeAsString();
266 
268 
274  vtkSetMacro(InterpolateScalarsBeforeMapping, vtkTypeBool);
275  vtkGetMacro(InterpolateScalarsBeforeMapping, vtkTypeBool);
276  vtkBooleanMacro(InterpolateScalarsBeforeMapping, vtkTypeBool);
278 
280 
288  vtkSetMacro(UseLookupTableScalarRange, vtkTypeBool);
289  vtkGetMacro(UseLookupTableScalarRange, vtkTypeBool);
290  vtkBooleanMacro(UseLookupTableScalarRange, vtkTypeBool);
292 
294 
299  vtkSetVector2Macro(ScalarRange, double);
300  vtkGetVectorMacro(ScalarRange, double, 2);
302 
316  // When ScalarMode is set to use Field Data (ScalarModeToFieldData),
317  // you must call SelectColorArray to choose the field data array to
318  // be used to color cells. In this mode, the default behavior is to
319  // treat the field data tuples as being associated with cells. If
320  // the poly data contains triangle strips, the array is expected to
321  // contain the cell data for each mini-cell formed by any triangle
322  // strips in the poly data as opposed to treating them as a single
323  // tuple that applies to the entire strip. This mode can also be
324  // used to color the entire poly data by a single color obtained by
325  // mapping the tuple at a given index in the field data array
326  // through the color map. Use SetFieldDataTupleId() to specify
327  // the tuple index.
328  vtkSetMacro(ScalarMode, int);
329  vtkGetMacro(ScalarMode, int);
330  void SetScalarModeToDefault() { this->SetScalarMode(VTK_SCALAR_MODE_DEFAULT); }
334  {
335  this->SetScalarMode(VTK_SCALAR_MODE_USE_POINT_FIELD_DATA);
336  }
338  {
339  this->SetScalarMode(VTK_SCALAR_MODE_USE_CELL_FIELD_DATA);
340  }
342 
344 
349  void SelectColorArray(int arrayNum);
350  void SelectColorArray(const char* arrayName);
352 
353  // When ScalarMode is set to UseFieldData, set the index of the
354  // tuple by which to color the entire data set. By default, the
355  // index is -1, which means to treat the field data array selected
356  // with SelectColorArray as having a scalar value for each cell.
357  // Indices of 0 or higher mean to use the tuple at the given index
358  // for coloring the entire data set.
359  vtkSetMacro(FieldDataTupleId, vtkIdType);
360  vtkGetMacro(FieldDataTupleId, vtkIdType);
361 
363 
368  void ColorByArrayComponent(int arrayNum, int component);
369  void ColorByArrayComponent(const char* arrayName, int component);
371 
375  vtkGetStringMacro(ArrayName);
376  vtkSetStringMacro(ArrayName);
377  vtkGetMacro(ArrayId, int);
378  vtkSetMacro(ArrayId, int);
379  vtkGetMacro(ArrayAccessMode, int);
380  vtkSetMacro(ArrayAccessMode, int);
381  vtkGetMacro(ArrayComponent, int);
382  vtkSetMacro(ArrayComponent, int);
383 
387  const char* GetScalarModeAsString();
388 
390 
400  static void SetResolveCoincidentTopology(int val);
403  static void SetResolveCoincidentTopologyToOff() { SetResolveCoincidentTopology(VTK_RESOLVE_OFF); }
405  {
406  SetResolveCoincidentTopology(VTK_RESOLVE_POLYGON_OFFSET);
407  }
409  {
410  SetResolveCoincidentTopology(VTK_RESOLVE_SHIFT_ZBUFFER);
411  }
413 
415 
420  static void SetResolveCoincidentTopologyPolygonOffsetParameters(double factor, double units);
421  static void GetResolveCoincidentTopologyPolygonOffsetParameters(double& factor, double& units);
423 
425 
429  void SetRelativeCoincidentTopologyPolygonOffsetParameters(double factor, double units);
430  void GetRelativeCoincidentTopologyPolygonOffsetParameters(double& factor, double& units);
432 
434 
439  static void SetResolveCoincidentTopologyLineOffsetParameters(double factor, double units);
440  static void GetResolveCoincidentTopologyLineOffsetParameters(double& factor, double& units);
442 
444 
448  void SetRelativeCoincidentTopologyLineOffsetParameters(double factor, double units);
449  void GetRelativeCoincidentTopologyLineOffsetParameters(double& factor, double& units);
451 
453 
461 
463 
470 
472 
476  void GetCoincidentTopologyPolygonOffsetParameters(double& factor, double& units);
477  void GetCoincidentTopologyLineOffsetParameters(double& factor, double& units);
480 
482 
492 
494 
498  static void SetResolveCoincidentTopologyZShift(double val);
501 
506  double* GetBounds() VTK_SIZEHINT(6) override;
507  void GetBounds(double bounds[6]) override { this->vtkAbstractMapper3D::GetBounds(bounds); }
508 
514  void SetRenderTime(double time) { this->RenderTime = time; }
515  vtkGetMacro(RenderTime, double);
516 
522 
529  vtkDataSet* GetInputAsDataSet() { return this->GetInput(); }
530 
532 
540  virtual vtkUnsignedCharArray* MapScalars(double alpha, int& cellFlag);
542  virtual vtkUnsignedCharArray* MapScalars(vtkDataSet* input, double alpha, int& cellFlag);
544 
546 
551  virtual bool HasOpaqueGeometry();
554 
561  virtual bool GetSupportsSelection() { return false; }
562 
568  std::vector<unsigned int>& /* pixeloffsets */, vtkProp* /* prop */)
569  {
570  }
571 
581 
587 
592 
597 
602 
604 
608  vtkGetObjectMacro(Selection, vtkSelection);
609  virtual void SetSelection(vtkSelection*);
611 
612 protected:
614  ~vtkMapper() override;
615 
616  // color mapped colors
618 
619  // Use texture coordinates for coloring.
621  // Coordinate for each point.
623  // 1D ColorMap used for the texture image.
626 
630  double ScalarRange[2];
632 
635 
636  double RenderTime;
637 
638  // for coloring by a component of a field data array
639  int ArrayId;
640  char* ArrayName;
643 
644  // If coloring by field data, which tuple to use to color the entire
645  // data set. If -1, treat array values as cell data.
647 
649 
655 
656  vtkSelection* Selection = nullptr;
657 
658 private:
659  vtkMapper(const vtkMapper&) = delete;
660  void operator=(const vtkMapper&) = delete;
661 };
662 
664 #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:162
general representation of visualization data
abstract class to specify dataset behavior
Definition: vtkDataSet.h:174
dynamic, self-adjusting array of float
topologically and geometrically regular array of data
Definition: vtkImageData.h:164
a simple class to control print indentation
Definition: vtkIndent.h:120
abstract class specifies interface to map data to graphics primitives
Definition: vtkMapper.h:178
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:333
vtkScalarsToColors * LookupTable
Definition: vtkMapper.h:627
double CoincidentPolygonFactor
Definition: vtkMapper.h:650
void SetColorModeToMapScalars()
default (ColorModeToDefault), unsigned char scalars are treated as colors, and NOT mapped through the...
Definition: vtkMapper.h:258
int ColorMode
Definition: vtkMapper.h:633
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetScalarModeToUseCellData()
Definition: vtkMapper.h:332
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:620
void SetColorModeToDefault()
default (ColorModeToDefault), unsigned char scalars are treated as colors, and NOT mapped through the...
Definition: vtkMapper.h:257
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:631
void SetScalarModeToDefault()
Definition: vtkMapper.h:330
int ScalarMode
Definition: vtkMapper.h:634
virtual bool GetSupportsSelection()
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THIS METHOD OUTSIDE OF THE RENDERI...
Definition: vtkMapper.h:561
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:636
void SetScalarModeToUseCellFieldData()
Definition: vtkMapper.h:337
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:624
vtkTimeStamp BuildTime
Definition: vtkMapper.h:629
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:259
vtkTypeBool Static
Definition: vtkMapper.h:648
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:341
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:642
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:639
int ArrayComponent
Definition: vtkMapper.h:641
void SetRenderTime(double time)
This instance variable is used by vtkLODActor to determine which mapper to use.
Definition: vtkMapper.h:514
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:617
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:403
virtual void Render(vtkRenderer *ren, vtkActor *a)=0
Method initiates the mapping process.
vtkTypeBool ScalarVisibility
Definition: vtkMapper.h:628
vtkMTimeType GetMTime() override
Overload standard modified time function.
vtkIdType FieldDataTupleId
Definition: vtkMapper.h:646
double CoincidentPointOffset
Definition: vtkMapper.h:654
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:404
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:408
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:567
double CoincidentLineOffset
Definition: vtkMapper.h:653
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:622
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:331
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:529
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:652
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:651
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:640
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:205
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:77
abstract specification for renderers
Definition: vtkRenderer.h:183
Superclass for mapping scalar values to colors.
data object that represents a "selection" in VTK.
Definition: vtkSelection.h:170
record modification and/or execution time
Definition: vtkTimeStamp.h:56
dynamic, self-adjusting array of unsigned char
window superclass for vtkRenderWindow
Definition: vtkWindow.h:40
VTK_ABI_NAMESPACE_BEGIN void GetBounds(T a, double bds[6])
@ component
Definition: vtkX3D.h:187
@ time
Definition: vtkX3D.h:509
@ alpha
Definition: vtkX3D.h:262
int vtkTypeBool
Definition: vtkABI.h:71
#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:152
#define VTK_RESOLVE_OFF
Definition: vtkMapper.h:151
#define VTK_RESOLVE_SHIFT_ZBUFFER
Definition: vtkMapper.h:153
#define VTK_COLOR_MODE_MAP_SCALARS
#define VTK_COLOR_MODE_DEFAULT
#define VTK_COLOR_MODE_DIRECT_SCALARS
int vtkIdType
Definition: vtkType.h:326
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:281
#define VTK_SIZEHINT(...)