8#ifndef GRIDFORMAT_VTK_VTS_READER_HPP_
9#define GRIDFORMAT_VTK_VTS_READER_HPP_
15#include <gridformat/common/ranges.hpp>
31 auto helper = VTK::XMLReaderHelper::make_from(
filename,
"StructuredGrid");
32 _extents = Ranges::array_from_string<std::size_t, 6>(helper.get(
"StructuredGrid/Piece").get_attribute(
"Extent"));
33 VTK::XMLDetail::copy_field_names_from(helper.get(
"StructuredGrid"), fields);
34 _helper.emplace(std::move(helper));
37 void _close()
override {
42 std::string _name()
const override {
46 std::size_t _number_of_cells()
const override {
47 return VTK::CommonDetail::number_of_entities(_extents.value());
50 std::size_t _number_of_points()
const override {
51 auto pextents = _extents.value();
55 return VTK::CommonDetail::number_of_entities(pextents);
58 std::size_t _number_of_pieces()
const override {
63 const auto& ex = _extents.value();
65 result.lower_left = {ex[0], ex[2], ex[4]};
66 result.upper_right = {ex[1], ex[3], ex[5]};
70 bool _is_sequence()
const override {
75 return _helper.value().make_points_field(
"StructuredGrid/Piece/Points", _number_of_points());
78 void _visit_cells(
const typename GridReader::CellVisitor& visitor)
const override {
79 VTK::CommonDetail::visit_structured_cells(visitor, _extents.value(),
false);
82 FieldPtr _cell_field(std::string_view
name)
const override {
83 return _helper.value().make_data_array_field(
name,
"StructuredGrid/Piece/CellData", _number_of_cells());
86 FieldPtr _point_field(std::string_view
name)
const override {
87 return _helper.value().make_data_array_field(
name,
"StructuredGrid/Piece/PointData", _number_of_points());
90 FieldPtr _meta_data_field(std::string_view
name)
const override {
91 return _helper.value().make_data_array_field(
name,
"StructuredGrid/FieldData");
94 std::optional<VTK::XMLReaderHelper> _helper;
95 std::optional<std::array<std::size_t, 6>> _extents;
Base class for grid data readers.
std::shared_ptr< const Field > FieldPtr
Pointer type used by writers/readers for fields.
Definition: field.hpp:186
Common functionality for VTK writers.
Helper classes and functions for VTK XML-type file format writers & readers.