VTK  9.5.20250817
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;
40class vtkAnariDevice;
41
42class VTKRENDERINGANARI_EXPORT vtkAnariSceneGraph : public vtkRendererNode
43{
44public:
47 void PrintSelf(ostream& os, vtkIndent indent) override;
48
52 void Build(bool prepass) override;
53
57 void Render(bool prepass) override;
58
62 void Invalidate(bool prepass) override;
63
64 // state beyond rendering core...
65
72 void SetUpdateWorldOnly(bool onlyUpdateWorld = false);
73
81
84 static void SetAccumulationCount(vtkRenderer* renderer, int);
85 static int GetAccumulationCount(vtkRenderer* renderer);
87
95
98 static void SetCompositeOnGL(vtkRenderer* renderer, int);
99 static int GetCompositeOnGL(vtkRenderer* renderer);
101
103
112 void AddLight(anari::Light);
113
120 void AddSurface(anari::Surface);
121
127 void AddVolume(anari::Volume);
128
132 void SetCamera(anari::Camera);
133
138 anari::Device GetDeviceHandle() const;
139
143 anari::Renderer GetRendererHandle() const;
144
148 const anari::Extensions& GetAnariDeviceExtensions() const;
150
154 const char* const* GetAnariDeviceExtensionStrings() const;
156
160 virtual const unsigned char* GetBuffer();
161
165 virtual const float* GetZBuffer();
166
167 // if you want to traverse your children in a specific order
168 // or way override this method
169 virtual void Traverse(int operation) override;
170
175
179 virtual void WriteLayer(unsigned char* buffer, float* zbuffer, int buffx, int buffy, int layer);
180
185
190
196 void WarningMacroOnce(vtkSmartPointer<vtkObject> caller, const std::string& warning);
197
198protected:
201
212
213 vtkAnariSceneGraphInternals* Internal{ nullptr };
214
216 vtkMTimeType AnariSceneConstructedMTime{ 0 };
218 vtkMTimeType AnariRendererUpdatedTime{ 0 };
219
220 std::map<std::string, std::vector<std::string>> IssuedWarnings;
221
222private:
223 vtkAnariSceneGraph(const vtkAnariSceneGraph&) = delete;
224 void operator=(const vtkAnariSceneGraph&) = delete;
225
226 void SetAnariDevice(vtkAnariDevice* ad, anari::Extensions e, const char* const* es);
227 void SetAnariRenderer(anari::Renderer r);
228
229 // only allow these classes to set the Anari device + renderer
230 friend class vtkAnariPass;
231};
232
233VTK_ABI_NAMESPACE_END
234#endif
base class to objects which create + manage a ANARI library + device
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 ResetReservedPropIds()
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
std::map< std::string, std::vector< std::string > > IssuedWarnings
vtkTimeStamp AnariRendererModifiedTime
void Invalidate(bool prepass) override
Invalidates cached rendering data.
void SetUpdateWorldOnly(bool onlyUpdateWorld=false)
When passing 'true', the renderer will skip actually rendering frame.
const char *const * GetAnariDeviceExtensionStrings() const
Get the extensions supported by the current back-end device.
void WarningMacroOnce(vtkSmartPointer< vtkObject > caller, const std::string &warning)
Convenience API to warn the user once per device per renderer per warning type.
void AddVolume(anari::Volume)
Accessed by the AnariVolumeMapperNode to add Volumes to the world.
void DebugOutputWorldBounds()
int ReservePropId()
Reserve an Id which is unique to a render call.
static vtkAnariSceneGraph * New()
void Build(bool prepass) override
Builds objects for this renderer.
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.
void Render(bool prepass) override
Traverse graph in ANARI's preferred order and render.
~vtkAnariSceneGraph() override
static int GetCompositeOnGL(vtkRenderer *renderer)
vtkRenderer * GetRenderer()
Convenience method to get and downcast renderable.
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
Hold a reference to a vtkObjectBase instance.
record modification and/or execution time
static vtkInformationIntegerKey * ACCUMULATION_COUNT()
Set the number of frames to render which are accumulated to result in a better converged image.
static vtkInformationIntegerKey * COMPOSITE_ON_GL()
used to make the renderer add ANARI's content onto GL rendered content on the window
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:287