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{
54
55/*---------------------------------------------------------------------------*\
56 Class glTF::sceneWriter Declaration
57\*---------------------------------------------------------------------------*/
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;
76
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
89
90 //- Destructor - calls close()
92
93
94 // Member Functions
95
96 //- True if output file and scene exist
97 bool valid() const noexcept;
98
99 //- The json file name. Empty with !valid()
100 const fileName& path() const;
101
102 //- Const access to the scene. Error if valid() is not true!
103 const scene& getScene() const;
104
105 //- Non-const access to the scene. Error if valid() 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
116
117// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
118
119} // End namespace glTF
120} // End namespace Foam
121
122// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
123
124#endif
125
126// ************************************************************************* //
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A class for handling file names.
Definition: fileName.H:76
Wrapper for glTF scene for file output.
sceneWriter()=default
Default construct.
void operator=(const sceneWriter &)=delete
No copy assignment.
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 !valid()
bool valid() const noexcept
True if output file and scene exist.
~sceneWriter()
Destructor - calls close()
const scene & getScene() const
Const access to the scene. Error if valid() is not true!
Main class to assemble glTF components into a scene.
Definition: foamGltfScene.H:69
Namespace for OpenFOAM.
const direction noexcept
Definition: Scalar.H:223