VTK  9.2.6
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 =========================================================================*/
53 #ifndef vtkMapper_h
54 #define vtkMapper_h
55 
56 #include "vtkAbstractMapper3D.h"
57 #include "vtkRenderingCoreModule.h" // For export macro
58 #include "vtkSmartPointer.h" // needed for vtkSmartPointer.
59 #include "vtkSystemIncludes.h" // For VTK_COLOR_MODE_DEFAULT and _MAP_SCALARS
60 #include <vector> // for method args
61 
62 #define VTK_RESOLVE_OFF 0
63 #define VTK_RESOLVE_POLYGON_OFFSET 1
64 #define VTK_RESOLVE_SHIFT_ZBUFFER 2
65 
66 #define VTK_GET_ARRAY_BY_ID 0
67 #define VTK_GET_ARRAY_BY_NAME 1
68 
69 #define VTK_MATERIALMODE_DEFAULT 0
70 #define VTK_MATERIALMODE_AMBIENT 1
71 #define VTK_MATERIALMODE_DIFFUSE 2
72 #define VTK_MATERIALMODE_AMBIENT_AND_DIFFUSE 3
73 
74 class vtkActor;
75 class vtkDataSet;
76 class vtkDataObject;
77 class vtkFloatArray;
79 class vtkImageData;
80 class vtkProp;
81 class vtkRenderer;
82 class vtkScalarsToColors;
83 class vtkSelection;
85 class vtkWindow;
86 
87 class VTKRENDERINGCORE_EXPORT vtkMapper : public vtkAbstractMapper3D
88 {
89 public:
91  void PrintSelf(ostream& os, vtkIndent indent) override;
92 
96  void ShallowCopy(vtkAbstractMapper* m) override;
97 
102  vtkMTimeType GetMTime() override;
103 
108  virtual void Render(vtkRenderer* ren, vtkActor* a) = 0;
109 
116 
118 
121  void SetLookupTable(vtkScalarsToColors* lut);
122  vtkScalarsToColors* GetLookupTable();
124 
129  virtual void CreateDefaultLookupTable();
130 
132 
135  vtkSetMacro(ScalarVisibility, vtkTypeBool);
136  vtkGetMacro(ScalarVisibility, vtkTypeBool);
137  vtkBooleanMacro(ScalarVisibility, vtkTypeBool);
139 
141 
147  vtkSetMacro(Static, vtkTypeBool);
148  vtkGetMacro(Static, vtkTypeBool);
149  vtkBooleanMacro(Static, vtkTypeBool);
151 
153 
165  vtkSetMacro(ColorMode, int);
166  vtkGetMacro(ColorMode, int);
167  void SetColorModeToDefault() { this->SetColorMode(VTK_COLOR_MODE_DEFAULT); }
168  void SetColorModeToMapScalars() { this->SetColorMode(VTK_COLOR_MODE_MAP_SCALARS); }
171 
175  const char* GetColorModeAsString();
176 
178 
184  vtkSetMacro(InterpolateScalarsBeforeMapping, vtkTypeBool);
185  vtkGetMacro(InterpolateScalarsBeforeMapping, vtkTypeBool);
186  vtkBooleanMacro(InterpolateScalarsBeforeMapping, vtkTypeBool);
188 
190 
198  vtkSetMacro(UseLookupTableScalarRange, vtkTypeBool);
199  vtkGetMacro(UseLookupTableScalarRange, vtkTypeBool);
200  vtkBooleanMacro(UseLookupTableScalarRange, vtkTypeBool);
202 
204 
209  vtkSetVector2Macro(ScalarRange, double);
210  vtkGetVectorMacro(ScalarRange, double, 2);
212 
226  // When ScalarMode is set to use Field Data (ScalarModeToFieldData),
227  // you must call SelectColorArray to choose the field data array to
228  // be used to color cells. In this mode, the default behavior is to
229  // treat the field data tuples as being associated with cells. If
230  // the poly data contains triangle strips, the array is expected to
231  // contain the cell data for each mini-cell formed by any triangle
232  // strips in the poly data as opposed to treating them as a single
233  // tuple that applies to the entire strip. This mode can also be
234  // used to color the entire poly data by a single color obtained by
235  // mapping the tuple at a given index in the field data array
236  // through the color map. Use SetFieldDataTupleId() to specify
237  // the tuple index.
238  vtkSetMacro(ScalarMode, int);
239  vtkGetMacro(ScalarMode, int);
240  void SetScalarModeToDefault() { this->SetScalarMode(VTK_SCALAR_MODE_DEFAULT); }
244  {
245  this->SetScalarMode(VTK_SCALAR_MODE_USE_POINT_FIELD_DATA);
246  }
248  {
249  this->SetScalarMode(VTK_SCALAR_MODE_USE_CELL_FIELD_DATA);
250  }
252 
254 
259  void SelectColorArray(int arrayNum);
260  void SelectColorArray(const char* arrayName);
262 
263  // When ScalarMode is set to UseFieldData, set the index of the
264  // tuple by which to color the entire data set. By default, the
265  // index is -1, which means to treat the field data array selected
266  // with SelectColorArray as having a scalar value for each cell.
267  // Indices of 0 or higher mean to use the tuple at the given index
268  // for coloring the entire data set.
269  vtkSetMacro(FieldDataTupleId, vtkIdType);
270  vtkGetMacro(FieldDataTupleId, vtkIdType);
271 
273 
278  void ColorByArrayComponent(int arrayNum, int component);
279  void ColorByArrayComponent(const char* arrayName, int component);
281 
285  vtkGetStringMacro(ArrayName);
286  vtkSetStringMacro(ArrayName);
287  vtkGetMacro(ArrayId, int);
288  vtkSetMacro(ArrayId, int);
289  vtkGetMacro(ArrayAccessMode, int);
290  vtkSetMacro(ArrayAccessMode, int);
291  vtkGetMacro(ArrayComponent, int);
292  vtkSetMacro(ArrayComponent, int);
293 
297  const char* GetScalarModeAsString();
298 
300 
310  static void SetResolveCoincidentTopology(int val);
311  static int GetResolveCoincidentTopology();
312  static void SetResolveCoincidentTopologyToDefault();
313  static void SetResolveCoincidentTopologyToOff() { SetResolveCoincidentTopology(VTK_RESOLVE_OFF); }
315  {
316  SetResolveCoincidentTopology(VTK_RESOLVE_POLYGON_OFFSET);
317  }
319  {
320  SetResolveCoincidentTopology(VTK_RESOLVE_SHIFT_ZBUFFER);
321  }
323 
325 
330  static void SetResolveCoincidentTopologyPolygonOffsetParameters(double factor, double units);
331  static void GetResolveCoincidentTopologyPolygonOffsetParameters(double& factor, double& units);
333 
335 
339  void SetRelativeCoincidentTopologyPolygonOffsetParameters(double factor, double units);
340  void GetRelativeCoincidentTopologyPolygonOffsetParameters(double& factor, double& units);
342 
344 
349  static void SetResolveCoincidentTopologyLineOffsetParameters(double factor, double units);
350  static void GetResolveCoincidentTopologyLineOffsetParameters(double& factor, double& units);
352 
354 
358  void SetRelativeCoincidentTopologyLineOffsetParameters(double factor, double units);
359  void GetRelativeCoincidentTopologyLineOffsetParameters(double& factor, double& units);
361 
363 
368  static void SetResolveCoincidentTopologyPointOffsetParameter(double units);
369  static void GetResolveCoincidentTopologyPointOffsetParameter(double& units);
371 
373 
377  void SetRelativeCoincidentTopologyPointOffsetParameter(double units);
378  void GetRelativeCoincidentTopologyPointOffsetParameter(double& units);
380 
382 
386  void GetCoincidentTopologyPolygonOffsetParameters(double& factor, double& units);
387  void GetCoincidentTopologyLineOffsetParameters(double& factor, double& units);
388  void GetCoincidentTopologyPointOffsetParameter(double& units);
390 
392 
399  static void SetResolveCoincidentTopologyPolygonOffsetFaces(int faces);
400  static int GetResolveCoincidentTopologyPolygonOffsetFaces();
402 
404 
408  static void SetResolveCoincidentTopologyZShift(double val);
409  static double GetResolveCoincidentTopologyZShift();
411 
416  double* GetBounds() VTK_SIZEHINT(6) override;
417  void GetBounds(double bounds[6]) override { this->vtkAbstractMapper3D::GetBounds(bounds); }
418 
424  void SetRenderTime(double time) { this->RenderTime = time; }
425  vtkGetMacro(RenderTime, double);
426 
431  vtkDataSet* GetInput();
432 
439  vtkDataSet* GetInputAsDataSet() { return this->GetInput(); }
440 
442 
449  virtual vtkUnsignedCharArray* MapScalars(double alpha);
450  virtual vtkUnsignedCharArray* MapScalars(double alpha, int& cellFlag);
451  virtual vtkUnsignedCharArray* MapScalars(vtkDataSet* input, double alpha);
452  virtual vtkUnsignedCharArray* MapScalars(vtkDataSet* input, double alpha, int& cellFlag);
454 
456 
461  virtual bool HasOpaqueGeometry();
462  virtual bool HasTranslucentPolygonalGeometry();
464 
471  virtual bool GetSupportsSelection() { return false; }
472 
478  std::vector<unsigned int>& /* pixeloffsets */, vtkProp* /* prop */)
479  {
480  }
481 
490  virtual int CanUseTextureMapForColoring(vtkDataObject* input);
491 
496  void ClearColorArrays();
497 
501  vtkUnsignedCharArray* GetColorMapColors();
502 
506  vtkFloatArray* GetColorCoordinates();
507 
511  vtkImageData* GetColorTextureMap();
512 
514 
518  vtkGetObjectMacro(Selection, vtkSelection);
519  virtual void SetSelection(vtkSelection*);
521 
522 protected:
523  vtkMapper();
524  ~vtkMapper() override;
525 
526  // color mapped colors
528 
529  // Use texture coordinates for coloring.
531  // Coordinate for each point.
533  // 1D ColorMap used for the texture image.
535  void MapScalarsToTexture(vtkAbstractArray* scalars, double alpha);
536 
540  double ScalarRange[2];
542 
545 
546  double RenderTime;
547 
548  // for coloring by a component of a field data array
549  int ArrayId;
550  char* ArrayName;
553 
554  // If coloring by field data, which tuple to use to color the entire
555  // data set. If -1, treat array values as cell data.
557 
559 
565 
566  vtkSelection* Selection = nullptr;
567 
568 private:
569  vtkMapper(const vtkMapper&) = delete;
570  void operator=(const vtkMapper&) = delete;
571 };
572 
573 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:56
vtkIdType FieldDataTupleId
Definition: vtkMapper.h:556
#define VTK_COLOR_MODE_DIRECT_SCALARS
void SetScalarModeToUsePointData()
Definition: vtkMapper.h:241
void SetScalarModeToDefault()
Definition: vtkMapper.h:240
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:318
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:51
#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:439
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:287
vtkMTimeType GetMTime() override
Override Modifiedtime as we have added Clipping planes.
abstract class to specify dataset behavior
Definition: vtkDataSet.h:62
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:313
record modification and/or execution time
Definition: vtkTimeStamp.h:35
void SetScalarModeToUseCellData()
Definition: vtkMapper.h:242
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:41
vtkImageData * ColorTextureMap
Definition: vtkMapper.h:534
#define VTK_RESOLVE_SHIFT_ZBUFFER
Definition: vtkMapper.h:64
vtkTimeStamp BuildTime
Definition: vtkMapper.h:539
void SetColorModeToDefault()
default (ColorModeToDefault), unsigned char scalars are treated as colors, and NOT mapped through the...
Definition: vtkMapper.h:167
abstract specification for renderers
Definition: vtkRenderer.h:72
int ArrayAccessMode
Definition: vtkMapper.h:552
data object that represents a "selection" in VTK.
Definition: vtkSelection.h:59
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:314
vtkTypeBool Static
Definition: vtkMapper.h:558
void SetScalarModeToUseFieldData()
Definition: vtkMapper.h:251
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:477
int vtkIdType
Definition: vtkType.h:332
double CoincidentLineFactor
Definition: vtkMapper.h:562
vtkUnsignedCharArray * Colors
Definition: vtkMapper.h:527
vtkTypeBool ScalarVisibility
Definition: vtkMapper.h:538
void SetColorModeToDirectScalars()
default (ColorModeToDefault), unsigned char scalars are treated as colors, and NOT mapped through the...
Definition: vtkMapper.h:169
int ScalarMode
Definition: vtkMapper.h:544
int vtkTypeBool
Definition: vtkABI.h:69
Superclass for mapping scalar values to colors.
window superclass for vtkRenderWindow
Definition: vtkWindow.h:38
double CoincidentPointOffset
Definition: vtkMapper.h:564
void SetRenderTime(double time)
This instance variable is used by vtkLODActor to determine which mapper to use.
Definition: vtkMapper.h:424
#define VTK_COLOR_MODE_MAP_SCALARS
#define VTK_SCALAR_MODE_USE_POINT_DATA
a simple class to control print indentation
Definition: vtkIndent.h:39
void SetScalarModeToUsePointFieldData()
Definition: vtkMapper.h:243
double CoincidentLineOffset
Definition: vtkMapper.h:563
topologically and geometrically regular array of data
Definition: vtkImageData.h:53
#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:560
double CoincidentPolygonOffset
Definition: vtkMapper.h:561
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:87
dynamic, self-adjusting array of unsigned char
abstract class specifies interface to map data
int ArrayId
Definition: vtkMapper.h:549
char * ArrayName
Definition: vtkMapper.h:550
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:168
int ArrayComponent
Definition: vtkMapper.h:551
vtkTypeBool UseLookupTableScalarRange
Definition: vtkMapper.h:541
vtkFloatArray * ColorCoordinates
Definition: vtkMapper.h:532
virtual bool GetSupportsSelection()
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THIS METHOD OUTSIDE OF THE RENDERI...
Definition: vtkMapper.h:471
#define VTK_SCALAR_MODE_USE_CELL_DATA
#define VTK_RESOLVE_POLYGON_OFFSET
Definition: vtkMapper.h:63
general representation of visualization data
Definition: vtkDataObject.h:65
void SetScalarModeToUseCellFieldData()
Definition: vtkMapper.h:247
vtkScalarsToColors * LookupTable
Definition: vtkMapper.h:537
void ReleaseGraphicsResources(vtkWindow *) override
Release any graphics resources that are being consumed by this mapper.
Definition: vtkMapper.h:115
double RenderTime
Definition: vtkMapper.h:546
#define VTK_SCALAR_MODE_DEFAULT
vtkTypeBool InterpolateScalarsBeforeMapping
Definition: vtkMapper.h:530
#define VTK_RESOLVE_OFF
Definition: vtkMapper.h:62
int ColorMode
Definition: vtkMapper.h:543