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 -------------------------------------------------------------------------------
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 Class
27  Foam::glTF::sceneWriter
28 
29 Description
30  Wrapper for glTF scene for file output
31 
32 SourceFiles
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 
46 namespace Foam
47 {
48 
49 // Forward Declarations
50 class OFstream;
51 
52 namespace glTF
53 {
54 
55 /*---------------------------------------------------------------------------*\
56  Class glTF::sceneWriter Declaration
57 \*---------------------------------------------------------------------------*/
58 
59 class sceneWriter
60 {
61  // Private Data
62 
63  //- The backend output stream (json)
64  autoPtr<OFstream> ofile_;
65 
66  //- The scene to output
67  autoPtr<glTF::scene> scene_;
68 
69 
70 public:
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()
91  ~sceneWriter();
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 // ************************************************************************* //
~sceneWriter()
Destructor - calls close()
const scene & getScene() const
Const access to the scene. Error if good() is not true!
A class for handling file names.
Definition: fileName.H:72
bool good() const noexcept
True if output file and scene exist.
void close()
Write scene and close file.
Wrapper for glTF scene for file output.
Main class to assemble glTF components into a scene.
Definition: foamGltfScene.H:64
void operator=(const sceneWriter &)=delete
No copy assignment.
const fileName & path() const
The json file name. Empty with !good()
const direction noexcept
Definition: Scalar.H:258
sceneWriter()=default
Default construct.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
bool valid() const noexcept
Same as good()
void open(const fileName &outputFile)
Flush, output and open a new file for output.
Namespace for OpenFOAM.