VTK  9.7.1
vtkDGRenderResponder.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
13 #ifndef vtkDGRenderResponder_h
14 #define vtkDGRenderResponder_h
15 
17 
18 #include "vtkCellGridResponder.h" // For API.
19 #include "vtkDGCell.h" // For API.
20 #include "vtkDrawTexturedElements.h" // For CacheEntry.
21 #include "vtkInformation.h" // For CacheEntry.
23 #include "vtkRenderingCellGridModule.h" // For Export macro
24 
25 #include <string>
26 #include <vector>
27 
28 VTK_ABI_NAMESPACE_BEGIN
29 
30 class vtkCellMetadata;
31 class vtkDGCell;
32 class vtkDGRenderResponders;
34 
35 class VTKRENDERINGCELLGRID_EXPORT vtkDGRenderResponder
36  : public vtkCellGridResponder<vtkCellGridRenderRequest>
37 {
38 public:
39  static vtkDGRenderResponder* New();
41 
42  bool Query(vtkCellGridRenderRequest* request, vtkCellMetadata* metadata,
43  vtkCellGridResponders* caches) override;
44 
45  void AddMod(const std::string& className);
46  void AddMods(const std::vector<std::string>& classNames);
47  void RemoveMod(const std::string& className);
48  void RemoveAllMods();
49 
51  void ResetModsToDefault();
52 
58  {
59  NONE,
60  R,
61  S,
62  T,
63  L2_NORM_R_S,
64  L2_NORM_S_T,
65  L2_NORM_T_R,
66  };
67 
69  {
70  ScalarVisualizationOverride = type;
71  }
72 
73  static void SetVisualizeTessellation(bool value) { VisualizeTessellation = value; }
74 
75 protected:
77  ~vtkDGRenderResponder() override = default;
78 
79  bool DrawCells(vtkCellGridRenderRequest* request, vtkCellMetadata* metadata);
80  bool ReleaseResources(vtkCellGridRenderRequest* request, vtkCellMetadata* metadata);
81 
82  bool DrawShapes(vtkCellGridRenderRequest* request, vtkDGCell* metadata,
83  const vtkDGCell::Source& cellSource, int cellTypeIdx, std::size_t specIdx);
84  // std::pair<GLenum, std::vector<GLubyte>> ShapeToPrimitiveInfo(int shapeId);
85 
87  struct CacheEntry
88  {
103 
109  mutable std::unique_ptr<vtkDrawTexturedElements> RenderHelper;
127  mutable vtkMTimeType RenderPassStageTime{ 0 };
131  mutable bool UsesGeometryShaders;
133 
137  std::vector<std::string> ModNames;
138 
142  bool IsUpToDate(vtkRenderer* renderer, vtkActor* actor, vtkMapper* mapper,
143  vtkDGRenderResponder* responder) const;
144 
146  void PrepareHelper(vtkRenderer* renderer, vtkActor* actor, vtkMapper* mapper) const;
147 
149  bool operator<(const CacheEntry& other) const;
150  };
151 
152  std::set<CacheEntry> Helpers;
153  static vtkDrawTexturedElements::ElementShape PrimitiveFromShape(vtkDGCell::Shape shape);
154  static vtkDrawTexturedElements::PatchShape PatchPrimitiveFromShape(vtkDGCell::Shape shape);
155 
156  std::vector<std::string> ModNames;
157  std::set<std::string> ModNamesUnique;
158  static std::vector<std::string> DefaultModNames;
159 
163 
166 
167 private:
169  void operator=(const vtkDGRenderResponder&) = delete;
170 };
171 
172 VTK_ABI_NAMESPACE_END
173 #endif // vtkDGRenderResponder_h
174 // VTK-HeaderTest-Exclude: vtkDGRenderResponder.h
ElementShape
The type of primitive to output.
vtkSmartPointer< vtkCellAttribute > Shape
The vector-valued attribute used to move from reference coordinates to world coordinates.
std::unique_ptr< vtkDrawTexturedElements > RenderHelper
The MTime of the shape cell-attribute at the time RenderHelper was configured.
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:41
vtkNew< vtkInformation > LastRenderPassInfo
The last render pass information is cached when RenderHelper is configured.
vtkMTimeType ColorTime
The MTime of the color cell-attribute at the time RenderHelper was configured.
Provide information about a cell attribute's basis functions on one cell type.
Respond to a query on one particular type of cell.
std::set< std::string > ModNamesUnique
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:318
State used by vtkCellGridMapper during rendering.
vtkMTimeType PropertyTime
The MTime of the property at the time RenderHelper was configured.
Metadata for a particular type of cell (finite element).
ScalarVisualizationOverrideType
These properties are useful to debug/show-off/understand the parameter space and basis functions...
abstract specification for renderers
Definition: vtkRenderer.h:63
A container that holds objects able to respond to queries specialized for particular vtkCellMetadata ...
vtkMTimeType GridTime
The MTime of the cell-grid which owns CellType at the time RenderHelper was configured.
static void SetVisualizeTessellation(bool value)
std::set< CacheEntry > Helpers
vtkMTimeType MapperTime
The MTime of the mapper at the time RenderHelper was configured.
vtkMTimeType ShapeTime
The MTime of the shape cell-attribute at the time RenderHelper was configured.
Entries for a cache of render-helpers.
const vtkDGCell::Source * CellSource
The cell- or side-source within the cell-type to be rendered.
bool VTKCOMMONCORE_EXPORT operator<(const std::string &a, const vtkStringToken &b)
Base class for a discontinuous Galerkin cells of all shapes.
Definition: vtkDGCell.h:43
std::vector< std::string > ModNames
Determine whether to remove this cache entry because renderer, actor, or mapper have changed since it...
abstract class specifies interface to map data to graphics primitives
Definition: vtkMapper.h:77
bool UsesGeometryShaders
Geometry shader is used to debug distance-based tessellation.
PatchShape
The type of primitive that abstract patches are tessellated into.
Rendering simple DG cells (i.e., those with a fixed reference shape).
static bool VisualizeTessellation
These properties are useful to debug/show-off/understand dynamic distance-based tessellation.
virtual bool Query(QueryClass *query, vtkCellMetadata *cellType, vtkCellGridResponders *caches)=0
bool UsesTessellationShaders
Tessellation shaders are employed for higher order elements and quadrilaterals.
static ScalarVisualizationOverrideType ScalarVisualizationOverride
Default is None.
static void SetScalarVisualizationOverrideType(ScalarVisualizationOverrideType type)
vtkSmartPointer< vtkCellAttribute > Color
The attribute used to color the geometry (or null).
std::vector< std::string > ModNames
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
Records describing the source arrays for cells or cell-sides.
Definition: vtkDGCell.h:89
Shape
All possible shapes for DG cells.
Definition: vtkDGCell.h:70
static std::vector< std::string > DefaultModNames
vtkSmartPointer< vtkDGCell > CellType
The cell- or side-source within the cell-type to be rendered.