Blue Brain BioExplorer
Types.h
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 #pragma once
24 
27 
28 #include <array>
29 #include <cstdint>
30 #include <limits>
31 #include <map>
32 #include <memory>
33 #include <vector>
34 
35 using int64 = ::int64_t;
36 using uint64 = ::uint64_t;
37 using int32 = ::int32_t;
38 using uint32 = ::uint32_t;
39 using int16 = ::int16_t;
40 using uint16 = ::uint16_t;
41 using int8 = ::int8_t;
42 using uint8 = ::uint8_t;
43 using index_t = ::int64_t;
44 using strings = std::vector<std::string>;
45 using floats = std::vector<float>;
46 using ints = std::vector<int>;
47 using uints = std::vector<unsigned int>;
48 using int8_ts = std::vector<int8_t>;
49 using uint8_ts = std::vector<uint8_t>;
50 using int16_ts = std::vector<int16_t>;
51 using uint16_ts = std::vector<uint16_t>;
52 using int32_ts = std::vector<int32_t>;
53 using uint32_ts = std::vector<uint32_t>;
54 using int64_ts = std::vector<int64_t>;
55 using uint64_ts = std::vector<uint64_t>;
56 using size_ts = std::vector<size_t>;
57 using StringMap = std::map<std::string, std::string>;
59 using Palette = std::vector<Color>;
60 using Quaternions = std::vector<core::Quaterniond>;
61 using bools = std::vector<bool>;
62 using doubles = std::vector<double>;
63 using strings = std::vector<std::string>;
64 using Vector3ds = std::vector<core::Vector3d>;
65 using Vector3dm = std::map<uint64_t, core::Vector3d>;
66 using Vector4ds = std::vector<core::Vector4d>;
67 using Vector2uis = std::vector<core::Vector2ui>;
68 using Vector3uis = std::vector<core::Vector3ui>;
69 using uint8_ts = std::vector<uint8_t>;
70 using uint8_tm = std::map<uint64_t, uint8_t>;
71 using uint32_ts = std::vector<uint32_t>;
72 using uint64_ts = std::vector<uint64_t>;
73 using uint64_tm = std::map<uint64_t, uint64_t>;
74 using CommandLineArguments = std::map<std::string, std::string>;
75 
76 namespace core
77 {
78 // Forward declarations
79 class Core;
80 
81 class ActionInterface;
82 using ActionInterfacePtr = std::shared_ptr<ActionInterface>;
83 
84 class Engine;
85 using EnginePtr = std::shared_ptr<Engine>;
86 
87 class Scene;
88 using ScenePtr = std::shared_ptr<Scene>;
89 
91 
92 class Camera;
93 using CameraPtr = std::shared_ptr<Camera>;
94 
95 class TransferFunction;
96 class Renderer;
97 using RendererPtr = std::shared_ptr<Renderer>;
98 
99 class FrameBuffer;
100 using FrameBufferPtr = std::shared_ptr<FrameBuffer>;
101 
102 class Model;
103 using ModelPtr = std::unique_ptr<Model>;
104 using ModelMetadata = std::map<std::string, std::string>;
105 
106 class Transformation;
107 using Transformations = std::vector<Transformation>;
108 
109 class ModelInstance;
110 class ModelParams;
111 class ModelDescriptor;
112 using ModelDescriptorPtr = std::shared_ptr<ModelDescriptor>;
113 using ModelDescriptors = std::vector<ModelDescriptorPtr>;
114 using ModelInstances = std::vector<ModelInstance>;
115 
116 class Material;
117 using MaterialPtr = std::shared_ptr<Material>;
118 using MaterialMap = std::map<size_t, MaterialPtr>;
119 
120 class ClipPlane;
121 using ClipPlanePtr = std::shared_ptr<ClipPlane>;
122 using ClipPlanes = std::vector<ClipPlanePtr>;
123 
124 struct Sphere;
125 using Spheres = std::vector<Sphere>;
126 using SpheresMap = std::map<size_t, Spheres>;
127 
128 struct Cylinder;
129 using Cylinders = std::vector<Cylinder>;
130 using CylindersMap = std::map<size_t, Cylinders>;
131 
132 struct Cone;
133 using Cones = std::vector<Cone>;
134 using ConesMap = std::map<size_t, Cones>;
135 
136 struct TriangleMesh;
137 using TriangleMeshMap = std::map<size_t, TriangleMesh>;
138 
139 struct StreamlinesData;
140 using StreamlinesDataMap = std::map<size_t, StreamlinesData>;
141 
142 struct Curve;
143 using Curves = std::vector<Curve>;
144 using CurvesMap = std::map<size_t, Curves>;
145 
146 class Field;
147 using FieldPtr = std::shared_ptr<Field>;
148 using FieldsMap = std::map<size_t, FieldPtr>;
149 
150 class Volume;
151 class BrickedVolume;
152 class SharedDataVolume;
153 using VolumePtr = std::shared_ptr<Volume>;
154 using SharedDataVolumePtr = std::shared_ptr<SharedDataVolume>;
155 using BrickedVolumePtr = std::shared_ptr<BrickedVolume>;
156 using VolumesMap = std::map<size_t, VolumePtr>;
157 
158 class Texture2D;
159 using Texture2DPtr = std::shared_ptr<Texture2D>;
160 using TexturesMap = std::map<std::string, Texture2DPtr>;
161 
162 class Light;
163 using LightPtr = std::shared_ptr<Light>;
164 using Lights = std::vector<LightPtr>;
165 
166 class DirectionalLight;
167 using DirectionalLightPtr = std::shared_ptr<DirectionalLight>;
168 
169 class SphereLight;
170 using SphereLightPtr = std::shared_ptr<SphereLight>;
171 
172 class QuadLight;
173 using QuadLightPtr = std::shared_ptr<QuadLight>;
174 
175 class SpotLight;
176 using SpotLightPtr = std::shared_ptr<SpotLight>;
177 
179 using AbstractSimulationHandlerPtr = std::shared_ptr<AbstractSimulationHandler>;
180 
181 class AbstractParameters;
182 class AnimationParameters;
184 class GeometryParameters;
185 class ParametersManager;
186 class RenderingParameters;
187 class VolumeParameters;
188 class FieldParameters;
189 
190 class PluginAPI;
191 class ExtensionPlugin;
192 
193 class KeyboardHandler;
194 
195 class MeshLoader;
196 
197 class Statistics;
198 
200 static const char* ENGINE_OSPRAY = "ospray";
201 static const char* ENGINE_OPTIX_6 = "optix6";
202 
205 {
206  rgba_i8,
207  bgra_i8,
208  rgb_i8,
209  rgb_f32,
210  none
211 };
212 
215 {
216  linear = 0,
217  ai_denoised = 1,
218 };
219 
221 enum class GeometryQuality
222 {
223  low,
224  medium,
225  high
226 };
227 
231 static const size_t NO_MATERIAL = std::numeric_limits<size_t>::max();
232 static const size_t BOUNDINGBOX_MATERIAL_ID = NO_MATERIAL - 1;
233 static const size_t SECONDARY_MODEL_MATERIAL_ID = NO_MATERIAL - 2;
234 static const size_t VOLUME_MATERIAL_ID = NO_MATERIAL - 3;
235 static const size_t VOLUME_OCTREE_INDICES_MATERIAL_ID = NO_MATERIAL - 4;
236 static const size_t VOLUME_OCTREE_VALUES_MATERIAL_ID = NO_MATERIAL - 5;
237 static const size_t FIELD_MATERIAL_ID = NO_MATERIAL - 6;
238 
239 static const std::string IRRADIANCE_MAP = "-irradiance";
240 static const std::string RADIANCE_MAP = "-radiance";
241 static const std::string BRDF_LUT = "-brdfLUT";
242 
243 enum class TextureType : uint8_t
244 {
245  diffuse = 0,
246  normals,
247  bump,
248  specular,
249  emissive,
250  opacity,
251  reflection,
252  refraction,
253  occlusion,
254  radiance,
255  irradiance,
256  brdf_lut,
257  volume,
261 };
262 
263 static const strings textureTypeToString{"albedoMetallic_map",
264  "normalRoughness_map",
265  "bump_map",
266  "aoEmissive_map",
267  "map_ns",
268  "map_d",
269  "map_reflection",
270  "map_refraction",
271  "map_occlusion",
272  "radiance_map",
273  "irradiance_map",
274  "brdf_lut",
275  "volume_map",
276  "transfer_function_map",
277  "octree_indices_map",
278  "octree_values_map"};
279 
280 enum class MemoryMode
281 {
282  shared,
283  replicated
284 };
285 
287 {
288  random, // Random materials including transparency, reflection,
289  // and light emission
290  shades_of_grey, // 255 shades of grey
291  gradient, // Gradient from blue to yellow through green
292  pastel // Random pastel colors
293 };
294 
298 enum class CameraMode
299 {
300  flying,
301  inspect
302 };
303 
308 using Plane = std::array<double, 4>;
309 using Planes = std::vector<Plane>;
310 
312 {
314 
318 };
319 
321 {
326 };
327 
328 class Progress;
329 
330 class AbstractTask;
331 using TaskPtr = std::shared_ptr<AbstractTask>;
332 
333 struct Blob
334 {
335  std::string type;
336  std::string name;
338 };
339 
340 class Loader;
341 using LoaderPtr = std::unique_ptr<Loader>;
342 
343 enum class DataType
344 {
345  FLOAT,
346  DOUBLE,
347  UINT8,
348  UINT16,
349  UINT32,
350  INT8,
351  INT16,
352  INT32
353 };
354 
355 class PropertyMap;
356 class PropertyObject;
357 
358 enum class Execution
359 {
360  sync,
361  async
362 };
363 
366 {
367  std::string methodName;
368  std::string methodDescription;
370 };
371 
374 {
375  RpcParameterDescription(const std::string& methodName_, const std::string& methodDescription_,
376  const Execution type_, const std::string& paramName_, const std::string& paramDescription_)
377  : RpcDescription{methodName_, methodDescription_, type_}
378  , paramName(paramName_)
379  , paramDescription(paramDescription_)
380  {
381  }
382 
383  RpcParameterDescription(const std::string& methodName_, const std::string& methodDescription_,
384  const std::string& paramName_, const std::string& paramDescription_)
385  : RpcDescription{methodName_, methodDescription_, Execution::sync}
386  , paramName(paramName_)
387  , paramDescription(paramDescription_)
388  {
389  }
390 
391  std::string paramName;
392  std::string paramDescription;
393 };
394 
395 enum class BVHFlag
396 {
397  dynamic,
398  compact,
399  robust
400 };
401 
403 
404 template <>
405 inline std::vector<std::pair<std::string, GeometryQuality>> enumMap()
406 {
407  return {{"low", GeometryQuality::low}, {"medium", GeometryQuality::medium}, {"high", GeometryQuality::high}};
408 }
409 
410 template <>
411 inline std::vector<std::pair<std::string, DataType>> enumMap()
412 {
413  return {{"float", DataType::FLOAT}, {"double", DataType::DOUBLE}, {"uint8", DataType::UINT8},
414  {"uint16", DataType::UINT16}, {"uint32", DataType::UINT32}, {"int8", DataType::INT8},
415  {"int16", DataType::INT16}, {"int32", DataType::INT32}};
416 }
417 
419 
420 typedef struct
421 {
424 } OctreeVector;
425 using OctreeVectors = std::vector<OctreeVector>;
426 
427 typedef struct
428 {
430  double radius;
431  double value;
432 } OctreePoint;
433 using OctreePoints = std::vector<OctreePoint>;
434 
436 
437 static const float DEFAULT_GEOMETRY_SDF_EPSILON = 0.0001f;
438 static const uint32_t DEFAULT_GEOMETRY_SDF_NB_MARCH_ITERATIONS = 32;
439 static const float DEFAULT_GEOMETRY_SDF_BLEND_FACTOR = 0.4;
440 static const float DEFAULT_GEOMETRY_SDF_BLEND_LERP_FACTOR = 0.2;
441 static const float DEFAULT_GEOMETRY_SDF_OMEGA = 1.0f;
442 static const float DEFAULT_GEOMETRY_SDF_DISTANCE = 250.f;
443 
444 } // namespace core
The AbstractSimulationHandler class handles simulation frames for the current circuit.
A volume type where the voxels are copied for each added brick.
Definition: BrickedVolume.h:35
The Camera class is an abstract interface for a camera in a 3D graphics application....
Definition: Camera.h:41
Provides an abstract implementation of a ray-tracing engine.
Definition: Engine.h:59
A field is volume in which voxels are computed in real-time using a pre-loaded Octree structure of ev...
Definition: Field.h:37
This class represents a frame buffer for an engine specific code. It provides an API for utilizing an...
Definition: FrameBuffer.h:39
The KeyboardHandler class manages keyboard shortcuts and special keys.
The Light class defines the common base class for all lights.
Definition: Light.h:43
The class that represents the material object. This class is derived from PropertyObject and provides...
Definition: Material.h:47
The ModelDescriptor struct defines the metadata attached to a model.Model descriptor are exposed via ...
Definition: Model.h:285
A class representing an instance of a 3D model.
Definition: Model.h:80
The ModelParams class represents the parameters needed for initializing a model instance.
Definition: Model.h:178
The abstract Model class holds the geometry attached to an asset of the scene (mesh,...
Definition: Model.h:469
Renderer class inherits from PropertyObject class The Renderer class has methods to render a FrameBuf...
Definition: Renderer.h:42
Scene object This object contains collections of geometries, materials and light sources that are use...
Definition: Scene.h:43
Defines the translation, rotation and scale parameters to be applied to a scene asset.
A base class for volumes.
Definition: Volume.h:34
std::vector< Transformation > Transformations
Definition: Types.h:107
std::shared_ptr< Camera > CameraPtr
Definition: Types.h:93
std::map< size_t, Cones > ConesMap
Definition: Types.h:134
GeometryQuality
Definition: Types.h:222
std::map< size_t, StreamlinesData > StreamlinesDataMap
Definition: Types.h:140
std::map< std::string, std::string > ModelMetadata
Definition: Types.h:104
std::shared_ptr< Volume > VolumePtr
Definition: Types.h:153
std::vector< ModelDescriptorPtr > ModelDescriptors
Definition: Types.h:113
std::vector< Cylinder > Cylinders
Definition: Types.h:129
std::map< size_t, MaterialPtr > MaterialMap
Definition: Types.h:118
std::shared_ptr< BrickedVolume > BrickedVolumePtr
Definition: Types.h:155
std::map< std::string, Texture2DPtr > TexturesMap
Definition: Types.h:160
std::shared_ptr< Light > LightPtr
Definition: Types.h:163
std::shared_ptr< ClipPlane > ClipPlanePtr
Definition: Types.h:121
std::map< size_t, Curves > CurvesMap
Definition: Types.h:144
std::shared_ptr< AbstractSimulationHandler > AbstractSimulationHandlerPtr
Definition: Types.h:179
glm::vec< 2, int32_t > Vector2i
Definition: MathTypes.h:130
MaterialsColorMap
Definition: Types.h:287
std::shared_ptr< SharedDataVolume > SharedDataVolumePtr
Definition: Types.h:154
Execution
Definition: Types.h:359
std::shared_ptr< Texture2D > Texture2DPtr
Definition: Types.h:159
std::map< size_t, FieldPtr > FieldsMap
Definition: Types.h:148
std::shared_ptr< SpotLight > SpotLightPtr
Definition: Types.h:176
glm::vec< 3, double > Vector3d
Definition: MathTypes.h:143
std::shared_ptr< Renderer > RendererPtr
Definition: Types.h:97
std::shared_ptr< FrameBuffer > FrameBufferPtr
Definition: Types.h:100
DataType
Definition: Types.h:344
std::shared_ptr< SphereLight > SphereLightPtr
Definition: Types.h:170
std::vector< Curve > Curves
Definition: Types.h:143
std::map< size_t, Cylinders > CylindersMap
Definition: Types.h:130
std::shared_ptr< Scene > ScenePtr
Definition: Types.h:88
std::vector< OctreeVector > OctreeVectors
Definition: Types.h:425
MemoryMode
Definition: Types.h:281
std::map< size_t, TriangleMesh > TriangleMeshMap
Definition: Types.h:137
std::vector< ClipPlanePtr > ClipPlanes
Definition: Types.h:122
TextureType
Definition: Types.h:244
std::vector< Sphere > Spheres
Definition: Types.h:125
std::shared_ptr< ModelDescriptor > ModelDescriptorPtr
Definition: Types.h:112
std::vector< Plane > Planes
Definition: Types.h:309
FrameBufferFormat
Definition: Types.h:205
std::shared_ptr< Field > FieldPtr
Definition: Types.h:147
std::map< size_t, Spheres > SpheresMap
Definition: Types.h:126
std::map< size_t, VolumePtr > VolumesMap
Definition: Types.h:156
CameraMode
Definition: Types.h:299
glm::tquat< double, glm::highp > Quaterniond
Double quaternion.
Definition: MathTypes.h:153
std::unique_ptr< Loader > LoaderPtr
Definition: Types.h:341
BVHFlag
Definition: Types.h:396
std::vector< std::pair< std::string, GeometryQuality > > enumMap()
Definition: Types.h:405
std::shared_ptr< ActionInterface > ActionInterfacePtr
Definition: Types.h:82
std::shared_ptr< AbstractTask > TaskPtr
Definition: Types.h:331
AccumulationType
Definition: Types.h:215
std::shared_ptr< Engine > EnginePtr
Definition: Types.h:85
std::vector< OctreePoint > OctreePoints
Definition: Types.h:433
std::vector< ModelInstance > ModelInstances
Definition: Types.h:114
std::shared_ptr< DirectionalLight > DirectionalLightPtr
Definition: Types.h:167
std::vector< Cone > Cones
Definition: Types.h:133
std::unique_ptr< Model > ModelPtr
Definition: Types.h:103
std::shared_ptr< QuadLight > QuadLightPtr
Definition: Types.h:173
std::vector< LightPtr > Lights
Definition: Types.h:164
std::shared_ptr< Material > MaterialPtr
Definition: Types.h:117
std::array< double, 4 > Plane
Definition: Types.h:308
std::vector< core::Vector3d > Vector3ds
Definition: Types.h:64
std::vector< Color > Palette
Definition: Types.h:59
std::vector< int16_t > int16_ts
Definition: Types.h:50
::int32_t int32
Definition: Types.h:37
std::vector< uint8_t > uint8_ts
Definition: Types.h:49
std::vector< double > doubles
Definition: Types.h:62
::int16_t int16
Definition: Types.h:39
std::map< uint64_t, core::Vector3d > Vector3dm
Definition: Types.h:65
std::vector< int8_t > int8_ts
Definition: Types.h:48
std::map< std::string, std::string > CommandLineArguments
Definition: Types.h:74
::int8_t int8
Definition: Types.h:41
std::vector< std::string > strings
Definition: Types.h:44
std::vector< core::Vector4d > Vector4ds
Definition: Types.h:66
std::vector< int32_t > int32_ts
Definition: Types.h:52
std::vector< uint16_t > uint16_ts
Definition: Types.h:51
std::vector< size_t > size_ts
Definition: Types.h:56
::int64_t index_t
Definition: Types.h:43
::uint64_t uint64
Definition: Types.h:36
std::vector< core::Quaterniond > Quaternions
Definition: Types.h:60
std::vector< bool > bools
Definition: Types.h:61
std::vector< uint32_t > uint32_ts
Definition: Types.h:53
::uint16_t uint16
Definition: Types.h:40
::uint32_t uint32
Definition: Types.h:38
std::vector< unsigned int > uints
Definition: Types.h:47
std::vector< core::Vector2ui > Vector2uis
Definition: Types.h:67
std::vector< uint64_t > uint64_ts
Definition: Types.h:55
std::vector< float > floats
Definition: Types.h:45
std::map< uint64_t, uint64_t > uint64_tm
Definition: Types.h:73
std::vector< int64_t > int64_ts
Definition: Types.h:54
std::vector< core::Vector3ui > Vector3uis
Definition: Types.h:68
std::map< uint64_t, uint8_t > uint8_tm
Definition: Types.h:70
std::vector< int > ints
Definition: Types.h:46
::uint8_t uint8
Definition: Types.h:42
core::Vector3d Color
Definition: Types.h:58
std::map< std::string, std::string > StringMap
Definition: Types.h:57
::int64_t int64
Definition: Types.h:35
Definition: Cone.h:35
Definition: Sphere.h:35
std::string name
Definition: Types.h:336
uint8_ts data
Definition: Types.h:337
std::string type
Definition: Types.h:335
Vector3d position
Definition: Types.h:429
double radius
Definition: Types.h:430
double value
Definition: Types.h:431
Vector3d position
Definition: Types.h:422
Vector3d direction
Definition: Types.h:423
Quaterniond orientation
Definition: Types.h:317
Vector3d target
Definition: Types.h:316
Vector3d position
Definition: Types.h:315
Vector2i windowSize
Definition: Types.h:313
floats floatBuffer
Definition: Types.h:324
Vector2i frameSize
Definition: Types.h:322
uint8_ts colorBuffer
Definition: Types.h:323
FrameBufferFormat colorBufferFormat
Definition: Types.h:325
Execution type
Definition: Types.h:369
std::string methodName
Definition: Types.h:367
std::string methodDescription
Definition: Types.h:368
RpcParameterDescription(const std::string &methodName_, const std::string &methodDescription_, const std::string &paramName_, const std::string &paramDescription_)
Definition: Types.h:383
std::string paramDescription
Definition: Types.h:392
RpcParameterDescription(const std::string &methodName_, const std::string &methodDescription_, const Execution type_, const std::string &paramName_, const std::string &paramDescription_)
Definition: Types.h:375