foamVtkCore.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) 2016-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 Namespace
27  Foam::vtk
28 
29 Description
30  Namespace for handling VTK input/output.
31 
32 SourceFiles
33  foamVtkCore.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef Foam_vtk_core_H
38 #define Foam_vtk_core_H
39 
40 #include <cstdint>
41 #include "Enum.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 namespace vtk
48 {
49 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52  // Enumerations
53 
54  //- The context when outputting a VTK file (XML or legacy).
55  enum OutputContext : uint8_t
56  {
58  HEADER,
59  APPEND
60  };
61 
62 
63  //- The output format type for file contents.
64  // Upper bits for output type, lower bits for the format itself.
65  enum class formatType : uint8_t
66  {
67  INLINE_ASCII = 0,
68  INLINE_BASE64 = 0x01,
69  APPEND_BASE64 = 0x11,
70  APPEND_BINARY = 0x12,
71  LEGACY_ASCII = 0x20,
72  LEGACY_BINARY = 0x22,
73  };
74 
75  //- Test for vtk append format (xml)
76  inline bool isAppend(enum formatType fmt) noexcept
77  {
78  return (uint8_t(fmt) & 0x10);
79  }
80 
81  //- Test for vtk legacy format
82  inline bool isLegacy(enum formatType fmt) noexcept
83  {
84  return (uint8_t(fmt) & 0x20);
85  }
86 
87 
88  //- Equivalent to enumeration in "vtkCellType.h" (should be uint8_t)
89  enum cellType : uint8_t
90  {
91  VTK_EMPTY_CELL = 0,
92  VTK_VERTEX = 1,
93  VTK_POLY_VERTEX = 2,
94  VTK_LINE = 3,
95  VTK_POLY_LINE = 4,
99  VTK_PIXEL = 8,
100  VTK_QUAD = 9,
101  VTK_TETRA = 10,
102  VTK_VOXEL = 11,
104  VTK_WEDGE = 13,
109  };
112  //- Some common XML tags for vtk files
113  enum class fileTag : uint8_t
114  {
116  DATA_ARRAY,
117  BLOCK,
118  PIECE,
119  DATA_SET,
120  POINTS,
121  CELLS,
123  VERTS,
124  LINES,
125  CELL_DATA,
126  POINT_DATA,
127  FIELD_DATA,
128  POLY_DATA,
130  MULTI_BLOCK,
131  };
132 
133  //- File extension (without ".") for some vtk XML file content types
134  extern const Foam::Enum<fileTag> fileExtension;
135 
136  //- Version string for some vtk XML file content types
138 
139  //- Strings corresponding to the vtk XML tags
140  extern const Foam::Enum<fileTag> fileTagNames;
141 
142  //- Some common XML attributes for vtk files
143  enum class fileAttr : uint8_t
144  {
145  OFFSET,
153  };
154 
155  //- Strings corresponding to the vtk XML attributes
156  extern const Foam::Enum<fileAttr> fileAttrNames;
157 
158  //- Some common names for XML DataArray entries
159  enum class dataArrayAttr : uint8_t
160  {
161  POINTS,
162  OFFSETS,
163  CONNECTIVITY,
164  TYPES,
165  FACES,
166  FACEOFFSETS,
167  };
168 
169  //- Strings corresponding to the vtk XML DataArray attributes
171 
172 
173 /*---------------------------------------------------------------------------*\
174  Namespace legacy
175 \*---------------------------------------------------------------------------*/
176 
177 namespace legacy
178 {
179 
180  //- Legacy file extension ("vtk")
181  extern const word fileExtension;
182 
183  //- Legacy content names (POLYDATA, UNSTRUCTURED_GRID)
185 
186  //- Legacy file tags (eg, LINES, CELL_DATA, POINT_DATA, ...)
188 
189  //- Legacy attributes (eg, OFFSETS)
191 
192 
193 } // End namespace legacy
194 
195 
196 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
197 
198 } // End namespace vtk
199 
200 } // End namespace Foam
201 
202 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
203 
204 #endif
205 
206 // ************************************************************************* //
cellType
Equivalent to enumeration in "vtkCellType.h" (should be uint8_t)
Definition: foamVtkCore.H:96
const Foam::Enum< vtk::fileTag > fileTagNames
Legacy file tags (eg, LINES, CELL_DATA, POINT_DATA, ...)
XML append raw binary, appendRawFormatter.
"vtkMultiBlockDataSet"
const word fileExtension
Legacy file extension ("vtk")
Generate header only.
Definition: foamVtkCore.H:56
OutputContext
The context when outputting a VTK file (XML or legacy).
Definition: foamVtkCore.H:53
const Foam::Enum< fileTag > fileContentVersions
Version string for some vtk XML file content types.
XML inline ASCII, asciiFormatter.
Generate append-data.
Definition: foamVtkCore.H:57
const Foam::Enum< dataArrayAttr > dataArrayAttrNames
Legacy attributes (eg, OFFSETS)
fileAttr
Some common XML attributes for vtk files.
Definition: foamVtkCore.H:160
const Foam::Enum< fileAttr > fileAttrNames
Strings corresponding to the vtk XML attributes.
A class for handling words, derived from Foam::string.
Definition: word.H:63
Legacy raw binary, legacyRawFormatter.
formatType
The output format type for file contents.
Definition: foamVtkCore.H:66
dataArrayAttr
Some common names for XML DataArray entries.
Definition: foamVtkCore.H:180
const direction noexcept
Definition: Scalar.H:258
Generate header and inline data.
Definition: foamVtkCore.H:55
const Foam::Enum< fileTag > fileTagNames
Strings corresponding to the vtk XML tags.
const Foam::Enum< dataArrayAttr > dataArrayAttrNames
Strings corresponding to the vtk XML DataArray attributes.
const Foam::Enum< fileTag > fileExtension
File extension (without ".") for some vtk XML file content types.
fileTag
Some common XML tags for vtk files.
Definition: foamVtkCore.H:122
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition: error.H:64
bool isLegacy(enum formatType fmt) noexcept
Test for vtk legacy format.
Definition: foamVtkCore.H:87
XML append base64, appendBase64Formatter.
Legacy ASCII, legacyAsciiFormatter.
XML inline base64, base64Formatter.
bool isAppend(enum formatType fmt) noexcept
Test for vtk append format (xml)
Definition: foamVtkCore.H:79
const Foam::Enum< vtk::fileTag > contentNames
Legacy content names (POLYDATA, UNSTRUCTURED_GRID)
Namespace for OpenFOAM.