Loading...
Searching...
No Matches
foamGltfBase.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2021-2025 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Namespace
27 Foam::glTF
28
29Description
30 Namespace for handling glTF creation.
31 https://www.khronos.org/registry/glTF/
32
33Class
34 Foam::glTF::base
35
36Description
37 Base class for glTF entities
38
39\*---------------------------------------------------------------------------*/
40
41#ifndef Foam_gltf_base_H
42#define Foam_gltf_base_H
43
44#include "word.H"
45#include "label.H"
46#include "Ostream.H"
47
48// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50namespace Foam
52namespace glTF
55 enum class componentTypes : int
56 {
57 BYTE = 5120,
58 UNSIGNED_BYTE = 5121,
59 SHORT = 5122,
61 UNSIGNED_INT = 5125,
62 FLOAT = 5126
63 };
65 // accessor
66 enum class dataTypes
67 {
69 VEC2,
70 VEC3,
89 // bufferView
90 enum class targetTypes : int
91 {
92 ARRAY_BUFFER = 34962,
94 };
96 enum class primitiveModes : int
97 {
98 POINTS = 0,
99 LINES = 1,
100 LINE_LOOP = 2,
101 LINE_STRIP = 3,
102 TRIANGLES = 4,
103 TRIANGLE_STRIP = 5,
104 TRIANGLE_FAN = 6
105 };
106
107 //- Helper function to return the enum value
108 template<class Type, class = std::enable_if_t<std::is_enum_v<Type>>>
109 constexpr auto key(const Type& t) noexcept
110 {
111 return static_cast<std::underlying_type_t<Type>>(t);
112 }
113
114
115/*---------------------------------------------------------------------------*\
116 Class base Declaration
117\*---------------------------------------------------------------------------*/
118
119class base
120{
121protected:
122
123 // Protected Data
125 //- Name
126 word name_;
127
128 //- ID
129 label id_;
130
131
132public:
133
134 // Constructors
135
136 //- Default construct
137 base()
138 :
139 id_(-1)
140 {}
141
142 //- Construct with name
143 explicit base(const word& name)
144 :
145 name_(name),
146 id_(-1)
147 {}
148
149
150 //- Destructor
151 ~base() = default;
152
153
154 // Member Functions
155
156 //- Return access to the ID
157 label& id() noexcept
158 {
159 return id_;
160 }
161
162 //- Return const access to the name
163 const word& name() const noexcept
164 {
165 return name_;
166 }
167
168 //- Write
169 void write(Ostream& os) const
170 {
171 os << "," << nl
172 << indent << "\"name\" : \"" << name_ << "\"";
174
175
176 // Member Operators
177
178 void operator=(const base& gltf)
179 {
180 name_ = gltf.name_;
181 id_ = gltf.id_;
182 }
183};
184
185
186// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
187
188} // End namespace glTF
189} // End namespace Foam
191// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
192
193#endif
194
195// ************************************************************************* //
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
Base class for glTF entities.
~base()=default
Destructor.
base(const word &name)
Construct with name.
void write(Ostream &os) const
Write.
const word & name() const noexcept
Return const access to the name.
label & id() noexcept
Return access to the ID.
void operator=(const base &gltf)
base()
Default construct.
A class for handling words, derived from Foam::string.
Definition word.H:66
OBJstream os(runTime.globalPath()/outputName)
Namespace for handling glTF creation. https://www.khronos.org/registry/glTF/.
@ NORMAL
VEC3 Normalised XYZ vertex normals.
@ TEXCOORD_0
VEC2 UV texture coordinates.
@ TANGENT
VEC4 XYZW vertex tangents.
@ COLOR_0
VEC3 (rgb), VEC4 (rgba).
@ POSITION
VEC3 XYZ vertex positions; requires 'min' and 'max'.
@ TEXCOORD_1
VEC2 UV texture coordinates.
constexpr auto key(const Type &t) noexcept
Helper function to return the enum value.
@ ELEMENT_ARRAY_BUFFER
vertex indices
@ ARRAY_BUFFER
vertex attributes
@ MAT4
16 components
Namespace for OpenFOAM.
Ostream & indent(Ostream &os)
Indent stream.
Definition Ostream.H:481
const direction noexcept
Definition scalarImpl.H:265
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
runTime write()