foamGltfAccessor.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::accessor
28 
29 Description
30  glTF accessor
31 
32 Note
33  Implements the glTF v2 specification
34 
35 SourceFiles
36  foamGltfAccessor.C
37  foamGltfAccessorTemplates.C
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef foam_gltf_accessor_H
42 #define foam_gltf_accessor_H
43 
44 #include "foamGltfBase.H"
45 #include "Field.H"
46 #include "label.H"
47 #include "string.H"
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 namespace glTF
54 {
55  class accessor;
56 }
57 
59 
60 namespace glTF
61 {
62 
63 /*---------------------------------------------------------------------------*\
64  Class glTF::accessor Declaration
65 \*---------------------------------------------------------------------------*/
66 
67 class accessor
68 :
69  public base
70 {
71 protected:
72 
73  // Protected Data
74 
75  //- Buffer view index
76  label bufferViewId_;
77 
78  //- Byte offset
79  label byteOffset_;
80 
81  //- Component type
82  label componentType_;
83 
84  //- Data size
85  label count_;
86 
87  //- Data type
88  string type_;
89 
90  //- Max value. Note: stored as a string for convenience
91  string max_;
92 
93  //- Min value. Note: stored as a string for convenience
94  string min_;
95 
96  //- Flag to indicate whether min and max values are available
97  bool minMax_;
98 
99 
100  // Protected Member Functions
101 
102  //- Return the glTF value type for the given OpenFOAM type
103  template<class Type>
104  static string getValueType();
105 
106  //- Stringify the value
107  template<class Type>
108  static string toString(const Type& val);
109 
110 
111 public:
112 
113  // Constructors
114 
115  //- Default construct
116  accessor();
117 
118  //- Construct from name
119  explicit accessor(const word& name);
120 
121 
122  //- Destructor
123  ~accessor() = default;
124 
125 
126  // Public Member Functions
127 
128  //- Return the buffer view index
129  label& bufferViewId() noexcept;
130 
131  //- Return the byte offset
132  label& byteOffset() noexcept;
133 
134  //- Return the component type
135  label& componentType() noexcept;
136 
137  //- Return the data size
138  label& count() noexcept;
139 
140  //- Return the type
141  string& type() noexcept;
142 
143  //- Set the accessor
144  template<class Type>
145  void set(const Field<Type>& fld, bool calcMinMax = true);
146 
147  //- Write
148  void write(Ostream& os) const;
149 };
150 
151 
152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153 
154 } // End namespace glTF
155 } // End namespace Foam
156 
157 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
158 
159 #ifdef NoRepository
160  #include "foamGltfAccessorTemplates.C"
161 #endif
162 
163 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
164 
165 #endif
166 
167 // ************************************************************************* //
Foam::glTF::accessor::byteOffset_
label byteOffset_
Byte offset.
Definition: foamGltfAccessor.H:78
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::glTF::accessor::set
void set(const Field< Type > &fld, bool calcMinMax=true)
Set the accessor.
Definition: foamGltfAccessorTemplates.C:86
Foam::glTF::accessor::componentType
label & componentType() noexcept
Return the component type.
Definition: foamGltfAccessor.C:74
string.H
Foam::glTF::base::name
const word & name() const noexcept
Return const access to the name.
Definition: foamGltfBase.H:165
Foam::glTF::accessor::count
label & count() noexcept
Return the data size.
Definition: foamGltfAccessor.C:80
Foam::glTF::accessor::bufferViewId
label & bufferViewId() noexcept
Return the buffer view index.
Definition: foamGltfAccessor.C:62
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Foam::glTF::base
Base class for glTF entities.
Definition: foamGltfBase.H:121
Foam::glTF::accessor::minMax_
bool minMax_
Flag to indicate whether min and max values are available.
Definition: foamGltfAccessor.H:96
Foam::glTF::accessor::type_
string type_
Data type.
Definition: foamGltfAccessor.H:87
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::glTF::accessor::byteOffset
label & byteOffset() noexcept
Return the byte offset.
Definition: foamGltfAccessor.C:68
Foam::glTF::accessor::type
string & type() noexcept
Return the type.
Definition: foamGltfAccessor.C:86
Foam::glTF::accessor::bufferViewId_
label bufferViewId_
Buffer view index.
Definition: foamGltfAccessor.H:75
foamGltfBase.H
Foam::glTF::accessor
glTF accessor
Definition: foamGltfAccessor.H:66
Foam::glTF::accessor::componentType_
label componentType_
Component type.
Definition: foamGltfAccessor.H:81
foamGltfAccessorTemplates.C
Field.H
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
os
OBJstream os(runTime.globalPath()/outputName)
Foam::glTF::accessor::min_
string min_
Min value. Note: stored as a string for convenience.
Definition: foamGltfAccessor.H:93
Foam::glTF::accessor::toString
static string toString(const Type &val)
Stringify the value.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::glTF::accessor::write
void write(Ostream &os) const
Write.
Definition: foamGltfAccessor.C:92
Foam::glTF::accessor::~accessor
~accessor()=default
Destructor.
label.H
Foam::glTF::accessor::count_
label count_
Data size.
Definition: foamGltfAccessor.H:84
Foam::glTF::accessor::max_
string max_
Max value. Note: stored as a string for convenience.
Definition: foamGltfAccessor.H:90
Foam::glTF::accessor::accessor
accessor()
Default construct.
Definition: foamGltfAccessor.C:32
Foam::glTF::accessor::getValueType
static string getValueType()
Return the glTF value type for the given OpenFOAM type.
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56