VTK  9.3.1
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
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 <vector> // for method args
49 
50 #define VTK_RESOLVE_OFF 0
51 #define VTK_RESOLVE_POLYGON_OFFSET 1
52 #define VTK_RESOLVE_SHIFT_ZBUFFER 2
53 
54 #define VTK_GET_ARRAY_BY_ID 0
55 #define VTK_GET_ARRAY_BY_NAME 1
56 
57 #define VTK_MATERIALMODE_DEFAULT 0
58 #define VTK_MATERIALMODE_AMBIENT 1
59 #define VTK_MATERIALMODE_DIFFUSE 2
60 #define VTK_MATERIALMODE_AMBIENT_AND_DIFFUSE 3
61 
62 VTK_ABI_NAMESPACE_BEGIN
63 class vtkActor;
64 class vtkDataSet;
65 class vtkDataObject;
66 class vtkFloatArray;
68 class vtkImageData;
69 class vtkProp;
70 class vtkRenderer;
71 class vtkScalarsToColors;
72 class vtkSelection;
74 class vtkWindow;
75 
76 class VTKRENDERINGCORE_EXPORT vtkMapper : public vtkAbstractMapper3D
77 {
78 public:
80  void PrintSelf(ostream& os, vtkIndent indent) override;
81 
85  void ShallowCopy(vtkAbstractMapper* m) override;
86 
91  vtkMTimeType GetMTime() override;
92 
97  virtual void Render(vtkRenderer* ren, vtkActor* a) = 0;
98 
105 
107 
110  void SetLookupTable(vtkScalarsToColors* lut);
111  vtkScalarsToColors* GetLookupTable();
113 
118  virtual void CreateDefaultLookupTable();
119 
121 
124  vtkSetMacro(ScalarVisibility, vtkTypeBool);
125  vtkGetMacro(ScalarVisibility, vtkTypeBool);
126  vtkBooleanMacro(ScalarVisibility, vtkTypeBool);
128 
130 
136  vtkSetMacro(Static, vtkTypeBool);
137  vtkGetMacro(Static, vtkTypeBool);
138  vtkBooleanMacro(Static, vtkTypeBool);
140 
142 
154  vtkSetMacro(ColorMode, int);
155  vtkGetMacro(ColorMode, int);
156  void SetColorModeToDefault() { this->SetColorMode(VTK_COLOR_MODE_DEFAULT); }
157  void SetColorModeToMapScalars() { this->SetColorMode(VTK_COLOR_MODE_MAP_SCALARS); }
160 
164  const char* GetColorModeAsString();
165 
167 
173  vtkSetMacro(InterpolateScalarsBeforeMapping, vtkTypeBool);
174  vtkGetMacro(InterpolateScalarsBeforeMapping, vtkTypeBool);
175  vtkBooleanMacro(InterpolateScalarsBeforeMapping, vtkTypeBool);
177 
179 
187  vtkSetMacro(UseLookupTableScalarRange, vtkTypeBool);
188  vtkGetMacro(UseLookupTableScalarRange, vtkTypeBool);
189  vtkBooleanMacro(UseLookupTableScalarRange, vtkTypeBool);
191 
193 
198  vtkSetVector2Macro(ScalarRange, double);
199  vtkGetVectorMacro(ScalarRange, double, 2);
201 
215  // When ScalarMode is set to use Field Data (ScalarModeToFieldData),
216  // you must call SelectColorArray to choose the field data array to
217  // be used to color cells. In this mode, the default behavior is to
218  // treat the field data tuples as being associated with cells. If
219  // the poly data contains triangle strips, the array is expected to
220  // contain the cell data for each mini-cell formed by any triangle
221  // strips in the poly data as opposed to treating them as a single
222  // tuple that applies to the entire strip. This mode can also be
223  // used to color the entire poly data by a single color obtained by
224  // mapping the tuple at a given index in the field data array
225  // through the color map. Use SetFieldDataTupleId() to specify
226  // the tuple index.
227  vtkSetMacro(ScalarMode, int);
228  vtkGetMacro(ScalarMode, int);
229  void SetScalarModeToDefault() { this->SetScalarMode(VTK_SCALAR_MODE_DEFAULT); }
233  {
234  this->SetScalarMode(VTK_SCALAR_MODE_USE_POINT_FIELD_DATA);
235  }
237  {
238  this->SetScalarMode(VTK_SCALAR_MODE_USE_CELL_FIELD_DATA);
239  }
241 
243 
248  void SelectColorArray(int arrayNum);
249  void SelectColorArray(const char* arrayName);
251 
252  // When ScalarMode is set to UseFieldData, set the index of the
253  // tuple by which to color the entire data set. By default, the
254  // index is -1, which means to treat the field data array selected
255  // with SelectColorArray as having a scalar value for each cell.
256  // Indices of 0 or higher mean to use the tuple at the given index
257  // for coloring the entire data set.
258  vtkSetMacro(FieldDataTupleId, vtkIdType);
259  vtkGetMacro(FieldDataTupleId, vtkIdType);
260 
262 
267  void ColorByArrayComponent(int arrayNum, int component);
268  void ColorByArrayComponent(const char* arrayName, int component);
270 
274  vtkGetStringMacro(ArrayName);
275  vtkSetStringMacro(ArrayName);
276  vtkGetMacro(ArrayId, int);
277  vtkSetMacro(ArrayId, int);
278  vtkGetMacro(ArrayAccessMode, int);
279  vtkSetMacro(ArrayAccessMode, int);
280  vtkGetMacro(ArrayComponent, int);
281  vtkSetMacro(ArrayComponent, int);
282 
286  const char* GetScalarModeAsString();
287 
289 
299  static void SetResolveCoincidentTopology(int val);
300  static int GetResolveCoincidentTopology();
301  static void SetResolveCoincidentTopologyToDefault();
302  static void SetResolveCoincidentTopologyToOff() { SetResolveCoincidentTopology(VTK_RESOLVE_OFF); }
304  {
305  SetResolveCoincidentTopology(VTK_RESOLVE_POLYGON_OFFSET);
306  }
308  {
309  SetResolveCoincidentTopology(VTK_RESOLVE_SHIFT_ZBUFFER);
310  }
312 
314 
319  static void SetResolveCoincidentTopologyPolygonOffsetParameters(double factor, double units);
320  static void GetResolveCoincidentTopologyPolygonOffsetParameters(double& factor, double& units);
322 
324 
328  void SetRelativeCoincidentTopologyPolygonOffsetParameters(double factor, double units);
329  void GetRelativeCoincidentTopologyPolygonOffsetParameters(double& factor, double& units);
331 
333 
338  static void SetResolveCoincidentTopologyLineOffsetParameters(double factor, double units);
339  static void GetResolveCoincidentTopologyLineOffsetParameters(double& factor, double& units);
341 
343 
347  void SetRelativeCoincidentTopologyLineOffsetParameters(double factor, double units);
348  void GetRelativeCoincidentTopologyLineOffsetParameters(double& factor, double& units);
350 
352 
357  static void SetResolveCoincidentTopologyPointOffsetParameter(double units);
358  static void GetResolveCoincidentTopologyPointOffsetParameter(double& units);
360 
362 
366  void SetRelativeCoincidentTopologyPointOffsetParameter(double units);
367  void GetRelativeCoincidentTopologyPointOffsetParameter(double& units);
369 
371 
375  void GetCoincidentTopologyPolygonOffsetParameters(double& factor, double& units);
376  void GetCoincidentTopologyLineOffsetParameters(double& factor, double& units);
377  void GetCoincidentTopologyPointOffsetParameter(double& units);
379 
381 
388  static void SetResolveCoincidentTopologyPolygonOffsetFaces(int faces);
389  static int GetResolveCoincidentTopologyPolygonOffsetFaces();
391 
393 
397  static void SetResolveCoincidentTopologyZShift(double val);
398  static double GetResolveCoincidentTopologyZShift();
400 
405  double* GetBounds() VTK_SIZEHINT(6) override;
406  void GetBounds(double bounds[6]) override { this->vtkAbstractMapper3D::GetBounds(bounds); }
407 
413  void SetRenderTime(double time) { this->RenderTime = time; }
414  vtkGetMacro(RenderTime, double);
415 
420  vtkDataSet* GetInput();
421 
428  vtkDataSet* GetInputAsDataSet() { return this->GetInput(); }
429 
431 
438  virtual vtkUnsignedCharArray* MapScalars(double alpha);
439  virtual vtkUnsignedCharArray* MapScalars(double alpha, int& cellFlag);
440  virtual vtkUnsignedCharArray* MapScalars(vtkDataSet* input, double alpha);
441  virtual vtkUnsignedCharArray* MapScalars(vtkDataSet* input, double alpha, int& cellFlag);
443 
445 
450  virtual bool HasOpaqueGeometry();
451  virtual bool HasTranslucentPolygonalGeometry();
453 
460  virtual bool GetSupportsSelection() { return false; }
461 
467  std::vector<unsigned int>& /* pixeloffsets */, vtkProp* /* prop */)
468  {
469  }
470 
479  virtual int CanUseTextureMapForColoring(vtkDataObject* input);
480 
485  void ClearColorArrays();
486 
490  vtkUnsignedCharArray* GetColorMapColors();
491 
495  vtkFloatArray* GetColorCoordinates();
496 
500  vtkImageData* GetColorTextureMap();
501 
503 
507  vtkGetObjectMacro(Selection, vtkSelection);
508  virtual void SetSelection(vtkSelection*);
510 
511 protected:
512  vtkMapper();
513  ~vtkMapper() override;
514 
515  // color mapped colors
517 
518  // Use texture coordinates for coloring.
520  // Coordinate for each point.
522  // 1D ColorMap used for the texture image.
524  void MapScalarsToTexture(vtkAbstractArray* scalars, double alpha);
525 
529  double ScalarRange[2];
531 
534 
535  double RenderTime;
536 
537  // for coloring by a component of a field data array
538  int ArrayId;
539  char* ArrayName;
542 
543  // If coloring by field data, which tuple to use to color the entire
544  // data set. If -1, treat array values as cell data.
546 
548 
554 
555  vtkSelection* Selection = nullptr;
556 
557 private:
558  vtkMapper(const vtkMapper&) = delete;
559  void operator=(const vtkMapper&) = delete;
560 };
561 
562 VTK_ABI_NAMESPACE_END
563 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:45
vtkIdType FieldDataTupleId
Definition: vtkMapper.h:545
#define VTK_COLOR_MODE_DIRECT_SCALARS
void SetScalarModeToUsePointData()
Definition: vtkMapper.h:230
void SetScalarModeToDefault()
Definition: vtkMapper.h:229
void GetBounds(T a, double bds[6])
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:307
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:40
#define VTK_SCALAR_MODE_USE_CELL_FIELD_DATA
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:428
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:270
vtkMTimeType GetMTime() override
Override Modifiedtime as we have added Clipping planes.
abstract class to specify dataset behavior
Definition: vtkDataSet.h:52
Abstract superclass for all arrays.
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:302
record modification and/or execution time
Definition: vtkTimeStamp.h:24
void SetScalarModeToUseCellData()
Definition: vtkMapper.h:231
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:30
vtkImageData * ColorTextureMap
Definition: vtkMapper.h:523
#define VTK_RESOLVE_SHIFT_ZBUFFER
Definition: vtkMapper.h:52
vtkTimeStamp BuildTime
Definition: vtkMapper.h:528
void SetColorModeToDefault()
default (ColorModeToDefault), unsigned char scalars are treated as colors, and NOT mapped through the...
Definition: vtkMapper.h:156
abstract specification for renderers
Definition: vtkRenderer.h:61
int ArrayAccessMode
Definition: vtkMapper.h:541
data object that represents a "selection" in VTK.
Definition: vtkSelection.h:49
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:303
vtkTypeBool Static
Definition: vtkMapper.h:547
void SetScalarModeToUseFieldData()
Definition: vtkMapper.h:240
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:466
int vtkIdType
Definition: vtkType.h:315
double CoincidentLineFactor
Definition: vtkMapper.h:551
vtkUnsignedCharArray * Colors
Definition: vtkMapper.h:516
vtkTypeBool ScalarVisibility
Definition: vtkMapper.h:527
void SetColorModeToDirectScalars()
default (ColorModeToDefault), unsigned char scalars are treated as colors, and NOT mapped through the...
Definition: vtkMapper.h:158
int ScalarMode
Definition: vtkMapper.h:533
int vtkTypeBool
Definition: vtkABI.h:64
Superclass for mapping scalar values to colors.
window superclass for vtkRenderWindow
Definition: vtkWindow.h:27
double CoincidentPointOffset
Definition: vtkMapper.h:553
void SetRenderTime(double time)
This instance variable is used by vtkLODActor to determine which mapper to use.
Definition: vtkMapper.h:413
#define VTK_COLOR_MODE_MAP_SCALARS
#define VTK_SCALAR_MODE_USE_POINT_DATA
a simple class to control print indentation
Definition: vtkIndent.h:28
void SetScalarModeToUsePointFieldData()
Definition: vtkMapper.h:232
double CoincidentLineOffset
Definition: vtkMapper.h:552
topologically and geometrically regular array of data
Definition: vtkImageData.h:42
#define VTK_SCALAR_MODE_USE_POINT_FIELD_DATA
virtual void ShallowCopy(vtkAbstractMapper *m)
Make a shallow copy of this mapper.
double CoincidentPolygonFactor
Definition: vtkMapper.h:549
double CoincidentPolygonOffset
Definition: vtkMapper.h:550
virtual double * GetBounds()=0
Return bounding box (array of six doubles) of data expressed as (xmin,xmax, ymin,ymax, zmin,zmax).
abstract class specifies interface to map 3D data
#define VTK_COLOR_MODE_DEFAULT
#define VTK_SIZEHINT(...)
#define VTK_SCALAR_MODE_USE_FIELD_DATA
abstract class specifies interface to map data to graphics primitives
Definition: vtkMapper.h:76
dynamic, self-adjusting array of unsigned char
abstract class specifies interface to map data
int ArrayId
Definition: vtkMapper.h:538
char * ArrayName
Definition: vtkMapper.h:539
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetColorModeToMapScalars()
default (ColorModeToDefault), unsigned char scalars are treated as colors, and NOT mapped through the...
Definition: vtkMapper.h:157
int ArrayComponent
Definition: vtkMapper.h:540
vtkTypeBool UseLookupTableScalarRange
Definition: vtkMapper.h:530
vtkFloatArray * ColorCoordinates
Definition: vtkMapper.h:521
virtual bool GetSupportsSelection()
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THIS METHOD OUTSIDE OF THE RENDERI...
Definition: vtkMapper.h:460
#define VTK_SCALAR_MODE_USE_CELL_DATA
#define VTK_RESOLVE_POLYGON_OFFSET
Definition: vtkMapper.h:51
general representation of visualization data
Definition: vtkDataObject.h:54
void SetScalarModeToUseCellFieldData()
Definition: vtkMapper.h:236
vtkScalarsToColors * LookupTable
Definition: vtkMapper.h:526
void ReleaseGraphicsResources(vtkWindow *) override
Release any graphics resources that are being consumed by this mapper.
Definition: vtkMapper.h:104
double RenderTime
Definition: vtkMapper.h:535
#define VTK_SCALAR_MODE_DEFAULT
vtkTypeBool InterpolateScalarsBeforeMapping
Definition: vtkMapper.h:519
#define VTK_RESOLVE_OFF
Definition: vtkMapper.h:50
int ColorMode
Definition: vtkMapper.h:532