VTK  9.7.20261004
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 "vtkRenderingAnariCoreModule.h" // For export macro
29
30#include <anari/anari_cpp.hpp> // For ANARI handles
31
32VTK_ABI_NAMESPACE_BEGIN
33
39class vtkAnariSceneGraphInternals;
40class vtkRenderer;
42class vtkAnariDevice;
44
45class VTKRENDERINGANARICORE_EXPORT vtkAnariSceneGraph : public vtkRendererNode
46{
47public:
50 void PrintSelf(ostream& os, vtkIndent indent) override;
51
55 void Build(bool prepass) override;
56
60 void Render(bool prepass) override;
61
65 void Invalidate(bool prepass) override;
66
67 // state beyond rendering core...
68
75 void SetUpdateWorldOnly(bool onlyUpdateWorld = false);
76
83
85
88 static void SetAccumulationCount(vtkRenderer* renderer, int);
89 static int GetAccumulationCount(vtkRenderer* renderer);
91
98
100
103 static void SetCompositeOnGL(vtkRenderer* renderer, int);
104 static int GetCompositeOnGL(vtkRenderer* renderer);
106
112 void AddLight(anari::Light);
113
120 void AddSurface(anari::Surface);
121
127 void AddVolume(anari::Volume);
128
132 void SetCamera(anari::Camera);
133
139
144
148 virtual const unsigned char* GetBuffer();
149
153 virtual const float* GetZBuffer();
154
155 // if you want to traverse your children in a specific order
156 // or way override this method
157 void Traverse(int operation) override;
158
163
167 virtual void WriteLayer(unsigned char* buffer, float* zbuffer, int buffx, int buffy, int layer);
168
173
179
181
189
195
200
206 void WarningMacroOnce(vtkSmartPointer<vtkObject> caller, const std::string& warning);
207
208protected:
211
222
223 vtkAnariSceneGraphInternals* Internal{ nullptr };
224
229
230 std::map<std::string, std::vector<std::string>> IssuedWarnings;
231
232private:
233 vtkAnariSceneGraph(const vtkAnariSceneGraph&) = delete;
234 void operator=(const vtkAnariSceneGraph&) = delete;
235
236 void SetAnariDevice(vtkAnariDevice* ad);
237 void SetAnariRenderer(vtkAnariRenderer* r);
238
239 // only allow these classes to set the Anari device + renderer
240 friend class vtkAnariPass;
242};
243
244VTK_ABI_NAMESPACE_END
245#endif
base class to objects which create + manage a ANARI library + device
base class to objects which create + manage an ANARI library, device, and renderer
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)
vtkSmartPointer< vtkAnariDevice > GetDevice() const
Get the ANARI back-end device.
void AddSurface(anari::Surface)
Accessed by the AnariPolyDataMapperNode to an ANARISurface to the world.
void ResetReservedPropIds()
void UpdateAnariFrameSize()
void InitAnariFrame(vtkRenderer *ren)
void SetCamera(anari::Camera)
Accessed by the AnariCameraNode to set the ANARICamera on the ANARIFrame.
void AddLight(anari::Light)
Accessed by the AnariLightNode to add an ANARILight to the world.
static int GetAccumulationCount(vtkRenderer *renderer)
void InvalidateSceneStructure()
Indicate that a new RenderTraversal of children needs to occur next frame.
vtkSmartPointer< vtkAnariRenderer > GetAnariRenderer() 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 Traverse(int operation) override
void CopyAnariFrameBufferData()
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.
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.
void Render(bool prepass) override
Traverse graph in ANARI's preferred order and render.
~vtkAnariSceneGraph() override
friend class vtkAnariRenderWindow
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