VTK  9.7.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 "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 
63 VTK_ABI_NAMESPACE_BEGIN
64 class vtkActor;
65 class vtkDataSet;
66 class vtkDataObject;
67 class vtkFloatArray;
69 class vtkImageData;
70 class vtkProp;
71 class vtkRenderer;
72 class vtkScalarsToColors;
73 class vtkSelection;
75 class vtkWindow;
76 
77 class VTKRENDERINGCORE_EXPORT VTK_MARSHALAUTO vtkMapper : public vtkAbstractMapper3D
78 {
79 public:
81  void PrintSelf(ostream& os, vtkIndent indent) override;
82 
86  void ShallowCopy(vtkAbstractMapper* m) override;
87 
92  vtkMTimeType GetMTime() override;
93 
98  virtual void Render(vtkRenderer* ren, vtkActor* a) = 0;
99 
106 
108 
111  void SetLookupTable(vtkScalarsToColors* lut);
112  vtkScalarsToColors* GetLookupTable();
114 
119  virtual void CreateDefaultLookupTable();
120 
122 
125  vtkSetMacro(ScalarVisibility, vtkTypeBool);
126  vtkGetMacro(ScalarVisibility, vtkTypeBool);
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);
157  void SetColorModeToDefault() { this->SetColorMode(VTK_COLOR_MODE_DEFAULT); }
158  void SetColorModeToMapScalars() { this->SetColorMode(VTK_COLOR_MODE_MAP_SCALARS); }
161 
165  const char* GetColorModeAsString();
166 
168 
174  vtkSetMacro(InterpolateScalarsBeforeMapping, vtkTypeBool);
175  vtkGetMacro(InterpolateScalarsBeforeMapping, vtkTypeBool);
176  vtkBooleanMacro(InterpolateScalarsBeforeMapping, vtkTypeBool);
178 
180 
188  vtkSetMacro(UseLookupTableScalarRange, vtkTypeBool);
189  vtkGetMacro(UseLookupTableScalarRange, vtkTypeBool);
190  vtkBooleanMacro(UseLookupTableScalarRange, vtkTypeBool);
192 
194 
199  vtkSetVector2Macro(ScalarRange, double);
200  vtkGetVectorMacro(ScalarRange, double, 2);
202 
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);
230  void SetScalarModeToDefault() { this->SetScalarMode(VTK_SCALAR_MODE_DEFAULT); }
234  {
235  this->SetScalarMode(VTK_SCALAR_MODE_USE_POINT_FIELD_DATA);
236  }
238  {
239  this->SetScalarMode(VTK_SCALAR_MODE_USE_CELL_FIELD_DATA);
240  }
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.
259  vtkSetMacro(FieldDataTupleId, vtkIdType);
260  vtkGetMacro(FieldDataTupleId, vtkIdType);
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 
287  const char* GetScalarModeAsString();
288 
290 
300  static void SetResolveCoincidentTopology(int val);
301  static int GetResolveCoincidentTopology();
302  static void SetResolveCoincidentTopologyToDefault();
303  static void SetResolveCoincidentTopologyToOff() { SetResolveCoincidentTopology(VTK_RESOLVE_OFF); }
305  {
306  SetResolveCoincidentTopology(VTK_RESOLVE_POLYGON_OFFSET);
307  }
309  {
310  SetResolveCoincidentTopology(VTK_RESOLVE_SHIFT_ZBUFFER);
311  }
313 
315 
320  static void SetResolveCoincidentTopologyPolygonOffsetParameters(double factor, double units);
321  static void GetResolveCoincidentTopologyPolygonOffsetParameters(double& factor, double& units);
323 
325 
329  void SetRelativeCoincidentTopologyPolygonOffsetParameters(double factor, double units);
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 
358  static void SetResolveCoincidentTopologyPointOffsetParameter(double units);
359  static void GetResolveCoincidentTopologyPointOffsetParameter(double& units);
361 
363 
367  void SetRelativeCoincidentTopologyPointOffsetParameter(double units);
368  void GetRelativeCoincidentTopologyPointOffsetParameter(double& units);
370 
372 
376  void GetCoincidentTopologyPolygonOffsetParameters(double& factor, double& units);
377  void GetCoincidentTopologyLineOffsetParameters(double& factor, double& units);
378  void GetCoincidentTopologyPointOffsetParameter(double& units);
380 
382 
389  static void SetResolveCoincidentTopologyPolygonOffsetFaces(int faces);
390  static int GetResolveCoincidentTopologyPolygonOffsetFaces();
392 
394 
398  static void SetResolveCoincidentTopologyZShift(double val);
399  static double GetResolveCoincidentTopologyZShift();
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 
421  vtkDataSet* GetInput();
422 
424 
430  vtkDataSet* GetDataSetInput() { return this->GetInput(); }
432 
434 
441  virtual vtkUnsignedCharArray* MapScalars(double alpha);
442  virtual vtkUnsignedCharArray* MapScalars(double alpha, int& cellFlag);
443  virtual vtkUnsignedCharArray* MapScalars(vtkDataSet* input, double alpha);
444  virtual vtkUnsignedCharArray* MapScalars(vtkDataSet* input, double alpha, int& cellFlag);
446 
448 
453  virtual bool HasOpaqueGeometry();
454  virtual bool HasTranslucentPolygonalGeometry();
456 
463  virtual bool GetSupportsSelection() { return false; }
464 
470  std::vector<unsigned int>& /* pixeloffsets */, vtkProp* /* prop */)
471  {
472  }
473 
482  virtual int CanUseTextureMapForColoring(vtkDataObject* input);
483 
488  void ClearColorArrays();
489 
493  vtkUnsignedCharArray* GetColorMapColors();
494 
498  vtkFloatArray* GetColorCoordinates();
499 
503  vtkImageData* GetColorTextureMap();
504 
506 
510  vtkGetObjectMacro(Selection, vtkSelection);
511  virtual void SetSelection(vtkSelection*);
513 
517  static vtkSmartPointer<vtkImageData> BuildColorTextureImage(
518  vtkScalarsToColors* lkup, int colorMode);
519 
520 protected:
521  vtkMapper();
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 
544  double RenderTime;
545 
546  // for coloring by a component of a field data array
547  int ArrayId;
548  char* ArrayName;
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 
566 private:
567  vtkMapper(const vtkMapper&) = delete;
568  void operator=(const vtkMapper&) = delete;
569 };
570 
571 VTK_ABI_NAMESPACE_END
572 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:49
vtkIdType FieldDataTupleId
Definition: vtkMapper.h:554
#define VTK_COLOR_MODE_DIRECT_SCALARS
void SetScalarModeToUsePointData()
Definition: vtkMapper.h:231
void SetScalarModeToDefault()
Definition: vtkMapper.h:230
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:308
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:41
#define VTK_SCALAR_MODE_USE_CELL_FIELD_DATA
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:318
vtkMTimeType GetMTime() override
Override Modifiedtime as we have added Clipping planes.
abstract class to specify dataset behavior
Definition: vtkDataSet.h:56
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:303
record modification and/or execution time
Definition: vtkTimeStamp.h:24
void SetScalarModeToUseCellData()
Definition: vtkMapper.h:232
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:31
vtkImageData * ColorTextureMap
Definition: vtkMapper.h:532
#define VTK_RESOLVE_SHIFT_ZBUFFER
Definition: vtkMapper.h:53
vtkTimeStamp BuildTime
Definition: vtkMapper.h:537
void SetColorModeToDefault()
default (ColorModeToDefault), unsigned char scalars are treated as colors, and NOT mapped through the...
Definition: vtkMapper.h:157
abstract specification for renderers
Definition: vtkRenderer.h:63
int ArrayAccessMode
Definition: vtkMapper.h:550
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:304
vtkTypeBool Static
Definition: vtkMapper.h:556
void SetScalarModeToUseFieldData()
Definition: vtkMapper.h:241
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:469
int vtkIdType
Definition: vtkType.h:363
double CoincidentLineFactor
Definition: vtkMapper.h:560
vtkUnsignedCharArray * Colors
Definition: vtkMapper.h:525
vtkTypeBool ScalarVisibility
Definition: vtkMapper.h:536
void SetColorModeToDirectScalars()
default (ColorModeToDefault), unsigned char scalars are treated as colors, and NOT mapped through the...
Definition: vtkMapper.h:159
int ScalarMode
Definition: vtkMapper.h:542
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:430
int vtkTypeBool
Definition: vtkABI.h:64
Superclass for mapping scalar values to colors.
window superclass for vtkRenderWindow
Definition: vtkWindow.h:41
double CoincidentPointOffset
Definition: vtkMapper.h:562
void SetRenderTime(double time)
This instance variable is used by vtkLODActor to determine which mapper to use.
Definition: vtkMapper.h:414
#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:233
double CoincidentLineOffset
Definition: vtkMapper.h:561
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
#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:558
double CoincidentPolygonOffset
Definition: vtkMapper.h:559
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:77
dynamic, self-adjusting array of unsigned char
abstract class specifies interface to map data
int ArrayId
Definition: vtkMapper.h:547
char * ArrayName
Definition: vtkMapper.h:548
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:158
int ArrayComponent
Definition: vtkMapper.h:549
vtkTypeBool UseLookupTableScalarRange
Definition: vtkMapper.h:539
vtkFloatArray * ColorCoordinates
Definition: vtkMapper.h:530
#define VTK_MARSHALAUTO
virtual bool GetSupportsSelection()
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THIS METHOD OUTSIDE OF THE RENDERI...
Definition: vtkMapper.h:463
#define VTK_SCALAR_MODE_USE_CELL_DATA
#define VTK_RESOLVE_POLYGON_OFFSET
Definition: vtkMapper.h:52
general representation of visualization data
Definition: vtkDataObject.h:55
void SetScalarModeToUseCellFieldData()
Definition: vtkMapper.h:237
vtkScalarsToColors * LookupTable
Definition: vtkMapper.h:535
void ReleaseGraphicsResources(vtkWindow *) override
Release any graphics resources that are being consumed by this mapper.
Definition: vtkMapper.h:105
double RenderTime
Definition: vtkMapper.h:544
#define VTK_SCALAR_MODE_DEFAULT
vtkTypeBool InterpolateScalarsBeforeMapping
Definition: vtkMapper.h:528
#define VTK_RESOLVE_OFF
Definition: vtkMapper.h:51
int ColorMode
Definition: vtkMapper.h:541