Blue Brain BioExplorer
Engine.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2024, EPFL/Blue Brain Project
3  *
4  * The Blue Brain BioExplorer is a tool for scientists to extract and analyse
5  * scientific data from visualization
6  *
7  * This file is part of Blue Brain BioExplorer <https://github.com/BlueBrain/BioExplorer>
8  *
9  * This library is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU Lesser General Public License version 3.0 as published
11  * by the Free Software Foundation.
12  *
13  * This library is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this library; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  */
22 
23 #include "Engine.h"
24 
29 
31 
33 
34 namespace core
35 {
36 Engine::Engine(ParametersManager& parametersManager)
37  : _parametersManager(parametersManager)
38 {
39 }
40 
42 {
43  _renderer->commit();
44 }
45 
47 {
48  for (auto frameBuffer : _frameBuffers)
49  {
50  frameBuffer->setAccumulation(_renderer->getAccumulation());
51  frameBuffer->setSubsampling(_renderer->getSubsampling());
52  }
53 }
54 
56 {
57  for (auto frameBuffer : _frameBuffers)
58  {
59  _camera->setBufferTarget(frameBuffer->getName());
60  _camera->commit();
61  _camera->resetModified();
62  _renderer->render(frameBuffer);
63  }
64 }
65 
67 {
68  for (auto frameBuffer : _frameBuffers)
69  frameBuffer->incrementAccumFrames();
70 }
71 
73 {
74  return *_renderer;
75 }
76 
78 {
79  auto frameBuffer = _frameBuffers[0];
81  (frameBuffer->getAccumulation() && (frameBuffer->numAccumFrames() < _renderer->getMaxAccumFrames()));
82 }
83 
85 {
86  _frameBuffers.push_back(frameBuffer);
87 }
88 
90 {
91  _frameBuffers.erase(std::remove(_frameBuffers.begin(), _frameBuffers.end(), frameBuffer), _frameBuffers.end());
92 }
93 
95 {
96  for (auto frameBuffer : _frameBuffers)
97  frameBuffer->clear();
98 }
99 
101 {
102  for (auto frameBuffer : _frameBuffers)
103  frameBuffer->resetModified();
104 }
105 
106 void Engine::addRendererType(const std::string& name, const PropertyMap& properties)
107 {
109  getRenderer().setProperties(name, properties);
110  _rendererTypes.push_back(name);
111 }
112 
113 void Engine::addCameraType(const std::string& name, const PropertyMap& properties)
114 {
116  getCamera().setProperties(name, properties);
117 }
118 } // namespace core
PLATFORM_API void removeFrameBuffer(FrameBufferPtr frameBuffer)
Removes a frame buffer from the list of buffers that are filled during rendering.
Definition: Engine.cpp:89
PLATFORM_API void addRendererType(const std::string &name, const PropertyMap &properties={})
Adds a new renderer type with optional properties.
Definition: Engine.cpp:106
std::vector< FrameBufferPtr > _frameBuffers
Definition: Engine.h:280
PLATFORM_API bool continueRendering() const
Returns a boolean indicating whether render calls shall be continued based on current accumulation se...
Definition: Engine.cpp:77
ParametersManager & _parametersManager
Definition: Engine.h:276
PLATFORM_API Renderer & getRenderer()
Returns the renderer.
Definition: Engine.cpp:72
virtual PLATFORM_API void commit()
Commits changes to the engine. This includes scene modifications, camera modifications and renderer m...
Definition: Engine.cpp:41
virtual PLATFORM_API void preRender()
Executes engine-specific pre-render operations.
Definition: Engine.cpp:46
PLATFORM_API void clearFrameBuffers()
Clears all frame buffers.
Definition: Engine.cpp:94
PLATFORM_API void render()
Renders the current scene and populates the frame buffer accordingly.
Definition: Engine.cpp:55
RendererPtr _renderer
Definition: Engine.h:279
PLATFORM_API void addFrameBuffer(FrameBufferPtr frameBuffer)
Adds a frame buffer to the list to be filled during rendering.
Definition: Engine.cpp:84
virtual PLATFORM_API void postRender()
Executes engine-specific post-render operations.
Definition: Engine.cpp:66
PLATFORM_API void addCameraType(const std::string &name, const PropertyMap &properties={})
Adds a new camera type with optional properties.
Definition: Engine.cpp:113
strings _rendererTypes
Definition: Engine.h:282
PLATFORM_API void resetFrameBuffers()
Resets all frame buffers.
Definition: Engine.cpp:100
CameraPtr _camera
Definition: Engine.h:278
PLATFORM_API const Camera & getCamera() const
Returns the camera.
Definition: Engine.h:161
PLATFORM_API Engine(ParametersManager &parametersManager)
Engine Constructor.
Definition: Engine.cpp:36
PLATFORM_API AnimationParameters & getAnimationParameters()
PLATFORM_API RenderingParameters & getRenderingParameters()
void setProperties(const PropertyMap &properties)
Renderer class inherits from PropertyObject class The Renderer class has methods to render a FrameBuf...
Definition: Renderer.h:42
void addCamera(const std::string &camera)
void addRenderer(const std::string &renderer)
std::shared_ptr< FrameBuffer > FrameBufferPtr
Definition: Types.h:100