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 
61 #define VTK_RESOLVE_OFF 0
62 #define VTK_RESOLVE_POLYGON_OFFSET 1
63 #define VTK_RESOLVE_SHIFT_ZBUFFER 2
64 
65 #define VTK_GET_ARRAY_BY_ID 0
66 #define VTK_GET_ARRAY_BY_NAME 1
67 
68 #define VTK_MATERIALMODE_DEFAULT 0
69 #define VTK_MATERIALMODE_AMBIENT 1
70 #define VTK_MATERIALMODE_DIFFUSE 2
71 #define VTK_MATERIALMODE_AMBIENT_AND_DIFFUSE 3
72 
73 class vtkWindow;
74 class vtkRenderer;
75 class vtkActor;
76 class vtkDataSet;
77 class vtkDataObject;
78 class vtkFloatArray;
79 class vtkImageData;
80 class vtkScalarsToColors;
82 
83 class VTKRENDERINGCORE_EXPORT vtkMapper : public vtkAbstractMapper3D
84 {
85 public:
87  void PrintSelf(ostream& os, vtkIndent indent) override;
88 
93 
98  vtkMTimeType GetMTime() override;
99 
104  virtual void Render(vtkRenderer *ren, vtkActor *a) = 0;
105 
112 
114 
117  void SetLookupTable(vtkScalarsToColors *lut);
118  vtkScalarsToColors *GetLookupTable();
120 
125  virtual void CreateDefaultLookupTable();
126 
128 
131  vtkSetMacro(ScalarVisibility, vtkTypeBool);
132  vtkGetMacro(ScalarVisibility, vtkTypeBool);
133  vtkBooleanMacro(ScalarVisibility, vtkTypeBool);
135 
137 
143  vtkSetMacro(Static, vtkTypeBool);
144  vtkGetMacro(Static, vtkTypeBool);
145  vtkBooleanMacro(Static, vtkTypeBool);
147 
149 
161  vtkSetMacro(ColorMode, int);
162  vtkGetMacro(ColorMode, int);
164  { this->SetColorMode(VTK_COLOR_MODE_DEFAULT); }
166  { this->SetColorMode(VTK_COLOR_MODE_MAP_SCALARS); }
168  { this->SetColorMode(VTK_COLOR_MODE_DIRECT_SCALARS); }
170 
174  const char *GetColorModeAsString();
175 
177 
183  vtkSetMacro(InterpolateScalarsBeforeMapping, vtkTypeBool);
184  vtkGetMacro(InterpolateScalarsBeforeMapping, vtkTypeBool);
185  vtkBooleanMacro(InterpolateScalarsBeforeMapping, vtkTypeBool);
187 
189 
197  vtkSetMacro(UseLookupTableScalarRange, vtkTypeBool);
198  vtkGetMacro(UseLookupTableScalarRange, vtkTypeBool);
199  vtkBooleanMacro(UseLookupTableScalarRange, vtkTypeBool);
201 
203 
208  vtkSetVector2Macro(ScalarRange, double);
209  vtkGetVectorMacro(ScalarRange, double, 2);
211 
225  // When ScalarMode is set to use Field Data (ScalarModeToFieldData),
226  // you must call SelectColorArray to choose the field data array to
227  // be used to color cells. In this mode, the default behavior is to
228  // treat the field data tuples as being associated with cells. If
229  // the poly data contains triangle strips, the array is expected to
230  // contain the cell data for each mini-cell formed by any triangle
231  // strips in the poly data as opposed to treating them as a single
232  // tuple that applies to the entire strip. This mode can also be
233  // used to color the entire poly data by a single color obtained by
234  // mapping the tuple at a given index in the field data array
235  // through the color map. Use SetFieldDataTupleId() to specify
236  // the tuple index.
237  vtkSetMacro(ScalarMode, int);
238  vtkGetMacro(ScalarMode, int);
240  { this->SetScalarMode(VTK_SCALAR_MODE_DEFAULT); }
242  { this->SetScalarMode(VTK_SCALAR_MODE_USE_POINT_DATA); }
244  { this->SetScalarMode(VTK_SCALAR_MODE_USE_CELL_DATA); }
246  { this->SetScalarMode(VTK_SCALAR_MODE_USE_POINT_FIELD_DATA); }
248  { this->SetScalarMode(VTK_SCALAR_MODE_USE_CELL_FIELD_DATA); }
250  { this->SetScalarMode(VTK_SCALAR_MODE_USE_FIELD_DATA); }
251 
253 
258  void SelectColorArray(int arrayNum);
259  void SelectColorArray(const char* arrayName);
261 
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();
314  { SetResolveCoincidentTopology(VTK_RESOLVE_OFF) ;}
316  { SetResolveCoincidentTopology(VTK_RESOLVE_POLYGON_OFFSET); }
318  { SetResolveCoincidentTopology(VTK_RESOLVE_SHIFT_ZBUFFER); }
320 
322 
327  static void SetResolveCoincidentTopologyPolygonOffsetParameters(
328  double factor, double units);
329  static void GetResolveCoincidentTopologyPolygonOffsetParameters(
330  double& factor, double& units);
332 
334 
338  void SetRelativeCoincidentTopologyPolygonOffsetParameters(
339  double factor, double units);
340  void GetRelativeCoincidentTopologyPolygonOffsetParameters(
341  double& factor, double& units);
343 
345 
350  static void SetResolveCoincidentTopologyLineOffsetParameters(
351  double factor, double units);
352  static void GetResolveCoincidentTopologyLineOffsetParameters(
353  double& factor, double& units);
355 
357 
361  void SetRelativeCoincidentTopologyLineOffsetParameters(
362  double factor, double units);
363  void GetRelativeCoincidentTopologyLineOffsetParameters(
364  double& factor, double& units);
366 
368 
373  static void SetResolveCoincidentTopologyPointOffsetParameter(
374  double units);
375  static void GetResolveCoincidentTopologyPointOffsetParameter(
376  double& units);
378 
380 
384  void SetRelativeCoincidentTopologyPointOffsetParameter(double units);
385  void GetRelativeCoincidentTopologyPointOffsetParameter(double& units);
387 
389 
393  void GetCoincidentTopologyPolygonOffsetParameters(
394  double& factor, double& units);
395  void GetCoincidentTopologyLineOffsetParameters(
396  double& factor, double& units);
397  void GetCoincidentTopologyPointOffsetParameter(double& units);
399 
401 
408  static void SetResolveCoincidentTopologyPolygonOffsetFaces(int faces);
409  static int GetResolveCoincidentTopologyPolygonOffsetFaces();
411 
413 
417  static void SetResolveCoincidentTopologyZShift(double val);
418  static double GetResolveCoincidentTopologyZShift();
420 
425  double *GetBounds() VTK_SIZEHINT(6) override;
426  void GetBounds(double bounds[6]) override
427  { this->vtkAbstractMapper3D::GetBounds(bounds); }
428 
434  void SetRenderTime(double time) {this->RenderTime = time;}
435  vtkGetMacro(RenderTime, double);
436 
441  vtkDataSet *GetInput();
442 
450  { return this->GetInput(); }
451 
453 
460  virtual vtkUnsignedCharArray *MapScalars(double alpha);
461  virtual vtkUnsignedCharArray *MapScalars(double alpha,
462  int &cellFlag);
463  virtual vtkUnsignedCharArray *MapScalars(vtkDataSet *input,
464  double alpha);
465  virtual vtkUnsignedCharArray *MapScalars(vtkDataSet *input,
466  double alpha,
467  int &cellFlag);
469 
478  virtual bool GetIsOpaque();
479 
486  virtual bool GetSupportsSelection()
487  { return false; }
488 
497  virtual int CanUseTextureMapForColoring(vtkDataObject* input);
498 
503  void ClearColorArrays();
504 
508  vtkUnsignedCharArray *GetColorMapColors();
509 
513  vtkFloatArray *GetColorCoordinates();
514 
518  vtkImageData* GetColorTextureMap();
519 
520 protected:
521  vtkMapper();
522  ~vtkMapper() override;
523 
524  // color mapped colors
526 
527  // Use texture coordinates for coloring.
529  // Coordinate for each point.
531  // 1D ColorMap used for the texture image.
533  void MapScalarsToTexture(vtkAbstractArray* scalars, double alpha);
534 
538  double ScalarRange[2];
540 
543 
544  double RenderTime;
545 
546  // for coloring by a component of a field data array
547  int ArrayId;
548  char* ArrayName;
551 
552  // If coloring by field data, which tuple to use to color the entire
553  // data set. If -1, treat array values as cell data.
555 
557 
563 
564 private:
565  vtkMapper(const vtkMapper&) = delete;
566  void operator=(const vtkMapper&) = delete;
567 };
568 
569 #endif
vtkIdType FieldDataTupleId
Definition: vtkMapper.h:554
#define VTK_COLOR_MODE_DIRECT_SCALARS
void SetScalarModeToUsePointData()
Definition: vtkMapper.h:241
void SetScalarModeToDefault()
Definition: vtkMapper.h:239
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:317
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:449
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:300
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:243
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:41
vtkImageData * ColorTextureMap
Definition: vtkMapper.h:532
#define VTK_RESOLVE_SHIFT_ZBUFFER
Definition: vtkMapper.h:63
vtkTimeStamp BuildTime
Definition: vtkMapper.h:537
void SetColorModeToDefault()
default (ColorModeToDefault), unsigned char scalars are treated as colors, and NOT mapped through the...
Definition: vtkMapper.h:163
abstract specification for renderers
Definition: vtkRenderer.h:63
int ArrayAccessMode
Definition: vtkMapper.h:550
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:315
vtkTypeBool Static
Definition: vtkMapper.h:556
void SetScalarModeToUseFieldData()
Definition: vtkMapper.h:249
int vtkIdType
Definition: vtkType.h:345
double CoincidentLineFactor
Definition: vtkMapper.h:560
vtkUnsignedCharArray * Colors
Definition: vtkMapper.h:525
vtkTypeBool ScalarVisibility
Definition: vtkMapper.h:536
void SetColorModeToDirectScalars()
default (ColorModeToDefault), unsigned char scalars are treated as colors, and NOT mapped through the...
Definition: vtkMapper.h:167
int ScalarMode
Definition: vtkMapper.h:542
int vtkTypeBool
Definition: vtkABI.h:69
Superclass for mapping scalar values to colors.
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
double CoincidentPointOffset
Definition: vtkMapper.h:562
void SetRenderTime(double time)
This instance variable is used by vtkLODActor to determine which mapper to use.
Definition: vtkMapper.h:434
#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:245
double CoincidentLineOffset
Definition: vtkMapper.h:561
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
#define VTK_SCALAR_MODE_USE_POINT_FIELD_DATA
double CoincidentPolygonFactor
Definition: vtkMapper.h:558
double CoincidentPolygonOffset
Definition: vtkMapper.h:559
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:83
dynamic, self-adjusting array of unsigned char
abstract class specifies interface to map data
int ArrayId
Definition: vtkMapper.h:547
char * ArrayName
Definition: vtkMapper.h:548
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:165
int ArrayComponent
Definition: vtkMapper.h:549
void ShallowCopy(vtkAbstractMapper *m)
Make a shallow copy of this mapper.
vtkTypeBool UseLookupTableScalarRange
Definition: vtkMapper.h:539
vtkFloatArray * ColorCoordinates
Definition: vtkMapper.h:530
virtual bool GetSupportsSelection()
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THIS METHOD OUTSIDE OF THE RENDERI...
Definition: vtkMapper.h:486
#define VTK_SCALAR_MODE_USE_CELL_DATA
#define VTK_RESOLVE_POLYGON_OFFSET
Definition: vtkMapper.h:62
general representation of visualization data
Definition: vtkDataObject.h:64
void SetScalarModeToUseCellFieldData()
Definition: vtkMapper.h:247
vtkScalarsToColors * LookupTable
Definition: vtkMapper.h:535
void ReleaseGraphicsResources(vtkWindow *) override
Release any graphics resources that are being consumed by this mapper.
Definition: vtkMapper.h:111
double RenderTime
Definition: vtkMapper.h:544
#define VTK_SCALAR_MODE_DEFAULT
vtkTypeBool InterpolateScalarsBeforeMapping
Definition: vtkMapper.h:528
#define VTK_RESOLVE_OFF
Definition: vtkMapper.h:61
int ColorMode
Definition: vtkMapper.h:541