VTK  9.0.20201026
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 =========================================================================*/
47 #ifndef vtkMapper_h
48 #define vtkMapper_h
49 
50 #include "vtkAbstractMapper3D.h"
51 #include "vtkRenderingCoreModule.h" // For export macro
52 #include "vtkSmartPointer.h" // needed for vtkSmartPointer.
53 #include "vtkSystemIncludes.h" // For VTK_COLOR_MODE_DEFAULT and _MAP_SCALARS
54 #include <vector> // for method args
55 
56 #define VTK_RESOLVE_OFF 0
57 #define VTK_RESOLVE_POLYGON_OFFSET 1
58 #define VTK_RESOLVE_SHIFT_ZBUFFER 2
59 
60 #define VTK_GET_ARRAY_BY_ID 0
61 #define VTK_GET_ARRAY_BY_NAME 1
62 
63 #define VTK_MATERIALMODE_DEFAULT 0
64 #define VTK_MATERIALMODE_AMBIENT 1
65 #define VTK_MATERIALMODE_DIFFUSE 2
66 #define VTK_MATERIALMODE_AMBIENT_AND_DIFFUSE 3
67 
68 class vtkActor;
69 class vtkDataSet;
70 class vtkDataObject;
71 class vtkFloatArray;
73 class vtkImageData;
74 class vtkProp;
75 class vtkRenderer;
76 class vtkScalarsToColors;
77 class vtkSelection;
79 class vtkWindow;
80 
81 class VTKRENDERINGCORE_EXPORT vtkMapper : public vtkAbstractMapper3D
82 {
83 public:
85  void PrintSelf(ostream& os, vtkIndent indent) override;
86 
90  void ShallowCopy(vtkAbstractMapper* m) override;
91 
96  vtkMTimeType GetMTime() override;
97 
102  virtual void Render(vtkRenderer* ren, vtkActor* a) = 0;
103 
110 
112 
115  void SetLookupTable(vtkScalarsToColors* lut);
116  vtkScalarsToColors* GetLookupTable();
118 
123  virtual void CreateDefaultLookupTable();
124 
126 
129  vtkSetMacro(ScalarVisibility, vtkTypeBool);
130  vtkGetMacro(ScalarVisibility, vtkTypeBool);
131  vtkBooleanMacro(ScalarVisibility, vtkTypeBool);
133 
135 
141  vtkSetMacro(Static, vtkTypeBool);
142  vtkGetMacro(Static, vtkTypeBool);
143  vtkBooleanMacro(Static, vtkTypeBool);
145 
147 
159  vtkSetMacro(ColorMode, int);
160  vtkGetMacro(ColorMode, int);
161  void SetColorModeToDefault() { this->SetColorMode(VTK_COLOR_MODE_DEFAULT); }
162  void SetColorModeToMapScalars() { this->SetColorMode(VTK_COLOR_MODE_MAP_SCALARS); }
165 
169  const char* GetColorModeAsString();
170 
172 
178  vtkSetMacro(InterpolateScalarsBeforeMapping, vtkTypeBool);
179  vtkGetMacro(InterpolateScalarsBeforeMapping, vtkTypeBool);
180  vtkBooleanMacro(InterpolateScalarsBeforeMapping, vtkTypeBool);
182 
184 
192  vtkSetMacro(UseLookupTableScalarRange, vtkTypeBool);
193  vtkGetMacro(UseLookupTableScalarRange, vtkTypeBool);
194  vtkBooleanMacro(UseLookupTableScalarRange, vtkTypeBool);
196 
198 
203  vtkSetVector2Macro(ScalarRange, double);
204  vtkGetVectorMacro(ScalarRange, double, 2);
206 
220  // When ScalarMode is set to use Field Data (ScalarModeToFieldData),
221  // you must call SelectColorArray to choose the field data array to
222  // be used to color cells. In this mode, the default behavior is to
223  // treat the field data tuples as being associated with cells. If
224  // the poly data contains triangle strips, the array is expected to
225  // contain the cell data for each mini-cell formed by any triangle
226  // strips in the poly data as opposed to treating them as a single
227  // tuple that applies to the entire strip. This mode can also be
228  // used to color the entire poly data by a single color obtained by
229  // mapping the tuple at a given index in the field data array
230  // through the color map. Use SetFieldDataTupleId() to specify
231  // the tuple index.
232  vtkSetMacro(ScalarMode, int);
233  vtkGetMacro(ScalarMode, int);
234  void SetScalarModeToDefault() { this->SetScalarMode(VTK_SCALAR_MODE_DEFAULT); }
238  {
239  this->SetScalarMode(VTK_SCALAR_MODE_USE_POINT_FIELD_DATA);
240  }
242  {
243  this->SetScalarMode(VTK_SCALAR_MODE_USE_CELL_FIELD_DATA);
244  }
246 
248 
253  void SelectColorArray(int arrayNum);
254  void SelectColorArray(const char* arrayName);
256 
257  // When ScalarMode is set to UseFieldData, set the index of the
258  // tuple by which to color the entire data set. By default, the
259  // index is -1, which means to treat the field data array selected
260  // with SelectColorArray as having a scalar value for each cell.
261  // Indices of 0 or higher mean to use the tuple at the given index
262  // for coloring the entire data set.
263  vtkSetMacro(FieldDataTupleId, vtkIdType);
264  vtkGetMacro(FieldDataTupleId, vtkIdType);
265 
267 
272  void ColorByArrayComponent(int arrayNum, int component);
273  void ColorByArrayComponent(const char* arrayName, int component);
275 
279  vtkGetStringMacro(ArrayName);
280  vtkSetStringMacro(ArrayName);
281  vtkGetMacro(ArrayId, int);
282  vtkSetMacro(ArrayId, int);
283  vtkGetMacro(ArrayAccessMode, int);
284  vtkSetMacro(ArrayAccessMode, int);
285  vtkGetMacro(ArrayComponent, int);
286  vtkSetMacro(ArrayComponent, int);
287 
291  const char* GetScalarModeAsString();
292 
294 
304  static void SetResolveCoincidentTopology(int val);
305  static int GetResolveCoincidentTopology();
306  static void SetResolveCoincidentTopologyToDefault();
307  static void SetResolveCoincidentTopologyToOff() { SetResolveCoincidentTopology(VTK_RESOLVE_OFF); }
309  {
310  SetResolveCoincidentTopology(VTK_RESOLVE_POLYGON_OFFSET);
311  }
313  {
314  SetResolveCoincidentTopology(VTK_RESOLVE_SHIFT_ZBUFFER);
315  }
317 
319 
324  static void SetResolveCoincidentTopologyPolygonOffsetParameters(double factor, double units);
325  static void GetResolveCoincidentTopologyPolygonOffsetParameters(double& factor, double& units);
327 
329 
333  void SetRelativeCoincidentTopologyPolygonOffsetParameters(double factor, double units);
334  void GetRelativeCoincidentTopologyPolygonOffsetParameters(double& factor, double& units);
336 
338 
343  static void SetResolveCoincidentTopologyLineOffsetParameters(double factor, double units);
344  static void GetResolveCoincidentTopologyLineOffsetParameters(double& factor, double& units);
346 
348 
352  void SetRelativeCoincidentTopologyLineOffsetParameters(double factor, double units);
353  void GetRelativeCoincidentTopologyLineOffsetParameters(double& factor, double& units);
355 
357 
362  static void SetResolveCoincidentTopologyPointOffsetParameter(double units);
363  static void GetResolveCoincidentTopologyPointOffsetParameter(double& units);
365 
367 
371  void SetRelativeCoincidentTopologyPointOffsetParameter(double units);
372  void GetRelativeCoincidentTopologyPointOffsetParameter(double& units);
374 
376 
380  void GetCoincidentTopologyPolygonOffsetParameters(double& factor, double& units);
381  void GetCoincidentTopologyLineOffsetParameters(double& factor, double& units);
382  void GetCoincidentTopologyPointOffsetParameter(double& units);
384 
386 
393  static void SetResolveCoincidentTopologyPolygonOffsetFaces(int faces);
394  static int GetResolveCoincidentTopologyPolygonOffsetFaces();
396 
398 
402  static void SetResolveCoincidentTopologyZShift(double val);
403  static double GetResolveCoincidentTopologyZShift();
405 
410  double* GetBounds() VTK_SIZEHINT(6) override;
411  void GetBounds(double bounds[6]) override { this->vtkAbstractMapper3D::GetBounds(bounds); }
412 
418  void SetRenderTime(double time) { this->RenderTime = time; }
419  vtkGetMacro(RenderTime, double);
420 
425  vtkDataSet* GetInput();
426 
433  vtkDataSet* GetInputAsDataSet() { return this->GetInput(); }
434 
436 
443  virtual vtkUnsignedCharArray* MapScalars(double alpha);
444  virtual vtkUnsignedCharArray* MapScalars(double alpha, int& cellFlag);
445  virtual vtkUnsignedCharArray* MapScalars(vtkDataSet* input, double alpha);
446  virtual vtkUnsignedCharArray* MapScalars(vtkDataSet* input, double alpha, int& cellFlag);
448 
450 
455  virtual bool HasOpaqueGeometry();
456  virtual bool HasTranslucentPolygonalGeometry();
458 
465  virtual bool GetSupportsSelection() { return false; }
466 
472  std::vector<unsigned int>& /* pixeloffsets */, vtkProp* /* prop */)
473  {
474  }
475 
484  virtual int CanUseTextureMapForColoring(vtkDataObject* input);
485 
490  void ClearColorArrays();
491 
495  vtkUnsignedCharArray* GetColorMapColors();
496 
500  vtkFloatArray* GetColorCoordinates();
501 
505  vtkImageData* GetColorTextureMap();
506 
508 
512  vtkGetObjectMacro(Selection, vtkSelection);
513  virtual void SetSelection(vtkSelection*);
515 
516 protected:
517  vtkMapper();
518  ~vtkMapper() override;
519 
520  // color mapped colors
522 
523  // Use texture coordinates for coloring.
525  // Coordinate for each point.
527  // 1D ColorMap used for the texture image.
529  void MapScalarsToTexture(vtkAbstractArray* scalars, double alpha);
530 
534  double ScalarRange[2];
536 
539 
540  double RenderTime;
541 
542  // for coloring by a component of a field data array
543  int ArrayId;
544  char* ArrayName;
547 
548  // If coloring by field data, which tuple to use to color the entire
549  // data set. If -1, treat array values as cell data.
551 
553 
559 
560  vtkSelection* Selection = nullptr;
561 
562 private:
563  vtkMapper(const vtkMapper&) = delete;
564  void operator=(const vtkMapper&) = delete;
565 };
566 
567 #endif
vtkMapper::SetResolveCoincidentTopologyToOff
static void SetResolveCoincidentTopologyToOff()
Definition: vtkMapper.h:307
VTK_SCALAR_MODE_DEFAULT
#define VTK_SCALAR_MODE_DEFAULT
Definition: vtkAbstractMapper.h:34
vtkMapper::SetScalarModeToUsePointData
void SetScalarModeToUsePointData()
Definition: vtkMapper.h:235
VTK_SCALAR_MODE_USE_CELL_FIELD_DATA
#define VTK_SCALAR_MODE_USE_CELL_FIELD_DATA
Definition: vtkAbstractMapper.h:38
VTK_SCALAR_MODE_USE_POINT_DATA
#define VTK_SCALAR_MODE_USE_POINT_DATA
Definition: vtkAbstractMapper.h:35
VTK_COLOR_MODE_MAP_SCALARS
#define VTK_COLOR_MODE_MAP_SCALARS
Definition: vtkSystemIncludes.h:90
vtkMapper::SetResolveCoincidentTopologyToShiftZBuffer
static void SetResolveCoincidentTopologyToShiftZBuffer()
Definition: vtkMapper.h:312
vtkX3D::alpha
Definition: vtkX3D.h:256
vtkX3D::component
Definition: vtkX3D.h:181
vtkMapper::SetColorModeToDefault
void SetColorModeToDefault()
Definition: vtkMapper.h:161
VTK_SCALAR_MODE_USE_POINT_FIELD_DATA
#define VTK_SCALAR_MODE_USE_POINT_FIELD_DATA
Definition: vtkAbstractMapper.h:37
vtkAbstractMapper3D::GetBounds
virtual double * GetBounds()=0
Return bounding box (array of six doubles) of data expressed as (xmin,xmax, ymin,ymax,...
vtkMapper::CoincidentPointOffset
double CoincidentPointOffset
Definition: vtkMapper.h:558
vtkIdType
int vtkIdType
Definition: vtkType.h:330
vtkMapper::ArrayId
int ArrayId
Definition: vtkMapper.h:543
VTK_RESOLVE_POLYGON_OFFSET
#define VTK_RESOLVE_POLYGON_OFFSET
Definition: vtkMapper.h:57
vtkFloatArray
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:35
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:32
vtkAbstractMapper::GetMTime
vtkMTimeType GetMTime() override
Override Modifiedtime as we have added Clipping planes.
vtkUnsignedCharArray
dynamic, self-adjusting array of unsigned char
Definition: vtkUnsignedCharArray.h:35
vtkMapper::ColorTextureMap
vtkImageData * ColorTextureMap
Definition: vtkMapper.h:528
vtkMapper::CoincidentPolygonOffset
double CoincidentPolygonOffset
Definition: vtkMapper.h:555
vtkSelection
data object that represents a "selection" in VTK.
Definition: vtkSelection.h:57
vtkX3D::time
Definition: vtkX3D.h:503
vtkMapper::SetRenderTime
void SetRenderTime(double time)
This instance variable is used by vtkLODActor to determine which mapper to use.
Definition: vtkMapper.h:418
vtkMapper::Colors
vtkUnsignedCharArray * Colors
Definition: vtkMapper.h:521
vtkAbstractMapper3D.h
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:38
vtkMapper::CoincidentPolygonFactor
double CoincidentPolygonFactor
Definition: vtkMapper.h:554
vtkMapper::SetScalarModeToDefault
void SetScalarModeToDefault()
Definition: vtkMapper.h:234
vtkMapper::ScalarVisibility
vtkTypeBool ScalarVisibility
Definition: vtkMapper.h:532
vtkMapper::SetScalarModeToUseCellData
void SetScalarModeToUseCellData()
Definition: vtkMapper.h:236
vtkAbstractMapper3D::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
VTK_SCALAR_MODE_USE_CELL_DATA
#define VTK_SCALAR_MODE_USE_CELL_DATA
Definition: vtkAbstractMapper.h:36
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:45
vtkMapper::InterpolateScalarsBeforeMapping
vtkTypeBool InterpolateScalarsBeforeMapping
Definition: vtkMapper.h:524
vtkMapper::ProcessSelectorPixelBuffers
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:471
vtkMapper::BuildTime
vtkTimeStamp BuildTime
Definition: vtkMapper.h:533
vtkMapper::ArrayAccessMode
int ArrayAccessMode
Definition: vtkMapper.h:546
vtkMapper
abstract class specifies interface to map data to graphics primitives
Definition: vtkMapper.h:81
vtkBlockSortHelper::GetBounds
void GetBounds(T a, double bds[6])
Definition: vtkBlockSortHelper.h:37
vtkHardwareSelector
Definition: vtkHardwareSelector.h:123
VTK_RESOLVE_OFF
#define VTK_RESOLVE_OFF
Definition: vtkMapper.h:56
VTK_SCALAR_MODE_USE_FIELD_DATA
#define VTK_SCALAR_MODE_USE_FIELD_DATA
Definition: vtkAbstractMapper.h:39
vtkMapper::FieldDataTupleId
vtkIdType FieldDataTupleId
Definition: vtkMapper.h:550
vtkMapper::ColorCoordinates
vtkFloatArray * ColorCoordinates
Definition: vtkMapper.h:526
vtkActor
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:45
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:47
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkSmartPointer.h
vtkAbstractMapper::ShallowCopy
virtual void ShallowCopy(vtkAbstractMapper *m)
Make a shallow copy of this mapper.
vtkMapper::RenderTime
double RenderTime
Definition: vtkMapper.h:540
vtkScalarsToColors
Superclass for mapping scalar values to colors.
Definition: vtkScalarsToColors.h:59
vtkMapper::SetScalarModeToUseFieldData
void SetScalarModeToUseFieldData()
Definition: vtkMapper.h:245
vtkMapper::ArrayName
char * ArrayName
Definition: vtkMapper.h:544
vtkMapper::GetInputAsDataSet
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:433
vtkMapper::ReleaseGraphicsResources
void ReleaseGraphicsResources(vtkWindow *) override
Release any graphics resources that are being consumed by this mapper.
Definition: vtkMapper.h:109
vtkDataSet
abstract class to specify dataset behavior
Definition: vtkDataSet.h:56
vtkAbstractArray
Abstract superclass for all arrays.
Definition: vtkAbstractArray.h:75
vtkMapper::ColorMode
int ColorMode
Definition: vtkMapper.h:537
vtkMapper::GetSupportsSelection
virtual bool GetSupportsSelection()
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THIS METHOD OUTSIDE OF THE RENDERI...
Definition: vtkMapper.h:465
vtkProp
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:56
vtkMapper::SetColorModeToDirectScalars
void SetColorModeToDirectScalars()
Definition: vtkMapper.h:163
VTK_COLOR_MODE_DEFAULT
#define VTK_COLOR_MODE_DEFAULT
Definition: vtkSystemIncludes.h:89
vtkAbstractMapper3D
abstract class specifies interface to map 3D data
Definition: vtkAbstractMapper3D.h:42
vtkMapper::SetColorModeToMapScalars
void SetColorModeToMapScalars()
Definition: vtkMapper.h:162
vtkMapper::CoincidentLineOffset
double CoincidentLineOffset
Definition: vtkMapper.h:557
vtkMapper::Static
vtkTypeBool Static
Definition: vtkMapper.h:552
vtkMapper::SetResolveCoincidentTopologyToPolygonOffset
static void SetResolveCoincidentTopologyToPolygonOffset()
Definition: vtkMapper.h:308
vtkRenderer
abstract specification for renderers
Definition: vtkRenderer.h:67
VTK_RESOLVE_SHIFT_ZBUFFER
#define VTK_RESOLVE_SHIFT_ZBUFFER
Definition: vtkMapper.h:58
vtkMapper::LookupTable
vtkScalarsToColors * LookupTable
Definition: vtkMapper.h:531
vtkMapper::UseLookupTableScalarRange
vtkTypeBool UseLookupTableScalarRange
Definition: vtkMapper.h:535
VTK_COLOR_MODE_DIRECT_SCALARS
#define VTK_COLOR_MODE_DIRECT_SCALARS
Definition: vtkSystemIncludes.h:91
vtkMapper::CoincidentLineFactor
double CoincidentLineFactor
Definition: vtkMapper.h:556
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:59
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkMapper::SetScalarModeToUsePointFieldData
void SetScalarModeToUsePointFieldData()
Definition: vtkMapper.h:237
vtkMapper::ArrayComponent
int ArrayComponent
Definition: vtkMapper.h:545
vtkSystemIncludes.h
vtkAbstractMapper
abstract class specifies interface to map data
Definition: vtkAbstractMapper.h:52
vtkMTimeType
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:285
vtkMapper::ScalarMode
int ScalarMode
Definition: vtkMapper.h:538
vtkMapper::SetScalarModeToUseCellFieldData
void SetScalarModeToUseCellFieldData()
Definition: vtkMapper.h:241