VTK  9.6.20260629
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
23
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
39class vtkAnariSceneGraphInternals;
40class vtkRenderer;
41class vtkAnariDevice;
43
44class VTKRENDERINGANARI_EXPORT vtkAnariSceneGraph : public vtkRendererNode
45{
46public:
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
83
86 static void SetAccumulationCount(vtkRenderer* renderer, int);
87 static int GetAccumulationCount(vtkRenderer* renderer);
89
97
100 static void SetCompositeOnGL(vtkRenderer* renderer, int);
101 static int GetCompositeOnGL(vtkRenderer* renderer);
103
105
108
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
177
181 virtual void WriteLayer(unsigned char* buffer, float* zbuffer, int buffx, int buffy, int layer);
182
187
193
195
203
209
214
220 void WarningMacroOnce(vtkSmartPointer<vtkObject> caller, const std::string& warning);
221
222protected:
225
236
237 vtkAnariSceneGraphInternals* Internal{ nullptr };
238
243
244 std::map<std::string, std::vector<std::string>> IssuedWarnings;
245
246private:
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
257VTK_ABI_NAMESPACE_END
258#endif
base class to objects which create + manage a ANARI library + device
static void SetCompositeOnGL(vtkRenderer *renderer, int)
Convenience method to set/get COMPOSITE_ON_GL on a vtkRenderer.
static void SetMaterialLibrary(vtkRenderMaterialLibrary *, vtkRenderer *renderer)
Convenience method to set/get a material library on a vtkRenderer for use with the ANARI renderer.
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
static vtkRenderMaterialLibrary * GetMaterialLibrary(vtkRenderer *renderer)
Convenience method to set/get a material library on a vtkRenderer for use with the ANARI renderer.
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.
vtkMTimeType AnariSceneConstructedMTime
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()
vtkAnariSceneGraphInternals * Internal
int ReservePropId()
Reserve an Id which is unique to a render call.
static vtkAnariSceneGraph * New()
vtkMTimeType AnariRendererUpdatedTime
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 vtkObjectBase values.
Key for string values in vtkInformation.
a renderer-agnostic collection of materials for VTK apps to draw from
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 vtkInformationStringKey * MATERIAL_NAMES()
Get information key for material names.
static vtkInformationObjectBaseKey * MATERIAL_LIBRARY()
Material Library attached to the renderer.
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:318