ENH: vtkUnstructuredReader: handle more vtk file types

This commit is contained in:
mattijs
2012-04-10 12:30:38 +01:00
parent ccb510e6ff
commit 16ee9174f9
2 changed files with 23 additions and 5 deletions

View File

@ -36,14 +36,18 @@ defineTypeNameAndDebug(Foam::vtkUnstructuredReader, 0);
template<> template<>
const char* const char*
Foam::NamedEnum<Foam::vtkUnstructuredReader::vtkDataType, 4>::names[] = Foam::NamedEnum<Foam::vtkUnstructuredReader::vtkDataType, 8>::names[] =
{ {
"int", "int",
"unsigned_int",
"long",
"unsigned_long",
"float", "float",
"double",
"string", "string",
"vtkIdType" "vtkIdType"
}; };
const Foam::NamedEnum<Foam::vtkUnstructuredReader::vtkDataType, 4> const Foam::NamedEnum<Foam::vtkUnstructuredReader::vtkDataType, 8>
Foam::vtkUnstructuredReader::vtkDataTypeNames; Foam::vtkUnstructuredReader::vtkDataTypeNames;
@ -385,6 +389,9 @@ void Foam::vtkUnstructuredReader::readField
switch (vtkDataTypeNames[dataType]) switch (vtkDataTypeNames[dataType])
{ {
case VTK_INT: case VTK_INT:
case VTK_UINT:
case VTK_LONG:
case VTK_ULONG:
case VTK_ID: case VTK_ID:
{ {
autoPtr<labelIOField> fieldVals autoPtr<labelIOField> fieldVals
@ -406,6 +413,7 @@ void Foam::vtkUnstructuredReader::readField
break; break;
case VTK_FLOAT: case VTK_FLOAT:
case VTK_DOUBLE:
{ {
autoPtr<scalarIOField> fieldVals autoPtr<scalarIOField> fieldVals
( (
@ -627,7 +635,7 @@ void Foam::vtkUnstructuredReader::read(ISstream& inFile)
} }
word primitiveTag(inFile); word primitiveTag(inFile);
if (primitiveTag != "float") if (primitiveTag != "float" && primitiveTag != "double")
{ {
FatalIOErrorIn("vtkUnstructuredReader::read(..)", inFile) FatalIOErrorIn("vtkUnstructuredReader::read(..)", inFile)
<< "Expected 'float' entry but found " << "Expected 'float' entry but found "
@ -809,7 +817,11 @@ void Foam::vtkUnstructuredReader::read(ISstream& inFile)
3*wantedSize 3*wantedSize
); );
if (vtkDataTypeNames[dataType] == VTK_FLOAT) if
(
vtkDataTypeNames[dataType] == VTK_FLOAT
|| vtkDataTypeNames[dataType] == VTK_DOUBLE
)
{ {
objectRegistry::iterator iter = reg.find(dataName); objectRegistry::iterator iter = reg.find(dataName);
scalarField s(*dynamic_cast<const scalarField*>(iter())); scalarField s(*dynamic_cast<const scalarField*>(iter()));

View File

@ -28,6 +28,8 @@ Description
Reader for vtk unstructured_grid legacy files. Supports single CELLS, POINTS Reader for vtk unstructured_grid legacy files. Supports single CELLS, POINTS
etc. entry only. etc. entry only.
- all integer types (int, unsigned_int, long etc.) become Foam::label
- all real types (float, double) become Foam::scalar
- POINTS becomes OpenFOAM points - POINTS becomes OpenFOAM points
- CELLS gets split into OpenFOAM - CELLS gets split into OpenFOAM
- cells - cells
@ -69,12 +71,16 @@ public:
enum vtkDataType enum vtkDataType
{ {
VTK_INT, VTK_INT,
VTK_UINT,
VTK_LONG,
VTK_ULONG,
VTK_FLOAT, VTK_FLOAT,
VTK_DOUBLE,
VTK_STRING, VTK_STRING,
VTK_ID VTK_ID
}; };
static const NamedEnum<vtkDataType, 4> vtkDataTypeNames; static const NamedEnum<vtkDataType, 8> vtkDataTypeNames;
//- Enumeration defining the vtk dataset types //- Enumeration defining the vtk dataset types