vtk-m/vtkm/io/reader/VTKStructuredGridReader.h

83 lines
2.3 KiB
C
Raw Normal View History

2015-10-26 14:07:36 +00:00
//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt 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 2015 Sandia Corporation.
// Copyright 2015 UT-Battelle, LLC.
// Copyright 2015 Los Alamos National Security.
//
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
// the U.S. Government retains certain rights in this software.
//
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
// Laboratory (LANL), the U.S. Government retains certain rights in
// this software.
//============================================================================
#ifndef vtk_m_io_reader_VTKStructuredGridReader_h
#define vtk_m_io_reader_VTKStructuredGridReader_h
#include <vtkm/io/reader/VTKDataSetReaderBase.h>
namespace vtkm {
namespace io {
namespace reader {
VTKM_SILENCE_WEAK_VTABLE_WARNING_START
2015-10-26 14:07:36 +00:00
class VTKStructuredGridReader : public VTKDataSetReaderBase
{
public:
explicit VTKStructuredGridReader(const char *fileName)
: VTKDataSetReaderBase(fileName)
{ }
private:
virtual void Read()
{
if (this->DataFile->Structure != vtkm::io::internal::DATASET_STRUCTURED_GRID)
2015-10-26 14:07:36 +00:00
{
throw vtkm::io::ErrorIO("Incorrect DataSet type");
}
std::string tag;
//We need to be able to handle VisIt files which dump Field data
//at the top of a VTK file
this->DataFile->Stream >> tag;
if(tag == "FIELD")
{
std::string name;
this->ReadFields(name);
this->DataFile->Stream >> tag;
}
2015-10-26 14:07:36 +00:00
// Read structured grid specific meta-data
internal::parseAssert(tag == "DIMENSIONS");
2015-10-26 14:07:36 +00:00
vtkm::Id3 dim;
this->DataFile->Stream >> dim[0] >> dim[1] >> dim[2] >> std::ws;
2015-10-26 14:07:36 +00:00
this->DataSet.AddCellSet(internal::CreateCellSetStructured(dim));
2015-10-26 14:07:36 +00:00
// Read the points
this->DataFile->Stream >> tag;
internal::parseAssert(tag == "POINTS");
2015-10-26 14:07:36 +00:00
this->ReadPoints();
// Read points and cell attributes
this->ReadAttributes();
}
};
VTKM_SILENCE_WEAK_VTABLE_WARNING_END
2015-10-26 14:07:36 +00:00
}
}
} // namespace vtkm::io:reader
#endif // vtk_m_io_reader_VTKStructuredGridReader_h