foamGltfBufferView.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 "foamGltfBufferView.H"
29 
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 
33 :
34  base(),
35  buffer_(0),
36  byteOffset_(-1),
37  byteLength_(-1),
38  target_(-1)
39 {}
40 
41 
43 :
44  base("BufferView:"+name),
45  buffer_(0),
46  byteOffset_(-1),
47  byteLength_(-1),
48  target_(-1)
49 {}
50 
51 
52 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
53 
54 Foam::label& Foam::glTF::bufferView::buffer() noexcept
55 {
56  return buffer_;
57 }
58 
59 
60 Foam::label& Foam::glTF::bufferView::byteOffset() noexcept
61 {
62  return byteOffset_;
63 }
64 
65 
66 Foam::label& Foam::glTF::bufferView::byteLength() noexcept
67 {
68  return byteLength_;
69 }
70 
71 
72 Foam::label& Foam::glTF::bufferView::target() noexcept
73 {
74  return target_;
75 }
76 
77 
79 {
80  os << indent << "\"buffer\" : " << buffer_ << "," << nl
81  << indent << "\"byteOffset\" : " << byteOffset_ << "," << nl
82  << indent << "\"byteLength\" : " << byteLength_;
83 
84  if (target_ != -1)
85  {
86  os << "," << nl
87  << indent << "\"target\" : " << target_;
88  }
89 
90  base::write(os);
91 }
92 
93 
95 {
96  base::operator=(bv);
97 
98  buffer_ = bv.buffer_;
99  byteOffset_ = bv.byteOffset_;
100  byteLength_ = bv.byteLength_;
101  target_ = bv.target_;
102 }
103 
104 
106 {
107  bv.write(os);
108 
109  return os;
110 }
111 
112 
113 // ************************************************************************* //
Foam::glTF::bufferView::target
label & target() noexcept
Return the target.
Definition: foamGltfBufferView.C:72
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::glTF::bufferView::byteLength_
label byteLength_
Byte length.
Definition: foamGltfBufferView.H:78
Foam::glTF::bufferView::buffer
label & buffer() noexcept
Return the buffer index.
Definition: foamGltfBufferView.C:54
Foam::glTF::bufferView::buffer_
label buffer_
Buffer index.
Definition: foamGltfBufferView.H:72
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Foam::glTF::base::operator=
void operator=(const base &gltf)
Definition: foamGltfBase.H:180
Foam::glTF::base
Base class for glTF entities.
Definition: foamGltfBase.H:121
Foam::glTF::bufferView
glTF buffer view - provides a view/slice of the glTF buffer
Definition: foamGltfBufferView.H:63
Foam::glTF::base::write
void write(Ostream &os) const
Write.
Definition: foamGltfBase.H:171
Foam::glTF::bufferView::target_
label target_
Target.
Definition: foamGltfBufferView.H:81
os
OBJstream os(runTime.globalPath()/outputName)
Foam::indent
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:339
foamGltfBufferView.H
Foam::glTF::bufferView::byteOffset_
label byteOffset_
Byte offset.
Definition: foamGltfBufferView.H:75
Foam::glTF::bufferView::operator=
void operator=(const bufferView &bv)
Definition: foamGltfBufferView.C:94
Foam::glTF::bufferView::byteOffset
label & byteOffset() noexcept
Return the byte offset.
Definition: foamGltfBufferView.C:60
Foam::nl
constexpr char nl
Definition: Ostream.H:404
Foam::glTF::bufferView::bufferView
bufferView()
Default construct.
Definition: foamGltfBufferView.C:32
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
Foam::glTF::bufferView::write
void write(Ostream &os) const
Write.
Definition: foamGltfBufferView.C:78
Foam::glTF::bufferView::byteLength
label & byteLength() noexcept
Return the byte length.
Definition: foamGltfBufferView.C:66