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-2021 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).
56  {
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 XML append format
76  inline bool isAppend(enum formatType fmt)
77  {
78  return (uint8_t(fmt) & 0x10);
79  }
80 
81  //- Test for vtk legacy format
82  inline bool isLegacy(enum formatType fmt)
83  {
84  return (uint8_t(fmt) & 0x20);
85  }
86 
87 
88  //- Equivalent to enumeration in "vtkCellType.h"
89  enum cellType
90  {
94  VTK_LINE = 3,
99  VTK_PIXEL = 8,
100  VTK_QUAD = 9,
101  VTK_TETRA = 10,
102  VTK_VOXEL = 11,
104  VTK_WEDGE = 13,
109  };
110 
111 
112  //- Some common XML tags for vtk files
113  enum class fileTag
114  {
115  VTK_FILE,
116  DATA_ARRAY,
117  BLOCK,
118  PIECE,
119  DATA_SET,
120  POINTS,
121  CELLS,
122  POLYS,
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
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
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 // ************************************************************************* //
Foam::vtk::dataArrayAttrNames
const Foam::Enum< dataArrayAttr > dataArrayAttrNames
Strings corresponding to the vtk XML DataArray attributes.
Foam::vtk::HEADER
Generate header only.
Definition: foamVtkCore.H:58
Foam::vtk::INLINE
Generate header and inline data.
Definition: foamVtkCore.H:57
Foam::vtk::fileTag::VTK_FILE
"VTKFile"
Foam::Enum
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition: IOstreamOption.H:57
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::vtk::legacy::fileExtension
const word fileExtension
Legacy file extension ("vtk")
Foam::vtk::legacy::contentNames
const Foam::Enum< vtk::fileTag > contentNames
Legacy content names (POLYDATA, UNSTRUCTURED_GRID)
Foam::vtk::fileAttr::OFFSET
"offset"
Foam::vtk::fileTag::DATA_ARRAY
"DataArray"
Foam::vtk::legacy::fileTagNames
const Foam::Enum< vtk::fileTag > fileTagNames
Legacy file tags (eg, LINES, CELL_DATA, POINT_DATA, ...)
Foam::vtk::fileExtension
const Foam::Enum< fileTag > fileExtension
File extension (without ".") for some vtk XML file content types.
Foam::vtk::dataArrayAttr::OFFSETS
"offsets"
Foam::vtk::formatType::INLINE_ASCII
XML inline ASCII, asciiFormatter.
Foam::vtk::VTK_HEXAHEDRON
Definition: foamVtkCore.H:103
Foam::vtk::fileTag::POLY_DATA
"PolyData"
Foam::vtk::fileTag::BLOCK
"Block"
Foam::vtk::VTK_PYRAMID
Definition: foamVtkCore.H:105
Foam::vtk::fileAttr
fileAttr
Some common XML attributes for vtk files.
Definition: foamVtkCore.H:143
Foam::vtk::fileAttr::NUMBER_OF_TUPLES
"NumberOfTuples"
Foam::vtk::dataArrayAttr::FACES
"faces"
Foam::vtk::fileAttrNames
const Foam::Enum< fileAttr > fileAttrNames
Strings corresponding to the vtk XML attributes.
Foam::vtk::VTK_POLYHEDRON
Definition: foamVtkCore.H:108
Foam::vtk::VTK_EMPTY_CELL
Definition: foamVtkCore.H:91
Foam::vtk::VTK_PIXEL
Definition: foamVtkCore.H:99
Foam::vtk::fileTag::POLYS
"Polys"
Foam::vtk::VTK_LINE
Definition: foamVtkCore.H:94
Foam::vtk::formatType::LEGACY_ASCII
Legacy ASCII, legacyAsciiFormatter.
Foam::vtk::legacy::dataArrayAttrNames
const Foam::Enum< dataArrayAttr > dataArrayAttrNames
Legacy attributes (eg, OFFSETS)
Foam::vtk::fileTag::DATA_SET
"DataSet"
Foam::vtk::fileTag::CELLS
"Cells"
Foam::vtk::VTK_HEXAGONAL_PRISM
Definition: foamVtkCore.H:107
Foam::vtk::formatType::APPEND_BASE64
XML append base64, appendBase64Formatter.
Foam::vtk::formatType
formatType
The output format type for file contents.
Definition: foamVtkCore.H:65
Foam::vtk::fileAttr::NUMBER_OF_POINTS
"NumberOfPoints"
Foam::vtk::VTK_POLY_VERTEX
Definition: foamVtkCore.H:93
Foam::vtk::VTK_TRIANGLE_STRIP
Definition: foamVtkCore.H:97
Foam::vtk::VTK_WEDGE
Definition: foamVtkCore.H:104
Foam::vtk::fileTag::VERTS
"Verts"
Foam::vtk::OutputContext
OutputContext
The context when outputting a VTK file (XML or legacy).
Definition: foamVtkCore.H:55
Foam::vtk::dataArrayAttr
dataArrayAttr
Some common names for XML DataArray entries.
Definition: foamVtkCore.H:159
Foam::vtk::VTK_TRIANGLE
Definition: foamVtkCore.H:96
Foam::vtk::fileAttr::NUMBER_OF_CELLS
"NumberOfCells"
Foam::vtk::formatType::INLINE_BASE64
XML inline base64, base64Formatter.
Foam::vtk::fileTag::FIELD_DATA
"FieldData"
Foam::vtk::VTK_POLY_LINE
Definition: foamVtkCore.H:95
Foam::vtk::fileTag::POINTS
"Points"
Foam::vtk::fileTag
fileTag
Some common XML tags for vtk files.
Definition: foamVtkCore.H:113
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::vtk::VTK_VERTEX
Definition: foamVtkCore.H:92
Foam::vtk::isLegacy
bool isLegacy(enum formatType fmt)
Test for vtk legacy format.
Definition: foamVtkCore.H:82
Foam::vtk::fileTagNames
const Foam::Enum< fileTag > fileTagNames
Strings corresponding to the vtk XML tags.
Foam::vtk::fileTag::POINT_DATA
"PointData"
Foam::vtk::dataArrayAttr::TYPES
"types"
Foam::vtk::fileTag::UNSTRUCTURED_GRID
"UnstructuredGrid"
Foam::vtk::formatType::LEGACY_BINARY
Legacy raw binary, legacyRawFormatter.
Foam::vtk::fileTag::MULTI_BLOCK
"vtkMultiBlockDataSet"
Foam::vtk::fileContentVersions
const Foam::Enum< fileTag > fileContentVersions
Version string for some vtk XML file content types.
Foam::vtk::dataArrayAttr::FACEOFFSETS
"faceoffsets"
Foam::vtk::APPEND
Generate append-data.
Definition: foamVtkCore.H:59
Foam::vtk::fileTag::LINES
"Lines"
Foam::vtk::cellType
cellType
Equivalent to enumeration in "vtkCellType.h".
Definition: foamVtkCore.H:89
Foam::vtk::VTK_POLYGON
Definition: foamVtkCore.H:98
Foam::vtk::VTK_TETRA
Definition: foamVtkCore.H:101
Foam::vtk::dataArrayAttr::CONNECTIVITY
"connectivity"
Foam::vtk::fileTag::CELL_DATA
"CellData"
Foam::vtk::fileAttr::NUMBER_OF_VERTS
"NumberOfVerts"
Foam::vtk::fileTag::PIECE
"Piece"
Foam::vtk::VTK_QUAD
Definition: foamVtkCore.H:100
Foam::vtk::dataArrayAttr::POINTS
"Points"
Foam::vtk::formatType::APPEND_BINARY
XML append raw binary, appendRawFormatter.
Foam::vtk::fileAttr::NUMBER_OF_LINES
"NumberOfLines"
Foam::vtk::VTK_PENTAGONAL_PRISM
Definition: foamVtkCore.H:106
Foam::vtk::fileAttr::NUMBER_OF_COMPONENTS
"NumberOfComponents"
Foam::vtk::VTK_VOXEL
Definition: foamVtkCore.H:102
Foam::vtk::isAppend
bool isAppend(enum formatType fmt)
Test for XML append format.
Definition: foamVtkCore.H:76
Foam::vtk::fileAttr::NUMBER_OF_POLYS
"NumberOfPolys"
Enum.H