Go to the documentation of this file.
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
void SetCellsPermutation(const vtkm::cont::ArrayHandle< vtkm::Id > &permutation)
Definition: VTKDataSetReaderBase.h:135
vtkm::Float64 dataType
Definition: TreeCompiler.h:72
vtkm::cont::ArrayHandle< vtkm::Id > CellsPermutation
Definition: VTKDataSetReaderBase.h:105
void SkipArray(std::size_t numElements, T)
Definition: VTKDataSetReaderBase.h:238
Groups connected points that have the same field value.
Definition: Atomic.h:19
@ Warn
Less important user errors, such as out-of-bounds parameters.
Definition: VTKDataSetReaderBase.h:97
vtkm::Int32 IdComponent
Represents a component ID (index of component in a vector).
Definition: Types.h:168
const vtkm::cont::DataSet & GetDataSet() const
Definition: VTKDataSetReaderBase.h:121
static VTKM_EXEC_CONT void SetComponent(VecType &vector, vtkm::IdComponent component, ComponentType value)
Changes the value in a given component of the vector.
Association
Definition: cont/Field.h:34
An ArrayHandle of an unknown value type and storage.
Definition: UnknownArrayHandle.h:406
int16_t Int16
Definition: Types.h:158
VTKM_CONT void TransferDataFile(VTKDataSetReaderBase &reader)
Definition: VTKDataSetReaderBase.h:145
A CellSet of an unknown type.
Definition: UnknownCellSet.h:48
VTKM_CONT void ReadArray(std::vector< T > &buffer)
Definition: VTKDataSetReaderBase.h:194
bool Loaded
Definition: VTKDataSetReaderBase.h:104
vtkm::cont::DataSet DataSet
Definition: VTKDataSetReaderBase.h:101
int8_t Int8
Definition: Types.h:156
#define VTKM_CONT
Definition: ExportMacros.h:57
std::unique_ptr< internal::VTKDataSetFile > DataFile
Definition: VTKDataSetReaderBase.h:100
uint8_t UInt8
Definition: Types.h:157
constexpr VTKM_EXEC_CONT vtkm::Vec< T, vtkm::IdComponent(sizeof...(Ts)+1)> make_Vec(T value0, Ts &&... args)
Initializes and returns a Vec containing all the arguments.
Definition: Types.h:1212
#define VTKM_LOG_S(level,...)
Writes a message using stream syntax to the indicated log level.
Definition: Logging.h:261
Definition: VTKDataSetReader.h:20
void SkipArray(std::size_t numElements, vtkm::Vec< vtkm::io::internal::DummyBitType, NumComponents >)
Definition: VTKDataSetReaderBase.h:264
A short fixed-length array.
Definition: Types.h:767
void SetPointDimensions(SchedulingRangeType dimensions)
Definition: CellSetStructured.h:49
VTKM_CONT void ReadArray(std::vector< vtkm::Vec< vtkm::io::internal::DummyBitType, NumComponents >> &buffer)
Definition: VTKDataSetReaderBase.h:226
typename VecType::ComponentType ComponentType
Type of the components in the vector.
Definition: VecTraits.h:73
The VecTraits class gives several static members that define how to use a given type as a vector.
Definition: VecTraits.h:66
uint16_t UInt16
Definition: Types.h:159
VTKM_CONT vtkm::cont::ArrayHandle< vtkm::Id > GetCellsPermutation() const
Definition: VTKDataSetReaderBase.h:140