95 <<
"Skipping unknown cell type " <<
type <<
endl;
118 label cellI = cells_.size();
119 cells_.setSize(cellI+cellTypes.
size());
120 cellMap_.setSize(cells_.size(), -1);
122 label faceI = faces_.size();
123 faces_.setSize(faceI+cellTypes.
size());
124 faceMap_.setSize(faces_.size(), -1);
126 label lineI = lines_.size();
127 lines_.setSize(lineI+cellTypes.
size());
128 lineMap_.setSize(lines_.size(), -1);
138 switch (cellTypes[i])
142 warnUnhandledType(inFile, cellTypes[i], warningGiven);
143 label nRead = cellVertData[dataIndex++];
149 ) <<
"Expected size 1 for VTK_VERTEX but found "
156 case VTK_POLY_VERTEX:
158 warnUnhandledType(inFile, cellTypes[i], warningGiven);
159 label nRead = cellVertData[dataIndex++];
167 label nRead = cellVertData[dataIndex++];
173 ) <<
"Expected size 2 for VTK_LINE but found "
179 segment[0] = cellVertData[dataIndex++];
180 segment[1] = cellVertData[dataIndex++];
187 label nRead = cellVertData[dataIndex++];
193 segment[i] = cellVertData[dataIndex++];
201 face&
f = faces_[faceI++];
203 label nRead = cellVertData[dataIndex++];
209 ) <<
"Expected size 3 for VTK_TRIANGLE but found "
212 f[0] = cellVertData[dataIndex++];
213 f[1] = cellVertData[dataIndex++];
214 f[2] = cellVertData[dataIndex++];
221 face&
f = faces_[faceI++];
223 label nRead = cellVertData[dataIndex++];
229 ) <<
"Expected size 4 for VTK_QUAD but found "
232 f[0] = cellVertData[dataIndex++];
233 f[1] = cellVertData[dataIndex++];
234 f[2] = cellVertData[dataIndex++];
235 f[3] = cellVertData[dataIndex++];
242 face&
f = faces_[faceI++];
243 label nRead = cellVertData[dataIndex++];
247 f[fp] = cellVertData[dataIndex++];
254 label nRead = cellVertData[dataIndex++];
260 ) <<
"Expected size 4 for VTK_TETRA but found "
263 tetPoints[0] = cellVertData[dataIndex++];
264 tetPoints[1] = cellVertData[dataIndex++];
265 tetPoints[2] = cellVertData[dataIndex++];
266 tetPoints[3] = cellVertData[dataIndex++];
274 label nRead = cellVertData[dataIndex++];
280 ) <<
"Expected size 5 for VTK_PYRAMID but found "
283 pyrPoints[0] = cellVertData[dataIndex++];
284 pyrPoints[1] = cellVertData[dataIndex++];
285 pyrPoints[2] = cellVertData[dataIndex++];
286 pyrPoints[3] = cellVertData[dataIndex++];
287 pyrPoints[4] = cellVertData[dataIndex++];
289 cells_[cellI++] =
cellShape(pyr, pyrPoints,
true);
295 label nRead = cellVertData[dataIndex++];
301 ) <<
"Expected size 6 for VTK_WEDGE but found "
304 prismPoints[0] = cellVertData[dataIndex++];
305 prismPoints[1] = cellVertData[dataIndex++];
306 prismPoints[2] = cellVertData[dataIndex++];
307 prismPoints[3] = cellVertData[dataIndex++];
308 prismPoints[4] = cellVertData[dataIndex++];
309 prismPoints[5] = cellVertData[dataIndex++];
311 cells_[cellI++] =
cellShape(prism, prismPoints,
true);
317 label nRead = cellVertData[dataIndex++];
323 ) <<
"Expected size 8 for VTK_HEXAHEDRON but found "
326 hexPoints[0] = cellVertData[dataIndex++];
327 hexPoints[1] = cellVertData[dataIndex++];
328 hexPoints[2] = cellVertData[dataIndex++];
329 hexPoints[3] = cellVertData[dataIndex++];
330 hexPoints[4] = cellVertData[dataIndex++];
331 hexPoints[5] = cellVertData[dataIndex++];
332 hexPoints[6] = cellVertData[dataIndex++];
333 hexPoints[7] = cellVertData[dataIndex++];
340 warnUnhandledType(inFile, cellTypes[i], warningGiven);
341 label nRead = cellVertData[dataIndex++];
348 Info<<
"Read " << cellI <<
" cells;" << faceI <<
" faces." <<
endl;
350 cells_.setSize(cellI);
351 cellMap_.setSize(cellI);
352 faces_.setSize(faceI);
353 faceMap_.setSize(faceI);
354 lines_.setSize(lineI);
355 lineMap_.setSize(lineI);
364 const word& arrayName,
365 const word& dataType,
369 switch (vtkDataTypeNames[dataType])
390 readBlock(inFile, fieldVals().size(), fieldVals());
391 regIOobject::store(fieldVals);
411 readBlock(inFile, fieldVals().size(), fieldVals());
412 regIOobject::store(fieldVals);
420 Info<<
"Reading strings:" << size <<
endl;
436 inFile.
getLine(fieldVals()[0]);
440 inFile.
getLine(fieldVals()[i]);
442 regIOobject::store(fieldVals);
449 <<
"Unhandled type " << vtkDataTypeNames[dataType] <<
endl
450 <<
"Skipping " << size
451 <<
" words." <<
endl;
453 readBlock(inFile, size, fieldVals);
466 const label wantedSize
471 word dataName(inFile);
474 Info<<
"dataName:" << dataName <<
endl;
479 Pout<<
"numArrays:" << numArrays <<
endl;
481 for (
label i = 0; i < numArrays; i++)
483 word arrayName(inFile);
486 word dataType(inFile);
490 Info<<
"Reading field " << arrayName
491 <<
" of " << numTuples <<
" tuples of rank " << numComp <<
endl;
494 if (wantedSize != -1 && numTuples != wantedSize)
497 <<
"Expected " << wantedSize <<
" tuples but only have "
520 if (readMode == CELL_DATA)
524 else if (readMode == POINT_DATA)
543 cellData_(
IOobject(
"cellData", obr)),
544 pointData_(
IOobject(
"pointData", obr)),
545 otherData_(
IOobject(
"otherData", obr))
576 label wantedSize = -1;
582 while (inFile.
good())
594 <<
" tag:" << tag <<
endl;
597 if (tag ==
"DATASET")
599 word geomType(inFile);
602 Info<<
"geomType : " << geomType <<
endl;
607 else if (tag ==
"POINTS")
613 Info<<
"Reading " <<
nPoints <<
" numbers representing "
617 word primitiveTag(inFile);
618 if (primitiveTag !=
"float" && primitiveTag !=
"double")
621 <<
"Expected 'float' entry but found "
630 else if (tag ==
"CELLS")
636 Info<<
"Reading " << nCells <<
" cells or faces." <<
endl;
640 else if (tag ==
"CELL_TYPES")
645 readBlock(inFile, nCellTypes, cellTypes);
647 if (cellTypes.
size() > 0 && cellVerts.
size() == 0)
650 <<
"Found " << cellTypes.
size()
651 <<
" cellTypes but no cells."
658 else if (tag ==
"LINES")
664 Info<<
"Reading " << nLines <<
" lines." <<
endl;
674 for (
label i = 0; i < nLines; i++)
678 f.setSize(lineVerts[elemI++]);
681 f[fp] = lineVerts[elemI++];
686 else if (tag ==
"POLYGONS")
694 Info<<
"Reading " << nFaces <<
" faces." <<
endl;
704 for (
label i = 0; i < nFaces; i++)
708 f.setSize(faceVerts[elemI++]);
711 f[fp] = faceVerts[elemI++];
716 else if (tag ==
"POINT_DATA")
726 <<
"Reading POINT_DATA : expected " << wantedSize
730 else if (tag ==
"CELL_DATA")
736 if (nCells != wantedSize)
739 <<
"Reading CELL_DATA : expected "
744 else if (tag ==
"FIELD")
749 else if (tag ==
"SCALARS")
760 Info<<
"Reading scalar " << dataName
762 <<
" from lookup table" <<
endl;
765 word lookupTableTag(inFile);
766 if (lookupTableTag !=
"LOOKUP_TABLE")
769 <<
"Expected tag LOOKUP_TABLE but read "
774 word lookupTableName(inFile);
785 else if (tag ==
"VECTORS" || tag ==
"NORMALS")
795 Info<<
"Reading vector " << dataName
836 fieldVals()[i].x() =
s[elemI++];
837 fieldVals()[i].y() =
s[elemI++];
838 fieldVals()[i].z() =
s[elemI++];
843 else if (tag ==
"TEXTURE_COORDINATES")
855 Info<<
"Reading texture coords " << dataName
856 <<
" dimension " << dim
861 readBlock(inFile, coords.size(), coords);
863 else if (tag ==
"TRIANGLE_STRIPS")
869 Info<<
"Reading " << nStrips <<
" triangle strips." <<
endl;
877 for (
label i = 0; i < nStrips; i++)
879 label nVerts = faceVerts[elemI++];
890 for (
label i = 0; i < nStrips; i++)
892 label nVerts = faceVerts[elemI++];
893 label nTris = nVerts-2;
899 f[0] = faceVerts[elemI++];
900 f[1] = faceVerts[elemI++];
901 f[2] = faceVerts[elemI++];
902 for (
label triI = 1; triI < nTris; triI++)
907 f[0] = faceVerts[elemI-1];
908 f[1] = faceVerts[elemI-2];
909 f[2] = faceVerts[elemI++];
916 <<
"Unsupported tag "
930 printFieldStats<vectorIOField>(
cellData_);
931 printFieldStats<scalarIOField>(
cellData_);
932 printFieldStats<labelIOField>(
cellData_);
933 printFieldStats<stringIOList>(
cellData_);