vtk-m/vtkm/io/VTKDataSetWriter.h
Kenneth Moreland 8f1c453c0b Support writing binary files to legacy VTK files
The legacy VTK file writer writes out in ASCII. This is helpful when a
human is trying to read the file. However, if you have more than a
trivial amount of data, the file can get impractically large. To get
around this, `VTKDataSetWriter` now has a flag that allows you to write
the data in binary format.
2021-10-11 13:08:59 -06:00

57 lines
1.6 KiB
C++

//============================================================================
// 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.
//============================================================================
#ifndef vtk_m_io_DataSetWriter_h
#define vtk_m_io_DataSetWriter_h
#include <vtkm/cont/DataSet.h>
#include <vtkm/io/vtkm_io_export.h>
namespace vtkm
{
namespace io
{
// Might want to place this somewhere else.
enum struct FileType
{
ASCII,
BINARY
};
struct VTKM_IO_EXPORT VTKDataSetWriter
{
public:
VTKM_CONT VTKDataSetWriter(const char* fileName);
VTKM_CONT VTKDataSetWriter(const std::string& fileName);
VTKM_CONT void WriteDataSet(const vtkm::cont::DataSet& dataSet) const;
/// \brief Get whether the file will be written in ASCII or binary format.
///
VTKM_CONT vtkm::io::FileType GetFileType() const;
/// \{
/// \brief Set whether the file will be written in ASCII or binary format.
VTKM_CONT void SetFileType(vtkm::io::FileType type);
VTKM_CONT void SetFileTypeToAscii() { this->SetFileType(vtkm::io::FileType::ASCII); }
VTKM_CONT void SetFileTypeToBinary() { this->SetFileType(vtkm::io::FileType::BINARY); }
/// \}
private:
std::string FileName;
vtkm::io::FileType FileType = vtkm::io::FileType::ASCII;
}; //struct VTKDataSetWriter
}
} //namespace vtkm::io
#endif //vtk_m_io_DataSetWriter_h