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 -------------------------------------------------------------------------------
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 \*---------------------------------------------------------------------------*/
27 
28 #include "foamGltfList.H"
29 
30 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
31 
32 template<class Type>
34 {
35  Type obj(name);
36  obj.id() = data_.size();
37  data_.append(obj);
38 
39  return data_.last();
40 }
41 
42 
43 template<class Type>
45 {
46  return data_;
47 }
48 
49 
50 template<class Type>
51 bool Foam::glTF::List<Type>::empty() const noexcept
52 {
53  return data_.empty();
54 }
55 
56 
57 template<class Type>
58 Foam::label Foam::glTF::List<Type>::size() const noexcept
59 {
60  return data_.size();
61 }
62 
63 
64 template<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 }
88 
89 
90 template<class Type>
92 {
93  forAll(data_, i)
94  {
95  os << indent << "{"
96  << nl << incrIndent
97  << data_[i]
98  << nl << decrIndent
99  << indent << "}";
100 
101  if (i != data_.size() - 1) os << "," << nl;
102  }
103 }
104 
105 
106 template<class Type>
108 {
109  return data_[i];
110 }
111 
112 
113 template<class Type>
115 {
116  lst.write(os);
117 
118  return os;
119 }
120 
121 
122 // ************************************************************************* //
Foam::glTF::List::size
label size() const noexcept
Return the list size.
Definition: foamGltfList.C:58
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
foamGltfList.H
Foam::DynamicList< Type >
Foam::incrIndent
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Definition: Ostream.H:346
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Foam::glTF::List::create
Type & create(const word &name)
Helper to create a new Type on the list and set the ID.
Definition: foamGltfList.C:33
Foam::glTF::List::write
void write(Ostream &os, const word &keyword, bool firstEntry=false)
Write.
Definition: foamGltfList.C:66
os
OBJstream os(runTime.globalPath()/outputName)
Foam::decrIndent
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Definition: Ostream.H:353
Foam::glTF::List::data
const DynamicList< Type > & data() const noexcept
Return const access to the underlying list.
Definition: foamGltfList.C:44
Foam::indent
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:339
Foam::glTF::List
Container for glTF entities.
Definition: foamGltfList.H:51
Foam::nl
constexpr char nl
Definition: Ostream.H:404
Foam::glTF::List::empty
bool empty() const noexcept
List contains no data.
Definition: foamGltfList.C:51
Foam::glTF::List::operator[]
Type & operator[](const label i)
Definition: foamGltfList.C:107
Foam::vtk::write
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
Definition: foamVtkOutputTemplates.C:36
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