foamVtkBase64Layer.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) 2017 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::vtk::foamVtkBase64Layer
28 
29 Description
30  Base-64 encoded output layer - normally only used indirectly by formatters.
31 
32 SourceFiles
33  foamVtkBase64Layer.cxx
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef Foam_vtk_base64Layer_H
38 #define Foam_vtk_base64Layer_H
39 
40 #include "foamVtkFormatter.H"
41 #include "base64Layer.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 namespace vtk
48 {
49 
50 /*---------------------------------------------------------------------------*\
51  Class vtk::foamVtkBase64Layer Declaration
52 \*---------------------------------------------------------------------------*/
53 
55 :
56  public vtk::formatter,
57  protected Foam::base64Layer
58 {
59  // Private Data Members
60 
61  static const char* encoding_;
62 
63 
64 protected:
65 
66  // Protected Member Functions
67 
68  //- Write
69  void write(const char* s, std::streamsize n);
70 
71  //- No copy construct
72  foamVtkBase64Layer(const foamVtkBase64Layer&) = delete;
73 
74  //- No copy assignment
75  void operator=(const foamVtkBase64Layer&) = delete;
76 
77 
78  // Constructors
79 
80  //- Construct and attach to an output stream
81  explicit foamVtkBase64Layer(std::ostream& os);
82 
83 public:
84 
85  //- Destructor. Closes/flushes the underlying layer
86  virtual ~foamVtkBase64Layer();
87 
88 
89  // Member Functions
90 
91  //- Name for the XML append encoding ("base64").
92  virtual const char* encoding() const;
93 
94  //- Write leading size for binary output
95  // \return True - format uses this information
96  virtual bool writeSize(const uint64_t numbytes);
97 
98  virtual void write(const uint8_t val);
99  virtual void write(const label val);
100  virtual void write(const float val);
101  virtual void write(const double val);
102 
103  //- End the encoding sequence (padding the final characters with '=')
104  virtual void flush();
105 
106  //- The encoded length for base64 encoded output.
107  virtual std::size_t encodedLength(std::size_t n) const;
108 };
109 
110 
111 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
112 
113 } // End namespace vtk
114 } // End namespace Foam
115 
116 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
117 
118 #endif
119 
120 // ************************************************************************* //
An output filter layer to write base-64 encoded content.
Definition: base64Layer.H:51
Abstract class for a VTK output stream formatter.
foamVtkBase64Layer(const foamVtkBase64Layer &)=delete
No copy construct.
Base-64 encoded output layer - normally only used indirectly by formatters.
std::ostream & os() noexcept
Access to the underlying output stream.
virtual const char * encoding() const
Name for the XML append encoding ("base64").
virtual std::size_t encodedLength(std::size_t n) const
The encoded length for base64 encoded output.
virtual void flush()
End the encoding sequence (padding the final characters with &#39;=&#39;)
virtual bool writeSize(const uint64_t numbytes)
Write leading size for binary output.
void write(const char *s, std::streamsize n)
Write.
label n
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Namespace for OpenFOAM.
virtual ~foamVtkBase64Layer()
Destructor. Closes/flushes the underlying layer.
void operator=(const foamVtkBase64Layer &)=delete
No copy assignment.