added tecplot table reader with test

parent da4e277a
set(Module_SRCS
vtkTecplotTableReader.cxx
)
vtk_module_library(vtkIOTecplotTable ${Module_SRCS})
INCLUDE_DIRECTORIES(
${VTK_SOURCE_DIR}/Common/Testing/Cxx/
${VTK_SOURCE_DIR}/Rendering/Testing/Cxx/
${VTK_SOURCE_DIR}/Testing/Core/
)
vtk_add_test_cxx(${vtk-module}CxxTests tests
NO_VALID
TestTecplotTableReader.cxx
)
ExternalData_add_test(VTKData
NAME TestTecplotTableReader
COMMAND ${vtk-module}CxxTests TestTecplotTableReader
-D DATA{../Data/residuals.dat}
)
vtk_test_cxx_executable(${vtk-module}CxxTests tests)
/*=========================================================================
Program: Visualization Toolkit
Module: TestDelimitedTextReader.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include <vtkTecplotTableReader.h>
#include <vtkTable.h>
#include <vtkTestUtilities.h>
// This tests the ability to read a Tecplot table. The test file contains residuals from a CFD calculation.
int TestTecplotTableReader(int argc, char *argv[])
{
//------------ test the reader with an input file-----------------
if (argc != 3) return 0; // for some reason we get called twice, once with 5 arguments that are not pointing to the file
char* filename = argv[2];
std::cout << filename << std::endl;
vtkTecplotTableReader *reader = vtkTecplotTableReader::New();
reader->SetFileName(filename);
reader->OutputPedigreeIdsOn();
reader->Update();
vtkTable* table = reader->GetOutput();
table->Dump();
cout << "Printing reader info..." << endl;
reader->Print(cout);
if (table->GetNumberOfRows() != 171)
{
cout << "ERROR: Wrong number of rows: " << table->GetNumberOfRows()<<endl;
return 1;
}
if (table->GetNumberOfColumns() != 11 + 1) // one extra for pedigree ids
{
cout << "ERROR: Wrong number of columns: " << table->GetNumberOfColumns()<<endl;
return 1;
}
reader->Delete();
return 0;
}
ad064f17d0cf8231239690b0e0c412ed
vtk_module(vtkIOTecplotTable
GROUPS
StandAlone
DEPENDS
vtkCommonDataModel
vtkCommonSystem
vtkCommonMisc
vtkIOCore
vtkIOLegacy
vtkIOXML
PRIVATE_DEPENDS
vtksys
)
This diff is collapsed.
/*=========================================================================
Program: Visualization Toolkit
Module: vtkTecplotTableReader.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/*-------------------------------------------------------------------------
Copyright 2016 Menno Deij - van Rijswijk (MARIN)
-------------------------------------------------------------------------*/
// .NAME vtkTecplotTableReader - reads in Tecplot tabular data
// and outputs a vtkTable data structure.
//
// .SECTION Description
// vtkTecplotTableReader is an interface for reading tabulat data in Tecplot
// ascii format.
//
// .SECTION Thanks
// Thanks to vtkDelimitedTextReader authors.
//
#ifndef vtkTecplotTableReader_h
#define vtkTecplotTableReader_h
#include "vtkIOTecplotTableModule.h" // For export macro
#include "vtkTableAlgorithm.h"
#include "vtkUnicodeString.h" // Needed for vtkUnicodeString
#include "vtkStdString.h" // Needed for vtkStdString
class VTKIOTECPLOTTABLE_EXPORT vtkTecplotTableReader : public vtkTableAlgorithm
{
public:
static vtkTecplotTableReader* New();
vtkTypeMacro(vtkTecplotTableReader, vtkTableAlgorithm);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Specifies the delimited text file to be loaded.
vtkGetStringMacro(FileName);
vtkSetStringMacro(FileName);
// Description:
// Specifies the maximum number of records to read from the file. Limiting the
// number of records to read is useful for previewing the contents of a file.
vtkGetMacro(MaxRecords, vtkIdType);
vtkSetMacro(MaxRecords, vtkIdType);
// Description:
// Specifies the number of lines that form the header of the file. Default is 2.
vtkGetMacro(HeaderLines, vtkIdType);
vtkSetMacro(HeaderLines, vtkIdType);
// Description:
// Specifies the line number that holds the column names. Default is 1.
vtkGetMacro(ColumnNamesOnLine, vtkIdType);
vtkSetMacro(ColumnNamesOnLine, vtkIdType);
// Description
// Specifies the number of fields to skip while reading the column names. Default is 1.
vtkGetMacro(SkipColumnNames, vtkIdType);
vtkSetMacro(SkipColumnNames, vtkIdType);
// Description:
// The name of the array for generating or assigning pedigree ids
// (default "id").
vtkSetStringMacro(PedigreeIdArrayName);
vtkGetStringMacro(PedigreeIdArrayName);
// Description:
// If on (default), generates pedigree ids automatically.
// If off, assign one of the arrays to be the pedigree id.
vtkSetMacro(GeneratePedigreeIds, bool);
vtkGetMacro(GeneratePedigreeIds, bool);
vtkBooleanMacro(GeneratePedigreeIds, bool);
// Description:
// If on, assigns pedigree ids to output. Defaults to off.
vtkSetMacro(OutputPedigreeIds, bool);
vtkGetMacro(OutputPedigreeIds, bool);
vtkBooleanMacro(OutputPedigreeIds, bool);
// Description:
// Returns a human-readable description of the most recent error, if any.
// Otherwise, returns an empty string. Note that the result is only valid
// after calling Update().
vtkStdString GetLastError();
protected:
vtkTecplotTableReader();
~vtkTecplotTableReader();
int RequestData(
vtkInformation*,
vtkInformationVector**,
vtkInformationVector*);
char* FileName;
vtkIdType MaxRecords;
vtkIdType HeaderLines;
vtkIdType ColumnNamesOnLine;
vtkIdType SkipColumnNames;
char* PedigreeIdArrayName;
bool GeneratePedigreeIds;
bool OutputPedigreeIds;
vtkStdString LastError;
private:
vtkTecplotTableReader(const vtkTecplotTableReader&); // Not implemented
void operator=(const vtkTecplotTableReader&); // Not implemented
};
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment