2015-10-26 14:07:36 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
2019-04-15 23:24:21 +00:00
|
|
|
//
|
2015-10-26 14:07:36 +00:00
|
|
|
// 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.
|
|
|
|
//============================================================================
|
|
|
|
#ifndef vtk_m_io_reader_VTKStructuredGridReader_h
|
|
|
|
#define vtk_m_io_reader_VTKStructuredGridReader_h
|
|
|
|
|
|
|
|
#include <vtkm/io/reader/VTKDataSetReaderBase.h>
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace io
|
|
|
|
{
|
|
|
|
namespace reader
|
|
|
|
{
|
2015-10-26 14:07:36 +00:00
|
|
|
|
2017-04-13 18:06:33 +00:00
|
|
|
VTKM_SILENCE_WEAK_VTABLE_WARNING_START
|
|
|
|
|
2015-10-26 14:07:36 +00:00
|
|
|
class VTKStructuredGridReader : public VTKDataSetReaderBase
|
|
|
|
{
|
|
|
|
public:
|
2017-05-18 14:29:41 +00:00
|
|
|
explicit VTKStructuredGridReader(const char* fileName)
|
2015-10-26 14:07:36 +00:00
|
|
|
: VTKDataSetReaderBase(fileName)
|
2017-05-18 14:29:41 +00:00
|
|
|
{
|
|
|
|
}
|
2015-10-26 14:07:36 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
virtual void Read()
|
|
|
|
{
|
2015-11-17 16:32:19 +00:00
|
|
|
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;
|
|
|
|
|
2016-01-20 20:58:41 +00:00
|
|
|
//We need to be able to handle VisIt files which dump Field data
|
|
|
|
//at the top of a VTK file
|
|
|
|
this->DataFile->Stream >> tag;
|
2017-05-18 14:29:41 +00:00
|
|
|
if (tag == "FIELD")
|
2016-01-20 20:58:41 +00:00
|
|
|
{
|
2019-08-22 18:35:08 +00:00
|
|
|
this->ReadGlobalFields();
|
2016-01-20 20:58:41 +00:00
|
|
|
this->DataFile->Stream >> tag;
|
|
|
|
}
|
|
|
|
|
2015-10-26 14:07:36 +00:00
|
|
|
// Read structured grid specific meta-data
|
2017-03-13 17:07:47 +00:00
|
|
|
internal::parseAssert(tag == "DIMENSIONS");
|
2015-10-26 14:07:36 +00:00
|
|
|
vtkm::Id3 dim;
|
2016-01-20 20:58:41 +00:00
|
|
|
this->DataFile->Stream >> dim[0] >> dim[1] >> dim[2] >> std::ws;
|
|
|
|
|
2019-08-13 17:08:54 +00:00
|
|
|
this->DataSet.SetCellSet(internal::CreateCellSetStructured(dim));
|
2015-10-26 14:07:36 +00:00
|
|
|
|
|
|
|
// Read the points
|
2017-03-13 17:07:47 +00:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-04-13 18:06:33 +00:00
|
|
|
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
|