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 =========================================================================*/
60 #ifndef vtkMapper_h
61 #define vtkMapper_h
62 
63 #include "vtkRenderingCoreModule.h" // For export macro
64 #include "vtkAbstractMapper3D.h"
65 #include "vtkSystemIncludes.h" // For VTK_COLOR_MODE_DEFAULT and _MAP_SCALARS
66 #include "vtkSmartPointer.h" // needed for vtkSmartPointer.
67 
68 #define VTK_RESOLVE_OFF 0
69 #define VTK_RESOLVE_POLYGON_OFFSET 1
70 #define VTK_RESOLVE_SHIFT_ZBUFFER 2
71 
72 #define VTK_GET_ARRAY_BY_ID 0
73 #define VTK_GET_ARRAY_BY_NAME 1
74 
75 #define VTK_MATERIALMODE_DEFAULT 0
76 #define VTK_MATERIALMODE_AMBIENT 1
77 #define VTK_MATERIALMODE_DIFFUSE 2
78 #define VTK_MATERIALMODE_AMBIENT_AND_DIFFUSE 3
79 
80 class vtkWindow;
81 class vtkRenderer;
82 class vtkActor;
83 class vtkDataSet;
84 class vtkFloatArray;
85 class vtkImageData;
86 class vtkScalarsToColors;
88 
90 {
91 public:
93  void PrintSelf(ostream& os, vtkIndent indent);
94 
97 
100  unsigned long GetMTime();
101 
104  virtual void Render(vtkRenderer *ren, vtkActor *a) = 0;
105 
110 
112 
113  void SetLookupTable(vtkScalarsToColors *lut);
114  vtkScalarsToColors *GetLookupTable();
116 
119  virtual void CreateDefaultLookupTable();
120 
122 
124  vtkSetMacro(ScalarVisibility, int);
125  vtkGetMacro(ScalarVisibility, int);
126  vtkBooleanMacro(ScalarVisibility, int);
128 
130 
134  vtkSetMacro(Static, int);
135  vtkGetMacro(Static, int);
136  vtkBooleanMacro(Static, int);
138 
140 
149  vtkSetMacro(ColorMode, int);
150  vtkGetMacro(ColorMode, int);
152  { this->SetColorMode(VTK_COLOR_MODE_DEFAULT); }
154  { this->SetColorMode(VTK_COLOR_MODE_MAP_SCALARS); }
156  { this->SetColorMode(VTK_COLOR_MODE_DIRECT_SCALARS); }
158 
160  const char *GetColorModeAsString();
161 
163 
166  vtkSetMacro(InterpolateScalarsBeforeMapping, int);
167  vtkGetMacro(InterpolateScalarsBeforeMapping, int);
168  vtkBooleanMacro(InterpolateScalarsBeforeMapping, int);
170 
172 
178  vtkSetMacro(UseLookupTableScalarRange, int);
179  vtkGetMacro(UseLookupTableScalarRange, int);
180  vtkBooleanMacro(UseLookupTableScalarRange, int);
182 
184 
187  vtkSetVector2Macro(ScalarRange, double);
188  vtkGetVectorMacro(ScalarRange, double, 2);
190 
192 
197  vtkSetMacro(ImmediateModeRendering, int);
198  vtkGetMacro(ImmediateModeRendering, int);
199  vtkBooleanMacro(ImmediateModeRendering, int);
201 
203 
208  static void SetGlobalImmediateModeRendering(int val);
213  static int GetGlobalImmediateModeRendering();
215 
216  //BTX
218 
225  vtkGetMacro(ForceCompileOnly, int);
226  void SetForceCompileOnly(int value);
227  //ETX
229 
241  // When ScalarMode is set to use Field Data (ScalarModeToFieldData),
242  // you must call SelectColorArray to choose the field data array to
243  // be used to color cells. In this mode, the default behavior is to
244  // treat the field data tuples as being associated with cells. If
245  // the poly data contains triangle strips, the array is expected to
246  // contain the cell data for each mini-cell formed by any triangle
247  // strips in the poly data as opposed to treating them as a single
248  // tuple that applies to the entire strip. This mode can also be
249  // used to color the entire poly data by a single color obtained by
250  // mapping the tuple at a given index in the field data array
251  // through the color map. Use SetFieldDataTupleId() to specify
252  // the tuple index.
253  vtkSetMacro(ScalarMode, int);
254  vtkGetMacro(ScalarMode, int);
256  { this->SetScalarMode(VTK_SCALAR_MODE_DEFAULT); }
258  { this->SetScalarMode(VTK_SCALAR_MODE_USE_POINT_DATA); }
260  { this->SetScalarMode(VTK_SCALAR_MODE_USE_CELL_DATA); }
262  { this->SetScalarMode(VTK_SCALAR_MODE_USE_POINT_FIELD_DATA); }
264  { this->SetScalarMode(VTK_SCALAR_MODE_USE_CELL_FIELD_DATA); }
266  { this->SetScalarMode(VTK_SCALAR_MODE_USE_FIELD_DATA); }
267 
269 
272  void SelectColorArray(int arrayNum);
273  void SelectColorArray(const char* arrayName);
275 
276 
277  // When ScalarMode is set to UseFieldData, set the index of the
278  // tuple by which to color the entire data set. By default, the
279  // index is -1, which means to treat the field data array selected
280  // with SelectColorArray as having a scalar value for each cell.
281  // Indices of 0 or higher mean to use the tuple at the given index
282  // for coloring the entire data set.
283  vtkSetMacro(FieldDataTupleId, vtkIdType);
284  vtkGetMacro(FieldDataTupleId, vtkIdType);
285 
287 
289  void ColorByArrayComponent(int arrayNum, int component);
290  void ColorByArrayComponent(const char* arrayName, int component);
292 
294 
295  char* GetArrayName() { return this->ArrayName; }
296  int GetArrayId() { return this->ArrayId; }
297  int GetArrayAccessMode() { return this->ArrayAccessMode; }
298  int GetArrayComponent() { return this->ArrayComponent; }
300 
302  const char *GetScalarModeAsString();
303 
305 
315  static void SetResolveCoincidentTopology(int val);
316  static int GetResolveCoincidentTopology();
317  static void SetResolveCoincidentTopologyToDefault();
319  { SetResolveCoincidentTopology(VTK_RESOLVE_OFF) ;}
321  { SetResolveCoincidentTopology(VTK_RESOLVE_POLYGON_OFFSET); }
323  { SetResolveCoincidentTopology(VTK_RESOLVE_SHIFT_ZBUFFER); }
325 
327 
330  static void SetResolveCoincidentTopologyPolygonOffsetParameters(
331  double factor, double units);
332  static void GetResolveCoincidentTopologyPolygonOffsetParameters(
333  double& factor, double& units);
335 
337 
342  static void SetResolveCoincidentTopologyPolygonOffsetFaces(int faces);
343  static int GetResolveCoincidentTopologyPolygonOffsetFaces();
345 
347 
349  static void SetResolveCoincidentTopologyZShift(double val);
350  static double GetResolveCoincidentTopologyZShift();
352 
354 
356  virtual double *GetBounds();
357  virtual void GetBounds(double bounds[6])
358  { this->vtkAbstractMapper3D::GetBounds(bounds); }
360 
362 
365  void SetRenderTime(double time) {this->RenderTime = time;}
366  vtkGetMacro(RenderTime, double);
368 
369  //BTX
371 
373  vtkDataSet *GetInput();
374  //ETX
376 
378 
383  { return this->GetInput(); }
385 
387 
392  virtual vtkUnsignedCharArray *MapScalars(double alpha);
393  virtual vtkUnsignedCharArray *MapScalars(vtkDataSet *input,
394  double alpha);
396 
398 
399  vtkSetMacro(ScalarMaterialMode,int);
400  vtkGetMacro(ScalarMaterialMode,int);
402  { this->SetScalarMaterialMode(VTK_MATERIALMODE_DEFAULT); }
404  { this->SetScalarMaterialMode(VTK_MATERIALMODE_AMBIENT); }
406  { this->SetScalarMaterialMode(VTK_MATERIALMODE_DIFFUSE); }
408  { this->SetScalarMaterialMode(VTK_MATERIALMODE_AMBIENT_AND_DIFFUSE); }
410 
412  const char *GetScalarMaterialModeAsString();
413 
415 
422  virtual bool GetIsOpaque()
423  { return true; }
425 
427 
431  virtual bool GetSupportsSelection()
432  { return false; }
434 
441  virtual int CanUseTextureMapForColoring(vtkDataObject* input);
442 
443 protected:
444  vtkMapper();
445  ~vtkMapper();
446 
448 
449  // Use texture coordinates for coloring.
451  // Coordinate for each point.
453  // 1D ColorMap used for the texture image.
455  void MapScalarsToTexture(vtkAbstractArray* scalars, double alpha);
456 
460  double ScalarRange[2];
466 
467  double RenderTime;
468 
469  // for coloring by a component of a field data array
470  int ArrayId;
471  char ArrayName[256];
474 
475  // If coloring by field data, which tuple to use to color the entire
476  // data set. If -1, treat array values as cell data.
478 
479  int Static;
480 
482 
483 private:
484  vtkMapper(const vtkMapper&); // Not implemented.
485  void operator=(const vtkMapper&); // Not implemented.
486 };
487 
488 #endif
int ForceCompileOnly
Definition: vtkMapper.h:481
vtkIdType FieldDataTupleId
Definition: vtkMapper.h:477
virtual unsigned long GetMTime()
#define VTK_COLOR_MODE_DIRECT_SCALARS
void SetScalarModeToUsePointData()
Definition: vtkMapper.h:257
int ScalarVisibility
Definition: vtkMapper.h:458
void SetScalarModeToDefault()
Definition: vtkMapper.h:255
static void SetResolveCoincidentTopologyToShiftZBuffer()
Definition: vtkMapper.h:322
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:50
#define VTK_SCALAR_MODE_USE_CELL_FIELD_DATA
void SetScalarMaterialModeToAmbientAndDiffuse()
Definition: vtkMapper.h:407
virtual void ReleaseGraphicsResources(vtkWindow *)
Definition: vtkMapper.h:109
vtkDataSet * GetInputAsDataSet()
Definition: vtkMapper.h:382
int ScalarMaterialMode
Definition: vtkMapper.h:465
abstract class to specify dataset behavior
Definition: vtkDataSet.h:61
Abstract superclass for all arrays.
static void SetResolveCoincidentTopologyToOff()
Definition: vtkMapper.h:318
record modification and/or execution time
Definition: vtkTimeStamp.h:34
void SetScalarModeToUseCellData()
Definition: vtkMapper.h:259
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:45
vtkImageData * ColorTextureMap
Definition: vtkMapper.h:454
#define VTK_RESOLVE_SHIFT_ZBUFFER
Definition: vtkMapper.h:70
void SetScalarMaterialModeToDiffuse()
Definition: vtkMapper.h:405
static void GlobalImmediateModeRenderingOff()
Definition: vtkMapper.h:211
vtkTimeStamp BuildTime
Definition: vtkMapper.h:459
void SetColorModeToDefault()
Definition: vtkMapper.h:151
abstract specification for renderers
Definition: vtkRenderer.h:63
int ArrayAccessMode
Definition: vtkMapper.h:473
static void SetResolveCoincidentTopologyToPolygonOffset()
Definition: vtkMapper.h:320
void SetScalarModeToUseFieldData()
Definition: vtkMapper.h:265
int vtkIdType
Definition: vtkType.h:275
virtual bool GetIsOpaque()
Definition: vtkMapper.h:422
vtkUnsignedCharArray * Colors
Definition: vtkMapper.h:447
void SetColorModeToDirectScalars()
Definition: vtkMapper.h:155
int ScalarMode
Definition: vtkMapper.h:464
#define VTK_MATERIALMODE_DIFFUSE
Definition: vtkMapper.h:77
Superclass for mapping scalar values to colors.
window superclass for vtkRenderWindow
Definition: vtkWindow.h:36
void SetScalarMaterialModeToAmbient()
Definition: vtkMapper.h:403
void SetRenderTime(double time)
Definition: vtkMapper.h:365
#define VTK_COLOR_MODE_MAP_SCALARS
#define VTK_SCALAR_MODE_USE_POINT_DATA
a simple class to control print indentation
Definition: vtkIndent.h:38
void SetScalarModeToUsePointFieldData()
Definition: vtkMapper.h:261
topologically and geometrically regular array of data
Definition: vtkImageData.h:44
#define VTK_SCALAR_MODE_USE_POINT_FIELD_DATA
#define VTK_MATERIALMODE_AMBIENT
Definition: vtkMapper.h:76
static void SetGlobalImmediateModeRendering(int val)
int ImmediateModeRendering
Definition: vtkMapper.h:462
virtual double * GetBounds()=0
abstract class specifies interface to map 3D data
int InterpolateScalarsBeforeMapping
Definition: vtkMapper.h:450
#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:89
dynamic, self-adjusting array of unsigned char
virtual void GetBounds(double bounds[6])
Definition: vtkMapper.h:357
abstract class specifies interface to map data
int ArrayId
Definition: vtkMapper.h:470
int GetArrayAccessMode()
Definition: vtkMapper.h:297
void SetColorModeToMapScalars()
Definition: vtkMapper.h:153
#define VTK_MATERIALMODE_DEFAULT
Definition: vtkMapper.h:75
int Static
Definition: vtkMapper.h:479
int ArrayComponent
Definition: vtkMapper.h:472
#define VTKRENDERINGCORE_EXPORT
void PrintSelf(ostream &os, vtkIndent indent)
int GetArrayId()
Definition: vtkMapper.h:296
void ShallowCopy(vtkAbstractMapper *m)
vtkFloatArray * ColorCoordinates
Definition: vtkMapper.h:452
int UseLookupTableScalarRange
Definition: vtkMapper.h:461
virtual bool GetSupportsSelection()
Definition: vtkMapper.h:431
void SetScalarMaterialModeToDefault()
Definition: vtkMapper.h:401
#define VTK_SCALAR_MODE_USE_CELL_DATA
#define VTK_RESOLVE_POLYGON_OFFSET
Definition: vtkMapper.h:69
general representation of visualization data
Definition: vtkDataObject.h:64
void SetScalarModeToUseCellFieldData()
Definition: vtkMapper.h:263
vtkScalarsToColors * LookupTable
Definition: vtkMapper.h:457
int GetArrayComponent()
Definition: vtkMapper.h:298
static void GlobalImmediateModeRenderingOn()
Definition: vtkMapper.h:209
double RenderTime
Definition: vtkMapper.h:467
#define VTK_SCALAR_MODE_DEFAULT
#define VTK_RESOLVE_OFF
Definition: vtkMapper.h:68
#define VTK_MATERIALMODE_AMBIENT_AND_DIFFUSE
Definition: vtkMapper.h:78
char * GetArrayName()
Definition: vtkMapper.h:295
int ColorMode
Definition: vtkMapper.h:463