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 =========================================================================*/
55 #ifndef vtkMapper_h
56 #define vtkMapper_h
57 
58 #include "vtkRenderingCoreModule.h" // For export macro
59 #include "vtkAbstractMapper3D.h"
60 #include "vtkSystemIncludes.h" // For VTK_COLOR_MODE_DEFAULT and _MAP_SCALARS
61 #include "vtkSmartPointer.h" // needed for vtkSmartPointer.
62 
63 #define VTK_RESOLVE_OFF 0
64 #define VTK_RESOLVE_POLYGON_OFFSET 1
65 #define VTK_RESOLVE_SHIFT_ZBUFFER 2
66 
67 #define VTK_GET_ARRAY_BY_ID 0
68 #define VTK_GET_ARRAY_BY_NAME 1
69 
70 #define VTK_MATERIALMODE_DEFAULT 0
71 #define VTK_MATERIALMODE_AMBIENT 1
72 #define VTK_MATERIALMODE_DIFFUSE 2
73 #define VTK_MATERIALMODE_AMBIENT_AND_DIFFUSE 3
74 
75 class vtkWindow;
76 class vtkRenderer;
77 class vtkActor;
78 class vtkDataSet;
79 class vtkDataObject;
80 class vtkFloatArray;
81 class vtkImageData;
82 class vtkScalarsToColors;
84 
85 class VTKRENDERINGCORE_EXPORT vtkMapper : public vtkAbstractMapper3D
86 {
87 public:
89  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
90 
95 
100  vtkMTimeType GetMTime() VTK_OVERRIDE;
101 
106  virtual void Render(vtkRenderer *ren, vtkActor *a) = 0;
107 
113  void ReleaseGraphicsResources(vtkWindow *) VTK_OVERRIDE {}
114 
116 
119  void SetLookupTable(vtkScalarsToColors *lut);
120  vtkScalarsToColors *GetLookupTable();
122 
127  virtual void CreateDefaultLookupTable();
128 
130 
133  vtkSetMacro(ScalarVisibility, int);
134  vtkGetMacro(ScalarVisibility, int);
135  vtkBooleanMacro(ScalarVisibility, int);
137 
139 
145  vtkSetMacro(Static, int);
146  vtkGetMacro(Static, int);
147  vtkBooleanMacro(Static, int);
149 
151 
163  vtkSetMacro(ColorMode, int);
164  vtkGetMacro(ColorMode, int);
166  { this->SetColorMode(VTK_COLOR_MODE_DEFAULT); }
168  { this->SetColorMode(VTK_COLOR_MODE_MAP_SCALARS); }
170  { this->SetColorMode(VTK_COLOR_MODE_DIRECT_SCALARS); }
172 
176  const char *GetColorModeAsString();
177 
179 
185  vtkSetMacro(InterpolateScalarsBeforeMapping, int);
186  vtkGetMacro(InterpolateScalarsBeforeMapping, int);
187  vtkBooleanMacro(InterpolateScalarsBeforeMapping, int);
189 
191 
199  vtkSetMacro(UseLookupTableScalarRange, int);
200  vtkGetMacro(UseLookupTableScalarRange, int);
201  vtkBooleanMacro(UseLookupTableScalarRange, int);
203 
205 
210  vtkSetVector2Macro(ScalarRange, double);
211  vtkGetVectorMacro(ScalarRange, double, 2);
213 
215 
223  vtkSetMacro(ImmediateModeRendering, int);
224  vtkGetMacro(ImmediateModeRendering, int);
225  vtkBooleanMacro(ImmediateModeRendering, int);
227 
229 
237  static void SetGlobalImmediateModeRendering(int val);
242  static int GetGlobalImmediateModeRendering();
244 
246 
255  vtkGetMacro(ForceCompileOnly, int);
256  void SetForceCompileOnly(int value);
258 
272  // When ScalarMode is set to use Field Data (ScalarModeToFieldData),
273  // you must call SelectColorArray to choose the field data array to
274  // be used to color cells. In this mode, the default behavior is to
275  // treat the field data tuples as being associated with cells. If
276  // the poly data contains triangle strips, the array is expected to
277  // contain the cell data for each mini-cell formed by any triangle
278  // strips in the poly data as opposed to treating them as a single
279  // tuple that applies to the entire strip. This mode can also be
280  // used to color the entire poly data by a single color obtained by
281  // mapping the tuple at a given index in the field data array
282  // through the color map. Use SetFieldDataTupleId() to specify
283  // the tuple index.
284  vtkSetMacro(ScalarMode, int);
285  vtkGetMacro(ScalarMode, int);
287  { this->SetScalarMode(VTK_SCALAR_MODE_DEFAULT); }
289  { this->SetScalarMode(VTK_SCALAR_MODE_USE_POINT_DATA); }
291  { this->SetScalarMode(VTK_SCALAR_MODE_USE_CELL_DATA); }
293  { this->SetScalarMode(VTK_SCALAR_MODE_USE_POINT_FIELD_DATA); }
295  { this->SetScalarMode(VTK_SCALAR_MODE_USE_CELL_FIELD_DATA); }
297  { this->SetScalarMode(VTK_SCALAR_MODE_USE_FIELD_DATA); }
298 
300 
305  void SelectColorArray(int arrayNum);
306  void SelectColorArray(const char* arrayName);
308 
309 
310  // When ScalarMode is set to UseFieldData, set the index of the
311  // tuple by which to color the entire data set. By default, the
312  // index is -1, which means to treat the field data array selected
313  // with SelectColorArray as having a scalar value for each cell.
314  // Indices of 0 or higher mean to use the tuple at the given index
315  // for coloring the entire data set.
316  vtkSetMacro(FieldDataTupleId, vtkIdType);
317  vtkGetMacro(FieldDataTupleId, vtkIdType);
318 
320 
325  void ColorByArrayComponent(int arrayNum, int component);
326  void ColorByArrayComponent(const char* arrayName, int component);
328 
332  vtkGetStringMacro(ArrayName);
333  vtkSetStringMacro(ArrayName);
334  vtkGetMacro(ArrayId, int);
335  vtkSetMacro(ArrayId, int);
336  vtkGetMacro(ArrayAccessMode, int);
337  vtkSetMacro(ArrayAccessMode, int);
338  vtkGetMacro(ArrayComponent, int);
339  vtkSetMacro(ArrayComponent, int);
340 
344  const char *GetScalarModeAsString();
345 
347 
359  static void SetResolveCoincidentTopology(int val);
360  static int GetResolveCoincidentTopology();
361  static void SetResolveCoincidentTopologyToDefault();
363  { SetResolveCoincidentTopology(VTK_RESOLVE_OFF) ;}
365  { SetResolveCoincidentTopology(VTK_RESOLVE_POLYGON_OFFSET); }
367  { SetResolveCoincidentTopology(VTK_RESOLVE_SHIFT_ZBUFFER); }
369 
371 
376  static void SetResolveCoincidentTopologyPolygonOffsetParameters(
377  double factor, double units);
378  static void GetResolveCoincidentTopologyPolygonOffsetParameters(
379  double& factor, double& units);
381 
383 
387  void SetRelativeCoincidentTopologyPolygonOffsetParameters(
388  double factor, double units);
389  void GetRelativeCoincidentTopologyPolygonOffsetParameters(
390  double& factor, double& units);
392 
394 
399  static void SetResolveCoincidentTopologyLineOffsetParameters(
400  double factor, double units);
401  static void GetResolveCoincidentTopologyLineOffsetParameters(
402  double& factor, double& units);
404 
406 
410  void SetRelativeCoincidentTopologyLineOffsetParameters(
411  double factor, double units);
412  void GetRelativeCoincidentTopologyLineOffsetParameters(
413  double& factor, double& units);
415 
417 
422  static void SetResolveCoincidentTopologyPointOffsetParameter(
423  double units);
424  static void GetResolveCoincidentTopologyPointOffsetParameter(
425  double& units);
427 
429 
433  void SetRelativeCoincidentTopologyPointOffsetParameter(double units);
434  void GetRelativeCoincidentTopologyPointOffsetParameter(double& units);
436 
438 
442  void GetCoincidentTopologyPolygonOffsetParameters(
443  double& factor, double& units);
444  void GetCoincidentTopologyLineOffsetParameters(
445  double& factor, double& units);
446  void GetCoincidentTopologyPointOffsetParameter(double& units);
448 
450 
457  static void SetResolveCoincidentTopologyPolygonOffsetFaces(int faces);
458  static int GetResolveCoincidentTopologyPolygonOffsetFaces();
460 
462 
466  static void SetResolveCoincidentTopologyZShift(double val);
467  static double GetResolveCoincidentTopologyZShift();
469 
474  double *GetBounds() VTK_OVERRIDE;
475  void GetBounds(double bounds[6]) VTK_OVERRIDE
476  { this->vtkAbstractMapper3D::GetBounds(bounds); }
477 
483  void SetRenderTime(double time) {this->RenderTime = time;}
484  vtkGetMacro(RenderTime, double);
485 
490  vtkDataSet *GetInput();
491 
499  { return this->GetInput(); }
500 
502 
509  virtual vtkUnsignedCharArray *MapScalars(double alpha);
510  virtual vtkUnsignedCharArray *MapScalars(double alpha,
511  int &cellFlag);
512  virtual vtkUnsignedCharArray *MapScalars(vtkDataSet *input,
513  double alpha);
514  virtual vtkUnsignedCharArray *MapScalars(vtkDataSet *input,
515  double alpha,
516  int &cellFlag);
518 
520 
523  vtkSetMacro(ScalarMaterialMode,int);
524  vtkGetMacro(ScalarMaterialMode,int);
526  { this->SetScalarMaterialMode(VTK_MATERIALMODE_DEFAULT); }
528  { this->SetScalarMaterialMode(VTK_MATERIALMODE_AMBIENT); }
530  { this->SetScalarMaterialMode(VTK_MATERIALMODE_DIFFUSE); }
532  { this->SetScalarMaterialMode(VTK_MATERIALMODE_AMBIENT_AND_DIFFUSE); }
534 
538  const char *GetScalarMaterialModeAsString();
539 
548  virtual bool GetIsOpaque();
549 
556  virtual bool GetSupportsSelection()
557  { return false; }
558 
567  virtual int CanUseTextureMapForColoring(vtkDataObject* input);
568 
573  void ClearColorArrays();
574 
578  vtkUnsignedCharArray *GetColorMapColors();
579 
583  vtkFloatArray *GetColorCoordinates();
584 
588  vtkImageData* GetColorTextureMap();
589 
590 protected:
591  vtkMapper();
592  ~vtkMapper() VTK_OVERRIDE;
593 
594  // color mapped colors
596 
597  // Use texture coordinates for coloring.
599  // Coordinate for each point.
601  // 1D ColorMap used for the texture image.
603  void MapScalarsToTexture(vtkAbstractArray* scalars, double alpha);
604 
608  double ScalarRange[2];
614 
615  double RenderTime;
616 
617  // for coloring by a component of a field data array
618  int ArrayId;
619  char* ArrayName;
622 
623  // If coloring by field data, which tuple to use to color the entire
624  // data set. If -1, treat array values as cell data.
626 
627  int Static;
628 
630 
636 
637 private:
638  vtkMapper(const vtkMapper&) VTK_DELETE_FUNCTION;
639  void operator=(const vtkMapper&) VTK_DELETE_FUNCTION;
640 };
641 
642 #endif
int ForceCompileOnly
Definition: vtkMapper.h:629
vtkIdType FieldDataTupleId
Definition: vtkMapper.h:625
#define VTK_COLOR_MODE_DIRECT_SCALARS
void SetScalarModeToUsePointData()
Definition: vtkMapper.h:288
int ScalarVisibility
Definition: vtkMapper.h:606
void SetScalarModeToDefault()
Definition: vtkMapper.h:286
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:366
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:45
#define VTK_SCALAR_MODE_USE_CELL_FIELD_DATA
void SetScalarMaterialModeToAmbientAndDiffuse()
Set/Get the light-model color mode.
Definition: vtkMapper.h:531
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:498
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:300
int ScalarMaterialMode
Definition: vtkMapper.h:613
vtkMTimeType GetMTime() override
Override Modifiedtime as we have added Clipping planes.
abstract class to specify dataset behavior
Definition: vtkDataSet.h:56
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:362
record modification and/or execution time
Definition: vtkTimeStamp.h:32
void SetScalarModeToUseCellData()
Definition: vtkMapper.h:290
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:35
vtkImageData * ColorTextureMap
Definition: vtkMapper.h:602
#define VTK_RESOLVE_SHIFT_ZBUFFER
Definition: vtkMapper.h:65
void SetScalarMaterialModeToDiffuse()
Set/Get the light-model color mode.
Definition: vtkMapper.h:529
static void GlobalImmediateModeRenderingOff()
Turn on/off flag to control whether data is rendered using immediate mode or note.
Definition: vtkMapper.h:240
vtkTimeStamp BuildTime
Definition: vtkMapper.h:607
void SetColorModeToDefault()
default (ColorModeToDefault), unsigned char scalars are treated as colors, and NOT mapped through the...
Definition: vtkMapper.h:165
abstract specification for renderers
Definition: vtkRenderer.h:57
int ArrayAccessMode
Definition: vtkMapper.h:621
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:364
void SetScalarModeToUseFieldData()
Definition: vtkMapper.h:296
int vtkIdType
Definition: vtkType.h:345
double CoincidentLineFactor
Definition: vtkMapper.h:633
vtkUnsignedCharArray * Colors
Definition: vtkMapper.h:595
void SetColorModeToDirectScalars()
default (ColorModeToDefault), unsigned char scalars are treated as colors, and NOT mapped through the...
Definition: vtkMapper.h:169
int ScalarMode
Definition: vtkMapper.h:612
#define VTK_MATERIALMODE_DIFFUSE
Definition: vtkMapper.h:72
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:475
void SetScalarMaterialModeToAmbient()
Set/Get the light-model color mode.
Definition: vtkMapper.h:527
double CoincidentPointOffset
Definition: vtkMapper.h:635
void SetRenderTime(double time)
This instance variable is used by vtkLODActor to determine which mapper to use.
Definition: vtkMapper.h:483
#define VTK_COLOR_MODE_MAP_SCALARS
#define VTK_SCALAR_MODE_USE_POINT_DATA
a simple class to control print indentation
Definition: vtkIndent.h:33
void SetScalarModeToUsePointFieldData()
Definition: vtkMapper.h:292
double CoincidentLineOffset
Definition: vtkMapper.h:634
topologically and geometrically regular array of data
Definition: vtkImageData.h:39
#define VTK_SCALAR_MODE_USE_POINT_FIELD_DATA
#define VTK_MATERIALMODE_AMBIENT
Definition: vtkMapper.h:71
double CoincidentPolygonFactor
Definition: vtkMapper.h:631
static void SetGlobalImmediateModeRendering(int val)
Turn on/off flag to control whether data is rendered using immediate mode or note.
int ImmediateModeRendering
Definition: vtkMapper.h:610
double CoincidentPolygonOffset
Definition: vtkMapper.h:632
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:598
#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:85
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:618
char * ArrayName
Definition: vtkMapper.h:619
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:167
#define VTK_MATERIALMODE_DEFAULT
Definition: vtkMapper.h:70
int Static
Definition: vtkMapper.h:627
int ArrayComponent
Definition: vtkMapper.h:620
void ShallowCopy(vtkAbstractMapper *m)
Make a shallow copy of this mapper.
vtkFloatArray * ColorCoordinates
Definition: vtkMapper.h:600
int UseLookupTableScalarRange
Definition: vtkMapper.h:609
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:556
void SetScalarMaterialModeToDefault()
Set/Get the light-model color mode.
Definition: vtkMapper.h:525
#define VTK_SCALAR_MODE_USE_CELL_DATA
#define VTK_RESOLVE_POLYGON_OFFSET
Definition: vtkMapper.h:64
general representation of visualization data
Definition: vtkDataObject.h:58
void SetScalarModeToUseCellFieldData()
Definition: vtkMapper.h:294
vtkScalarsToColors * LookupTable
Definition: vtkMapper.h:605
static void GlobalImmediateModeRenderingOn()
Turn on/off flag to control whether data is rendered using immediate mode or note.
Definition: vtkMapper.h:238
double RenderTime
Definition: vtkMapper.h:615
#define VTK_SCALAR_MODE_DEFAULT
#define VTK_RESOLVE_OFF
Definition: vtkMapper.h:63
#define VTK_MATERIALMODE_AMBIENT_AND_DIFFUSE
Definition: vtkMapper.h:73
int ColorMode
Definition: vtkMapper.h:611