Blue Brain BioExplorer
core::Engine Class Referenceabstract

Provides an abstract implementation of a ray-tracing engine. More...

#include <Engine.h>

Inheritance diagram for core::Engine:
Collaboration diagram for core::Engine:

Public Member Functions

virtual PLATFORM_API void commit ()
 Commits changes to the engine. This includes scene modifications, camera modifications and renderer modifications. More...
 
virtual PLATFORM_API void preRender ()
 Executes engine-specific pre-render operations. More...
 
virtual PLATFORM_API void postRender ()
 Executes engine-specific post-render operations. More...
 
virtual PLATFORM_API Vector2ui getMinimumFrameSize () const =0
 Returns the minimum frame size in pixels supported by this engine. More...
 
virtual PLATFORM_API FrameBufferPtr createFrameBuffer (const std::string &name, const Vector2ui &frameSize, FrameBufferFormat frameBufferFormat) const =0
 Factory method to create an engine-specific framebuffer. More...
 
virtual PLATFORM_API ScenePtr createScene (AnimationParameters &animationParameters, GeometryParameters &geometryParameters, VolumeParameters &volumeParameters, FieldParameters &fieldParameters) const =0
 Factory method to create an engine-specific scene. More...
 
virtual PLATFORM_API CameraPtr createCamera () const =0
 Factory method to create an engine-specific camera. More...
 
virtual PLATFORM_API RendererPtr createRenderer (const AnimationParameters &animationParameters, const RenderingParameters &renderingParameters) const =0
 Factory method to create an engine-specific renderer. More...
 
PLATFORM_API Engine (ParametersManager &parametersManager)
 Engine Constructor. More...
 
virtual PLATFORM_API ~Engine ()=default
 
PLATFORM_API void render ()
 Renders the current scene and populates the frame buffer accordingly. More...
 
PLATFORM_API ScenegetScene ()
 Returns the scene. More...
 
PLATFORM_API FrameBuffergetFrameBuffer ()
 Returns the frame buffer. More...
 
PLATFORM_API const CameragetCamera () const
 Returns the camera. More...
 
PLATFORM_API CameragetCamera ()
 
PLATFORM_API RenderergetRenderer ()
 Returns the renderer. More...
 
PLATFORM_API void setKeepRunning (bool keepRunning)
 Sets a flag to continue or stop rendering. More...
 
PLATFORM_API bool getKeepRunning () const
 Returns a boolean indicating whether the user wants to continue rendering. More...
 
PLATFORM_API StatisticsgetStatistics ()
 Returns statistics information. More...
 
PLATFORM_API bool continueRendering () const
 Returns a boolean indicating whether render calls shall be continued based on current accumulation settings. More...
 
PLATFORM_API const auto & getParametersManager () const
 Returns the parameter manager. More...
 
PLATFORM_API void addFrameBuffer (FrameBufferPtr frameBuffer)
 Adds a frame buffer to the list to be filled during rendering. More...
 
PLATFORM_API void removeFrameBuffer (FrameBufferPtr frameBuffer)
 Removes a frame buffer from the list of buffers that are filled during rendering. More...
 
PLATFORM_API const std::vector< FrameBufferPtr > & getFrameBuffers () const
 Returns all registered frame buffers that are used during rendering. More...
 
PLATFORM_API void clearFrameBuffers ()
 Clears all frame buffers. More...
 
PLATFORM_API void resetFrameBuffers ()
 Resets all frame buffers. More...
 
PLATFORM_API void setRendererType (const std::string &name)
 Adds a new renderer type with optional properties. More...
 
PLATFORM_API void addRendererType (const std::string &name, const PropertyMap &properties={})
 Adds a new renderer type with optional properties. More...
 
PLATFORM_API const stringsgetRendererTypes () const
 Returns all renderer types. More...
 
PLATFORM_API void addCameraType (const std::string &name, const PropertyMap &properties={})
 Adds a new camera type with optional properties. More...
 

Public Attributes

PLATFORM_API std::function< void()> triggerRender {[] {}}
 Callback when a new frame shall be triggered. Currently called by event plugins Deflect and Rockets. More...
 

Protected Attributes

std::string _rendererType {RENDERER_PROPERTY_TYPE_BASIC}
 
ParametersManager_parametersManager
 
ScenePtr _scene
 
CameraPtr _camera
 
RendererPtr _renderer
 
std::vector< FrameBufferPtr_frameBuffers
 
Statistics _statistics
 
strings _rendererTypes
 
bool _keepRunning {true}
 

Detailed Description

Provides an abstract implementation of a ray-tracing engine.

The above code is a C++ class called "Engine", which provides an abstract implementation of a ray-tracing engine that uses a 3rd party acceleration library. The engine holds a native implementation of a scene, a camera, a frame buffer and one or several renderers according to the capabilities of the acceleration library.

The class provides several API for engine-specific code, such as committing changes to the engine, executing engine specific pre-render operations, executing engine specific post-render operations, getting the minimum frame size in pixels supported by the engine, creating an engine-specific framebuffer, creating an engine-specific scene, creating an engine-specific camera, and creating an engine-specific renderer.

