VTK  9.4.20250130
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
32VTK_ABI_NAMESPACE_BEGIN
33
38class vtkAnariSceneGraphInternals;
39class vtkRenderer;
40
41class VTKRENDERINGANARI_EXPORT vtkAnariSceneGraph : public vtkRendererNode
42{
43public:
46 void PrintSelf(ostream& os, vtkIndent indent) override;
47
51 virtual void Build(bool prepass) override;
52
56 virtual void Render(bool prepass) override;
57
61 virtual void Invalidate(bool prepass) override;
62
63 // state beyond rendering core...
64
71 void SetUpdateWorldOnly(bool onlyUpdateWorld = false);
72
79
82 static void SetAccumulationCount(vtkRenderer* renderer, int);
83 static int GetAccumulationCount(vtkRenderer* renderer);
85
92
95 static void SetCompositeOnGL(vtkRenderer* renderer, int);
96 static int GetCompositeOnGL(vtkRenderer* renderer);
98
100
109 void AddLight(anari::Light);
110
117 void AddSurface(anari::Surface);
118
124 void AddVolume(anari::Volume);
125
129 void SetCamera(anari::Camera);
130
135 anari::Device GetDeviceHandle() const;
136
140 anari::Renderer GetRendererHandle() const;
141
145 const anari::Extensions& GetAnariDeviceExtensions() const;
147
151 virtual const unsigned char* GetBuffer();
152
156 virtual const float* GetZBuffer();
157
158 // if you want to traverse your children in a specific order
159 // or way override this method
160 virtual void Traverse(int operation) override;
161
166
170 virtual void WriteLayer(unsigned char* buffer, float* zbuffer, int buffx, int buffy, int layer);
171
176
177protected:
180
190
191 vtkAnariSceneGraphInternals* Internal{ nullptr };
192
194 vtkMTimeType AnariSceneConstructedMTime{ 0 };
196 vtkMTimeType AnariRendererUpdatedTime{ 0 };
197
198private:
199 vtkAnariSceneGraph(const vtkAnariSceneGraph&) = delete;
200 void operator=(const vtkAnariSceneGraph&) = delete;
201
202 void SetAnariDevice(anari::Device d, anari::Extensions e);
203 void SetAnariRenderer(anari::Renderer r);
204
205 // only allow these classes to set the Anari device + renderer
206 friend class vtkAnariPass;
207 friend class vtkAnariWindowNode;
208};
209
210VTK_ABI_NAMESPACE_END
211#endif
a render pass that uses ANARI (ANAlytic Rendering Interface) instead of OpenGL.
links vtkRenderers to ANARI
static void SetCompositeOnGL(vtkRenderer *renderer, int)
Convenience method to set/get COMPOSITE_ON_GL on a vtkRenderer.
virtual const unsigned char * GetBuffer()
Get the last rendered ColorBuffer.
void SetupAnariRendererParameters(vtkRenderer *ren)
void AddSurface(anari::Surface)
Accessed by the AnariPolyDataMapperNode to an ANARISurface to the world.
void UpdateAnariFrameSize()
void InitAnariFrame(vtkRenderer *ren)
anari::Device GetDeviceHandle() const
Get the ANARI back-end device.
void SetCamera(anari::Camera)
Accessed by the AnariCameraNode to set the ANARICamera on the ANARIFrame.
void AddLight(anari::Light)
Methods for other nodes to access.
static int GetAccumulationCount(vtkRenderer *renderer)
void InvalidateSceneStructure()
Indicate that a new RenderTraversal of children needs to occur next frame.
anari::Renderer GetRendererHandle() const
Get the currently set ANARI renderer.
virtual void WriteLayer(unsigned char *buffer, float *zbuffer, int buffx, int buffy, int layer)
Put my results into the correct place in the provided pixel buffer.
void CopyAnariFrameBufferData()
virtual void Traverse(int operation) override
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkTimeStamp AnariSceneStructureModifiedMTime
static vtkInformationIntegerKey * ACCUMULATION_COUNT()
Set the number of frames to render which are accumulated to result in a better converged image.
vtkTimeStamp AnariRendererModifiedTime
void SetUpdateWorldOnly(bool onlyUpdateWorld=false)
When passing 'true', the renderer will skip actually rendering frame.
virtual void Build(bool prepass) override
Builds objects for this renderer.
static vtkInformationIntegerKey * COMPOSITE_ON_GL()
used to make the renderer add ANARI's content onto GL rendered content on the window
void AddVolume(anari::Volume)
Accessed by the AnariVolumeMapperNode to add Volumes to the world.
void DebugOutputWorldBounds()
static vtkAnariSceneGraph * New()
virtual void Render(bool prepass) override
Traverse graph in ANARI's preferred order and render.
static void SetAccumulationCount(vtkRenderer *renderer, int)
Convenience method to set/get ACCUMULATION_COUNT on a vtkRenderer.
virtual const float * GetZBuffer()
Get the last rendered ZBuffer.
const anari::Extensions & GetAnariDeviceExtensions() const
Get the extensions supported by the current back-end device.
static int GetCompositeOnGL(vtkRenderer *renderer)
vtkRenderer * GetRenderer()
Convenience method to get and downcast renderable.
virtual void Invalidate(bool prepass) override
Invalidates cached rendering data.
void UpdateAnariSurfaces()
a simple class to control print indentation
Definition vtkIndent.h:108
Key for double values in vtkInformation.
Key for integer values in vtkInformation.
Key for string values in vtkInformation.
vtkViewNode specialized for vtkRenderers
abstract specification for renderers
record modification and/or execution time
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:270