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 #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 
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);
161  { this->SetColorMode(VTK_COLOR_MODE_DEFAULT); }
163  { this->SetColorMode(VTK_COLOR_MODE_MAP_SCALARS); }
165  { this->SetColorMode(VTK_COLOR_MODE_DIRECT_SCALARS); }
167 
171  const char *GetColorModeAsString();
172 
174 
180  vtkSetMacro(InterpolateScalarsBeforeMapping, vtkTypeBool);
181  vtkGetMacro(InterpolateScalarsBeforeMapping, vtkTypeBool);
182  vtkBooleanMacro(InterpolateScalarsBeforeMapping, vtkTypeBool);
184 
186 
194  vtkSetMacro(UseLookupTableScalarRange, vtkTypeBool);
195  vtkGetMacro(UseLookupTableScalarRange, vtkTypeBool);
196  vtkBooleanMacro(UseLookupTableScalarRange, vtkTypeBool);
198 
200 
205  vtkSetVector2Macro(ScalarRange, double);
206  vtkGetVectorMacro(ScalarRange, double, 2);
208 
222  // When ScalarMode is set to use Field Data (ScalarModeToFieldData),
223  // you must call SelectColorArray to choose the field data array to
224  // be used to color cells. In this mode, the default behavior is to
225  // treat the field data tuples as being associated with cells. If
226  // the poly data contains triangle strips, the array is expected to
227  // contain the cell data for each mini-cell formed by any triangle
228  // strips in the poly data as opposed to treating them as a single
229  // tuple that applies to the entire strip. This mode can also be
230  // used to color the entire poly data by a single color obtained by
231  // mapping the tuple at a given index in the field data array
232  // through the color map. Use SetFieldDataTupleId() to specify
233  // the tuple index.
234  vtkSetMacro(ScalarMode, int);
235  vtkGetMacro(ScalarMode, int);
237  { this->SetScalarMode(VTK_SCALAR_MODE_DEFAULT); }
239  { this->SetScalarMode(VTK_SCALAR_MODE_USE_POINT_DATA); }
241  { this->SetScalarMode(VTK_SCALAR_MODE_USE_CELL_DATA); }
243  { this->SetScalarMode(VTK_SCALAR_MODE_USE_POINT_FIELD_DATA); }
245  { this->SetScalarMode(VTK_SCALAR_MODE_USE_CELL_FIELD_DATA); }
247  { this->SetScalarMode(VTK_SCALAR_MODE_USE_FIELD_DATA); }
248 
250 
255  void SelectColorArray(int arrayNum);
256  void SelectColorArray(const char* arrayName);
258 
259 
260  // When ScalarMode is set to UseFieldData, set the index of the
261  // tuple by which to color the entire data set. By default, the
262  // index is -1, which means to treat the field data array selected
263  // with SelectColorArray as having a scalar value for each cell.
264  // Indices of 0 or higher mean to use the tuple at the given index
265  // for coloring the entire data set.
266  vtkSetMacro(FieldDataTupleId, vtkIdType);
267  vtkGetMacro(FieldDataTupleId, vtkIdType);
268 
270 
275  void ColorByArrayComponent(int arrayNum, int component);
276  void ColorByArrayComponent(const char* arrayName, int component);
278 
282  vtkGetStringMacro(ArrayName);
283  vtkSetStringMacro(ArrayName);
284  vtkGetMacro(ArrayId, int);
285  vtkSetMacro(ArrayId, int);
286  vtkGetMacro(ArrayAccessMode, int);
287  vtkSetMacro(ArrayAccessMode, int);
288  vtkGetMacro(ArrayComponent, int);
289  vtkSetMacro(ArrayComponent, int);
290 
294  const char *GetScalarModeAsString();
295 
297 
307  static void SetResolveCoincidentTopology(int val);
308  static int GetResolveCoincidentTopology();
309  static void SetResolveCoincidentTopologyToDefault();
311  { SetResolveCoincidentTopology(VTK_RESOLVE_OFF) ;}
313  { SetResolveCoincidentTopology(VTK_RESOLVE_POLYGON_OFFSET); }
315  { SetResolveCoincidentTopology(VTK_RESOLVE_SHIFT_ZBUFFER); }
317 
319 
324  static void SetResolveCoincidentTopologyPolygonOffsetParameters(
325  double factor, double units);
326  static void GetResolveCoincidentTopologyPolygonOffsetParameters(
327  double& factor, double& units);
329 
331 
335  void SetRelativeCoincidentTopologyPolygonOffsetParameters(
336  double factor, double units);
337  void GetRelativeCoincidentTopologyPolygonOffsetParameters(
338  double& factor, double& units);
340 
342 
347  static void SetResolveCoincidentTopologyLineOffsetParameters(
348  double factor, double units);
349  static void GetResolveCoincidentTopologyLineOffsetParameters(
350  double& factor, double& units);
352 
354 
358  void SetRelativeCoincidentTopologyLineOffsetParameters(
359  double factor, double units);
360  void GetRelativeCoincidentTopologyLineOffsetParameters(
361  double& factor, double& units);
363 
365 
370  static void SetResolveCoincidentTopologyPointOffsetParameter(
371  double units);
372  static void GetResolveCoincidentTopologyPointOffsetParameter(
373  double& units);
375 
377 
381  void SetRelativeCoincidentTopologyPointOffsetParameter(double units);
382  void GetRelativeCoincidentTopologyPointOffsetParameter(double& units);
384 
386 
390  void GetCoincidentTopologyPolygonOffsetParameters(
391  double& factor, double& units);
392  void GetCoincidentTopologyLineOffsetParameters(
393  double& factor, double& units);
394  void GetCoincidentTopologyPointOffsetParameter(double& units);
396 
398 
405  static void SetResolveCoincidentTopologyPolygonOffsetFaces(int faces);
406  static int GetResolveCoincidentTopologyPolygonOffsetFaces();
408 
410 
414  static void SetResolveCoincidentTopologyZShift(double val);
415  static double GetResolveCoincidentTopologyZShift();
417 
422  double *GetBounds() VTK_SIZEHINT(6) override;
423  void GetBounds(double bounds[6]) override
424  { this->vtkAbstractMapper3D::GetBounds(bounds); }
425 
431  void SetRenderTime(double time) {this->RenderTime = time;}
432  vtkGetMacro(RenderTime, double);
433 
438  vtkDataSet *GetInput();
439 
447  { return this->GetInput(); }
448 
450 
457  virtual vtkUnsignedCharArray *MapScalars(double alpha);
458  virtual vtkUnsignedCharArray *MapScalars(double alpha,
459  int &cellFlag);
460  virtual vtkUnsignedCharArray *MapScalars(vtkDataSet *input,
461  double alpha);
462  virtual vtkUnsignedCharArray *MapScalars(vtkDataSet *input,
463  double alpha,
464  int &cellFlag);
466 
475  virtual bool GetIsOpaque();
476 
483  virtual bool GetSupportsSelection()
484  { return false; }
485 
491  std::vector<unsigned int> & /* pixeloffsets */,
492  vtkProp * /* prop */) { };
493 
502  virtual int CanUseTextureMapForColoring(vtkDataObject* input);
503 
508  void ClearColorArrays();
509 
513  vtkUnsignedCharArray *GetColorMapColors();
514 
518  vtkFloatArray *GetColorCoordinates();
519 
523  vtkImageData* GetColorTextureMap();
524 
525 protected:
526  vtkMapper();
527  ~vtkMapper() override;
528 
529  // color mapped colors
531 
532  // Use texture coordinates for coloring.
534  // Coordinate for each point.
536  // 1D ColorMap used for the texture image.
538  void MapScalarsToTexture(vtkAbstractArray* scalars, double alpha);
539 
543  double ScalarRange[2];
545 
548 
549  double RenderTime;
550 
551  // for coloring by a component of a field data array
552  int ArrayId;
553  char* ArrayName;
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 
562 
568 
569 private:
570  vtkMapper(const vtkMapper&) = delete;
571  void operator=(const vtkMapper&) = delete;
572 };
573 
574 #endif
vtkMapper::SetResolveCoincidentTopologyToOff
static void SetResolveCoincidentTopologyToOff()
Definition: vtkMapper.h:310
VTK_SCALAR_MODE_DEFAULT
#define VTK_SCALAR_MODE_DEFAULT
Definition: vtkAbstractMapper.h:34
vtkMapper::SetScalarModeToUsePointData
void SetScalarModeToUsePointData()
Definition: vtkMapper.h:238
VTK_SCALAR_MODE_USE_CELL_FIELD_DATA
#define VTK_SCALAR_MODE_USE_CELL_FIELD_DATA
Definition: vtkAbstractMapper.h:38
VTK_SCALAR_MODE_USE_POINT_DATA
#define VTK_SCALAR_MODE_USE_POINT_DATA
Definition: vtkAbstractMapper.h:35
VTK_COLOR_MODE_MAP_SCALARS
#define VTK_COLOR_MODE_MAP_SCALARS
Definition: vtkSystemIncludes.h:103
vtkMapper::SetResolveCoincidentTopologyToShiftZBuffer
static void SetResolveCoincidentTopologyToShiftZBuffer()
Definition: vtkMapper.h:314
vtkX3D::alpha
Definition: vtkX3D.h:250
vtkX3D::component
Definition: vtkX3D.h:175
vtkMapper::SetColorModeToDefault
void SetColorModeToDefault()
Definition: vtkMapper.h:160
VTK_SCALAR_MODE_USE_POINT_FIELD_DATA
#define VTK_SCALAR_MODE_USE_POINT_FIELD_DATA
Definition: vtkAbstractMapper.h:37
vtkAbstractMapper3D::GetBounds
virtual double * GetBounds()=0
Return bounding box (array of six doubles) of data expressed as (xmin,xmax, ymin,ymax,...
vtkMapper::CoincidentPointOffset
double CoincidentPointOffset
Definition: vtkMapper.h:567
vtkIdType
int vtkIdType
Definition: vtkType.h:347
vtkMapper::ArrayId
int ArrayId
Definition: vtkMapper.h:552
VTK_RESOLVE_POLYGON_OFFSET
#define VTK_RESOLVE_POLYGON_OFFSET
Definition: vtkMapper.h:57
vtkFloatArray
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:35
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:32
vtkAbstractMapper::GetMTime
vtkMTimeType GetMTime() override
Override Modifiedtime as we have added Clipping planes.
vtkUnsignedCharArray
dynamic, self-adjusting array of unsigned char
Definition: vtkUnsignedCharArray.h:35
vtkMapper::ColorTextureMap
vtkImageData * ColorTextureMap
Definition: vtkMapper.h:537
vtkMapper::CoincidentPolygonOffset
double CoincidentPolygonOffset
Definition: vtkMapper.h:564
vtkX3D::time
Definition: vtkX3D.h:497
vtkMapper::SetRenderTime
void SetRenderTime(double time)
This instance variable is used by vtkLODActor to determine which mapper to use.
Definition: vtkMapper.h:431
vtkMapper::Colors
vtkUnsignedCharArray * Colors
Definition: vtkMapper.h:530
vtkAbstractMapper3D.h
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:34
vtkMapper::CoincidentPolygonFactor
double CoincidentPolygonFactor
Definition: vtkMapper.h:563
vtkMapper::SetScalarModeToDefault
void SetScalarModeToDefault()
Definition: vtkMapper.h:236
vtkMapper::ScalarVisibility
vtkTypeBool ScalarVisibility
Definition: vtkMapper.h:541
vtkMapper::SetScalarModeToUseCellData
void SetScalarModeToUseCellData()
Definition: vtkMapper.h:240
vtkAbstractMapper3D::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
VTK_SCALAR_MODE_USE_CELL_DATA
#define VTK_SCALAR_MODE_USE_CELL_DATA
Definition: vtkAbstractMapper.h:36
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:42
vtkMapper::InterpolateScalarsBeforeMapping
vtkTypeBool InterpolateScalarsBeforeMapping
Definition: vtkMapper.h:533
vtkMapper::ProcessSelectorPixelBuffers
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:490
vtkMapper::BuildTime
vtkTimeStamp BuildTime
Definition: vtkMapper.h:542
vtkMapper::ArrayAccessMode
int ArrayAccessMode
Definition: vtkMapper.h:555
vtkMapper
abstract class specifies interface to map data to graphics primitives
Definition: vtkMapper.h:80
vtkHardwareSelector
Definition: vtkHardwareSelector.h:123
VTK_RESOLVE_OFF
#define VTK_RESOLVE_OFF
Definition: vtkMapper.h:56
VTK_SCALAR_MODE_USE_FIELD_DATA
#define VTK_SCALAR_MODE_USE_FIELD_DATA
Definition: vtkAbstractMapper.h:39
vtkMapper::FieldDataTupleId
vtkIdType FieldDataTupleId
Definition: vtkMapper.h:559
vtkMapper::ColorCoordinates
vtkFloatArray * ColorCoordinates
Definition: vtkMapper.h:535
vtkActor
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:45
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:39
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkSmartPointer.h
vtkMapper::RenderTime
double RenderTime
Definition: vtkMapper.h:549
vtkScalarsToColors
Superclass for mapping scalar values to colors.
Definition: vtkScalarsToColors.h:60
vtkMapper::SetScalarModeToUseFieldData
void SetScalarModeToUseFieldData()
Definition: vtkMapper.h:246
vtkMapper::ArrayName
char * ArrayName
Definition: vtkMapper.h:553
vtkMapper::GetInputAsDataSet
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:446
vtkMapper::ReleaseGraphicsResources
void ReleaseGraphicsResources(vtkWindow *) override
Release any graphics resources that are being consumed by this mapper.
Definition: vtkMapper.h:108
vtkDataSet
abstract class to specify dataset behavior
Definition: vtkDataSet.h:56
vtkAbstractArray
Abstract superclass for all arrays.
Definition: vtkAbstractArray.h:75
vtkMapper::ColorMode
int ColorMode
Definition: vtkMapper.h:546
vtkMapper::GetSupportsSelection
virtual bool GetSupportsSelection()
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THIS METHOD OUTSIDE OF THE RENDERI...
Definition: vtkMapper.h:483
vtkProp
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:46
vtkMapper::SetColorModeToDirectScalars
void SetColorModeToDirectScalars()
Definition: vtkMapper.h:164
VTK_COLOR_MODE_DEFAULT
#define VTK_COLOR_MODE_DEFAULT
Definition: vtkSystemIncludes.h:102
vtkAbstractMapper3D
abstract class specifies interface to map 3D data
Definition: vtkAbstractMapper3D.h:42
vtkMapper::SetColorModeToMapScalars
void SetColorModeToMapScalars()
Definition: vtkMapper.h:162
vtkMapper::CoincidentLineOffset
double CoincidentLineOffset
Definition: vtkMapper.h:566
vtkMapper::Static
vtkTypeBool Static
Definition: vtkMapper.h:561
vtkMapper::SetResolveCoincidentTopologyToPolygonOffset
static void SetResolveCoincidentTopologyToPolygonOffset()
Definition: vtkMapper.h:312
vtkRenderer
abstract specification for renderers
Definition: vtkRenderer.h:57
VTK_RESOLVE_SHIFT_ZBUFFER
#define VTK_RESOLVE_SHIFT_ZBUFFER
Definition: vtkMapper.h:58
vtkMapper::LookupTable
vtkScalarsToColors * LookupTable
Definition: vtkMapper.h:540
vtkMapper::UseLookupTableScalarRange
vtkTypeBool UseLookupTableScalarRange
Definition: vtkMapper.h:544
VTK_COLOR_MODE_DIRECT_SCALARS
#define VTK_COLOR_MODE_DIRECT_SCALARS
Definition: vtkSystemIncludes.h:104
vtkMapper::CoincidentLineFactor
double CoincidentLineFactor
Definition: vtkMapper.h:565
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:58
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkMapper::SetScalarModeToUsePointFieldData
void SetScalarModeToUsePointFieldData()
Definition: vtkMapper.h:242
vtkMapper::ArrayComponent
int ArrayComponent
Definition: vtkMapper.h:554
vtkAbstractMapper::ShallowCopy
void ShallowCopy(vtkAbstractMapper *m)
Make a shallow copy of this mapper.
vtkSystemIncludes.h
vtkAbstractMapper
abstract class specifies interface to map data
Definition: vtkAbstractMapper.h:52
vtkMTimeType
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:302
vtkMapper::ScalarMode
int ScalarMode
Definition: vtkMapper.h:547
vtkMapper::SetScalarModeToUseCellFieldData
void SetScalarModeToUseCellFieldData()
Definition: vtkMapper.h:244