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 
67 #define VTK_RESOLVE_OFF 0
68 #define VTK_RESOLVE_POLYGON_OFFSET 1
69 #define VTK_RESOLVE_SHIFT_ZBUFFER 2
70 
71 #define VTK_GET_ARRAY_BY_ID 0
72 #define VTK_GET_ARRAY_BY_NAME 1
73 
74 #define VTK_MATERIALMODE_DEFAULT 0
75 #define VTK_MATERIALMODE_AMBIENT 1
76 #define VTK_MATERIALMODE_DIFFUSE 2
77 #define VTK_MATERIALMODE_AMBIENT_AND_DIFFUSE 3
78 
79 class vtkWindow;
80 class vtkRenderer;
81 class vtkActor;
82 class vtkDataSet;
83 class vtkFloatArray;
84 class vtkImageData;
85 class vtkScalarsToColors;
87 
89 {
90 public:
92  void PrintSelf(ostream& os, vtkIndent indent);
93 
96 
99  unsigned long GetMTime();
100 
103  virtual void Render(vtkRenderer *ren, vtkActor *a) = 0;
104 
109 
111 
112  void SetLookupTable(vtkScalarsToColors *lut);
113  vtkScalarsToColors *GetLookupTable();
115 
118  virtual void CreateDefaultLookupTable();
119 
121 
123  vtkSetMacro(ScalarVisibility, int);
124  vtkGetMacro(ScalarVisibility, int);
125  vtkBooleanMacro(ScalarVisibility, int);
127 
129 
133  vtkSetMacro(Static, int);
134  vtkGetMacro(Static, int);
135  vtkBooleanMacro(Static, int);
137 
139 
148  vtkSetMacro(ColorMode, int);
149  vtkGetMacro(ColorMode, int);
151  { this->SetColorMode(VTK_COLOR_MODE_DEFAULT); }
153  { this->SetColorMode(VTK_COLOR_MODE_MAP_SCALARS); }
155  { this->SetColorMode(VTK_COLOR_MODE_DIRECT_SCALARS); }
157 
159  const char *GetColorModeAsString();
160 
162 
165  vtkSetMacro(InterpolateScalarsBeforeMapping, int);
166  vtkGetMacro(InterpolateScalarsBeforeMapping, int);
167  vtkBooleanMacro(InterpolateScalarsBeforeMapping, int);
169 
171 
177  vtkSetMacro(UseLookupTableScalarRange, int);
178  vtkGetMacro(UseLookupTableScalarRange, int);
179  vtkBooleanMacro(UseLookupTableScalarRange, int);
181 
183 
186  vtkSetVector2Macro(ScalarRange, double);
187  vtkGetVectorMacro(ScalarRange, double, 2);
189 
191 
196  vtkSetMacro(ImmediateModeRendering, int);
197  vtkGetMacro(ImmediateModeRendering, int);
198  vtkBooleanMacro(ImmediateModeRendering, int);
200 
202 
207  static void SetGlobalImmediateModeRendering(int val);
212  static int GetGlobalImmediateModeRendering();
214 
215  //BTX
217 
224  vtkGetMacro(ForceCompileOnly, int);
225  void SetForceCompileOnly(int value);
226  //ETX
228 
240  // When ScalarMode is set to use Field Data (ScalarModeToFieldData),
241  // you must call SelectColorArray to choose the field data array to
242  // be used to color cells. In this mode, the default behavior is to
243  // treat the field data tuples as being associated with cells. If
244  // the poly data contains triangle strips, the array is expected to
245  // contain the cell data for each mini-cell formed by any triangle
246  // strips in the poly data as opposed to treating them as a single
247  // tuple that applies to the entire strip. This mode can also be
248  // used to color the entire poly data by a single color obtained by
249  // mapping the tuple at a given index in the field data array
250  // through the color map. Use SetFieldDataTupleId() to specify
251  // the tuple index.
252  vtkSetMacro(ScalarMode, int);
253  vtkGetMacro(ScalarMode, int);
255  { this->SetScalarMode(VTK_SCALAR_MODE_DEFAULT); }
257  { this->SetScalarMode(VTK_SCALAR_MODE_USE_POINT_DATA); }
259  { this->SetScalarMode(VTK_SCALAR_MODE_USE_CELL_DATA); }
261  { this->SetScalarMode(VTK_SCALAR_MODE_USE_POINT_FIELD_DATA); }
263  { this->SetScalarMode(VTK_SCALAR_MODE_USE_CELL_FIELD_DATA); }
265  { this->SetScalarMode(VTK_SCALAR_MODE_USE_FIELD_DATA); }
266 
268 
271  void SelectColorArray(int arrayNum);
272  void SelectColorArray(const char* arrayName);
274 
275 
276  // When ScalarMode is set to UseFieldData, set the index of the
277  // tuple by which to color the entire data set. By default, the
278  // index is -1, which means to treat the field data array selected
279  // with SelectColorArray as having a scalar value for each cell.
280  // Indices of 0 or higher mean to use the tuple at the given index
281  // for coloring the entire data set.
282  vtkSetMacro(FieldDataTupleId, vtkIdType);
283  vtkGetMacro(FieldDataTupleId, vtkIdType);
284 
286 
288  void ColorByArrayComponent(int arrayNum, int component);
289  void ColorByArrayComponent(const char* arrayName, int component);
291 
293 
294  char* GetArrayName() { return this->ArrayName; }
295  int GetArrayId() { return this->ArrayId; }
296  int GetArrayAccessMode() { return this->ArrayAccessMode; }
297  int GetArrayComponent() { return this->ArrayComponent; }
299 
301  const char *GetScalarModeAsString();
302 
304 
314  static void SetResolveCoincidentTopology(int val);
315  static int GetResolveCoincidentTopology();
316  static void SetResolveCoincidentTopologyToDefault();
318  { SetResolveCoincidentTopology(VTK_RESOLVE_OFF) ;}
320  { SetResolveCoincidentTopology(VTK_RESOLVE_POLYGON_OFFSET); }
322  { SetResolveCoincidentTopology(VTK_RESOLVE_SHIFT_ZBUFFER); }
324 
326 
329  static void SetResolveCoincidentTopologyPolygonOffsetParameters(
330  double factor, double units);
331  static void GetResolveCoincidentTopologyPolygonOffsetParameters(
332  double& factor, double& units);
334 
336 
341  static void SetResolveCoincidentTopologyPolygonOffsetFaces(int faces);
342  static int GetResolveCoincidentTopologyPolygonOffsetFaces();
344 
346 
348  static void SetResolveCoincidentTopologyZShift(double val);
349  static double GetResolveCoincidentTopologyZShift();
351 
353 
355  virtual double *GetBounds();
356  virtual void GetBounds(double bounds[6])
357  { this->vtkAbstractMapper3D::GetBounds(bounds); }
359 
361 
364  void SetRenderTime(double time) {this->RenderTime = time;}
365  vtkGetMacro(RenderTime, double);
367 
368  //BTX
370 
372  vtkDataSet *GetInput();
373  //ETX
375 
377 
382  { return this->GetInput(); }
384 
386 
391  virtual vtkUnsignedCharArray *MapScalars(double alpha);
392  virtual vtkUnsignedCharArray *MapScalars(vtkDataSet *input,
393  double alpha);
395 
397 
398  vtkSetMacro(ScalarMaterialMode,int);
399  vtkGetMacro(ScalarMaterialMode,int);
401  { this->SetScalarMaterialMode(VTK_MATERIALMODE_DEFAULT); }
403  { this->SetScalarMaterialMode(VTK_MATERIALMODE_AMBIENT); }
405  { this->SetScalarMaterialMode(VTK_MATERIALMODE_DIFFUSE); }
407  { this->SetScalarMaterialMode(VTK_MATERIALMODE_AMBIENT_AND_DIFFUSE); }
409 
411  const char *GetScalarMaterialModeAsString();
412 
414 
421  virtual bool GetIsOpaque()
422  { return true; }
424 
426 
430  virtual bool GetSupportsSelection()
431  { return false; }
432 protected:
433  vtkMapper();
434  ~vtkMapper();
436 
438 
439  // Use texture coordinates for coloring.
441  // Coordinate for each point.
443  // 1D ColorMap used for the texture image.
445  void MapScalarsToTexture(vtkDataArray* scalars, double alpha);
446 
450  double ScalarRange[2];
456 
457  double RenderTime;
458 
459  // for coloring by a component of a field data array
460  int ArrayId;
461  char ArrayName[256];
464 
465  // If coloring by field data, which tuple to use to color the entire
466  // data set. If -1, treat array values as cell data.
468 
469  int Static;
470 
472 
473 private:
474  vtkMapper(const vtkMapper&); // Not implemented.
475  void operator=(const vtkMapper&); // Not implemented.
476 };
477 
478 #endif
int ForceCompileOnly
Definition: vtkMapper.h:471
vtkIdType FieldDataTupleId
Definition: vtkMapper.h:467
virtual unsigned long GetMTime()
#define VTK_COLOR_MODE_DIRECT_SCALARS
void SetScalarModeToUsePointData()
Definition: vtkMapper.h:256
int ScalarVisibility
Definition: vtkMapper.h:448
void SetScalarModeToDefault()
Definition: vtkMapper.h:254
static void SetResolveCoincidentTopologyToShiftZBuffer()
Definition: vtkMapper.h:321
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:406
virtual void ReleaseGraphicsResources(vtkWindow *)
Definition: vtkMapper.h:108
vtkDataSet * GetInputAsDataSet()
Definition: vtkMapper.h:381
GLenum GLenum GLenum input
Definition: vtkgl.h:15941
int ScalarMaterialMode
Definition: vtkMapper.h:455
abstract class to specify dataset behavior
Definition: vtkDataSet.h:59
static void SetResolveCoincidentTopologyToOff()
Definition: vtkMapper.h:317
#define vtkGetMacro(name, type)
Definition: vtkSetGet.h:83
record modification and/or execution time
Definition: vtkTimeStamp.h:34
void SetScalarModeToUseCellData()
Definition: vtkMapper.h:258
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:45
vtkImageData * ColorTextureMap
Definition: vtkMapper.h:444
#define VTK_RESOLVE_SHIFT_ZBUFFER
Definition: vtkMapper.h:69
void SetScalarMaterialModeToDiffuse()
Definition: vtkMapper.h:404
static void GlobalImmediateModeRenderingOff()
Definition: vtkMapper.h:210
vtkTimeStamp BuildTime
Definition: vtkMapper.h:449
void SetColorModeToDefault()
Definition: vtkMapper.h:150
abstract specification for renderers
Definition: vtkRenderer.h:63
int ArrayAccessMode
Definition: vtkMapper.h:463
static void SetResolveCoincidentTopologyToPolygonOffset()
Definition: vtkMapper.h:319
void SetScalarModeToUseFieldData()
Definition: vtkMapper.h:264
GLsizei const GLfloat * value
Definition: vtkgl.h:12021
int vtkIdType
Definition: vtkType.h:281
virtual bool GetIsOpaque()
Definition: vtkMapper.h:421
vtkUnsignedCharArray * Colors
Definition: vtkMapper.h:437
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:632
void SetColorModeToDirectScalars()
Definition: vtkMapper.h:154
int ScalarMode
Definition: vtkMapper.h:454
#define VTK_MATERIALMODE_DIFFUSE
Definition: vtkMapper.h:76
Superclass for mapping scalar values to colors.
window superclass for vtkRenderWindow
Definition: vtkWindow.h:33
void SetScalarMaterialModeToAmbient()
Definition: vtkMapper.h:402
void SetRenderTime(double time)
Definition: vtkMapper.h:364
#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:260
const GLfloat * m
Definition: vtkgl.h:18169
topologically and geometrically regular array of data
Definition: vtkImageData.h:44
#define VTK_SCALAR_MODE_USE_POINT_FIELD_DATA
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:53
#define VTK_MATERIALMODE_AMBIENT
Definition: vtkMapper.h:75
static void SetGlobalImmediateModeRendering(int val)
int ImmediateModeRendering
Definition: vtkMapper.h:452
virtual double * GetBounds()=0
abstract class specifies interface to map 3D data
int InterpolateScalarsBeforeMapping
Definition: vtkMapper.h:440
#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:88
dynamic, self-adjusting array of unsigned char
virtual void GetBounds(double bounds[6])
Definition: vtkMapper.h:356
abstract class specifies interface to map data
int ArrayId
Definition: vtkMapper.h:460
GLboolean GLboolean GLboolean GLboolean a
Definition: vtkgl.h:12312
int GetArrayAccessMode()
Definition: vtkMapper.h:296
void SetColorModeToMapScalars()
Definition: vtkMapper.h:152
#define VTK_MATERIALMODE_DEFAULT
Definition: vtkMapper.h:74
int Static
Definition: vtkMapper.h:469
int ArrayComponent
Definition: vtkMapper.h:462
#define VTKRENDERINGCORE_EXPORT
void PrintSelf(ostream &os, vtkIndent indent)
int GetArrayId()
Definition: vtkMapper.h:295
void ShallowCopy(vtkAbstractMapper *m)
#define vtkBooleanMacro(name, type)
Definition: vtkSetGet.h:234
vtkFloatArray * ColorCoordinates
Definition: vtkMapper.h:442
int UseLookupTableScalarRange
Definition: vtkMapper.h:451
virtual bool GetSupportsSelection()
Definition: vtkMapper.h:430
GLclampf GLclampf GLclampf alpha
Definition: vtkgl.h:11313
void SetScalarMaterialModeToDefault()
Definition: vtkMapper.h:400
#define VTK_SCALAR_MODE_USE_CELL_DATA
#define VTK_RESOLVE_POLYGON_OFFSET
Definition: vtkMapper.h:68
#define vtkGetVectorMacro(name, type, count)
Definition: vtkSetGet.h:414
void SetScalarModeToUseCellFieldData()
Definition: vtkMapper.h:262
#define vtkSetVector2Macro(name, type)
Definition: vtkSetGet.h:244
vtkScalarsToColors * LookupTable
Definition: vtkMapper.h:447
int GetArrayComponent()
Definition: vtkMapper.h:297
static void GlobalImmediateModeRenderingOn()
Definition: vtkMapper.h:208
double RenderTime
Definition: vtkMapper.h:457
#define VTK_SCALAR_MODE_DEFAULT
#define VTK_RESOLVE_OFF
Definition: vtkMapper.h:67
GLuint GLfloat * val
Definition: vtkgl.h:13789
#define VTK_MATERIALMODE_AMBIENT_AND_DIFFUSE
Definition: vtkMapper.h:77
char * GetArrayName()
Definition: vtkMapper.h:294
#define vtkSetMacro(name, type)
Definition: vtkSetGet.h:69
int ColorMode
Definition: vtkMapper.h:453