The constructor takes in a parameters manager that holds all engine parameters, such as geometry and rendering parameters, and the class provides functions to retrieve the scene, frame buffer, camera, and renderer. The class also provides a render function that renders the current scene and populates the frame buffer accordingly.

In addition, there are several callback functions, such as triggerRender, which is called when a new frame shall be triggered, and setKeepRunning and getKeepRunning functions, which allow the user to set and get a flag to continue or stop rendering. The class also provides statistics and various functions to manage the frame buffers.

Overall, the "Engine" class provides a flexible and extensible framework for implementing a ray-tracing engine using a 3rd party acceleration library.

Definition at line 58 of file Engine.h.

Constructor & Destructor Documentation

◆ Engine()

core::Engine::Engine ( ParametersManager parametersManager)
explicit

Engine Constructor.

Parameters
parametersManagerThe parameter manager that holds all engine parameters.

Definition at line 36 of file Engine.cpp.

◆ ~Engine()

virtual PLATFORM_API core::Engine::~Engine ( )
virtualdefault

Member Function Documentation

◆ addCameraType()

void core::Engine::addCameraType ( const std::string &  name,
const PropertyMap properties = {} 
)

Adds a new camera type with optional properties.

Parameters
nameThe camera type name.
propertiesThe properties.

Definition at line 113 of file Engine.cpp.

◆ addFrameBuffer()

void core::Engine::addFrameBuffer ( FrameBufferPtr  frameBuffer)

Adds a frame buffer to the list to be filled during rendering.

Parameters
frameBufferThe frame buffer to add.

Definition at line 84 of file Engine.cpp.

◆ addRendererType()

void core::Engine::addRendererType ( const std::string &  name,
const PropertyMap properties = {} 
)

Adds a new renderer type with optional properties.

Parameters
nameThe renderer type name.
propertiesThe properties.

Definition at line 106 of file Engine.cpp.

◆ clearFrameBuffers()

void core::Engine::clearFrameBuffers ( )

Clears all frame buffers.

Definition at line 94 of file Engine.cpp.

◆ commit()

void core::Engine::commit ( )
virtual

Commits changes to the engine. This includes scene modifications, camera modifications and renderer modifications.

Reimplemented in core::engine::ospray::OSPRayEngine, and core::engine::optix::OptiXEngine.

Definition at line 41 of file Engine.cpp.

◆ continueRendering()

bool core::Engine::continueRendering ( ) const

Returns a boolean indicating whether render calls shall be continued based on current accumulation settings.

Returns
bool Value indicating whether render calls shall be continued based on current accumulation settings.

Definition at line 77 of file Engine.cpp.

◆ createCamera()

virtual PLATFORM_API CameraPtr core::Engine::createCamera ( ) const
pure virtual

Factory method to create an engine-specific camera.

Returns
CameraPtr The created camera.

Implemented in core::engine::ospray::OSPRayEngine, and core::engine::optix::OptiXEngine.

◆ createFrameBuffer()

virtual PLATFORM_API FrameBufferPtr core::Engine::createFrameBuffer ( const std::string &  name,
const Vector2ui frameSize,
FrameBufferFormat  frameBufferFormat 
) const
pure virtual

Factory method to create an engine-specific framebuffer.

Parameters
nameThe name of the frame buffer.
frameSizeThe size of the frame buffer.
frameBufferFormatThe frame buffer format.
Returns
FrameBufferPtr The created frame buffer.

Implemented in core::engine::ospray::OSPRayEngine, and core::engine::optix::OptiXEngine.

◆ createRenderer()

virtual PLATFORM_API RendererPtr core::Engine::createRenderer ( const AnimationParameters animationParameters,
const RenderingParameters renderingParameters 
) const
pure virtual

Factory method to create an engine-specific renderer.

Parameters
animationParametersThe animation parameters.
renderingParametersThe rendering parameters.
Returns
RendererPtr The created renderer.

Implemented in core::engine::ospray::OSPRayEngine, and core::engine::optix::OptiXEngine.

◆ createScene()

virtual PLATFORM_API ScenePtr core::Engine::createScene ( AnimationParameters animationParameters,
GeometryParameters geometryParameters,
VolumeParameters volumeParameters,
FieldParameters fieldParameters 
) const
pure virtual

Factory method to create an engine-specific scene.

Parameters
animationParametersThe animation parameters.
geometryParametersThe geometry parameters.
volumeParametersThe volume parameters.
Returns
ScenePtr The created scene.

Implemented in core::engine::ospray::OSPRayEngine, and core::engine::optix::OptiXEngine.

◆ getCamera() [1/2]

PLATFORM_API Camera& core::Engine::getCamera ( )
inline

Definition at line 162 of file Engine.h.

◆ getCamera() [2/2]

PLATFORM_API const Camera& core::Engine::getCamera ( ) const
inline

Returns the camera.

Returns
Camera& The camera.

Definition at line 161 of file Engine.h.

◆ getFrameBuffer()

