Loading...
Searching...
No Matches
foamGltfSceneWriter.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) 2022 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
26Class
27 Foam::glTF::sceneWriter
28
29Description
30 Wrapper for glTF scene for file output
31
32SourceFiles
33 foamGltfSceneWriter.C
34
35\*---------------------------------------------------------------------------*/
36
37#ifndef Foam_gltf_sceneWriter_H
38#define Foam_gltf_sceneWriter_H
39
40#include "autoPtr.H"
41#include "fileName.H"
42#include "foamGltfScene.H"
43
44// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45
46namespace Foam
47{
48
49// Forward Declarations
50class OFstream;
51
52namespace glTF
53{
55/*---------------------------------------------------------------------------*\
56 Class glTF::sceneWriter Declaration
57\*---------------------------------------------------------------------------*/
58
59class sceneWriter
60{
61 // Private Data
62
63 //- The backend output stream (json)
64 autoPtr<OFstream> ofile_;
65
66 //- The scene to output
68
69
70public:
71
72 // Generated Methods
73
74 //- No copy construct
75 sceneWriter(const sceneWriter&) = delete;
77 //- No copy assignment
78 void operator=(const sceneWriter&) = delete;
79
80
81 // Constructors
82
83 //- Default construct
84 sceneWriter() = default;
85
86 //- Construct and open with given file name
87 explicit sceneWriter(const fileName& outputFile);
88
90 //- Destructor - calls close()
92
93
94 // Member Functions
95
96 //- True if output file and scene exist
97 bool good() const noexcept;
98
99 //- The json file name. Empty with !good()
100 const fileName& path() const;
101
102 //- Const access to the scene. Error if good() is not true!
103 const scene& getScene() const;
104
105 //- Non-const access to the scene. Error if good() is not true!
106 scene& getScene();
107
108
109 //- Flush, output and open a new file for output
110 void open(const fileName& outputFile);
111
112 //- Write scene and close file
113 void close();
114
115 //- Same as good()
116 bool valid() const noexcept { return good(); }
117};
118
119
120// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
121
122} // End namespace glTF
123} // End namespace Foam
124
125// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
126
127#endif
128
129// ************************************************************************* //
Output to file stream as an OSstream, normally using std::ofstream for the actual output.
Definition OFstream.H:75
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
A class for handling file names.
Definition fileName.H:75
sceneWriter()=default
Default construct.
void operator=(const sceneWriter &)=delete
No copy assignment.
bool good() const noexcept
True if output file and scene exist.
void close()
Write scene and close file.
sceneWriter(const sceneWriter &)=delete
No copy construct.
void open(const fileName &outputFile)
Flush, output and open a new file for output.
const fileName & path() const
The json file name. Empty with !good().
bool valid() const noexcept
Same as good().
~sceneWriter()
Destructor - calls close().
const scene & getScene() const
Const access to the scene. Error if good() is not true!
Main class to assemble glTF components into a scene.
Namespace for handling glTF creation. https://www.khronos.org/registry/glTF/.
Namespace for OpenFOAM.
const direction noexcept
Definition scalarImpl.H:265