VTK  9.7.1
vtkAnariSceneGraph.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
24 #ifndef vtkAnariSceneGraph_h
25 #define vtkAnariSceneGraph_h
26 
27 #include "vtkRendererNode.h"
28 #include "vtkRenderingAnariModule.h" // For export macro
29 
30 #include <anari/anari_cpp.hpp> // For ANARI handles
31 
32 VTK_ABI_NAMESPACE_BEGIN
33 
39 class vtkAnariSceneGraphInternals;
40 class vtkRenderer;
41 class vtkAnariDevice;
43 
44 class VTKRENDERINGANARI_EXPORT vtkAnariSceneGraph : public vtkRendererNode
45 {
46 public:
47  static vtkAnariSceneGraph* New();
49  void PrintSelf(ostream& os, vtkIndent indent) override;
50 
54  void Build(bool prepass) override;
55 
59  void Render(bool prepass) override;
60 
64  void Invalidate(bool prepass) override;
65 
66  // state beyond rendering core...
67 
74  void SetUpdateWorldOnly(bool onlyUpdateWorld = false);
75 
81  static vtkInformationIntegerKey* ACCUMULATION_COUNT();
83 
86  static void SetAccumulationCount(vtkRenderer* renderer, int);
87  static int GetAccumulationCount(vtkRenderer* renderer);
89 
95  static vtkInformationIntegerKey* COMPOSITE_ON_GL();
97 
100  static void SetCompositeOnGL(vtkRenderer* renderer, int);
101  static int GetCompositeOnGL(vtkRenderer* renderer);
103 
105 
114  void AddLight(anari::Light);
115 
122  void AddSurface(anari::Surface);
123 
129  void AddVolume(anari::Volume);
130 
134  void SetCamera(anari::Camera);
135 
140  anari::Device GetDeviceHandle() const;
141 
145  anari::Renderer GetRendererHandle() const;
146 
150  const anari::Extensions& GetAnariDeviceExtensions() const;
152 
156  const char* const* GetAnariDeviceExtensionStrings() const;
158 
162  virtual const unsigned char* GetBuffer();
163 
167  virtual const float* GetZBuffer();
168 
169  // if you want to traverse your children in a specific order
170  // or way override this method
171  virtual void Traverse(int operation) override;
172 
176  vtkRenderer* GetRenderer();
177 
181  virtual void WriteLayer(unsigned char* buffer, float* zbuffer, int buffx, int buffy, int layer);
182 
186  void InvalidateSceneStructure();
187 
192  static vtkInformationObjectBaseKey* MATERIAL_LIBRARY();
193 
195 
200  static void SetMaterialLibrary(vtkRenderMaterialLibrary*, vtkRenderer* renderer);
201  static vtkRenderMaterialLibrary* GetMaterialLibrary(vtkRenderer* renderer);
203 
208  static vtkInformationStringKey* MATERIAL_NAMES();
209 
213  int ReservePropId();
214 
220  void WarningMacroOnce(vtkSmartPointer<vtkObject> caller, const std::string& warning);
221 
222 protected:
224  ~vtkAnariSceneGraph() override;
225 
226  void InitAnariFrame(vtkRenderer* ren);
227  void SetupAnariRendererParameters(vtkRenderer* ren);
228  void InitAnariWorld();
229  void UpdateAnariFrameSize();
230  void UpdateAnariLights();
231  void UpdateAnariSurfaces();
232  void UpdateAnariVolumes();
233  void CopyAnariFrameBufferData();
234  void DebugOutputWorldBounds();
235  void ResetReservedPropIds();
236 
237  vtkAnariSceneGraphInternals* Internal{ nullptr };
238 
240  vtkMTimeType AnariSceneConstructedMTime{ 0 };
242  vtkMTimeType AnariRendererUpdatedTime{ 0 };
243 
244  std::map<std::string, std::vector<std::string>> IssuedWarnings;
245 
246 private:
247  vtkAnariSceneGraph(const vtkAnariSceneGraph&) = delete;
248  void operator=(const vtkAnariSceneGraph&) = delete;
249 
250  void SetAnariDevice(vtkAnariDevice* ad, anari::Extensions e, const char* const* es);
251  void SetAnariRenderer(anari::Renderer r);
252 
253  // only allow these classes to set the Anari device + renderer
254  friend class vtkAnariPass;
255 };
256 
257 VTK_ABI_NAMESPACE_END
258 #endif
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:318
record modification and/or execution time
Definition: vtkTimeStamp.h:24
abstract specification for renderers
Definition: vtkRenderer.h:63
Hold a reference to a vtkObjectBase instance.
Definition: vtkMeta.h:23
Key for string values in vtkInformation.
vtkTimeStamp AnariSceneStructureModifiedMTime
Key for double vector values.
std::map< std::string, std::vector< std::string > > IssuedWarnings
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
a renderer-agnostic collection of materials for VTK apps to draw from
a simple class to control print indentation
Definition: vtkIndent.h:28
Key for integer values in vtkInformation.
Key for vtkObjectBase values.
a render pass that uses ANARI (ANAlytic Rendering Interface) instead of OpenGL.
Definition: vtkAnariPass.h:42
vtkTimeStamp AnariRendererModifiedTime
virtual void Render(bool)
Makes calls to make self visible.
Definition: vtkViewNode.h:56
vtkViewNode specialized for vtkRenderers
virtual void Invalidate(bool)
Clear any cached data.
Definition: vtkViewNode.h:61
base class to objects which create + manage a ANARI library + device
static vtkRendererNode * New()
Key for double values in vtkInformation.
virtual void Traverse(int operation)
void Build(bool prepass) override
Build containers for our child nodes.
links vtkRenderers to ANARI