vtk-m/vtkm/io/ImageReaderBase.cxx
Kenneth Moreland 1e91b32ace Update image readers to style and library
Updated the image reader classes to better follow VTK-m naming
convention (i.e. use `ImageReaderPNG` instead of `PNGReader`).
The structure of the image reader class now also better matches
the interface for the VTK reader.

Also put the implementation of the image readers into the `vtkm_io`
library so that it only has to be compiled once.
2020-06-01 10:00:18 -06:00

52 lines
1.3 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.
//============================================================================
#include <vtkm/io/ImageReaderBase.h>
#include <vtkm/cont/DataSetBuilderUniform.h>
#include <vtkm/rendering/Canvas.h>
namespace vtkm
{
namespace io
{
ImageReaderBase::ImageReaderBase(const char* filename)
: FileName(filename)
{
}
ImageReaderBase::ImageReaderBase(const std::string& filename)
: FileName(filename)
{
}
ImageReaderBase::~ImageReaderBase() noexcept
{
}
const vtkm::cont::DataSet& ImageReaderBase::ReadDataSet()
{
this->Read();
return this->DataSet;
}
void ImageReaderBase::InitializeImageDataSet(const vtkm::Id& width,
const vtkm::Id& height,
const ColorArrayType& pixels)
{
vtkm::cont::DataSetBuilderUniform dsb;
vtkm::Id2 dimensions(width, height);
this->DataSet = dsb.Create(dimensions);
this->DataSet.AddPointField(this->PointFieldName, pixels);
}
}
} // namespace vtkm::io