foamGltfList.C
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-------------------------------------------------------------------------------
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
26\*---------------------------------------------------------------------------*/
27
28#include "foamGltfList.H"
29
30// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
31
32template<class Type>
34{
35 Type obj(name);
36 obj.id() = data_.size();
37 data_.append(obj);
38
39 return data_.last();
40}
41
42
43template<class Type>
45{
46 return data_;
47}
48
49
50template<class Type>
51bool Foam::glTF::List<Type>::empty() const noexcept
52{
53 return data_.empty();
54}
55
56
57template<class Type>
58Foam::label Foam::glTF::List<Type>::size() const noexcept
59{
60 return data_.size();
61}
62
63
64template<class Type>
66(
67 Ostream& os,
68 const word& keyword,
69 bool firstEntry
70)
71{
72 if (empty())
73 {
74 return;
75 }
76
77 if (!firstEntry)
78 {
79 os << "," << nl;
80 }
81
82 os << indent << "\"" << keyword << "\" : [" << nl << incrIndent;
83
84 write(os);
85
86 os << decrIndent << nl << indent << "]";
87}
89
90template<class Type>
92{
93 forAll(data_, i)
94 {
95 os << indent << "{"
96 << nl << incrIndent
97 << data_[i]
98 << nl << decrIndent
99 << indent << "}";
101 if (i != data_.size() - 1) os << "," << nl;
102 }
104
106template<class Type>
108{
109 return data_[i];
110}
111
112
113template<class Type>
115{
116 lst.write(os);
117
118 return os;
119}
120
121
122// ************************************************************************* //
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:72
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
virtual bool write()
Write the output fields.
Container for glTF entities.
Definition: foamGltfList.H:66
Type & operator[](const label i)
Definition: foamGltfList.C:107
bool empty() const noexcept
List contains no data.
Definition: foamGltfList.C:51
label size() const noexcept
Return the list size.
Definition: foamGltfList.C:58
const DynamicList< Type > & data() const noexcept
Return const access to the underlying list.
Definition: foamGltfList.C:44
void write(Ostream &os, const word &keyword, bool firstEntry=false)
Write.
Definition: foamGltfList.C:66
Information * create()
Clear all profiling and restart with new profiling.
Definition: profiling.C:44
A class for handling words, derived from Foam::string.
Definition: word.H:68
OBJstream os(runTime.globalPath()/outputName)
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Definition: Ostream.H:349
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:342
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Definition: Ostream.H:356
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
runTime write()
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333