10 #ifndef vtk_m_io_VTKDataSetReaderBase_h
11 #define vtk_m_io_VTKDataSetReaderBase_h
16 #include <vtkm/io/vtkm_io_export.h>
39 vtkm::io::internal::DataSetStructure Structure;
43 inline void parseAssert(
bool condition)
69 if (dim[0] > 1 && dim[1] > 1 && dim[2] > 1)
75 else if (dim[0] > 1 && dim[1] > 1 && dim[2] <= 1)
81 else if (dim[0] > 1 && dim[1] <= 1 && dim[2] <= 1)
89 ss <<
"Unsupported dimensions: (" << dim[0] <<
", " << dim[1] <<
", " << dim[2]
90 <<
"), 2D structured datasets should be on X-Y plane and "
91 <<
"1D structured datasets should be along X axis";
100 std::unique_ptr<internal::VTKDataSetFile>
DataFile;
123 virtual VTKM_CONT void PrintSummary(std::ostream& out)
const;
137 this->CellsPermutation = permutation;
142 return this->CellsPermutation;
147 reader.
DataFile.swap(this->DataFile);
148 this->DataFile.reset(
nullptr);
158 VTKM_CONT void AddField(
const std::string& name,
163 std::size_t numElements);
166 std::size_t numElements);
170 std::size_t expectedNumElements);
172 std::size_t numElements);
175 VTKM_CONT void ReadGlobalFields(std::vector<vtkm::Float32>* visitBounds =
nullptr);
178 class SkipArrayVariant;
179 class ReadArrayVariant;
185 std::size_t numElements,
190 std::size_t numElements,
193 template <
typename T>
199 std::size_t numElements = buffer.size();
200 if (this->DataFile->IsBinary)
202 this->DataFile->Stream.read(
reinterpret_cast<char*
>(&buffer[0]),
203 static_cast<std::streamsize
>(numElements *
sizeof(T)));
204 if (vtkm::io::internal::IsLittleEndian())
206 vtkm::io::internal::FlipEndianness(buffer);
211 for (std::size_t i = 0; i < numElements; ++i)
215 typename internal::StreamIOType<ComponentType>::Type val;
216 this->DataFile->Stream >> val;
221 this->DataFile->Stream >> std::ws;
222 this->SkipArrayMetaData(numComponents);
225 template <vtkm::IdComponent NumComponents>
230 "Support for data type 'bit' is not implemented. Skipping.");
235 VTKM_CONT void ReadArray(std::vector<vtkm::io::internal::DummyBitType>& buffer);
237 template <
typename T>
243 if (this->DataFile->IsBinary)
245 this->DataFile->Stream.seekg(
static_cast<std::streamoff
>(numElements *
sizeof(T)),
250 for (std::size_t i = 0; i < numElements; ++i)
254 typename internal::StreamIOType<ComponentType>::Type val;
255 this->DataFile->Stream >> val;
259 this->DataFile->Stream >> std::ws;
260 this->SkipArrayMetaData(numComponents);
263 template <vtkm::IdComponent NumComponents>
267 this->SkipArray(numElements *
static_cast<std::size_t
>(NumComponents),
268 vtkm::io::internal::DummyBitType(),
272 VTKM_CONT void SkipArray(std::size_t numElements,
273 vtkm::io::internal::DummyBitType,
276 VTKM_CONT void SkipStringArray(std::size_t numStrings);
283 #endif // vtk_m_io_VTKDataSetReaderBase_h