VTK  9.3.20240418
vtkXdmfHeavyData.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
3 #ifndef vtkXdmfHeavyData_h
4 #define vtkXdmfHeavyData_h
5 
6 #include "vtk_xdmf2.h"
7 #include VTKXDMF2_HEADER(XdmfDataItem.h)
8 #include VTKXDMF2_HEADER(XdmfGrid.h) //won't compile without it
9 #include "vtkIOXdmf2Module.h" // For export macro
10 
11 VTK_ABI_NAMESPACE_BEGIN
12 class vtkAlgorithm;
13 class vtkDataArray;
14 class vtkDataObject;
15 class vtkDataSet;
16 class vtkImageData;
18 class vtkPoints;
19 class vtkRectilinearGrid;
20 class vtkStructuredGrid;
22 class vtkXdmfDomain;
23 
24 // vtkXdmfHeavyData helps in reading heavy data from Xdmf and putting that into
25 // vtkDataObject subclasses.
26 class VTKIOXDMF2_EXPORT vtkXdmfHeavyData
27 {
28  vtkXdmfDomain* Domain;
29  xdmf2::XdmfDataItem DataItem;
30  vtkAlgorithm* Reader;
31 
32 public:
33  // These must be set before using this class.
34  int Piece;
37  int Extents[6]; // < these are original extents without the stride taken in
38  // consideration
39  int Stride[3];
40  XdmfFloat64 Time;
41 
44 
45  // Description:
46  vtkDataObject* ReadData(xdmf2::XdmfGrid* xmfGrid, int blockId = -1);
47 
48  // Description:
50 
51  // Description:
52  // Returns the VTKCellType for the given xdmf topology. Returns VTK_EMPTY_CELL
53  // on error and VTK_NUMBER_OF_CELL_TYPES for XDMF_MIXED.
54  static int GetVTKCellType(XdmfInt32 topologyType);
55 
56  // Description:
57  // Returns the number of points per cell. -1 for error. 0 when no fixed number
58  // of points possible.
59  static int GetNumberOfPointsPerCell(int vtk_cell_type);
60 
61 private:
62  // Description:
63  // Read a temporal collection.
64  vtkDataObject* ReadTemporalCollection(xdmf2::XdmfGrid* xmfTemporalCollection, int blockId);
65 
66  // Description:
67  // Read a spatial-collection or a tree.
68  vtkDataObject* ReadComposite(xdmf2::XdmfGrid* xmfColOrTree);
69 
70  // Description:
71  // Read a non-composite grid. Note here uniform has nothing to do with
72  // vtkUniformGrid but to what Xdmf's GridType="Uniform".
73  vtkDataObject* ReadUniformData(xdmf2::XdmfGrid* xmfGrid, int blockId);
74 
75  // Description:
76  // Reads the topology and geometry for an unstructured grid. Does not read any
77  // data attributes or geometry.
78  vtkDataObject* ReadUnstructuredGrid(xdmf2::XdmfGrid* xmfGrid);
79 
80  // Description:
81  // Read the image data. Simply initializes the extents and origin and spacing
82  // for the image, doesn't really read any attributes including the active
83  // point attributes.
84  vtkImageData* RequestImageData(xdmf2::XdmfGrid* xmfGrid, bool use_uniform_grid);
85 
86  // Description:
87  // Reads the geometry and topology for a vtkStructuredGrid.
88  vtkStructuredGrid* RequestStructuredGrid(xdmf2::XdmfGrid* xmfGrid);
89 
90  // Description:
91  // Reads the geometry and topology for a vtkRectilinearGrid.
92  vtkRectilinearGrid* RequestRectilinearGrid(xdmf2::XdmfGrid* xmfGrid);
93 
94  // Description:
95  // Reads geometry for vtkUnstructuredGrid or vtkStructuredGrid i.e. of
96  // vtkPointSet subclasses. The extents only make sense when reading
97  // vtkStructuredGrid. If non-null, then the only the points for the sub-grid
98  // are read.
99  vtkPoints* ReadPoints(
100  xdmf2::XdmfGeometry* xmfGeometry, int* update_extents = nullptr, int* whole_extents = nullptr);
101 
102  // Description:
103  // Read attributes.
104  bool ReadAttributes(vtkDataSet* dataSet, xdmf2::XdmfGrid* xmfGrid, int* update_extents = nullptr);
105 
106  // Description:
107  // Reads an attribute.
108  // If update_extents are non-null, then we are reading structured attributes
109  // and we read only the sub-set specified by update_extents.
110  vtkDataArray* ReadAttribute(
111  xdmf2::XdmfAttribute* xmfAttribute, int data_dimensionality, int* update_extents = nullptr);
112 
113  // Description:
114  // Read sets that mark ghost cells/nodes and then create attribute arrays for
115  // marking the cells as such.
116  bool ReadGhostSets(vtkDataSet* ds, xdmf2::XdmfGrid* xmfGrid, int* update_extents = nullptr);
117 
118  vtkMultiBlockDataSet* ReadSets(
119  vtkDataSet* dataSet, xdmf2::XdmfGrid* xmfGrid, int* update_extents = nullptr);
120 
121  // Description:
122  // Used when reading node-sets.
123  // Creates a new dataset with points with given ids extracted from the input
124  // dataset.
125  vtkDataSet* ExtractPoints(xdmf2::XdmfSet* xmfSet, vtkDataSet* dataSet);
126 
127  // Description:
128  // Used when reading cell-sets.
129  // Creates a new dataset with cells with the given ids extracted from the
130  // input dataset.
131  vtkDataSet* ExtractCells(xdmf2::XdmfSet* xmfSet, vtkDataSet* dataSet);
132 
133  // Description:
134  // Used when reading face-sets.
135  // Creates a new dataset with faces selected by the set, extracting them from
136  // the input dataset.
137  vtkDataSet* ExtractFaces(xdmf2::XdmfSet* xmfSet, vtkDataSet* dataSet);
138 
139  // Description:
140  // Used when reading edge-sets.
141  // Creates a new dataset with edges selected by the set, extracting them from
142  // the input dataset.
143  vtkDataSet* ExtractEdges(xdmf2::XdmfSet* xmfSet, vtkDataSet* dataSet);
144 };
145 
146 VTK_ABI_NAMESPACE_END
147 #endif
148 
149 // VTK-HeaderTest-Exclude: vtkXdmfHeavyData.h
Superclass for all sources, filters, and sinks in VTK.
Definition: vtkAlgorithm.h:162
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:155
general representation of visualization data
abstract class to specify dataset behavior
Definition: vtkDataSet.h:166
topologically and geometrically regular array of data
Definition: vtkImageData.h:156
Composite dataset that organizes datasets into blocks.
represent and manipulate 3D points
Definition: vtkPoints.h:139
a dataset that is topologically regular with variable spacing in the three coordinate directions
topologically regular array of data
dataset represents arbitrary combinations of all possible cell types
vtkDataObject * ReadData()
vtkDataObject * ReadData(xdmf2::XdmfGrid *xmfGrid, int blockId=-1)
static int GetVTKCellType(XdmfInt32 topologyType)
vtkXdmfHeavyData(vtkXdmfDomain *domain, vtkAlgorithm *reader)
static int GetNumberOfPointsPerCell(int vtk_cell_type)