Loading...
Searching...
No Matches
vtkUnstructuredReader.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) 2012-2016 OpenFOAM Foundation
9 Copyright (C) 2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::vtkUnstructuredReader
29
30Description
31 Reader for vtk UNSTRUCTURED_GRID legacy files.
32 Supports single CELLS, POINTS etc. entry only.
33
34 - all integer types (int, unsigned_int, long etc.) become Foam::label
35 - all real types (float, double) become Foam::scalar
36 - POINTS becomes OpenFOAM points
37 - CELLS gets split into OpenFOAM
38 - cells
39 - faces
40 - lines
41 - CELL_DATA or POINT_DATA gets stored on the corresponding objectRegistry
42 in original vtk numbering order so use e.g. faceMap() to go from entry
43 in faces() back to vtk numbering.
44
45SourceFiles
46 vtkUnstructuredReader.cxx
47 vtkUnstructuredReader.txx
48
49\*---------------------------------------------------------------------------*/
50
51#ifndef vtkUnstructuredReader_H
52#define vtkUnstructuredReader_H
53
54#include "foamVtkCore.H"
55#include "objectRegistry.H"
56#include "cellShapeList.H"
57#include "HashSet.H"
58#include "Enum.H"
59
60// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
61
62namespace Foam
63{
65/*---------------------------------------------------------------------------*\
66 Class vtkUnstructuredReader Declaration
67\*---------------------------------------------------------------------------*/
68
70{
71public:
72
73 // Public Data Types
74
75 //- Enumeration defining the vtk data types
77 {
87 };
88
90
91
92 //- Enumeration defining the vtk dataset types
94 {
98 };
101
102
103 //- Enumeration defining the parse mode - type of data being read
104 enum parseMode
113 static const Enum<parseMode> parseModeNames;
115
116private:
117
118 //- The VTK version
119 float version_;
120
121 //- Header
122 string header_;
123
124 //- Title
125 string title_;
126
127 //- DataType
128 string dataType_;
129
130
131 // Geometry
132
133 //- Points
134 pointField points_;
135
136 //- 3D cells.
137 cellShapeList cells_;
138
139 //- Map from cells back to original ID
140 labelList cellMap_;
141
142 //- 2D cells (=faces)
143 faceList faces_;
144
145 //- Map from faces back to original ID
146 labelList faceMap_;
147
148 //- 1D cells (=edges)
149 labelListList lines_;
150
151 labelList lineMap_;
152
153
154 // Data
155
156 //- Cell based fields
157 objectRegistry cellData_;
158
159 //- Point based fields
160 objectRegistry pointData_;
161
162 //- Other fields
163 objectRegistry otherData_;
164
165
166
167 // Private Member Functions
168
169 //- Read OFFSETS, CONNECTIVITY arrays
170 static void readOffsetsConnectivity
171 (
172 ISstream& is,
173 const char* entryName,
174 const label nOffsets,
175 labelList& offsets,
176 const label nConnectivity,
177 labelList& connectivity
178 );
179
180 static void warnUnhandledType
181 (
182 const Istream& is, // For error message
183 const label type,
184 labelHashSet& warningGiven
185 );
186
187 //- Split cellTypes into cells, faces and lines
188 void extractCells
189 (
190 const Istream& is, // For error message
191 const labelUList& cellTypes,
192 const labelUList& cellOffsets,
193 const labelUList& cellVertData
194 );
195
196 //- Read single field and stores it on the objectRegistry.
197 void readField
198 (
199 ISstream& inFile,
200 objectRegistry& obj,
201 const word& arrayName,
202 const word& dataType,
203 const label size
204 ) const;
205
206 //- Reads fields, stores them on the objectRegistry. Returns a list of
207 // read fields
208 wordList readFieldArray
209 (
210 ISstream& inFile,
211 objectRegistry& obj,
212 const label wantedSize
213 ) const;
214
215 objectRegistry& selectRegistry(const parseMode readMode);
216
217 void read(ISstream& inFile);
218
219 //- No copy assignment
220 void operator=(const vtkUnstructuredReader&) = delete;
221
222
223public:
224
225 //- Runtime type information
226 ClassName("vtkUnstructuredReader");
227
228
229 // Constructors
230
231 //- Construct from input stream, read all
233
234
235 // Member Functions
236
237 //- Header
238 const string& header() const noexcept
239 {
240 return header_;
241 }
242
243 //- Title
244 const string& title() const noexcept
245 {
246 return title_;
247 }
248
249 //- DataType
250 const string& dataType() const noexcept
251 {
252 return dataType_;
253 }
254
255
256 //- Points
257 const pointField& points() const noexcept
258 {
259 return points_;
260 }
261
263 {
264 return points_;
265 }
267 //- 3D cells
268 const cellShapeList& cells() const noexcept
269 {
270 return cells_;
271 }
272
275 return cells_;
276 }
277
278 const labelList& cellMap() const noexcept
279 {
280 return cellMap_;
281 }
283 //- 2D cells (=faces)
284 const faceList& faces() const noexcept
285 {
286 return faces_;
287 }
288
291 return faces_;
292 }
293
294 const labelList& faceMap() const noexcept
295 {
296 return faceMap_;
297 }
299 //- 1D cells (=open lines)
300 const labelListList& lines() const noexcept
301 {
302 return lines_;
303 }
304
306 {
307 return lines_;
308 }
309
310 const labelList& lineMap() const noexcept
311 {
312 return lineMap_;
313 }
314
315 //- Cell based fields
316 const objectRegistry& cellData() const noexcept
317 {
318 return cellData_;
319 }
322 {
323 return cellData_;
324 }
326 //- Point based fields
327 const objectRegistry& pointData() const noexcept
328 {
329 return pointData_;
334 return pointData_;
335 }
336
337 //- Other fields
339 {
340 return otherData_;
341 }
342
344 {
345 return otherData_;
346 }
347
349 //- Debug: print contents of objectRegistry
350 template<class Type>
351 static void printFieldStats(const objectRegistry&);
352};
353
354
355// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
357} // End namespace Foam
358
359// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
360
361#ifdef NoRepository
362 #include "vtkUnstructuredReader.txx"
363#endif
364
365
366// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
367
368#endif
369
370// ************************************************************************* //
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition Enum.H:57
Generic input stream using a standard (STL) stream.
Definition ISstream.H:54
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
Registry of regIOobjects.
static void printFieldStats(const objectRegistry &)
Debug: print contents of objectRegistry.
const faceList & faces() const noexcept
2D cells (=faces)
const objectRegistry & otherData() const noexcept
Other fields.
const string & header() const noexcept
Header.
const cellShapeList & cells() const noexcept
3D cells
const objectRegistry & pointData() const noexcept
Point based fields.
static const Enum< vtkDataType > vtkDataTypeNames
const objectRegistry & cellData() const noexcept
Cell based fields.
vtkDataSetType
Enumeration defining the vtk dataset types.
labelListList & lines() noexcept
const labelList & faceMap() const noexcept
objectRegistry & cellData() noexcept
const labelListList & lines() const noexcept
1D cells (=open lines)
parseMode
Enumeration defining the parse mode - type of data being read.
vtkDataType
Enumeration defining the vtk data types.
const pointField & points() const noexcept
Points.
objectRegistry & pointData() noexcept
const string & dataType() const noexcept
DataType.
objectRegistry & otherData() noexcept
vtkUnstructuredReader(const objectRegistry &obr, ISstream &is)
Construct from input stream, read all.
const labelList & lineMap() const noexcept
cellShapeList & cells() noexcept
static const Enum< vtkDataSetType > vtkDataSetTypeNames
const labelList & cellMap() const noexcept
const string & title() const noexcept
Title.
static const Enum< parseMode > parseModeNames
ClassName("vtkUnstructuredReader")
Runtime type information.
A class for handling words, derived from Foam::string.
Definition word.H:66
#define ClassName(TypeNameString)
Add typeName information from argument TypeNameString to a class.
Definition className.H:74
Namespace for OpenFOAM.
List< word > wordList
List of word.
Definition fileName.H:60
List< labelList > labelListList
List of labelList.
Definition labelList.H:38
List< label > labelList
A List of labels.
Definition List.H:62
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
Definition HashSet.H:85
List< face > faceList
List of faces.
Definition faceListFwd.H:41
const direction noexcept
Definition scalarImpl.H:265
vectorField pointField
pointField is a vectorField.
UList< label > labelUList
A UList of labels.
Definition UList.H:75
List< cellShape > cellShapeList
List of cellShape.
const labelUList & cellTypes
Definition setCellMask.H:27