Go to the documentation of this file.
18 #ifndef viskores_io_VTKDataSetReaderBase_h
19 #define viskores_io_VTKDataSetReaderBase_h
47 viskores::io::internal::DataSetStructure Structure;
51 inline void parseAssert(
bool condition)
77 if (dim[0] > 1 && dim[1] > 1 && dim[2] > 1)
83 else if (dim[0] > 1 && dim[1] > 1 && dim[2] <= 1)
89 else if (dim[0] > 1 && dim[1] <= 1 && dim[2] <= 1)
97 ss <<
"Unsupported dimensions: (" << dim[0] <<
", " << dim[1] <<
", " << dim[2]
98 <<
"), 2D structured datasets should be on X-Y plane and "
99 <<
"1D structured datasets should be along X axis";
108 std::unique_ptr<internal::VTKDataSetFile>
DataFile;
132 virtual VISKORES_CONT void PrintSummary(std::ostream& out)
const;
146 this->CellsPermutation = permutation;
151 return this->CellsPermutation;
156 reader.
DataFile.swap(this->DataFile);
157 this->DataFile.reset(
nullptr);
171 std::size_t numElements);
173 std::size_t numElements);
176 std::size_t numElements);
178 std::size_t numElements);
180 std::size_t numElements);
182 std::size_t expectedNumElements);
184 std::size_t numElements);
187 VISKORES_CONT void ReadGlobalFields(std::vector<viskores::Float32>* visitBounds =
nullptr);
190 class SkipArrayVariant;
191 class ReadArrayVariant;
197 std::size_t numElements,
201 std::string dataType,
202 std::size_t numElements,
205 template <
typename T>
211 std::size_t numElements = buffer.size();
212 if (this->DataFile->IsBinary)
214 this->DataFile->Stream.read(
reinterpret_cast<char*
>(&buffer[0]),
215 static_cast<std::streamsize
>(numElements *
sizeof(T)));
216 if (viskores::io::internal::IsLittleEndian())
218 viskores::io::internal::FlipEndianness(buffer);
223 for (std::size_t i = 0; i < numElements; ++i)
227 typename internal::StreamIOType<ComponentType>::Type val;
228 this->DataFile->Stream >> val;
233 this->DataFile->Stream >> std::ws;
234 this->SkipArrayMetaData(numComponents);
237 template <viskores::IdComponent NumComponents>
242 "Support for data type 'bit' is not implemented. Skipping.");
243 this->SkipArray(buffer.size(),
248 VISKORES_CONT void ReadArray(std::vector<viskores::io::internal::DummyBitType>& buffer);
250 template <
typename T>
256 if (this->DataFile->IsBinary)
258 this->DataFile->Stream.seekg(
static_cast<std::streamoff
>(numElements *
sizeof(T)),
263 for (std::size_t i = 0; i < numElements; ++i)
267 typename internal::StreamIOType<ComponentType>::Type val;
268 this->DataFile->Stream >> val;
272 this->DataFile->Stream >> std::ws;
273 this->SkipArrayMetaData(numComponents);
276 template <viskores::IdComponent NumComponents>
280 this->SkipArray(numElements *
static_cast<std::size_t
>(NumComponents),
281 viskores::io::internal::DummyBitType(),
286 viskores::io::internal::DummyBitType,
296 #endif // viskores_io_VTKDataSetReaderBase_h
static void SetComponent(T &vector, viskores::IdComponent, ComponentType value)
Changes the value in a given component of the vector.
Definition: VecTraits.h:141
Contains and manages the geometric data structures that Viskores operates on.
Definition: DataSet.h:66
void SkipArray(std::size_t numElements, viskores::Vec< viskores::io::internal::DummyBitType, NumComponents >)
Definition: VTKDataSetReaderBase.h:277
int16_t Int16
Base type to use for 16-bit signed integer numbers.
Definition: Types.h:181
Association
Identifies what elements of a data set a field is associated with.
Definition: Field.h:46
@ Warn
Less important user errors, such as out-of-bounds parameters.
int8_t Int8
Base type to use for 8-bit signed integer numbers.
Definition: Types.h:173
uint16_t UInt16
Base type to use for 16-bit unsigned integer numbers.
Definition: Types.h:185
viskores::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:202
void SetCellsPermutation(const viskores::cont::ArrayHandle< viskores::Id > &permutation)
Definition: VTKDataSetReaderBase.h:144
void SkipArray(std::size_t numElements, T)
Definition: VTKDataSetReaderBase.h:251
#define VISKORES_CONT
Definition: ExportMacros.h:65
void TransferDataFile(VTKDataSetReaderBase &reader)
Definition: VTKDataSetReaderBase.h:154
Groups connected points that have the same field value.
Definition: Atomic.h:27
void ReadArray(std::vector< T > &buffer)
Definition: VTKDataSetReaderBase.h:206
This class is thrown when Viskores encounters an error with the file system.
Definition: ErrorIO.h:33
Traits that can be queried to treat any type as a Vec.
Definition: VecTraits.h:69
Reads a legacy VTK file.
Definition: VTKDataSetReader.h:33
Definition: VTKDataSetReaderBase.h:105
constexpr viskores::Vec< T, viskores::IdComponent(sizeof...(Ts)+1)> make_Vec(T value0, Ts &&... args)
Initializes and returns a Vec containing all the arguments.
Definition: Types.h:1262
uint8_t UInt8
Base type to use for 8-bit unsigned integer numbers.
Definition: Types.h:177
Defines a 1-, 2-, or 3-dimensional structured grid of points.
Definition: CastAndCall.h:40
viskores::cont::DataSet DataSet
Definition: VTKDataSetReaderBase.h:109
A CellSet of an unknown type.
Definition: UnknownCellSet.h:56
#define VISKORES_LOG_S(level,...)
Writes a message using stream syntax to the indicated log level.
Definition: Logging.h:216
void ReadArray(std::vector< viskores::Vec< viskores::io::internal::DummyBitType, NumComponents >> &buffer)
Definition: VTKDataSetReaderBase.h:238
T ComponentType
Type of the components in the vector.
Definition: VecTraits.h:79
viskores::cont::ArrayHandle< viskores::Id > GetCellsPermutation() const
Definition: VTKDataSetReaderBase.h:149
std::unique_ptr< internal::VTKDataSetFile > DataFile
Definition: VTKDataSetReaderBase.h:108
viskores::cont::ArrayHandle< viskores::Id > CellsPermutation
Definition: VTKDataSetReaderBase.h:113
An ArrayHandle of an unknown value type and storage.
Definition: UnknownArrayHandle.h:451
void SetPointDimensions(SchedulingRangeType dimensions)
Set the dimensions of the structured array of points.
Definition: CellSetStructured.h:66
bool Loaded
Definition: VTKDataSetReaderBase.h:112
const viskores::cont::DataSet & GetDataSet() const
Definition: VTKDataSetReaderBase.h:130