VTK
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 "vtkRenderingCoreModule.h" // For export macro
57 #include "vtkAbstractMapper3D.h"
58 #include "vtkSystemIncludes.h" // For VTK_COLOR_MODE_DEFAULT and _MAP_SCALARS
59 #include "vtkSmartPointer.h" // needed for vtkSmartPointer.
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;
84 class vtkWindow;
85 
86 class VTKRENDERINGCORE_EXPORT vtkMapper : public vtkAbstractMapper3D
87 {
88 public:
90  void PrintSelf(ostream& os, vtkIndent indent) override;
91 
95  void ShallowCopy(vtkAbstractMapper *m) override;
96 
101  vtkMTimeType GetMTime() override;
102 
107  virtual void Render(vtkRenderer *ren, vtkActor *a) = 0;
108 
115 
117 
120  void SetLookupTable(vtkScalarsToColors *lut);
121  vtkScalarsToColors *GetLookupTable();
123 
128  virtual void CreateDefaultLookupTable();
129 
131 
134  vtkSetMacro(ScalarVisibility, vtkTypeBool);
135  vtkGetMacro(ScalarVisibility, vtkTypeBool);
136  vtkBooleanMacro(ScalarVisibility, vtkTypeBool);
138 
140 
146  vtkSetMacro(Static, vtkTypeBool);
147  vtkGetMacro(Static, vtkTypeBool);
148  vtkBooleanMacro(Static, vtkTypeBool);
150 
152 
164  vtkSetMacro(ColorMode, int);
165  vtkGetMacro(ColorMode, int);
167  { this->SetColorMode(VTK_COLOR_MODE_DEFAULT); }
169  { this->SetColorMode(VTK_COLOR_MODE_MAP_SCALARS); }
171  { this->SetColorMode(VTK_COLOR_MODE_DIRECT_SCALARS); }
173 
177  const char *GetColorModeAsString();
178 
180 
186  vtkSetMacro(InterpolateScalarsBeforeMapping, vtkTypeBool);
187  vtkGetMacro(InterpolateScalarsBeforeMapping, vtkTypeBool);
188  vtkBooleanMacro(InterpolateScalarsBeforeMapping, vtkTypeBool);
190 
192 
200  vtkSetMacro(UseLookupTableScalarRange, vtkTypeBool);
201  vtkGetMacro(UseLookupTableScalarRange, vtkTypeBool);
202  vtkBooleanMacro(UseLookupTableScalarRange, vtkTypeBool);
204 
206 
211  vtkSetVector2Macro(ScalarRange, double);
212  vtkGetVectorMacro(ScalarRange, double, 2);
214 
228  // When ScalarMode is set to use Field Data (ScalarModeToFieldData),
229  // you must call SelectColorArray to choose the field data array to
230  // be used to color cells. In this mode, the default behavior is to
231  // treat the field data tuples as being associated with cells. If
232  // the poly data contains triangle strips, the array is expected to
233  // contain the cell data for each mini-cell formed by any triangle
234  // strips in the poly data as opposed to treating them as a single
235  // tuple that applies to the entire strip. This mode can also be
236  // used to color the entire poly data by a single color obtained by
237  // mapping the tuple at a given index in the field data array
238  // through the color map. Use SetFieldDataTupleId() to specify
239  // the tuple index.
240  vtkSetMacro(ScalarMode, int);
241  vtkGetMacro(ScalarMode, int);
243  { this->SetScalarMode(VTK_SCALAR_MODE_DEFAULT); }
245  { this->SetScalarMode(VTK_SCALAR_MODE_USE_POINT_DATA); }
247  { this->SetScalarMode(VTK_SCALAR_MODE_USE_CELL_DATA); }
249  { this->SetScalarMode(VTK_SCALAR_MODE_USE_POINT_FIELD_DATA); }
251  { this->SetScalarMode(VTK_SCALAR_MODE_USE_CELL_FIELD_DATA); }
253  { this->SetScalarMode(VTK_SCALAR_MODE_USE_FIELD_DATA); }
254 
256 
261  void SelectColorArray(int arrayNum);
262  void SelectColorArray(const char* arrayName);
264 
265 
266  // When ScalarMode is set to UseFieldData, set the index of the
267  // tuple by which to color the entire data set. By default, the
268  // index is -1, which means to treat the field data array selected
269  // with SelectColorArray as having a scalar value for each cell.
270  // Indices of 0 or higher mean to use the tuple at the given index
271  // for coloring the entire data set.
272  vtkSetMacro(FieldDataTupleId, vtkIdType);
273  vtkGetMacro(FieldDataTupleId, vtkIdType);
274 
276 
281  void ColorByArrayComponent(int arrayNum, int component);
282  void ColorByArrayComponent(const char* arrayName, int component);
284 
288  vtkGetStringMacro(ArrayName);
289  vtkSetStringMacro(ArrayName);
290  vtkGetMacro(ArrayId, int);
291  vtkSetMacro(ArrayId, int);
292  vtkGetMacro(ArrayAccessMode, int);
293  vtkSetMacro(ArrayAccessMode, int);
294  vtkGetMacro(ArrayComponent, int);
295  vtkSetMacro(ArrayComponent, int);
296 
300  const char *GetScalarModeAsString();
301 
303 
313  static void SetResolveCoincidentTopology(int val);
314  static int GetResolveCoincidentTopology();
315  static void SetResolveCoincidentTopologyToDefault();
317  { SetResolveCoincidentTopology(VTK_RESOLVE_OFF) ;}
319  { SetResolveCoincidentTopology(VTK_RESOLVE_POLYGON_OFFSET); }
321  { SetResolveCoincidentTopology(VTK_RESOLVE_SHIFT_ZBUFFER); }
323 
325 
330  static void SetResolveCoincidentTopologyPolygonOffsetParameters(
331  double factor, double units);
332  static void GetResolveCoincidentTopologyPolygonOffsetParameters(
333  double& factor, double& units);
335 
337 
341  void SetRelativeCoincidentTopologyPolygonOffsetParameters(
342  double factor, double units);
343  void GetRelativeCoincidentTopologyPolygonOffsetParameters(
344  double& factor, double& units);
346 
348 
353  static void SetResolveCoincidentTopologyLineOffsetParameters(
354  double factor, double units);
355  static void GetResolveCoincidentTopologyLineOffsetParameters(
356  double& factor, double& units);
358 
360 
364  void SetRelativeCoincidentTopologyLineOffsetParameters(
365  double factor, double units);
366  void GetRelativeCoincidentTopologyLineOffsetParameters(
367  double& factor, double& units);
369 
371 
376  static void SetResolveCoincidentTopologyPointOffsetParameter(
377  double units);
378  static void GetResolveCoincidentTopologyPointOffsetParameter(
379  double& units);
381 
383 
387  void SetRelativeCoincidentTopologyPointOffsetParameter(double units);
388  void GetRelativeCoincidentTopologyPointOffsetParameter(double& units);
390 
392 
396  void GetCoincidentTopologyPolygonOffsetParameters(
397  double& factor, double& units);
398  void GetCoincidentTopologyLineOffsetParameters(
399  double& factor, double& units);
400  void GetCoincidentTopologyPointOffsetParameter(double& units);
402 
404 
411  static void SetResolveCoincidentTopologyPolygonOffsetFaces(int faces);
412  static int GetResolveCoincidentTopologyPolygonOffsetFaces();
414 
416 
420  static void SetResolveCoincidentTopologyZShift(double val);
421  static double GetResolveCoincidentTopologyZShift();
423 
428  double *GetBounds() VTK_SIZEHINT(6) override;
429  void GetBounds(double bounds[6]) override
430  { this->vtkAbstractMapper3D::GetBounds(bounds); }
431 
437  void SetRenderTime(double time) {this->RenderTime = time;}
438  vtkGetMacro(RenderTime, double);
439 
444  vtkDataSet *GetInput();
445 
453  { return this->GetInput(); }
454 
456 
463  virtual vtkUnsignedCharArray *MapScalars(double alpha);
464  virtual vtkUnsignedCharArray *MapScalars(double alpha,
465  int &cellFlag);
466  virtual vtkUnsignedCharArray *MapScalars(vtkDataSet *input,
467  double alpha);
468  virtual vtkUnsignedCharArray *MapScalars(vtkDataSet *input,
469  double alpha,
470  int &cellFlag);
472 
481  virtual bool GetIsOpaque();
482 
489  virtual bool GetSupportsSelection()
490  { return false; }
491 
497  std::vector<unsigned int> & /* pixeloffsets */,
498  vtkProp * /* prop */) { };
499 
508  virtual int CanUseTextureMapForColoring(vtkDataObject* input);
509 
514  void ClearColorArrays();
515 
519  vtkUnsignedCharArray *GetColorMapColors();
520 
524  vtkFloatArray *GetColorCoordinates();
525 
529  vtkImageData* GetColorTextureMap();
530 
531 protected:
532  vtkMapper();
533  ~vtkMapper() override;
534 
535  // color mapped colors
537 
538  // Use texture coordinates for coloring.
540  // Coordinate for each point.
542  // 1D ColorMap used for the texture image.
544  void MapScalarsToTexture(vtkAbstractArray* scalars, double alpha);
545 
549  double ScalarRange[2];
551 
554 
555  double RenderTime;
556 
557  // for coloring by a component of a field data array
558  int ArrayId;
559  char* ArrayName;
562 
563  // If coloring by field data, which tuple to use to color the entire
564  // data set. If -1, treat array values as cell data.
566 
568 
574 
575 private:
576  vtkMapper(const vtkMapper&) = delete;
577  void operator=(const vtkMapper&) = delete;
578 };
579 
580 #endif
vtkMapper::SetResolveCoincidentTopologyToOff
static void SetResolveCoincidentTopologyToOff()
Definition: vtkMapper.h:316
VTK_SCALAR_MODE_DEFAULT
#define VTK_SCALAR_MODE_DEFAULT
Definition: vtkAbstractMapper.h:37
vtkMapper::SetScalarModeToUsePointData
void SetScalarModeToUsePointData()
Definition: vtkMapper.h:244
VTK_SCALAR_MODE_USE_CELL_FIELD_DATA
#define VTK_SCALAR_MODE_USE_CELL_FIELD_DATA
Definition: vtkAbstractMapper.h:41
VTK_SCALAR_MODE_USE_POINT_DATA
#define VTK_SCALAR_MODE_USE_POINT_DATA
Definition: vtkAbstractMapper.h:38
VTK_COLOR_MODE_MAP_SCALARS
#define VTK_COLOR_MODE_MAP_SCALARS
Definition: vtkSystemIncludes.h:103
vtkMapper::SetResolveCoincidentTopologyToShiftZBuffer
static void SetResolveCoincidentTopologyToShiftZBuffer()
Definition: vtkMapper.h:320
vtkX3D::alpha
Definition: vtkX3D.h:250
vtkX3D::component
Definition: vtkX3D.h:175
vtkMapper::SetColorModeToDefault
void SetColorModeToDefault()
Definition: vtkMapper.h:166
VTK_SCALAR_MODE_USE_POINT_FIELD_DATA
#define VTK_SCALAR_MODE_USE_POINT_FIELD_DATA
Definition: vtkAbstractMapper.h:40
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:573
vtkIdType
int vtkIdType
Definition: vtkType.h:347
vtkMapper::ArrayId
int ArrayId
Definition: vtkMapper.h:558
VTK_RESOLVE_POLYGON_OFFSET
#define VTK_RESOLVE_POLYGON_OFFSET
Definition: vtkMapper.h:63
vtkFloatArray
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:41
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:35
vtkAbstractMapper::GetMTime
vtkMTimeType GetMTime() override
Override Modifiedtime as we have added Clipping planes.
vtkUnsignedCharArray
dynamic, self-adjusting array of unsigned char
Definition: vtkUnsignedCharArray.h:41
vtkMapper::ColorTextureMap
vtkImageData * ColorTextureMap
Definition: vtkMapper.h:543
vtkMapper::CoincidentPolygonOffset
double CoincidentPolygonOffset
Definition: vtkMapper.h:570
vtkX3D::time
Definition: vtkX3D.h:497
vtkMapper::SetRenderTime
void SetRenderTime(double time)
This instance variable is used by vtkLODActor to determine which mapper to use.
Definition: vtkMapper.h:437
vtkMapper::Colors
vtkUnsignedCharArray * Colors
Definition: vtkMapper.h:536
vtkAbstractMapper3D.h
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
vtkMapper::CoincidentPolygonFactor
double CoincidentPolygonFactor
Definition: vtkMapper.h:569
vtkMapper::SetScalarModeToDefault
void SetScalarModeToDefault()
Definition: vtkMapper.h:242
vtkMapper::ScalarVisibility
vtkTypeBool ScalarVisibility
Definition: vtkMapper.h:547
vtkMapper::SetScalarModeToUseCellData
void SetScalarModeToUseCellData()
Definition: vtkMapper.h:246
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:39
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:42
vtkMapper::InterpolateScalarsBeforeMapping
vtkTypeBool InterpolateScalarsBeforeMapping
Definition: vtkMapper.h:539
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:496
vtkMapper::BuildTime
vtkTimeStamp BuildTime
Definition: vtkMapper.h:548
vtkMapper::ArrayAccessMode
int ArrayAccessMode
Definition: vtkMapper.h:561
vtkMapper
abstract class specifies interface to map data to graphics primitives
Definition: vtkMapper.h:86
vtkHardwareSelector
Definition: vtkHardwareSelector.h:123
VTK_RESOLVE_OFF
#define VTK_RESOLVE_OFF
Definition: vtkMapper.h:62
VTK_SCALAR_MODE_USE_FIELD_DATA
#define VTK_SCALAR_MODE_USE_FIELD_DATA
Definition: vtkAbstractMapper.h:42
vtkMapper::FieldDataTupleId
vtkIdType FieldDataTupleId
Definition: vtkMapper.h:565
vtkMapper::ColorCoordinates
vtkFloatArray * ColorCoordinates
Definition: vtkMapper.h:541
vtkActor
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:51
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkSmartPointer.h
vtkAbstractMapper::ShallowCopy
virtual void ShallowCopy(vtkAbstractMapper *m)
Make a shallow copy of this mapper.
vtkMapper::RenderTime
double RenderTime
Definition: vtkMapper.h:555
vtkScalarsToColors
Superclass for mapping scalar values to colors.
Definition: vtkScalarsToColors.h:66
vtkMapper::SetScalarModeToUseFieldData
void SetScalarModeToUseFieldData()
Definition: vtkMapper.h:252
vtkMapper::ArrayName
char * ArrayName
Definition: vtkMapper.h:559
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:452
vtkMapper::ReleaseGraphicsResources
void ReleaseGraphicsResources(vtkWindow *) override
Release any graphics resources that are being consumed by this mapper.
Definition: vtkMapper.h:114
vtkDataSet
abstract class to specify dataset behavior
Definition: vtkDataSet.h:62
vtkAbstractArray
Abstract superclass for all arrays.
Definition: vtkAbstractArray.h:78
vtkMapper::ColorMode
int ColorMode
Definition: vtkMapper.h:552
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:489
vtkProp
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:52
vtkMapper::SetColorModeToDirectScalars
void SetColorModeToDirectScalars()
Definition: vtkMapper.h:170
VTK_COLOR_MODE_DEFAULT
#define VTK_COLOR_MODE_DEFAULT
Definition: vtkSystemIncludes.h:102
vtkAbstractMapper3D
abstract class specifies interface to map 3D data
Definition: vtkAbstractMapper3D.h:45
vtkMapper::SetColorModeToMapScalars
void SetColorModeToMapScalars()
Definition: vtkMapper.h:168
vtkMapper::CoincidentLineOffset
double CoincidentLineOffset
Definition: vtkMapper.h:572
vtkMapper::Static
vtkTypeBool Static
Definition: vtkMapper.h:567
vtkMapper::SetResolveCoincidentTopologyToPolygonOffset
static void SetResolveCoincidentTopologyToPolygonOffset()
Definition: vtkMapper.h:318
vtkRenderer
abstract specification for renderers
Definition: vtkRenderer.h:63
VTK_RESOLVE_SHIFT_ZBUFFER
#define VTK_RESOLVE_SHIFT_ZBUFFER
Definition: vtkMapper.h:64
vtkMapper::LookupTable
vtkScalarsToColors * LookupTable
Definition: vtkMapper.h:546
vtkMapper::UseLookupTableScalarRange
vtkTypeBool UseLookupTableScalarRange
Definition: vtkMapper.h:550
VTK_COLOR_MODE_DIRECT_SCALARS
#define VTK_COLOR_MODE_DIRECT_SCALARS
Definition: vtkSystemIncludes.h:104
vtkMapper::CoincidentLineFactor
double CoincidentLineFactor
Definition: vtkMapper.h:571
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:64
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkMapper::SetScalarModeToUsePointFieldData
void SetScalarModeToUsePointFieldData()
Definition: vtkMapper.h:248
vtkMapper::ArrayComponent
int ArrayComponent
Definition: vtkMapper.h:560
vtkSystemIncludes.h
vtkAbstractMapper
abstract class specifies interface to map data
Definition: vtkAbstractMapper.h:55
vtkMTimeType
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:302
vtkMapper::ScalarMode
int ScalarMode
Definition: vtkMapper.h:553
vtkMapper::SetScalarModeToUseCellFieldData
void SetScalarModeToUseCellFieldData()
Definition: vtkMapper.h:250