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
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:52
vtkIdType FieldDataTupleId
Definition: vtkMapper.h:565
#define VTK_COLOR_MODE_DIRECT_SCALARS
void SetScalarModeToUsePointData()
Definition: vtkMapper.h:244
void SetScalarModeToDefault()
Definition: vtkMapper.h:242
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:320
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:452
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:302
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:316
record modification and/or execution time
Definition: vtkTimeStamp.h:35
void SetScalarModeToUseCellData()
Definition: vtkMapper.h:246
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:41
vtkImageData * ColorTextureMap
Definition: vtkMapper.h:543
#define VTK_RESOLVE_SHIFT_ZBUFFER
Definition: vtkMapper.h:64
vtkTimeStamp BuildTime
Definition: vtkMapper.h:548
void SetColorModeToDefault()
default (ColorModeToDefault), unsigned char scalars are treated as colors, and NOT mapped through the...
Definition: vtkMapper.h:166
abstract specification for renderers
Definition: vtkRenderer.h:63
int ArrayAccessMode
Definition: vtkMapper.h:561
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:318
vtkTypeBool Static
Definition: vtkMapper.h:567
void SetScalarModeToUseFieldData()
Definition: vtkMapper.h:252
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
int vtkIdType
Definition: vtkType.h:347
double CoincidentLineFactor
Definition: vtkMapper.h:571
vtkUnsignedCharArray * Colors
Definition: vtkMapper.h:536
vtkTypeBool ScalarVisibility
Definition: vtkMapper.h:547
void SetColorModeToDirectScalars()
default (ColorModeToDefault), unsigned char scalars are treated as colors, and NOT mapped through the...
Definition: vtkMapper.h:170
int ScalarMode
Definition: vtkMapper.h:553
int vtkTypeBool
Definition: vtkABI.h:69
Superclass for mapping scalar values to colors.
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
void GetBounds(double bounds[6]) override
Get the bounds for this mapper as (Xmin,Xmax,Ymin,Ymax,Zmin,Zmax).
Definition: vtkMapper.h:429
double CoincidentPointOffset
Definition: vtkMapper.h:573
void SetRenderTime(double time)
This instance variable is used by vtkLODActor to determine which mapper to use.
Definition: vtkMapper.h:437
#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:248
double CoincidentLineOffset
Definition: vtkMapper.h:572
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:569
double CoincidentPolygonOffset
Definition: vtkMapper.h:570
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:86
dynamic, self-adjusting array of unsigned char
abstract class specifies interface to map data
int ArrayId
Definition: vtkMapper.h:558
char * ArrayName
Definition: vtkMapper.h:559
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:560
vtkTypeBool UseLookupTableScalarRange
Definition: vtkMapper.h:550
vtkFloatArray * ColorCoordinates
Definition: vtkMapper.h:541
virtual bool GetSupportsSelection()
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THIS METHOD OUTSIDE OF THE RENDERI...
Definition: vtkMapper.h:489
#define VTK_SCALAR_MODE_USE_CELL_DATA
#define VTK_RESOLVE_POLYGON_OFFSET
Definition: vtkMapper.h:63
general representation of visualization data
Definition: vtkDataObject.h:64
void SetScalarModeToUseCellFieldData()
Definition: vtkMapper.h:250
vtkScalarsToColors * LookupTable
Definition: vtkMapper.h:546
void ReleaseGraphicsResources(vtkWindow *) override
Release any graphics resources that are being consumed by this mapper.
Definition: vtkMapper.h:114
double RenderTime
Definition: vtkMapper.h:555
#define VTK_SCALAR_MODE_DEFAULT
vtkTypeBool InterpolateScalarsBeforeMapping
Definition: vtkMapper.h:539
#define VTK_RESOLVE_OFF
Definition: vtkMapper.h:62
int ColorMode
Definition: vtkMapper.h:552