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 
474 
479  virtual bool HasOpaqueGeometry();
480  virtual bool HasTranslucentPolygonalGeometry();
482 
483 
490  virtual bool GetSupportsSelection()
491  { return false; }
492 
498  std::vector<unsigned int> & /* pixeloffsets */,
499  vtkProp * /* prop */) { };
500 
509  virtual int CanUseTextureMapForColoring(vtkDataObject* input);
510 
515  void ClearColorArrays();
516 
520  vtkUnsignedCharArray *GetColorMapColors();
521 
525  vtkFloatArray *GetColorCoordinates();
526 
530  vtkImageData* GetColorTextureMap();
531 
532 protected:
533  vtkMapper();
534  ~vtkMapper() override;
535 
536  // color mapped colors
538 
539  // Use texture coordinates for coloring.
541  // Coordinate for each point.
543  // 1D ColorMap used for the texture image.
545  void MapScalarsToTexture(vtkAbstractArray* scalars, double alpha);
546 
550  double ScalarRange[2];
552 
555 
556  double RenderTime;
557 
558  // for coloring by a component of a field data array
559  int ArrayId;
560  char* ArrayName;
563 
564  // If coloring by field data, which tuple to use to color the entire
565  // data set. If -1, treat array values as cell data.
567 
569 
575 
576 private:
577  vtkMapper(const vtkMapper&) = delete;
578  void operator=(const vtkMapper&) = delete;
579 };
580 
581 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:50
vtkIdType FieldDataTupleId
Definition: vtkMapper.h:566
#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:304
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:544
#define VTK_RESOLVE_SHIFT_ZBUFFER
Definition: vtkMapper.h:64
vtkTimeStamp BuildTime
Definition: vtkMapper.h:549
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:64
int ArrayAccessMode
Definition: vtkMapper.h:562
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:568
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:497
int vtkIdType
Definition: vtkType.h:349
double CoincidentLineFactor
Definition: vtkMapper.h:572
vtkUnsignedCharArray * Colors
Definition: vtkMapper.h:537
vtkTypeBool ScalarVisibility
Definition: vtkMapper.h:548
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:554
int vtkTypeBool
Definition: vtkABI.h:69
Superclass for mapping scalar values to colors.
window superclass for vtkRenderWindow
Definition: vtkWindow.h:34
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:574
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:573
topologically and geometrically regular array of data
Definition: vtkImageData.h:47
#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:570
double CoincidentPolygonOffset
Definition: vtkMapper.h:571
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:559
char * ArrayName
Definition: vtkMapper.h:560
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:561
vtkTypeBool UseLookupTableScalarRange
Definition: vtkMapper.h:551
vtkFloatArray * ColorCoordinates
Definition: vtkMapper.h:542
virtual bool GetSupportsSelection()
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THIS METHOD OUTSIDE OF THE RENDERI...
Definition: vtkMapper.h:490
#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:547
void ReleaseGraphicsResources(vtkWindow *) override
Release any graphics resources that are being consumed by this mapper.
Definition: vtkMapper.h:114
double RenderTime
Definition: vtkMapper.h:556
#define VTK_SCALAR_MODE_DEFAULT
vtkTypeBool InterpolateScalarsBeforeMapping
Definition: vtkMapper.h:540
#define VTK_RESOLVE_OFF
Definition: vtkMapper.h:62
int ColorMode
Definition: vtkMapper.h:553