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 
339  void SetRelativeCoincidentTopologyPolygonOffsetParameters(
340  double factor, double units);
341  void GetRelativeCoincidentTopologyPolygonOffsetParameters(
342  double& factor, double& units);
344 
346 
349  static void SetResolveCoincidentTopologyLineOffsetParameters(
350  double factor, double units);
351  static void GetResolveCoincidentTopologyLineOffsetParameters(
352  double& factor, double& units);
354 
356 
358  void SetRelativeCoincidentTopologyLineOffsetParameters(
359  double factor, double units);
360  void GetRelativeCoincidentTopologyLineOffsetParameters(
361  double& factor, double& units);
363 
365 
368  static void SetResolveCoincidentTopologyPointOffsetParameter(
369  double units);
370  static void GetResolveCoincidentTopologyPointOffsetParameter(
371  double& units);
373 
375 
377  void SetRelativeCoincidentTopologyPointOffsetParameter(double units);
378  void GetRelativeCoincidentTopologyPointOffsetParameter(double& units);
380 
382 
384  void GetCoincidentTopologyPolygonOffsetParameters(
385  double& factor, double& units);
386  void GetCoincidentTopologyLineOffsetParameters(
387  double& factor, double& units);
388  void GetCoincidentTopologyPointOffsetParameter(double& units);
390 
392 
397  static void SetResolveCoincidentTopologyPolygonOffsetFaces(int faces);
398  static int GetResolveCoincidentTopologyPolygonOffsetFaces();
400 
402 
404  static void SetResolveCoincidentTopologyZShift(double val);
405  static double GetResolveCoincidentTopologyZShift();
407 
409 
411  virtual double *GetBounds();
412  virtual void GetBounds(double bounds[6])
413  { this->vtkAbstractMapper3D::GetBounds(bounds); }
415 
417 
420  void SetRenderTime(double time) {this->RenderTime = time;}
421  vtkGetMacro(RenderTime, double);
423 
424  //BTX
426 
428  vtkDataSet *GetInput();
429  //ETX
431 
433 
438  { return this->GetInput(); }
440 
442 
447  virtual vtkUnsignedCharArray *MapScalars(double alpha);
448  virtual vtkUnsignedCharArray *MapScalars(vtkDataSet *input,
449  double alpha);
451 
453 
454  vtkSetMacro(ScalarMaterialMode,int);
455  vtkGetMacro(ScalarMaterialMode,int);
457  { this->SetScalarMaterialMode(VTK_MATERIALMODE_DEFAULT); }
459  { this->SetScalarMaterialMode(VTK_MATERIALMODE_AMBIENT); }
461  { this->SetScalarMaterialMode(VTK_MATERIALMODE_DIFFUSE); }
463  { this->SetScalarMaterialMode(VTK_MATERIALMODE_AMBIENT_AND_DIFFUSE); }
465 
467  const char *GetScalarMaterialModeAsString();
468 
476  virtual bool GetIsOpaque();
477 
479 
483  virtual bool GetSupportsSelection()
484  { return false; }
486 
493  virtual int CanUseTextureMapForColoring(vtkDataObject* input);
494 
496 
497  void UseInvertibleColorFor(int scalarMode,
498  int arrayAccessMode,
499  int arrayId,
500  const char *arrayName,
501  int arrayComponent,
502  double *scalarRange);
504 
506  void ClearInvertibleColor();
507 
509 
510  static void ValueToColor(double value, double min, double scale,
511  unsigned char *color);
513 
515 
516  static void ColorToValue(unsigned char *color, double min, double scale,
517  double &value);
519 
520 protected:
521  vtkMapper();
522  ~vtkMapper();
523 
525 
526  // Use texture coordinates for coloring.
528  // Coordinate for each point.
530  // 1D ColorMap used for the texture image.
532  void MapScalarsToTexture(vtkAbstractArray* scalars, double alpha);
533 
534  // Makes a lookup table that can be used for deferred colormaps
535  void AcquireInvertibleLookupTable();
538 
542  double ScalarRange[2];
548 
549  double RenderTime;
550 
551  // for coloring by a component of a field data array
552  int ArrayId;
553  char ArrayName[256];
556 
557  // If coloring by field data, which tuple to use to color the entire
558  // data set. If -1, treat array values as cell data.
560 
561  int Static;
562 
564 
566 
572 
573 private:
574  vtkMapper(const vtkMapper&); // Not implemented.
575  void operator=(const vtkMapper&); // Not implemented.
576 };
577 
578 #endif
int ForceCompileOnly
Definition: vtkMapper.h:563
vtkIdType FieldDataTupleId
Definition: vtkMapper.h:559
virtual unsigned long GetMTime()
vtkAbstractArray * InvertibleScalars
Definition: vtkMapper.h:565
#define VTK_COLOR_MODE_DIRECT_SCALARS
void SetScalarModeToUsePointData()
Definition: vtkMapper.h:257
int ScalarVisibility
Definition: vtkMapper.h:540
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:462
virtual void ReleaseGraphicsResources(vtkWindow *)
Definition: vtkMapper.h:109
static vtkScalarsToColors * InvertibleLookupTable
Definition: vtkMapper.h:537
vtkDataSet * GetInputAsDataSet()
Definition: vtkMapper.h:437
int ScalarMaterialMode
Definition: vtkMapper.h:547
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:531
#define VTK_RESOLVE_SHIFT_ZBUFFER
Definition: vtkMapper.h:70
void SetScalarMaterialModeToDiffuse()
Definition: vtkMapper.h:460
static void GlobalImmediateModeRenderingOff()
Definition: vtkMapper.h:211
vtkTimeStamp BuildTime
Definition: vtkMapper.h:541
void SetColorModeToDefault()
Definition: vtkMapper.h:151
abstract specification for renderers
Definition: vtkRenderer.h:62
int ArrayAccessMode
Definition: vtkMapper.h:555
static void SetResolveCoincidentTopologyToPolygonOffset()
Definition: vtkMapper.h:320
void SetScalarModeToUseFieldData()
Definition: vtkMapper.h:265
int vtkIdType
Definition: vtkType.h:247
double CoincidentLineFactor
Definition: vtkMapper.h:569
vtkUnsignedCharArray * Colors
Definition: vtkMapper.h:524
void SetColorModeToDirectScalars()
Definition: vtkMapper.h:155
int ScalarMode
Definition: vtkMapper.h:546
#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:458
double CoincidentPointOffset
Definition: vtkMapper.h:571
void SetRenderTime(double time)
Definition: vtkMapper.h:420
#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
double CoincidentLineOffset
Definition: vtkMapper.h:570
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
double CoincidentPolygonFactor
Definition: vtkMapper.h:567
static void SetGlobalImmediateModeRendering(int val)
int ImmediateModeRendering
Definition: vtkMapper.h:544
double CoincidentPolygonOffset
Definition: vtkMapper.h:568
virtual double * GetBounds()=0
abstract class specifies interface to map 3D data
int InterpolateScalarsBeforeMapping
Definition: vtkMapper.h:527
#define VTK_COLOR_MODE_DEFAULT
bool UseInvertibleColors
Definition: vtkMapper.h:536
#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:412
abstract class specifies interface to map data
int ArrayId
Definition: vtkMapper.h:552
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:561
int ArrayComponent
Definition: vtkMapper.h:554
#define VTKRENDERINGCORE_EXPORT
void PrintSelf(ostream &os, vtkIndent indent)
int GetArrayId()
Definition: vtkMapper.h:296
void ShallowCopy(vtkAbstractMapper *m)
vtkFloatArray * ColorCoordinates
Definition: vtkMapper.h:529
int UseLookupTableScalarRange
Definition: vtkMapper.h:543
virtual bool GetSupportsSelection()
Definition: vtkMapper.h:483
void SetScalarMaterialModeToDefault()
Definition: vtkMapper.h:456
#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:539
int GetArrayComponent()
Definition: vtkMapper.h:298
static void GlobalImmediateModeRenderingOn()
Definition: vtkMapper.h:209
double RenderTime
Definition: vtkMapper.h:549
#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:545