VTK  9.0.1
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 "vtkAbstractMapper3D.h"
51 #include "vtkRenderingCoreModule.h" // For export macro
52 #include "vtkSmartPointer.h" // needed for vtkSmartPointer.
53 #include "vtkSystemIncludes.h" // For VTK_COLOR_MODE_DEFAULT and _MAP_SCALARS
54 #include <vector> // for method args
55 
56 #define VTK_RESOLVE_OFF 0
57 #define VTK_RESOLVE_POLYGON_OFFSET 1
58 #define VTK_RESOLVE_SHIFT_ZBUFFER 2
59 
60 #define VTK_GET_ARRAY_BY_ID 0
61 #define VTK_GET_ARRAY_BY_NAME 1
62 
63 #define VTK_MATERIALMODE_DEFAULT 0
64 #define VTK_MATERIALMODE_AMBIENT 1
65 #define VTK_MATERIALMODE_DIFFUSE 2
66 #define VTK_MATERIALMODE_AMBIENT_AND_DIFFUSE 3
67 
68 class vtkActor;
69 class vtkDataSet;
70 class vtkDataObject;
71 class vtkFloatArray;
73 class vtkImageData;
74 class vtkProp;
75 class vtkRenderer;
76 class vtkScalarsToColors;
78 class vtkWindow;
79 
80 class VTKRENDERINGCORE_EXPORT vtkMapper : public vtkAbstractMapper3D
81 {
82 public:
84  void PrintSelf(ostream& os, vtkIndent indent) override;
85 
89  void ShallowCopy(vtkAbstractMapper* m) override;
90 
95  vtkMTimeType GetMTime() override;
96 
101  virtual void Render(vtkRenderer* ren, vtkActor* a) = 0;
102 
109 
111 
114  void SetLookupTable(vtkScalarsToColors* lut);
115  vtkScalarsToColors* GetLookupTable();
117 
122  virtual void CreateDefaultLookupTable();
123 
125 
128  vtkSetMacro(ScalarVisibility, vtkTypeBool);
129  vtkGetMacro(ScalarVisibility, vtkTypeBool);
130  vtkBooleanMacro(ScalarVisibility, vtkTypeBool);
132 
134 
140  vtkSetMacro(Static, vtkTypeBool);
141  vtkGetMacro(Static, vtkTypeBool);
142  vtkBooleanMacro(Static, vtkTypeBool);
144 
146 
158  vtkSetMacro(ColorMode, int);
159  vtkGetMacro(ColorMode, int);
160  void SetColorModeToDefault() { this->SetColorMode(VTK_COLOR_MODE_DEFAULT); }
161  void SetColorModeToMapScalars() { this->SetColorMode(VTK_COLOR_MODE_MAP_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);
233  void SetScalarModeToDefault() { this->SetScalarMode(VTK_SCALAR_MODE_DEFAULT); }
237  {
238  this->SetScalarMode(VTK_SCALAR_MODE_USE_POINT_FIELD_DATA);
239  }
241  {
242  this->SetScalarMode(VTK_SCALAR_MODE_USE_CELL_FIELD_DATA);
243  }
245 
247 
252  void SelectColorArray(int arrayNum);
253  void SelectColorArray(const char* arrayName);
255 
256  // When ScalarMode is set to UseFieldData, set the index of the
257  // tuple by which to color the entire data set. By default, the
258  // index is -1, which means to treat the field data array selected
259  // with SelectColorArray as having a scalar value for each cell.
260  // Indices of 0 or higher mean to use the tuple at the given index
261  // for coloring the entire data set.
262  vtkSetMacro(FieldDataTupleId, vtkIdType);
263  vtkGetMacro(FieldDataTupleId, vtkIdType);
264 
266 
271  void ColorByArrayComponent(int arrayNum, int component);
272  void ColorByArrayComponent(const char* arrayName, int component);
274 
278  vtkGetStringMacro(ArrayName);
279  vtkSetStringMacro(ArrayName);
280  vtkGetMacro(ArrayId, int);
281  vtkSetMacro(ArrayId, int);
282  vtkGetMacro(ArrayAccessMode, int);
283  vtkSetMacro(ArrayAccessMode, int);
284  vtkGetMacro(ArrayComponent, int);
285  vtkSetMacro(ArrayComponent, int);
286 
290  const char* GetScalarModeAsString();
291 
293 
303  static void SetResolveCoincidentTopology(int val);
304  static int GetResolveCoincidentTopology();
305  static void SetResolveCoincidentTopologyToDefault();
306  static void SetResolveCoincidentTopologyToOff() { SetResolveCoincidentTopology(VTK_RESOLVE_OFF); }
308  {
309  SetResolveCoincidentTopology(VTK_RESOLVE_POLYGON_OFFSET);
310  }
312  {
313  SetResolveCoincidentTopology(VTK_RESOLVE_SHIFT_ZBUFFER);
314  }
316 
318 
323  static void SetResolveCoincidentTopologyPolygonOffsetParameters(double factor, double units);
324  static void GetResolveCoincidentTopologyPolygonOffsetParameters(double& factor, double& units);
326 
328 
332  void SetRelativeCoincidentTopologyPolygonOffsetParameters(double factor, double units);
333  void GetRelativeCoincidentTopologyPolygonOffsetParameters(double& factor, double& units);
335 
337 
342  static void SetResolveCoincidentTopologyLineOffsetParameters(double factor, double units);
343  static void GetResolveCoincidentTopologyLineOffsetParameters(double& factor, double& units);
345 
347 
351  void SetRelativeCoincidentTopologyLineOffsetParameters(double factor, double units);
352  void GetRelativeCoincidentTopologyLineOffsetParameters(double& factor, double& units);
354 
356 
361  static void SetResolveCoincidentTopologyPointOffsetParameter(double units);
362  static void GetResolveCoincidentTopologyPointOffsetParameter(double& units);
364 
366 
370  void SetRelativeCoincidentTopologyPointOffsetParameter(double units);
371  void GetRelativeCoincidentTopologyPointOffsetParameter(double& units);
373 
375 
379  void GetCoincidentTopologyPolygonOffsetParameters(double& factor, double& units);
380  void GetCoincidentTopologyLineOffsetParameters(double& factor, double& units);
381  void GetCoincidentTopologyPointOffsetParameter(double& units);
383 
385 
392  static void SetResolveCoincidentTopologyPolygonOffsetFaces(int faces);
393  static int GetResolveCoincidentTopologyPolygonOffsetFaces();
395 
397 
401  static void SetResolveCoincidentTopologyZShift(double val);
402  static double GetResolveCoincidentTopologyZShift();
404 
409  double* GetBounds() VTK_SIZEHINT(6) override;
410  void GetBounds(double bounds[6]) override { this->vtkAbstractMapper3D::GetBounds(bounds); }
411 
417  void SetRenderTime(double time) { this->RenderTime = time; }
418  vtkGetMacro(RenderTime, double);
419 
424  vtkDataSet* GetInput();
425 
432  vtkDataSet* GetInputAsDataSet() { return this->GetInput(); }
433 
435 
442  virtual vtkUnsignedCharArray* MapScalars(double alpha);
443  virtual vtkUnsignedCharArray* MapScalars(double alpha, int& cellFlag);
444  virtual vtkUnsignedCharArray* MapScalars(vtkDataSet* input, double alpha);
445  virtual vtkUnsignedCharArray* MapScalars(vtkDataSet* input, double alpha, int& cellFlag);
447 
449 
454  virtual bool HasOpaqueGeometry();
455  virtual bool HasTranslucentPolygonalGeometry();
457 
464  virtual bool GetSupportsSelection() { return false; }
465 
471  std::vector<unsigned int>& /* pixeloffsets */, vtkProp* /* prop */)
472  {
473  }
474 
483  virtual int CanUseTextureMapForColoring(vtkDataObject* input);
484 
489  void ClearColorArrays();
490 
494  vtkUnsignedCharArray* GetColorMapColors();
495 
499  vtkFloatArray* GetColorCoordinates();
500 
504  vtkImageData* GetColorTextureMap();
505 
506 protected:
507  vtkMapper();
508  ~vtkMapper() override;
509 
510  // color mapped colors
512 
513  // Use texture coordinates for coloring.
515  // Coordinate for each point.
517  // 1D ColorMap used for the texture image.
519  void MapScalarsToTexture(vtkAbstractArray* scalars, double alpha);
520 
524  double ScalarRange[2];
526 
529 
530  double RenderTime;
531 
532  // for coloring by a component of a field data array
533  int ArrayId;
534  char* ArrayName;
537 
538  // If coloring by field data, which tuple to use to color the entire
539  // data set. If -1, treat array values as cell data.
541 
543 
549 
550 private:
551  vtkMapper(const vtkMapper&) = delete;
552  void operator=(const vtkMapper&) = delete;
553 };
554 
555 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:53
vtkIdType FieldDataTupleId
Definition: vtkMapper.h:540
#define VTK_COLOR_MODE_DIRECT_SCALARS
void SetScalarModeToUsePointData()
Definition: vtkMapper.h:234
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:432
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:293
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:306
record modification and/or execution time
Definition: vtkTimeStamp.h:32
void SetScalarModeToUseCellData()
Definition: vtkMapper.h:235
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:35
vtkImageData * ColorTextureMap
Definition: vtkMapper.h:518
#define VTK_RESOLVE_SHIFT_ZBUFFER
Definition: vtkMapper.h:58
vtkTimeStamp BuildTime
Definition: vtkMapper.h:523
void SetColorModeToDefault()
default (ColorModeToDefault), unsigned char scalars are treated as colors, and NOT mapped through the...
Definition: vtkMapper.h:160
abstract specification for renderers
Definition: vtkRenderer.h:67
int ArrayAccessMode
Definition: vtkMapper.h:536
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:307
vtkTypeBool Static
Definition: vtkMapper.h:542
void SetScalarModeToUseFieldData()
Definition: vtkMapper.h:244
virtual void ProcessSelectorPixelBuffers(vtkHardwareSelector *, std::vector< unsigned int > &, vtkProp *)
allows a mapper to update a selections color buffers Called from a prop which in turn is called from ...
Definition: vtkMapper.h:470
int vtkIdType
Definition: vtkType.h:338
double CoincidentLineFactor
Definition: vtkMapper.h:546
vtkUnsignedCharArray * Colors
Definition: vtkMapper.h:511
vtkTypeBool ScalarVisibility
Definition: vtkMapper.h:522
void SetColorModeToDirectScalars()
default (ColorModeToDefault), unsigned char scalars are treated as colors, and NOT mapped through the...
Definition: vtkMapper.h:162
int ScalarMode
Definition: vtkMapper.h:528
int vtkTypeBool
Definition: vtkABI.h:69
Superclass for mapping scalar values to colors.
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
double CoincidentPointOffset
Definition: vtkMapper.h:548
void SetRenderTime(double time)
This instance variable is used by vtkLODActor to determine which mapper to use.
Definition: vtkMapper.h:417
#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:236
double CoincidentLineOffset
Definition: vtkMapper.h:547
topologically and geometrically regular array of data
Definition: vtkImageData.h:41
#define VTK_SCALAR_MODE_USE_POINT_FIELD_DATA
virtual void ShallowCopy(vtkAbstractMapper *m)
Make a shallow copy of this mapper.
double CoincidentPolygonFactor
Definition: vtkMapper.h:544
double CoincidentPolygonOffset
Definition: vtkMapper.h:545
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
#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:80
dynamic, self-adjusting array of unsigned char
abstract class specifies interface to map data
int ArrayId
Definition: vtkMapper.h:533
char * ArrayName
Definition: vtkMapper.h:534
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:161
int ArrayComponent
Definition: vtkMapper.h:535
vtkTypeBool UseLookupTableScalarRange
Definition: vtkMapper.h:525
vtkFloatArray * ColorCoordinates
Definition: vtkMapper.h:516
virtual bool GetSupportsSelection()
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THIS METHOD OUTSIDE OF THE RENDERI...
Definition: vtkMapper.h:464
#define VTK_SCALAR_MODE_USE_CELL_DATA
#define VTK_RESOLVE_POLYGON_OFFSET
Definition: vtkMapper.h:57
general representation of visualization data
Definition: vtkDataObject.h:59
void SetScalarModeToUseCellFieldData()
Definition: vtkMapper.h:240
vtkScalarsToColors * LookupTable
Definition: vtkMapper.h:521
void ReleaseGraphicsResources(vtkWindow *) override
Release any graphics resources that are being consumed by this mapper.
Definition: vtkMapper.h:108
double RenderTime
Definition: vtkMapper.h:530
#define VTK_SCALAR_MODE_DEFAULT
vtkTypeBool InterpolateScalarsBeforeMapping
Definition: vtkMapper.h:514
#define VTK_RESOLVE_OFF
Definition: vtkMapper.h:56
int ColorMode
Definition: vtkMapper.h:527