85 void Foam::vtkUnstructuredReader::warnUnhandledType
92 if (warningGiven.
insert(type))
94 IOWarningIn(
"vtkUnstructuredReader::warnUnhandledType(..)", inFile)
95 <<
"Skipping unknown cell type " << type <<
endl;
101 void Foam::vtkUnstructuredReader::extractCells
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++];
148 "vtkUnstructuredReader::extractCells(..)",
150 ) <<
"Expected size 1 for VTK_VERTEX but found " 157 case VTK_POLY_VERTEX:
159 warnUnhandledType(inFile, cellTypes[i], warningGiven);
160 label nRead = cellVertData[dataIndex++];
168 label nRead = cellVertData[dataIndex++];
173 "vtkUnstructuredReader::extractCells(..)",
175 ) <<
"Expected size 2 for VTK_LINE but found " 181 segment[0] = cellVertData[dataIndex++];
182 segment[1] = cellVertData[dataIndex++];
189 label nRead = cellVertData[dataIndex++];
195 segment[i] = cellVertData[dataIndex++];
203 face&
f = faces_[faceI++];
205 label nRead = cellVertData[dataIndex++];
210 "vtkUnstructuredReader::extractCells(..)",
212 ) <<
"Expected size 3 for VTK_TRIANGLE but found " 215 f[0] = cellVertData[dataIndex++];
216 f[1] = cellVertData[dataIndex++];
217 f[2] = cellVertData[dataIndex++];
224 face&
f = faces_[faceI++];
226 label nRead = cellVertData[dataIndex++];
231 "vtkUnstructuredReader::extractCells(..)",
233 ) <<
"Expected size 4 for VTK_QUAD but found " 236 f[0] = cellVertData[dataIndex++];
237 f[1] = cellVertData[dataIndex++];
238 f[2] = cellVertData[dataIndex++];
239 f[3] = cellVertData[dataIndex++];
246 face&
f = faces_[faceI++];
247 label nRead = cellVertData[dataIndex++];
251 f[fp] = cellVertData[dataIndex++];
258 label nRead = cellVertData[dataIndex++];
263 "vtkUnstructuredReader::extractCells(..)",
265 ) <<
"Expected size 4 for VTK_TETRA but found " 268 tetPoints[0] = cellVertData[dataIndex++];
269 tetPoints[1] = cellVertData[dataIndex++];
270 tetPoints[2] = cellVertData[dataIndex++];
271 tetPoints[3] = cellVertData[dataIndex++];
273 cells_[cellI++] =
cellShape(tet, tetPoints,
true);
279 label nRead = cellVertData[dataIndex++];
284 "vtkUnstructuredReader::extractCells(..)",
286 ) <<
"Expected size 5 for VTK_PYRAMID but found " 289 pyrPoints[0] = cellVertData[dataIndex++];
290 pyrPoints[1] = cellVertData[dataIndex++];
291 pyrPoints[2] = cellVertData[dataIndex++];
292 pyrPoints[3] = cellVertData[dataIndex++];
293 pyrPoints[4] = cellVertData[dataIndex++];
295 cells_[cellI++] =
cellShape(pyr, pyrPoints,
true);
301 label nRead = cellVertData[dataIndex++];
306 "vtkUnstructuredReader::extractCells(..)",
308 ) <<
"Expected size 6 for VTK_WEDGE but found " 311 prismPoints[0] = cellVertData[dataIndex++];
312 prismPoints[1] = cellVertData[dataIndex++];
313 prismPoints[2] = cellVertData[dataIndex++];
314 prismPoints[3] = cellVertData[dataIndex++];
315 prismPoints[4] = cellVertData[dataIndex++];
316 prismPoints[5] = cellVertData[dataIndex++];
318 cells_[cellI++] =
cellShape(prism, prismPoints,
true);
324 label nRead = cellVertData[dataIndex++];
329 "vtkUnstructuredReader::extractCells(..)",
331 ) <<
"Expected size 8 for VTK_HEXAHEDRON but found " 334 hexPoints[0] = cellVertData[dataIndex++];
335 hexPoints[1] = cellVertData[dataIndex++];
336 hexPoints[2] = cellVertData[dataIndex++];
337 hexPoints[3] = cellVertData[dataIndex++];
338 hexPoints[4] = cellVertData[dataIndex++];
339 hexPoints[5] = cellVertData[dataIndex++];
340 hexPoints[6] = cellVertData[dataIndex++];
341 hexPoints[7] = cellVertData[dataIndex++];
343 cells_[cellI++] =
cellShape(hex, hexPoints,
true);
348 warnUnhandledType(inFile, cellTypes[i], warningGiven);
349 label nRead = cellVertData[dataIndex++];
356 Info<<
"Read " << cellI <<
" cells;" << faceI <<
" faces." <<
endl;
358 cells_.setSize(cellI);
359 cellMap_.setSize(cellI);
360 faces_.setSize(faceI);
361 faceMap_.setSize(faceI);
362 lines_.setSize(lineI);
363 lineMap_.setSize(lineI);
368 void Foam::vtkUnstructuredReader::readField
372 const word& arrayName,
373 const word& dataType,
377 switch (vtkDataTypeNames[dataType])
398 readBlock(inFile, fieldVals().size(), fieldVals());
419 readBlock(inFile, fieldVals().size(), fieldVals());
428 Info<<
"Reading strings:" << size <<
endl;
444 inFile.
getLine(fieldVals()[0]);
448 inFile.
getLine(fieldVals()[i]);
456 IOWarningIn(
"vtkUnstructuredReader::extractCells(..)", inFile)
457 <<
"Unhandled type " << vtkDataTypeNames[dataType] <<
endl 458 <<
"Skipping " << size
459 <<
" words." <<
endl;
461 readBlock(inFile, size, fieldVals);
474 const label wantedSize
479 word dataName(inFile);
482 Info<<
"dataName:" << dataName <<
endl;
487 Pout<<
"numArrays:" << numArrays <<
endl;
489 for (
label i = 0; i < numArrays; i++)
491 word arrayName(inFile);
494 word dataType(inFile);
498 Info<<
"Reading field " << arrayName
499 <<
" of " << numTuples <<
" tuples of rank " << numComp <<
endl;
502 if (wantedSize != -1 && numTuples != wantedSize)
504 FatalIOErrorIn(
"vtkUnstructuredReader::readFieldArray(..)", inFile)
505 <<
"Expected " << wantedSize <<
" tuples but only have " 525 const parseMode readMode
528 if (readMode == CELL_DATA)
532 else if (readMode == POINT_DATA)
551 cellData_(
IOobject(
"cellData", obr)),
552 pointData_(
IOobject(
"pointData", obr)),
553 otherData_(
IOobject(
"otherData", obr))
559 void Foam::vtkUnstructuredReader::read(
ISstream& inFile)
564 Info<<
"Header : " << header_ <<
endl;
569 Info<<
"Title : " << title_ <<
endl;
574 Info<<
"dataType : " << dataType_ <<
endl;
577 if (dataType_ ==
"BINARY")
584 label wantedSize = -1;
590 while (inFile.
good())
602 <<
" tag:" << tag <<
endl;
605 if (tag ==
"DATASET")
607 word geomType(inFile);
610 Info<<
"geomType : " << geomType <<
endl;
612 readMode = parseModeNames[geomType];
615 else if (tag ==
"POINTS")
618 points_.setSize(nPoints);
621 Info<<
"Reading " << nPoints <<
" numbers representing " 622 << points_.size() <<
" coordinates." <<
endl;
625 word primitiveTag(inFile);
626 if (primitiveTag !=
"float" && primitiveTag !=
"double")
629 <<
"Expected 'float' entry but found " 635 inFile >> points_[i].x() >> points_[i].y() >> points_[i].z();
638 else if (tag ==
"CELLS")
644 Info<<
"Reading " << nCells <<
" cells or faces." <<
endl;
646 readBlock(inFile, nNumbers, cellVerts);
648 else if (tag ==
"CELL_TYPES")
653 readBlock(inFile, nCellTypes, cellTypes);
655 if (cellTypes.
size() > 0 && cellVerts.
size() == 0)
658 <<
"Found " << cellTypes.
size()
659 <<
" cellTypes but no cells." 663 extractCells(inFile, cellTypes, cellVerts);
666 else if (tag ==
"LINES")
672 Info<<
"Reading " << nLines <<
" lines." <<
endl;
675 readBlock(inFile, nNumbers, lineVerts);
677 label lineI = lines_.size();
678 lines_.setSize(lineI+nLines);
679 lineMap_.setSize(lines_.size());
682 for (
label i = 0; i < nLines; i++)
684 lineMap_[lineI] = lineI;
689 f[fp] = lineVerts[elemI++];
694 else if (tag ==
"POLYGONS")
702 Info<<
"Reading " << nFaces <<
" faces." <<
endl;
705 readBlock(inFile, nNumbers, faceVerts);
707 label faceI = faces_.size();
708 faces_.setSize(faceI+nFaces);
709 faceMap_.setSize(faces_.size());
712 for (
label i = 0; i < nFaces; i++)
714 faceMap_[faceI] = faceI;
715 face&
f = faces_[faceI];
719 f[fp] = faceVerts[elemI++];
724 else if (tag ==
"POINT_DATA")
727 readMode = POINT_DATA;
728 wantedSize = points_.
size();
731 if (nPoints != wantedSize)
734 <<
"Reading POINT_DATA : expected " << wantedSize
738 else if (tag ==
"CELL_DATA")
740 readMode = CELL_DATA;
741 wantedSize = cells_.size()+faces_.size()+lines_.size();
744 if (nCells != wantedSize)
747 <<
"Reading CELL_DATA : expected " 752 else if (tag ==
"FIELD")
755 readFieldArray(inFile, selectRegistry(readMode), wantedSize);
757 else if (tag ==
"SCALARS")
768 Info<<
"Reading scalar " << dataName
769 <<
" of type " << dataType
770 <<
" from lookup table" <<
endl;
773 word lookupTableTag(inFile);
774 if (lookupTableTag !=
"LOOKUP_TABLE")
777 <<
"Expected tag LOOKUP_TABLE but read " 782 word lookupTableName(inFile);
787 selectRegistry(readMode),
793 else if (tag ==
"VECTORS" || tag ==
"NORMALS")
803 Info<<
"Reading vector " << dataName
804 <<
" of type " << dataType <<
endl;
820 vtkDataTypeNames[dataType] == VTK_FLOAT
821 || vtkDataTypeNames[dataType] == VTK_DOUBLE
825 scalarField s(*dynamic_cast<const scalarField*>(iter()));
844 fieldVals()[i].x() = s[elemI++];
845 fieldVals()[i].y() = s[elemI++];
846 fieldVals()[i].z() = s[elemI++];
851 else if (tag ==
"TEXTURE_COORDINATES")
863 Info<<
"Reading texture coords " << dataName
864 <<
" dimension " << dim
865 <<
" of type " << dataType <<
endl;
869 readBlock(inFile, coords.size(), coords);
871 else if (tag ==
"TRIANGLE_STRIPS")
877 Info<<
"Reading " << nStrips <<
" triangle strips." <<
endl;
880 readBlock(inFile, nNumbers, faceVerts);
885 for (
label i = 0; i < nStrips; i++)
887 label nVerts = faceVerts[elemI++];
895 faces_.setSize(faceI+nTris);
896 faceMap_.setSize(faces_.size());
898 for (
label i = 0; i < nStrips; i++)
900 label nVerts = faceVerts[elemI++];
901 label nTris = nVerts-2;
904 faceMap_[faceI] = faceI;
905 face&
f = faces_[faceI++];
907 f[0] = faceVerts[elemI++];
908 f[1] = faceVerts[elemI++];
909 f[2] = faceVerts[elemI++];
910 for (
label triI = 1; triI < nTris; triI++)
912 faceMap_[faceI] = faceI;
913 face& f = faces_[faceI++];
915 f[0] = faceVerts[elemI-1];
916 f[1] = faceVerts[elemI-2];
917 f[2] = faceVerts[elemI++];
924 <<
"Unsupported tag " 931 Info<<
"Read points:" << points_.size()
932 <<
" cellShapes:" << cells_.size()
933 <<
" faces:" << faces_.size()
934 <<
" lines:" << lines_.size()
938 printFieldStats<vectorIOField>(cellData_);
939 printFieldStats<scalarIOField>(cellData_);
940 printFieldStats<labelIOField>(cellData_);
941 printFieldStats<stringIOList>(cellData_);
945 printFieldStats<vectorIOField>(pointData_);
946 printFieldStats<scalarIOField>(pointData_);
947 printFieldStats<labelIOField>(pointData_);
948 printFieldStats<stringIOList>(pointData_);
952 printFieldStats<vectorIOField>(otherData_);
953 printFieldStats<scalarIOField>(otherData_);
954 printFieldStats<labelIOField>(otherData_);
955 printFieldStats<stringIOList>(otherData_);
Input from memory buffer stream.
An ordered pair of two objects of type <T> with first() and second() elements.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){gmvFile<< iter().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 ))
Info<< "Creating field dpdt\n"<< endl;volScalarField dpdt(IOobject("dpdt", runTime.timeName(), mesh), mesh, dimensionedScalar("dpdt", p.dimensions()/dimTime, 0));Info<< "Creating field kinetic energy K\n"<< endl;volScalarField K("K", 0.5 *magSqr(U));volScalarField p_rgh(IOobject("p_rgh", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE), mesh);p_rgh=p-rho *gh;mesh.setFluxRequired(p_rgh.name());multivariateSurfaceInterpolationScheme< scalar >::fieldTable fields
bool erase(const iterator &)
Erase a hashedEntry specified by given iterator.
static const NamedEnum< vtkDataSetType, 3 > vtkDataSetTypeNames
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
static const NamedEnum< vtkDataType, 8 > vtkDataTypeNames
A class for handling words, derived from string.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
void size(const label)
Override size to be inconsistent with allocated storage.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
errorManipArg< error, int > exit(error &err, const int errNo=1)
#define IOWarningIn(functionName, ios)
Report an IO warning using Foam::Warning.
label readLabel(Istream &is)
A face is a list of labels corresponding to mesh vertices.
An analytical geometric cellShape.
void clear()
Clear the list, i.e. set size to zero.
void setSize(const label)
Reset size of List.
Ostream & endl(Ostream &os)
Add newline and flush stream.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
void store()
Transfer ownership of this object to its registry.
Maps a geometry to a set of cell primitives, which enables geometric cell data to be calculated witho...
bool good() const
Return true if next operation might succeed.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & shrink()
Shrink the allocated space to the number of elements used.
vtkUnstructuredReader(const objectRegistry &obr, ISstream &)
Construct from Istream, read all.
label lineNumber() const
Return current stream line number.
ISstream & getLine(string &)
Raw, low-level getline into a string function.
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
Initialise the NamedEnum HashTable from the static list of names.
IOstream & hex(IOstream &io)
static const NamedEnum< parseMode, 5 > parseModeNames
Registry of regIOobjects.
A List of objects of type <T> with automated input and output.
bool read(const char *, int32_t &)
static const cellModel * lookup(const word &)
Look up a model by name and return a pointer to the model or NULL.
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
friend class iterator
Declare friendship with the iterator.
#define FatalIOErrorIn(functionName, ios)
Report an error message using Foam::FatalIOError.
parseMode
Enumeration defining the parse mode - what type of data is being.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Tet storage. Null constructable (unfortunately tetrahedron<point, point> is not)
defineTypeNameAndDebug(combustionModel, 0)
prefixOSstream Pout(cout,"Pout")
A primitive field of type <T> with automated input and output.
bool insert(const Key &key)
Insert a new entry.