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 
105 Foam::Ostream& Foam::operator<<(Ostream& os, const glTF::bufferView& bv)
106 {
107  bv.write(os);
108 
109  return os;
110 }
111 
112 
113 // ************************************************************************* //
Foam::glTF::bufferView::target
label & target() noexcept
Definition: foamGltfBufferView.C:65
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:63
Foam::glTF::bufferView::byteLength_
label byteLength_
Definition: foamGltfBufferView.H:74
Foam::glTF::bufferView::buffer
label & buffer() noexcept
Definition: foamGltfBufferView.C:47
Foam::glTF::bufferView::buffer_
label buffer_
Definition: foamGltfBufferView.H:68
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Definition: boundaryPatch.C:76
Foam::glTF::base::operator=
void operator=(const base &gltf)
Definition: foamGltfBase.H:175
Foam::glTF::base
Base class for glTF entities.
Definition: foamGltfBase.H:116
Foam::glTF::bufferView
glTF buffer view - provides a view/slice of the glTF buffer
Definition: foamGltfBufferView.H:59
Foam::glTF::base::write
void write(Ostream &os) const
Definition: foamGltfBase.H:166
Foam::glTF::bufferView::target_
label target_
Definition: foamGltfBufferView.H:77
os
OBJstream os(runTime.globalPath()/outputName)
Foam::Ostream::write
virtual bool write(const token &tok)=0
Foam::indent
Ostream & indent(Ostream &os)
Definition: Ostream.H:343
foamGltfBufferView.H
Foam::glTF::bufferView::byteOffset_
label byteOffset_
Definition: foamGltfBufferView.H:71
Foam::glTF::bufferView::operator=
void operator=(const bufferView &bv)
Definition: foamGltfBufferView.C:87
Foam::glTF::bufferView::byteOffset
label & byteOffset() noexcept
Definition: foamGltfBufferView.C:53
Foam::nl
constexpr char nl
Definition: Ostream.H:424
Foam::glTF::bufferView::bufferView
bufferView()
Definition: foamGltfBufferView.C:25
Foam::name
word name(const expressions::valueTypeCode typeCode)
Definition: exprTraits.C:52
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:52
Foam::glTF::bufferView::write
void write(Ostream &os) const
Definition: foamGltfBufferView.C:71
Foam::glTF::bufferView::byteLength
label & byteLength() noexcept
Definition: foamGltfBufferView.C:59