Blue Brain BioExplorer
Utils.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 <algorithm>
29 
30 namespace core
31 {
32 strings parseFolder(const std::string& folder, const strings& filters);
33 
34 std::string extractExtension(const std::string& filename);
35 
36 template <size_t M, typename T>
37 inline glm::vec<M, T> toGlmVec(const std::array<T, M>& input)
38 {
39  glm::vec<M, T> vec;
40  memcpy(glm::value_ptr(vec), input.data(), input.size() * sizeof(T));
41  return vec;
42 }
43 
44 template <size_t M, typename T>
45 inline std::array<T, M> toArray(const glm::vec<M, T>& input)
46 {
47  std::array<T, M> output;
48  memcpy(output.data(), glm::value_ptr(input), M * sizeof(T));
49  return output;
50 }
51 
61 Vector4f getBezierPoint(const Vector4fs& controlPoints, const float t);
62 
69 Vector3fs getRainbowColormap(const uint32_t colormapSize);
70 
79 template <typename To, typename From>
80 To lexical_cast(const From& from);
81 
82 } // namespace core
std::array< T, M > toArray(const glm::vec< M, T > &input)
Definition: Utils.h:45
strings parseFolder(const std::string &folder, const strings &filters)
Definition: Utils.cpp:37
glm::vec4 Vector4f
Definition: MathTypes.h:138
To lexical_cast(const From &from)
Function template taking two template parameters (To and From) representing the source and target typ...
Definition: Utils.cpp:139
Vector3fs getRainbowColormap(const uint32_t colormapSize)
Get the Rainbow Colormap.
Definition: Utils.cpp:126
std::vector< Vector4f > Vector4fs
Definition: MathTypes.h:140
glm::vec< M, T > toGlmVec(const std::array< T, M > &input)
Definition: Utils.h:37
std::vector< Vector3f > Vector3fs
Definition: MathTypes.h:139
Vector4f getBezierPoint(const Vector4fs &controlPoints, const float t)
Get the Bezier Point from a curve defined by the provided control points.
Definition: Utils.cpp:73
std::string extractExtension(const std::string &filename)
Definition: Utils.cpp:64
std::vector< std::string > strings
Definition: Types.h:44