VTK  9.3.1
vtkCompositePolyDataMapper2.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
19 #ifndef vtkCompositePolyDataMapper2_h
20 #define vtkCompositePolyDataMapper2_h
21 
22 #include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_3_0
23 #include "vtkRenderingOpenGL2Module.h" // For export macro
24 #include "vtkSmartPointer.h" // for vtkSmartPointer
25 #include "vtk_glew.h" // for OpenGL enums
26 // clang-format off
27 // Must be included after vtk_glew.h for GL_ES_VERSION_3_0
28 #ifndef GL_ES_VERSION_3_0
30 #define vtkOpenGLPolyDataMapperImplementation vtkOpenGLPolyDataMapper
31 #else
33 #define vtkOpenGLPolyDataMapperImplementation vtkOpenGLES30PolyDataMapper
34 #endif
35 // clang-format on
36 
37 #include "vtkColor.h" // used for ivars
38 #include <map> // use for ivars
39 #include <stack> // used for ivars
40 #include <vector> // used for ivars
41 
42 VTK_ABI_NAMESPACE_BEGIN
46 
48  VTKRENDERINGOPENGL2_EXPORT vtkCompositePolyDataMapper2
50 {
51 public:
52  static vtkCompositePolyDataMapper2* New();
54  void PrintSelf(ostream& os, vtkIndent indent) override;
55 
57 
62  bool HasOpaqueGeometry() override;
63  bool HasTranslucentPolygonalGeometry() override;
65 
67 
70  void SetCompositeDataDisplayAttributes(vtkCompositeDataDisplayAttributes* attributes);
71  vtkCompositeDataDisplayAttributes* GetCompositeDataDisplayAttributes();
73 
75 
78  void SetBlockVisibility(unsigned int index, bool visible);
79  bool GetBlockVisibility(unsigned int index);
80  void RemoveBlockVisibility(unsigned int index);
81  void RemoveBlockVisibilities();
83 
85 
88  void SetBlockColor(unsigned int index, const double color[3]);
89  void SetBlockColor(unsigned int index, double r, double g, double b)
90  {
91  double color[3] = { r, g, b };
92  this->SetBlockColor(index, color);
93  }
94  double* GetBlockColor(unsigned int index);
95  void RemoveBlockColor(unsigned int index);
96  void RemoveBlockColors();
98 
100 
103  void SetBlockOpacity(unsigned int index, double opacity);
104  double GetBlockOpacity(unsigned int index);
105  void RemoveBlockOpacity(unsigned int index);
106  void RemoveBlockOpacities();
108 
115  vtkSetMacro(ColorMissingArraysWithNanColor, bool);
116  vtkGetMacro(ColorMissingArraysWithNanColor, bool);
117  vtkBooleanMacro(ColorMissingArraysWithNanColor, bool);
125  void ReleaseGraphicsResources(vtkWindow*) override;
126 
130  void Render(vtkRenderer* ren, vtkActor* act) override;
131 
135  void SetVBOShiftScaleMethod(int m) override;
136 
141  void SetPauseShiftScale(bool pauseShiftScale) override;
142 
144 
148  void SetInputArrayToProcess(
149  int idx, int port, int connection, int fieldAssociation, const char* name) override;
150  void SetInputArrayToProcess(
151  int idx, int port, int connection, int fieldAssociation, int fieldAttributeType) override;
152  void SetInputArrayToProcess(int idx, vtkInformation* info) override;
154 
158  std::vector<vtkPolyData*> GetRenderedList() { return this->RenderedList; }
159 
164  void ProcessSelectorPixelBuffers(
165  vtkHardwareSelector* sel, std::vector<unsigned int>& pixeloffsets, vtkProp* prop) override;
166 
170  vtkMTimeType GetMTime() override;
171 
172 protected:
174  ~vtkCompositePolyDataMapper2() override;
175 
181  vtkExecutive* CreateDefaultExecutive() override;
182 
186  int FillInputPortInformation(int port, vtkInformation* info) override;
187 
191  void ComputeBounds() override;
192 
198  vtkRenderer* vtkNotUsed(ren), vtkActor* vtkNotUsed(act))
199  {
200  }
201 
206 
207  // what "index" are we currently rendering, -1 means none
209  std::map<const std::string, vtkCompositeMapperHelper2*> Helpers;
210  std::map<vtkPolyData*, vtkCompositeMapperHelperData*> HelperDataMap;
212 
213  virtual vtkCompositeMapperHelper2* CreateHelper();
214 
215  // copy values to the helpers
216  virtual void CopyMapperValuesToHelper(vtkCompositeMapperHelper2* helper);
217 
219  {
220  public:
221  std::stack<bool> Visibility;
222  std::stack<bool> Pickability;
223  std::stack<double> Opacity;
224  std::stack<vtkColor3d> AmbientColor;
225  std::stack<vtkColor3d> DiffuseColor;
226  std::stack<vtkColor3d> SpecularColor;
227  std::stack<vtkColor3d> SelectionColor;
228  std::stack<float> SelectionOpacity;
229  };
230 
231  bool RecursiveHasTranslucentGeometry(vtkDataObject* dobj, unsigned int& flat_index);
234 
235  void BuildRenderValues(
236  vtkRenderer* renderer, vtkActor* actor, vtkDataObject* dobj, unsigned int& flat_index);
238 
240  void RenderBlock(
241  vtkRenderer* renderer, vtkActor* actor, vtkDataObject* dobj, unsigned int& flat_index);
242 
247 
249 
255 
256  std::vector<vtkPolyData*> RenderedList;
257 
258 private:
259  double ColorResult[3];
260 
262  void operator=(const vtkCompositePolyDataMapper2&) = delete;
263 };
264 
265 VTK_ABI_NAMESPACE_END
266 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:45
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:40
Store vtkAlgorithm input/output information.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:270
mapper for composite dataset consisting of polygonal data.
std::vector< vtkPolyData * > GetRenderedList()
Accessor to the ordered list of PolyData that we end last drew.
record modification and/or execution time
Definition: vtkTimeStamp.h:24
Rendering attributes for a multi-block dataset.
abstract specification for renderers
Definition: vtkRenderer.h:61
Superclass for all pipeline executives in VTK.
Definition: vtkExecutive.h:38
void SetBlockColor(unsigned int index, double r, double g, double b)
Set/get the color for a block given its flat index.
virtual void InitializeHelpersBeforeRendering(vtkRenderer *vtkNotUsed(ren), vtkActor *vtkNotUsed(act))
This method is called before RenderPiece is called on helpers.
virtual void SetInputArrayToProcess(int idx, int port, int connection, int fieldAssociation, const char *name)
Set the input data arrays that this algorithm will process.
window superclass for vtkRenderWindow
Definition: vtkWindow.h:27
#define VTK_DEPRECATED_IN_9_3_0(reason)
std::map< const std::string, vtkCompositeMapperHelper2 * > Helpers
#define vtkOpenGLPolyDataMapperImplementation
a simple class to control print indentation
Definition: vtkIndent.h:28
Helper class for vtkCompositePolyDataMapper2 that is a subclass of vtkOpenGLPolyDataMapper.
vtkSmartPointer< vtkCompositeDataDisplayAttributes > CompositeAttributes
Composite data set attributes.
std::map< vtkPolyData *, vtkCompositeMapperHelperData * > HelperDataMap
std::vector< vtkPolyData * > RenderedList
bool ColorMissingArraysWithNanColor
If the current 'color by' array is missing on some datasets, color these dataset by the LookupTable's...
vtkTimeStamp BoundsMTime
Time stamp for computation of bounds.
general representation of visualization data
Definition: vtkDataObject.h:54
Class to make storing and comparing state quick and easy.
a class that renders hierarchical polygonal data