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 =========================================================================*/
47 #ifndef vtkMapper_h
48 #define vtkMapper_h
49 
50 #include "vtkRenderingCoreModule.h" // For export macro
51 #include "vtkAbstractMapper3D.h"
52 #include "vtkSystemIncludes.h" // For VTK_COLOR_MODE_DEFAULT and _MAP_SCALARS
53 #include "vtkSmartPointer.h" // needed for vtkSmartPointer.
54 
55 #define VTK_RESOLVE_OFF 0
56 #define VTK_RESOLVE_POLYGON_OFFSET 1
57 #define VTK_RESOLVE_SHIFT_ZBUFFER 2
58 
59 #define VTK_GET_ARRAY_BY_ID 0
60 #define VTK_GET_ARRAY_BY_NAME 1
61 
62 #define VTK_MATERIALMODE_DEFAULT 0
63 #define VTK_MATERIALMODE_AMBIENT 1
64 #define VTK_MATERIALMODE_DIFFUSE 2
65 #define VTK_MATERIALMODE_AMBIENT_AND_DIFFUSE 3
66 
67 class vtkWindow;
68 class vtkRenderer;
69 class vtkActor;
70 class vtkDataSet;
71 class vtkDataObject;
72 class vtkFloatArray;
73 class vtkImageData;
74 class vtkScalarsToColors;
76 
77 class VTKRENDERINGCORE_EXPORT vtkMapper : public vtkAbstractMapper3D
78 {
79 public:
81  void PrintSelf(ostream& os, vtkIndent indent) override;
82 
87 
92  vtkMTimeType GetMTime() override;
93 
98  virtual void Render(vtkRenderer *ren, vtkActor *a) = 0;
99 
106 
108 
111  void SetLookupTable(vtkScalarsToColors *lut);
112  vtkScalarsToColors *GetLookupTable();
114 
119  virtual void CreateDefaultLookupTable();
120 
122 
125  vtkSetMacro(ScalarVisibility, vtkTypeBool);
126  vtkGetMacro(ScalarVisibility, vtkTypeBool);
127  vtkBooleanMacro(ScalarVisibility, vtkTypeBool);
129 
131 
137  vtkSetMacro(Static, vtkTypeBool);
138  vtkGetMacro(Static, vtkTypeBool);
139  vtkBooleanMacro(Static, vtkTypeBool);
141 
143 
155  vtkSetMacro(ColorMode, int);
156  vtkGetMacro(ColorMode, int);
158  { this->SetColorMode(VTK_COLOR_MODE_DEFAULT); }
160  { this->SetColorMode(VTK_COLOR_MODE_MAP_SCALARS); }
162  { this->SetColorMode(VTK_COLOR_MODE_DIRECT_SCALARS); }
164 
168  const char *GetColorModeAsString();
169 
171 
177  vtkSetMacro(InterpolateScalarsBeforeMapping, vtkTypeBool);
178  vtkGetMacro(InterpolateScalarsBeforeMapping, vtkTypeBool);
179  vtkBooleanMacro(InterpolateScalarsBeforeMapping, vtkTypeBool);
181 
183 
191  vtkSetMacro(UseLookupTableScalarRange, vtkTypeBool);
192  vtkGetMacro(UseLookupTableScalarRange, vtkTypeBool);
193  vtkBooleanMacro(UseLookupTableScalarRange, vtkTypeBool);
195 
197 
202  vtkSetVector2Macro(ScalarRange, double);
203  vtkGetVectorMacro(ScalarRange, double, 2);
205 
219  // When ScalarMode is set to use Field Data (ScalarModeToFieldData),
220  // you must call SelectColorArray to choose the field data array to
221  // be used to color cells. In this mode, the default behavior is to
222  // treat the field data tuples as being associated with cells. If
223  // the poly data contains triangle strips, the array is expected to
224  // contain the cell data for each mini-cell formed by any triangle
225  // strips in the poly data as opposed to treating them as a single
226  // tuple that applies to the entire strip. This mode can also be
227  // used to color the entire poly data by a single color obtained by
228  // mapping the tuple at a given index in the field data array
229  // through the color map. Use SetFieldDataTupleId() to specify
230  // the tuple index.
231  vtkSetMacro(ScalarMode, int);
232  vtkGetMacro(ScalarMode, int);
234  { this->SetScalarMode(VTK_SCALAR_MODE_DEFAULT); }
236  { this->SetScalarMode(VTK_SCALAR_MODE_USE_POINT_DATA); }
238  { this->SetScalarMode(VTK_SCALAR_MODE_USE_CELL_DATA); }
240  { this->SetScalarMode(VTK_SCALAR_MODE_USE_POINT_FIELD_DATA); }
242  { this->SetScalarMode(VTK_SCALAR_MODE_USE_CELL_FIELD_DATA); }
244  { this->SetScalarMode(VTK_SCALAR_MODE_USE_FIELD_DATA); }
245 
247 
252  void SelectColorArray(int arrayNum);
253  void SelectColorArray(const char* arrayName);
255 
256 
257  // When ScalarMode is set to UseFieldData, set the index of the
258  // tuple by which to color the entire data set. By default, the
259  // index is -1, which means to treat the field data array selected
260  // with SelectColorArray as having a scalar value for each cell.
261  // Indices of 0 or higher mean to use the tuple at the given index
262  // for coloring the entire data set.
263  vtkSetMacro(FieldDataTupleId, vtkIdType);
264  vtkGetMacro(FieldDataTupleId, vtkIdType);
265 
267 
272  void ColorByArrayComponent(int arrayNum, int component);
273  void ColorByArrayComponent(const char* arrayName, int component);
275 
279  vtkGetStringMacro(ArrayName);
280  vtkSetStringMacro(ArrayName);
281  vtkGetMacro(ArrayId, int);
282  vtkSetMacro(ArrayId, int);
283  vtkGetMacro(ArrayAccessMode, int);
284  vtkSetMacro(ArrayAccessMode, int);
285  vtkGetMacro(ArrayComponent, int);
286  vtkSetMacro(ArrayComponent, int);
287 
291  const char *GetScalarModeAsString();
292 
294 
304  static void SetResolveCoincidentTopology(int val);
305  static int GetResolveCoincidentTopology();
306  static void SetResolveCoincidentTopologyToDefault();
308  { SetResolveCoincidentTopology(VTK_RESOLVE_OFF) ;}
310  { SetResolveCoincidentTopology(VTK_RESOLVE_POLYGON_OFFSET); }
312  { SetResolveCoincidentTopology(VTK_RESOLVE_SHIFT_ZBUFFER); }
314 
316 
321  static void SetResolveCoincidentTopologyPolygonOffsetParameters(
322  double factor, double units);
323  static void GetResolveCoincidentTopologyPolygonOffsetParameters(
324  double& factor, double& units);
326 
328 
332  void SetRelativeCoincidentTopologyPolygonOffsetParameters(
333  double factor, double units);
334  void GetRelativeCoincidentTopologyPolygonOffsetParameters(
335  double& factor, double& units);
337 
339 
344  static void SetResolveCoincidentTopologyLineOffsetParameters(
345  double factor, double units);
346  static void GetResolveCoincidentTopologyLineOffsetParameters(
347  double& factor, double& units);
349 
351 
355  void SetRelativeCoincidentTopologyLineOffsetParameters(
356  double factor, double units);
357  void GetRelativeCoincidentTopologyLineOffsetParameters(
358  double& factor, double& units);
360 
362 
367  static void SetResolveCoincidentTopologyPointOffsetParameter(
368  double units);
369  static void GetResolveCoincidentTopologyPointOffsetParameter(
370  double& units);
372 
374 
378  void SetRelativeCoincidentTopologyPointOffsetParameter(double units);
379  void GetRelativeCoincidentTopologyPointOffsetParameter(double& units);
381 
383 
387  void GetCoincidentTopologyPolygonOffsetParameters(
388  double& factor, double& units);
389  void GetCoincidentTopologyLineOffsetParameters(
390  double& factor, double& units);
391  void GetCoincidentTopologyPointOffsetParameter(double& units);
393 
395 
402  static void SetResolveCoincidentTopologyPolygonOffsetFaces(int faces);
403  static int GetResolveCoincidentTopologyPolygonOffsetFaces();
405 
407 
411  static void SetResolveCoincidentTopologyZShift(double val);
412  static double GetResolveCoincidentTopologyZShift();
414 
419  double *GetBounds() VTK_SIZEHINT(6) override;
420  void GetBounds(double bounds[6]) override
421  { this->vtkAbstractMapper3D::GetBounds(bounds); }
422 
428  void SetRenderTime(double time) {this->RenderTime = time;}
429  vtkGetMacro(RenderTime, double);
430 
435  vtkDataSet *GetInput();
436 
444  { return this->GetInput(); }
445 
447 
454  virtual vtkUnsignedCharArray *MapScalars(double alpha);
455  virtual vtkUnsignedCharArray *MapScalars(double alpha,
456  int &cellFlag);
457  virtual vtkUnsignedCharArray *MapScalars(vtkDataSet *input,
458  double alpha);
459  virtual vtkUnsignedCharArray *MapScalars(vtkDataSet *input,
460  double alpha,
461  int &cellFlag);
463 
472  virtual bool GetIsOpaque();
473 
480  virtual bool GetSupportsSelection()
481  { return false; }
482 
491  virtual int CanUseTextureMapForColoring(vtkDataObject* input);
492 
497  void ClearColorArrays();
498 
502  vtkUnsignedCharArray *GetColorMapColors();
503 
507  vtkFloatArray *GetColorCoordinates();
508 
512  vtkImageData* GetColorTextureMap();
513 
514 protected:
515  vtkMapper();
516  ~vtkMapper() override;
517 
518  // color mapped colors
520 
521  // Use texture coordinates for coloring.
523  // Coordinate for each point.
525  // 1D ColorMap used for the texture image.
527  void MapScalarsToTexture(vtkAbstractArray* scalars, double alpha);
528 
532  double ScalarRange[2];
534 
537 
538  double RenderTime;
539 
540  // for coloring by a component of a field data array
541  int ArrayId;
542  char* ArrayName;
545 
546  // If coloring by field data, which tuple to use to color the entire
547  // data set. If -1, treat array values as cell data.
549 
551 
557 
558 private:
559  vtkMapper(const vtkMapper&) = delete;
560  void operator=(const vtkMapper&) = delete;
561 };
562 
563 #endif
vtkIdType FieldDataTupleId
Definition: vtkMapper.h:548
#define VTK_COLOR_MODE_DIRECT_SCALARS
void SetScalarModeToUsePointData()
Definition: vtkMapper.h:235
void SetScalarModeToDefault()
Definition: vtkMapper.h:233
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:311
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:45
#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:443
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: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:307
record modification and/or execution time
Definition: vtkTimeStamp.h:32
void SetScalarModeToUseCellData()
Definition: vtkMapper.h:237
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:35
vtkImageData * ColorTextureMap
Definition: vtkMapper.h:526
#define VTK_RESOLVE_SHIFT_ZBUFFER
Definition: vtkMapper.h:57
vtkTimeStamp BuildTime
Definition: vtkMapper.h:531
void SetColorModeToDefault()
default (ColorModeToDefault), unsigned char scalars are treated as colors, and NOT mapped through the...
Definition: vtkMapper.h:157
abstract specification for renderers
Definition: vtkRenderer.h:57
int ArrayAccessMode
Definition: vtkMapper.h:544
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:309
vtkTypeBool Static
Definition: vtkMapper.h:550
void SetScalarModeToUseFieldData()
Definition: vtkMapper.h:243
int vtkIdType
Definition: vtkType.h:345
double CoincidentLineFactor
Definition: vtkMapper.h:554
vtkUnsignedCharArray * Colors
Definition: vtkMapper.h:519
vtkTypeBool ScalarVisibility
Definition: vtkMapper.h:530
void SetColorModeToDirectScalars()
default (ColorModeToDefault), unsigned char scalars are treated as colors, and NOT mapped through the...
Definition: vtkMapper.h:161
int ScalarMode
Definition: vtkMapper.h:536
int vtkTypeBool
Definition: vtkABI.h:69
Superclass for mapping scalar values to colors.
window superclass for vtkRenderWindow
Definition: vtkWindow.h:34
double CoincidentPointOffset
Definition: vtkMapper.h:556
void SetRenderTime(double time)
This instance variable is used by vtkLODActor to determine which mapper to use.
Definition: vtkMapper.h:428
#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:239
double CoincidentLineOffset
Definition: vtkMapper.h:555
topologically and geometrically regular array of data
Definition: vtkImageData.h:39
#define VTK_SCALAR_MODE_USE_POINT_FIELD_DATA
double CoincidentPolygonFactor
Definition: vtkMapper.h:552
double CoincidentPolygonOffset
Definition: vtkMapper.h:553
virtual double * GetBounds()=0
Return bounding box (array of six doubles) of data expressed as (xmin,xmax, ymin,ymax,...
abstract class specifies interface to map 3D data
#define VTK_COLOR_MODE_DEFAULT
#define VTK_SIZEHINT(...)
#define VTK_SCALAR_MODE_USE_FIELD_DATA
abstract class specifies interface to map data to graphics primitives
Definition: vtkMapper.h:77
dynamic, self-adjusting array of unsigned char
abstract class specifies interface to map data
int ArrayId
Definition: vtkMapper.h:541
char * ArrayName
Definition: vtkMapper.h:542
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:159
int ArrayComponent
Definition: vtkMapper.h:543
void ShallowCopy(vtkAbstractMapper *m)
Make a shallow copy of this mapper.
vtkTypeBool UseLookupTableScalarRange
Definition: vtkMapper.h:533
vtkFloatArray * ColorCoordinates
Definition: vtkMapper.h:524
virtual bool GetSupportsSelection()
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THIS METHOD OUTSIDE OF THE RENDERI...
Definition: vtkMapper.h:480
#define VTK_SCALAR_MODE_USE_CELL_DATA
#define VTK_RESOLVE_POLYGON_OFFSET
Definition: vtkMapper.h:56
general representation of visualization data
Definition: vtkDataObject.h:58
void SetScalarModeToUseCellFieldData()
Definition: vtkMapper.h:241
vtkScalarsToColors * LookupTable
Definition: vtkMapper.h:529
void ReleaseGraphicsResources(vtkWindow *) override
Release any graphics resources that are being consumed by this mapper.
Definition: vtkMapper.h:105
double RenderTime
Definition: vtkMapper.h:538
#define VTK_SCALAR_MODE_DEFAULT
vtkTypeBool InterpolateScalarsBeforeMapping
Definition: vtkMapper.h:522
#define VTK_RESOLVE_OFF
Definition: vtkMapper.h:55
int ColorMode
Definition: vtkMapper.h:535