PLATFORM_API FrameBuffer& core::Engine::getFrameBuffer ( )
inline

Returns the frame buffer.

Returns
FrameBuffer& The frame buffer.

Definition at line 154 of file Engine.h.

◆ getFrameBuffers()

PLATFORM_API const std::vector<FrameBufferPtr>& core::Engine::getFrameBuffers ( ) const
inline

Returns all registered frame buffers that are used during rendering.

Returns
const std::vector<FrameBufferPtr>& A vector containing all registered frame buffers.

Definition at line 231 of file Engine.h.

◆ getKeepRunning()

PLATFORM_API bool core::Engine::getKeepRunning ( ) const
inline

Returns a boolean indicating whether the user wants to continue rendering.

Returns
bool Value indicating whether the user wants to continue rendering. True if they do, false otherwise.

Definition at line 188 of file Engine.h.

◆ getMinimumFrameSize()

virtual PLATFORM_API Vector2ui core::Engine::getMinimumFrameSize ( ) const
pure virtual

Returns the minimum frame size in pixels supported by this engine.

Returns
Vector2ui The minimum frame size.

Implemented in core::engine::ospray::OSPRayEngine, and core::engine::optix::OptiXEngine.

◆ getParametersManager()

PLATFORM_API const auto& core::Engine::getParametersManager ( ) const
inline

Returns the parameter manager.

Returns
const auto& The parameter manager.

Definition at line 210 of file Engine.h.

◆ getRenderer()

Renderer & core::Engine::getRenderer ( )

Returns the renderer.

Returns
Renderer& The renderer.

Definition at line 72 of file Engine.cpp.

◆ getRendererTypes()

PLATFORM_API const strings& core::Engine::getRendererTypes ( ) const
inline

Returns all renderer types.

Returns
const strings& A vector containing all renderer types.

Definition at line 264 of file Engine.h.

◆ getScene()

PLATFORM_API Scene& core::Engine::getScene ( )
inline

Returns the scene.

Returns
Scene& The current scene.

Definition at line 147 of file Engine.h.

◆ getStatistics()

PLATFORM_API Statistics& core::Engine::getStatistics ( )
inline

Returns statistics information.

Returns
Statistics& Statistics information.

Definition at line 195 of file Engine.h.

◆ postRender()

void core::Engine::postRender ( )
virtual

Executes engine-specific post-render operations.

Definition at line 66 of file Engine.cpp.

◆ preRender()

void core::Engine::preRender ( )
virtual

Executes engine-specific pre-render operations.

Definition at line 46 of file Engine.cpp.

◆ removeFrameBuffer()

void core::Engine::removeFrameBuffer ( FrameBufferPtr  frameBuffer)

Removes a frame buffer from the list of buffers that are filled during rendering.

Parameters
frameBufferThe frame buffer to remove.

Definition at line 89 of file Engine.cpp.

◆ render()

void core::Engine::render ( )

Renders the current scene and populates the frame buffer accordingly.

Definition at line 55 of file Engine.cpp.

◆ resetFrameBuffers()

void core::Engine::resetFrameBuffers ( )

Resets all frame buffers.

Definition at line 100 of file Engine.cpp.

◆ setKeepRunning()

PLATFORM_API void core::Engine::setKeepRunning ( bool  keepRunning)
inline

Sets a flag to continue or stop rendering.

Parameters
keepRunningThe flag to set.

Definition at line 181 of file Engine.h.

◆ setRendererType()

PLATFORM_API void core::Engine::setRendererType ( const std::string &  name)
inline

Adds a new renderer type with optional properties.

Parameters
nameThe renderer type name.
propertiesThe properties.

Definition at line 249 of file Engine.h.

Member Data Documentation

◆ _camera

CameraPtr core::Engine::_camera
protected

Definition at line 278 of file Engine.h.

◆ _frameBuffers

std::vector<FrameBufferPtr> core::Engine::_frameBuffers
protected

Definition at line 280 of file Engine.h.

◆ _keepRunning

bool core::Engine::_keepRunning {true}
protected

Definition at line 283 of file Engine.h.

◆ _parametersManager

ParametersManager& core::Engine::_parametersManager
protected

Definition at line 276 of file Engine.h.

◆ _renderer

RendererPtr core::Engine::_renderer
protected

Definition at line 279 of file Engine.h.

◆ _rendererType

std::string core::Engine::_rendererType {RENDERER_PROPERTY_TYPE_BASIC}
protected

Definition at line 275 of file Engine.h.

◆ _rendererTypes

strings core::Engine::_rendererTypes
protected

Definition at line 282 of file Engine.h.

◆ _scene

ScenePtr core::Engine::_scene
protected

Definition at line 277 of file Engine.h.

◆ _statistics

Statistics core::Engine::_statistics
protected

Definition at line 281 of file Engine.h.

◆ triggerRender

PLATFORM_API std::function<void()> core::Engine::triggerRender {[] {}}

Callback when a new frame shall be triggered. Currently called by event plugins Deflect and Rockets.

Definition at line 174 of file Engine.h.


The documentation for this class was generated from the following files: