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, int);
132  vtkGetMacro(ScalarVisibility, int);
133  vtkBooleanMacro(ScalarVisibility, int);
135 
137 
143  vtkSetMacro(Static, int);
144  vtkGetMacro(Static, int);
145  vtkBooleanMacro(Static, int);
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, int);
184  vtkGetMacro(InterpolateScalarsBeforeMapping, int);
185  vtkBooleanMacro(InterpolateScalarsBeforeMapping, int);
187 
189 
197  vtkSetMacro(UseLookupTableScalarRange, int);
198  vtkGetMacro(UseLookupTableScalarRange, int);
199  vtkBooleanMacro(UseLookupTableScalarRange, int);
201 
203 
208  vtkSetVector2Macro(ScalarRange, double);
209  vtkGetVectorMacro(ScalarRange, double, 2);
211 
213 
221  VTK_LEGACY(void SetImmediateModeRendering(int));
222  VTK_LEGACY(int GetImmediateModeRendering());
223  VTK_LEGACY(void ImmediateModeRenderingOn());
224  VTK_LEGACY(void ImmediateModeRenderingOff());
226 
228 
236  VTK_LEGACY(static void SetGlobalImmediateModeRendering(int val));
237  VTK_LEGACY(static void GlobalImmediateModeRenderingOn());
238  VTK_LEGACY(static void GlobalImmediateModeRenderingOff());
239  VTK_LEGACY(static int GetGlobalImmediateModeRendering());
241 
243 
252  VTK_LEGACY(int GetForceCompileOnly());
253  VTK_LEGACY(void SetForceCompileOnly(int value));
255 
269  // When ScalarMode is set to use Field Data (ScalarModeToFieldData),
270  // you must call SelectColorArray to choose the field data array to
271  // be used to color cells. In this mode, the default behavior is to
272  // treat the field data tuples as being associated with cells. If
273  // the poly data contains triangle strips, the array is expected to
274  // contain the cell data for each mini-cell formed by any triangle
275  // strips in the poly data as opposed to treating them as a single
276  // tuple that applies to the entire strip. This mode can also be
277  // used to color the entire poly data by a single color obtained by
278  // mapping the tuple at a given index in the field data array
279  // through the color map. Use SetFieldDataTupleId() to specify
280  // the tuple index.
281  vtkSetMacro(ScalarMode, int);
282  vtkGetMacro(ScalarMode, int);
284  { this->SetScalarMode(VTK_SCALAR_MODE_DEFAULT); }
286  { this->SetScalarMode(VTK_SCALAR_MODE_USE_POINT_DATA); }
288  { this->SetScalarMode(VTK_SCALAR_MODE_USE_CELL_DATA); }
290  { this->SetScalarMode(VTK_SCALAR_MODE_USE_POINT_FIELD_DATA); }
292  { this->SetScalarMode(VTK_SCALAR_MODE_USE_CELL_FIELD_DATA); }
294  { this->SetScalarMode(VTK_SCALAR_MODE_USE_FIELD_DATA); }
295 
297 
302  void SelectColorArray(int arrayNum);
303  void SelectColorArray(const char* arrayName);
305 
306 
307  // When ScalarMode is set to UseFieldData, set the index of the
308  // tuple by which to color the entire data set. By default, the
309  // index is -1, which means to treat the field data array selected
310  // with SelectColorArray as having a scalar value for each cell.
311  // Indices of 0 or higher mean to use the tuple at the given index
312  // for coloring the entire data set.
313  vtkSetMacro(FieldDataTupleId, vtkIdType);
314  vtkGetMacro(FieldDataTupleId, vtkIdType);
315 
317 
322  void ColorByArrayComponent(int arrayNum, int component);
323  void ColorByArrayComponent(const char* arrayName, int component);
325 
329  vtkGetStringMacro(ArrayName);
330  vtkSetStringMacro(ArrayName);
331  vtkGetMacro(ArrayId, int);
332  vtkSetMacro(ArrayId, int);
333  vtkGetMacro(ArrayAccessMode, int);
334  vtkSetMacro(ArrayAccessMode, int);
335  vtkGetMacro(ArrayComponent, int);
336  vtkSetMacro(ArrayComponent, int);
337 
341  const char *GetScalarModeAsString();
342 
344 
356  static void SetResolveCoincidentTopology(int val);
357  static int GetResolveCoincidentTopology();
358  static void SetResolveCoincidentTopologyToDefault();
360  { SetResolveCoincidentTopology(VTK_RESOLVE_OFF) ;}
362  { SetResolveCoincidentTopology(VTK_RESOLVE_POLYGON_OFFSET); }
364  { SetResolveCoincidentTopology(VTK_RESOLVE_SHIFT_ZBUFFER); }
366 
368 
373  static void SetResolveCoincidentTopologyPolygonOffsetParameters(
374  double factor, double units);
375  static void GetResolveCoincidentTopologyPolygonOffsetParameters(
376  double& factor, double& units);
378 
380 
384  void SetRelativeCoincidentTopologyPolygonOffsetParameters(
385  double factor, double units);
386  void GetRelativeCoincidentTopologyPolygonOffsetParameters(
387  double& factor, double& units);
389 
391 
396  static void SetResolveCoincidentTopologyLineOffsetParameters(
397  double factor, double units);
398  static void GetResolveCoincidentTopologyLineOffsetParameters(
399  double& factor, double& units);
401 
403 
407  void SetRelativeCoincidentTopologyLineOffsetParameters(
408  double factor, double units);
409  void GetRelativeCoincidentTopologyLineOffsetParameters(
410  double& factor, double& units);
412 
414 
419  static void SetResolveCoincidentTopologyPointOffsetParameter(
420  double units);
421  static void GetResolveCoincidentTopologyPointOffsetParameter(
422  double& units);
424 
426 
430  void SetRelativeCoincidentTopologyPointOffsetParameter(double units);
431  void GetRelativeCoincidentTopologyPointOffsetParameter(double& units);
433 
435 
439  void GetCoincidentTopologyPolygonOffsetParameters(
440  double& factor, double& units);
441  void GetCoincidentTopologyLineOffsetParameters(
442  double& factor, double& units);
443  void GetCoincidentTopologyPointOffsetParameter(double& units);
445 
447 
454  static void SetResolveCoincidentTopologyPolygonOffsetFaces(int faces);
455  static int GetResolveCoincidentTopologyPolygonOffsetFaces();
457 
459 
463  static void SetResolveCoincidentTopologyZShift(double val);
464  static double GetResolveCoincidentTopologyZShift();
466 
471  double *GetBounds() override;
472  void GetBounds(double bounds[6]) override
473  { this->vtkAbstractMapper3D::GetBounds(bounds); }
474 
480  void SetRenderTime(double time) {this->RenderTime = time;}
481  vtkGetMacro(RenderTime, double);
482 
487  vtkDataSet *GetInput();
488 
496  { return this->GetInput(); }
497 
499 
506  virtual vtkUnsignedCharArray *MapScalars(double alpha);
507  virtual vtkUnsignedCharArray *MapScalars(double alpha,
508  int &cellFlag);
509  virtual vtkUnsignedCharArray *MapScalars(vtkDataSet *input,
510  double alpha);
511  virtual vtkUnsignedCharArray *MapScalars(vtkDataSet *input,
512  double alpha,
513  int &cellFlag);
515 
517 
520  VTK_LEGACY(void SetScalarMaterialMode(int val));
521  VTK_LEGACY(int GetScalarMaterialMode());
522  VTK_LEGACY(void SetScalarMaterialModeToDefault());
523  VTK_LEGACY(void SetScalarMaterialModeToAmbient());
524  VTK_LEGACY(void SetScalarMaterialModeToDiffuse());
525  VTK_LEGACY(void SetScalarMaterialModeToAmbientAndDiffuse());
527 
531  VTK_LEGACY(const char *GetScalarMaterialModeAsString());
532 
541  virtual bool GetIsOpaque();
542 
549  virtual bool GetSupportsSelection()
550  { return false; }
551 
560  virtual int CanUseTextureMapForColoring(vtkDataObject* input);
561 
566  void ClearColorArrays();
567 
571  vtkUnsignedCharArray *GetColorMapColors();
572 
576  vtkFloatArray *GetColorCoordinates();
577 
581  vtkImageData* GetColorTextureMap();
582 
583 protected:
584  vtkMapper();
585  ~vtkMapper() override;
586 
587  // color mapped colors
589 
590  // Use texture coordinates for coloring.
592  // Coordinate for each point.
594  // 1D ColorMap used for the texture image.
596  void MapScalarsToTexture(vtkAbstractArray* scalars, double alpha);
597 
601  double ScalarRange[2];
603 
604 #ifndef VTK_LEGACY_REMOVE
607 #endif
608 
611 
612  double RenderTime;
613 
614  // for coloring by a component of a field data array
615  int ArrayId;
616  char* ArrayName;
619 
620  // If coloring by field data, which tuple to use to color the entire
621  // data set. If -1, treat array values as cell data.
623 
624  int Static;
625 
631 
632 private:
633  vtkMapper(const vtkMapper&) = delete;
634  void operator=(const vtkMapper&) = delete;
635 };
636 
637 #endif
int ForceCompileOnly
Definition: vtkMapper.h:606
vtkIdType FieldDataTupleId
Definition: vtkMapper.h:622
#define VTK_COLOR_MODE_DIRECT_SCALARS
void SetScalarModeToUsePointData()
Definition: vtkMapper.h:285
int ScalarVisibility
Definition: vtkMapper.h:599
void SetScalarModeToDefault()
Definition: vtkMapper.h:283
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:363
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:495
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:359
record modification and/or execution time
Definition: vtkTimeStamp.h:35
void SetScalarModeToUseCellData()
Definition: vtkMapper.h:287
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:41
vtkImageData * ColorTextureMap
Definition: vtkMapper.h:595
#define VTK_RESOLVE_SHIFT_ZBUFFER
Definition: vtkMapper.h:63
vtkTimeStamp BuildTime
Definition: vtkMapper.h:600
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:618
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:361
void SetScalarModeToUseFieldData()
Definition: vtkMapper.h:293
int vtkIdType
Definition: vtkType.h:345
double CoincidentLineFactor
Definition: vtkMapper.h:628
vtkUnsignedCharArray * Colors
Definition: vtkMapper.h:588
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:610
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:472
double CoincidentPointOffset
Definition: vtkMapper.h:630
void SetRenderTime(double time)
This instance variable is used by vtkLODActor to determine which mapper to use.
Definition: vtkMapper.h:480
#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:289
double CoincidentLineOffset
Definition: vtkMapper.h:629
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
#define VTK_SCALAR_MODE_USE_POINT_FIELD_DATA
double CoincidentPolygonFactor
Definition: vtkMapper.h:626
int ImmediateModeRendering
Definition: vtkMapper.h:605
double CoincidentPolygonOffset
Definition: vtkMapper.h:627
vtkGetStringMacro(ExtensionsString)
Returns a string listing all available extensions.
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
int InterpolateScalarsBeforeMapping
Definition: vtkMapper.h:591
#define VTK_COLOR_MODE_DEFAULT
#define VTK_SCALAR_MODE_USE_FIELD_DATA
abstract class specifies interface to map data to graphics primitives
Definition: vtkMapper.h:83
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
dynamic, self-adjusting array of unsigned char
abstract class specifies interface to map data
int ArrayId
Definition: vtkMapper.h:615
char * ArrayName
Definition: vtkMapper.h:616
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 Static
Definition: vtkMapper.h:624
int ArrayComponent
Definition: vtkMapper.h:617
void ShallowCopy(vtkAbstractMapper *m)
Make a shallow copy of this mapper.
vtkFloatArray * ColorCoordinates
Definition: vtkMapper.h:593
int UseLookupTableScalarRange
Definition: vtkMapper.h:602
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
virtual bool GetSupportsSelection()
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THIS METHOD OUTSIDE OF THE RENDERI...
Definition: vtkMapper.h:549
#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:291
vtkScalarsToColors * LookupTable
Definition: vtkMapper.h:598
void ReleaseGraphicsResources(vtkWindow *) override
Release any graphics resources that are being consumed by this mapper.
Definition: vtkMapper.h:111
double RenderTime
Definition: vtkMapper.h:612
#define VTK_SCALAR_MODE_DEFAULT
#define VTK_RESOLVE_OFF
Definition: vtkMapper.h:61
int ColorMode
Definition: vtkMapper.h:609