Go to the documentation of this file.
10 #ifndef vtk_m_io_VTKDataSetReaderBase_h
11 #define vtk_m_io_VTKDataSetReaderBase_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;
124 virtual VTKM_CONT void PrintSummary(std::ostream& out)
const;
138 this->CellsPermutation = permutation;
143 return this->CellsPermutation;
148 reader.
DataFile.swap(this->DataFile);
149 this->DataFile.reset(
nullptr);
159 VTKM_CONT void AddField(
const std::string& name,
164 std::size_t numElements);
167 std::size_t numElements);
171 std::size_t expectedNumElements);
173 std::size_t numElements);
176 VTKM_CONT void ReadGlobalFields(std::vector<vtkm::Float32>* visitBounds =
nullptr);
179 class SkipArrayVariant;
180 class ReadArrayVariant;
185 VTKM_CONT void DoSkipArrayVariant(std::string dataType,
186 std::size_t numElements,
190 std::string dataType,
191 std::size_t numElements,
194 template <
typename T>
200 std::size_t numElements = buffer.size();
201 if (this->DataFile->IsBinary)
203 this->DataFile->Stream.read(
reinterpret_cast<char*
>(&buffer[0]),
204 static_cast<std::streamsize
>(numElements *
sizeof(T)));
205 if (vtkm::io::internal::IsLittleEndian())
207 vtkm::io::internal::FlipEndianness(buffer);
212 for (std::size_t i = 0; i < numElements; ++i)
216 typename internal::StreamIOType<ComponentType>::Type val;
217 this->DataFile->Stream >> val;
222 this->DataFile->Stream >> std::ws;
223 this->SkipArrayMetaData(numComponents);
226 template <vtkm::IdComponent NumComponents>
231 "Support for data type 'bit' is not implemented. Skipping.");
236 VTKM_CONT void ReadArray(std::vector<vtkm::io::internal::DummyBitType>& buffer);
238 template <
typename T>
244 if (this->DataFile->IsBinary)
246 this->DataFile->Stream.seekg(
static_cast<std::streamoff
>(numElements *
sizeof(T)),
251 for (std::size_t i = 0; i < numElements; ++i)
255 typename internal::StreamIOType<ComponentType>::Type val;
256 this->DataFile->Stream >> val;
260 this->DataFile->Stream >> std::ws;
261 this->SkipArrayMetaData(numComponents);
264 template <vtkm::IdComponent NumComponents>
268 this->SkipArray(numElements *
static_cast<std::size_t
>(NumComponents),
269 vtkm::io::internal::DummyBitType(),
273 VTKM_CONT void SkipArray(std::size_t numElements,
274 vtkm::io::internal::DummyBitType,
277 VTKM_CONT void SkipStringArray(std::size_t numStrings);
284 #endif // vtk_m_io_VTKDataSetReaderBase_h
void SetCellsPermutation(const vtkm::cont::ArrayHandle< vtkm::Id > &permutation)
Definition: VTKDataSetReaderBase.h:136
vtkm::cont::ArrayHandle< vtkm::Id > CellsPermutation
Definition: VTKDataSetReaderBase.h:105
void SkipArray(std::size_t numElements, T)
Definition: VTKDataSetReaderBase.h:239
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
constexpr 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:1250
vtkm::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:194
Defines a 1-, 2-, or 3-dimensional structured grid of points.
Definition: CastAndCall.h:32
const vtkm::cont::DataSet & GetDataSet() const
Definition: VTKDataSetReaderBase.h:122
Association
Identifies what elements of a data set a field is associated with.
Definition: Field.h:38
T ComponentType
Type of the components in the vector.
Definition: VecTraits.h:71
An ArrayHandle of an unknown value type and storage.
Definition: UnknownArrayHandle.h:430
void TransferDataFile(VTKDataSetReaderBase &reader)
Definition: VTKDataSetReaderBase.h:146
Contains and manages the geometric data structures that VTK-m operates on.
Definition: DataSet.h:57
int16_t Int16
Base type to use for 16-bit signed integer numbers.
Definition: Types.h:173
vtkm::cont::ArrayHandle< vtkm::Id > GetCellsPermutation() const
Definition: VTKDataSetReaderBase.h:141
A CellSet of an unknown type.
Definition: UnknownCellSet.h:48
#define VTKM_IO_EXPORT
Definition: vtkm_io_export.h:44
bool Loaded
Definition: VTKDataSetReaderBase.h:104
vtkm::cont::DataSet DataSet
Definition: VTKDataSetReaderBase.h:101
int8_t Int8
Base type to use for 8-bit signed integer numbers.
Definition: Types.h:165
This class is thrown when VTK-m encounters an error with the file system.
Definition: ErrorIO.h:25
void ReadArray(std::vector< T > &buffer)
Definition: VTKDataSetReaderBase.h:195
static void SetComponent(T &vector, vtkm::IdComponent, ComponentType value)
Changes the value in a given component of the vector.
Definition: VecTraits.h:131
#define VTKM_CONT
Definition: ExportMacros.h:57
std::unique_ptr< internal::VTKDataSetFile > DataFile
Definition: VTKDataSetReaderBase.h:100
uint8_t UInt8
Base type to use for 8-bit unsigned integer numbers.
Definition: Types.h:169
#define VTKM_LOG_S(level,...)
Writes a message using stream syntax to the indicated log level.
Definition: Logging.h:208
Reads a legacy VTK file.
Definition: VTKDataSetReader.h:25
void ReadArray(std::vector< vtkm::Vec< vtkm::io::internal::DummyBitType, NumComponents >> &buffer)
Definition: VTKDataSetReaderBase.h:227
void SkipArray(std::size_t numElements, vtkm::Vec< vtkm::io::internal::DummyBitType, NumComponents >)
Definition: VTKDataSetReaderBase.h:265
void SetPointDimensions(SchedulingRangeType dimensions)
Set the dimensions of the structured array of points.
Definition: CellSetStructured.h:58
Traits that can be queried to treat any type as a Vec.
Definition: VecTraits.h:61
uint16_t UInt16
Base type to use for 16-bit unsigned integer numbers.
Definition: Types.h:177