foamGltfScene.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 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
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 
26 Class
27  Foam::glTF::scene
28 
29 Description
30  Main class to assemble glTF components into a scene
31 
32 Note
33  Implements the glTF v2 specification
34 
35 SourceFiles
36  foamGltfScene.C
37  foamGltfSceneTemplates.C
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef foam_gltf_scene_H
42 #define foam_gltf_scene_H
43 
44 #include "foamGltfList.H"
45 #include "foamGltfObject.H"
46 #include "foamGltfMesh.H"
47 #include "foamGltfBufferView.H"
48 #include "foamGltfAccessor.H"
49 #include "foamGltfAnimation.H"
50 #include "scalarField.H"
51 #include "vectorField.H"
52 #include "OFstream.H"
53 
54 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 
56 namespace Foam
57 {
58 namespace glTF
59 {
60 
61 /*---------------------------------------------------------------------------*\
62  Class glTF::scene Declaration
63 \*---------------------------------------------------------------------------*/
64 
65 class scene
66 {
67  // Private Data
68 
69  //- List of binary objects
70  glTF::List<object> objects_;
71 
72  //- List of meshes
73  glTF::List<mesh> meshes_;
74 
75  //- List of buffer views
76  glTF::List<bufferView> bufferViews_;
77 
78  //- List of accessors
79  glTF::List<accessor> accessors_;
80 
81  //- List of animations
82  glTF::List<animation> animations_;
83 
84  //- Accumulative size in bytes
85  label bytes_;
86 
87 
88 public:
89 
90  // Constructors
91 
92  //- Default construct
93  scene();
94 
95 
96  // Public Member Functions
97 
98  //- Returns accessor index
99  template<class Type>
100  label addField
101  (
102  const Type& fld,
103  const word& name,
104  const label target = -1
105  );
106 
107  //- Returns index of last mesh
108  template<class Type>
109  label addMesh(const Type& fld, const word& name);
110 
111  //- Returns accessor index
112  template<class Type>
113  label addFieldToMesh
114  (
115  const Type& fld,
116  const word& name,
117  const label meshi
118  );
119 
120  //- Returns accessor index
121  label addColourToMesh
122  (
123  const vectorField& fld,
124  const word& name,
125  const label meshi,
126  const scalarField& alpha = scalarField()
127  );
128 
129  //- Returns index of last animation
130  label createAnimation(const word& name);
131 
132  //- Add to existing animation
133  void addToAnimation
134  (
135  const label animationi,
136  const label inputId,
137  const label outputId,
138  const label meshId,
139  const string& interpolation = "LINEAR"
140  );
141 
142  //- Write to stream (JSON and binary data)
143  void write(Ostream& os);
144 };
145 
146 
147 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
148 
149 } // End namespace glTF
150 } // End namespace Foam
151 
152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153 
154 #ifdef NoRepository
155  #include "foamGltfSceneTemplates.C"
156 #endif
157 
158 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
159 
160 #endif
161 
162 // ************************************************************************* //
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:52
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
foamGltfList.H
scalarField.H
Foam::glTF::scene::scene
scene()
Default construct.
Definition: foamGltfScene.C:33
Foam::glTF::scene::addField
label addField(const Type &fld, const word &name, const label target=-1)
Returns accessor index.
Foam::constant::atomic::alpha
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
Definition: readThermalProperties.H:212
Foam::glTF::scene::addMesh
label addMesh(const Type &fld, const word &name)
Returns index of last mesh.
Foam::glTF::scene::addToAnimation
void addToAnimation(const label animationi, const label inputId, const label outputId, const label meshId, const string &interpolation="LINEAR")
Add to existing animation.
Definition: foamGltfScene.C:102
OFstream.H
Foam::glTF::scene::addFieldToMesh
label addFieldToMesh(const Type &fld, const word &name, const label meshi)
Returns accessor index.
foamGltfSceneTemplates.C
foamGltfAccessor.H
Foam::Field< vector >
Foam::glTF::scene
Main class to assemble glTF components into a scene.
Definition: foamGltfScene.H:64
fld
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Definition: gmvOutputLagrangian.H:23
Foam::interpolation
Abstract base class for interpolation.
Definition: mappedPatchFieldBase.H:96
os
OBJstream os(runTime.globalPath()/outputName)
foamGltfMesh.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::glTF::scene::write
void write(Ostream &os)
Write to stream (JSON and binary data)
Definition: foamGltfScene.C:139
foamGltfAnimation.H
foamGltfBufferView.H
Foam::glTF::List
Container for glTF entities.
Definition: foamGltfList.H:51
foamGltfObject.H
Foam::glTF::scene::addColourToMesh
label addColourToMesh(const vectorField &fld, const word &name, const label meshi, const scalarField &alpha=scalarField())
Returns accessor index.
Definition: foamGltfScene.C:47
vectorField.H
Foam::glTF::scene::createAnimation
label createAnimation(const word &name)
Returns index of last animation.
Definition: foamGltfScene.C:94
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56