VTK  9.7.1
vtkXMLHyperTreeGridReader.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
32 #ifndef vtkXMLHyperTreeGridReader_h
33 #define vtkXMLHyperTreeGridReader_h
34 
35 #include "vtkIOXMLModule.h" // For export macro
36 #include "vtkXMLReader.h"
37 
38 #include <limits.h> // Use internal
39 #include <map> // Use internal
40 
41 VTK_ABI_NAMESPACE_BEGIN
42 class vtkBitArray;
43 class vtkHyperTree;
44 class vtkHyperTreeGrid;
46 class vtkIdTypeArray;
47 
48 class VTKIOXML_EXPORT vtkXMLHyperTreeGridReader : public vtkXMLReader
49 {
50 public:
52  void PrintSelf(ostream& os, vtkIndent indent) override;
54 
56 
59  vtkHyperTreeGrid* GetOutput();
60  vtkHyperTreeGrid* GetOutput(int idx);
62 
64 
68  vtkSetMacro(FixedLevel, unsigned int);
69  vtkGetMacro(FixedLevel, unsigned int);
71 
73 
81  void SetCoordinatesBoundingBox(
82  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax);
83 
84  void SetIndicesBoundingBox(unsigned int imin, unsigned int imax, unsigned int jmin,
85  unsigned int jmax, unsigned int kmin, unsigned int kmax);
86 
87  void ClearAndAddSelectedHT(unsigned int idg, unsigned int fixedLevel = UINT_MAX);
88  void AddSelectedHT(unsigned int idg, unsigned int fixedLevel = UINT_MAX);
90 
91  // These defer to the HyperTreeGrid output.
92  vtkIdType GetNumberOfPoints() const;
93 
94  vtkIdType GetNumberOfPieces() const;
95 
96  void SetupUpdateExtent(int piece, int numberOfPieces);
97 
98  void CopyOutputInformation(vtkInformation* outInfo, int port) override;
99 
100  // The most important stuff is here.
101  // Read the rest of the file and create the HyperTreeGrid.
102  void ReadXMLData() override;
103 
104 protected:
106  ~vtkXMLHyperTreeGridReader() override;
107 
108  // Finalize the selected HyperTrees by, for example, transform
109  // coordinates bounding box in indices coordinates bounding box
110  // after initialize HyperTreeGrid.
111  void CalculateHTs(const vtkHyperTreeGrid* grid);
112 
113  // Return true if HyperTree identified by treeIndx is selected for
114  // the load.
115  bool IsSelectedHT(const vtkHyperTreeGrid* grid, vtkIdType treeIndx) const;
116 
117  // Return the fixedLevel choice for this HyperTree
118  unsigned int GetFixedLevelOfThisHT(unsigned int numberOfLevels, vtkIdType treeIndx) const;
119 
120  const char* GetDataSetName() override;
121 
122  void DestroyPieces();
123 
124  void GetOutputUpdateExtent(int& piece, int& numberOfPieces);
125 
126  // Setup the output with no data available. Used in error cases.
127  void SetupEmptyOutput() override;
128 
129  // Initialize the total number of vertices
130  void SetupOutputTotals();
131 
132  // Initialize global start of next piece
133  void SetupNextPiece();
134 
135  // Initialize current output data
136  void SetupOutputData() override;
137 
138  // Setup the output's information
139  void SetupOutputInformation(vtkInformation* outInfo) override;
140 
141  // Setup the number of pieces
142  void SetupPieces(int numPieces);
143 
144  // Pipeline execute data driver called by vtkXMLReader
145  int ReadPrimaryElement(vtkXMLDataElement* ePrimary) override;
146 
147  // Declare that this reader produces HyperTreeGrids
148  int FillOutputPortInformation(int, vtkInformation*) override;
149 
150  // Read the coordinates describing the grid
151  void ReadGrid(vtkXMLDataElement* elem);
152 
153  //----------- Used for the major version < 1
154 
155  // Recover the structure of the HyperTreeGrid, used by ReadXMLData. File
156  // format version 0.
157  void ReadTrees_0(vtkXMLDataElement* elem);
158 
159  // Used by ReadTopology to recursively build the tree
160  void SubdivideFromDescriptor_0(vtkHyperTreeGridNonOrientedCursor* treeCursor, unsigned int level,
161  unsigned int numChildren, vtkBitArray* desc, vtkIdTypeArray* posByLevel);
162 
163  //---------- Used for other the major version
164 
165  // Recover the structure of the HyperTreeGrid, used by ReadXMLData. File
166  // format version 1.
167  void ReadTrees_1(vtkXMLDataElement* elem);
168 
169  // Recover the structure of the HyperTreeGrid, used by ReadXMLData. File
170  // format version 2.
171  void ReadTrees_2(vtkXMLDataElement* elem);
172 
173  // Number of vertices in HyperTreeGrid being read
176 
177  // Fixed the load maximum level
178  unsigned int FixedLevel;
179 
180  bool Verbose = false;
181 
182  bool FixedHTs = false;
184  {
188  IDS_SELECTED
189  };
190  SelectedType SelectedHTs = ALL;
191 
192  // Selected HTs by coordinates of bounding box
193  double CoordinatesBoundingBox[6];
194  // Selected HTs by indice coordinate of bounding box
195  unsigned int IndicesBoundingBox[6];
196  // Selected HTs by indice of HTs in the map.
197  // The value is the fixedLevel, but if this value is
198  // UINT_MAX, this is FixedLevel that is used.
199  std::map<unsigned int, unsigned int> IdsSelected;
200 
203 
207 
208 private:
210  void operator=(const vtkXMLHyperTreeGridReader&) = delete;
211 };
212 
213 VTK_ABI_NAMESPACE_END
214 #endif
Read VTK XML HyperTreeGrid files.
virtual const char * GetDataSetName()=0
Get the name of the data set being read.
virtual void SetupEmptyOutput()=0
Setup the output with no data available.
Represents an XML element and those nested inside.
std::map< unsigned int, unsigned int > IdsSelected
Store vtkAlgorithm input/output information.
A dataset containing a grid of vtkHyperTree instances arranged as a rectilinear grid.
dynamic, self-adjusting array of vtkIdType
virtual void ReadXMLData()
Pipeline execution methods to be defined by subclass.
int vtkIdType
Definition: vtkType.h:363
Objects for traversal a HyperTreeGrid.
virtual int FillOutputPortInformation(int port, vtkInformation *info)
Fill the output port information objects for this algorithm.
a simple class to control print indentation
Definition: vtkIndent.h:28
virtual void CopyOutputInformation(vtkInformation *outInfo, int port)
Definition: vtkXMLReader.h:209
virtual int ReadPrimaryElement(vtkXMLDataElement *ePrimary)
Read the primary element from the file.
dynamic, self-adjusting array of bits
Definition: vtkBitArray.h:32
A data object structured as a tree.
Definition: vtkHyperTree.h:170
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
static vtkAlgorithm * New()
virtual void SetupOutputInformation(vtkInformation *outInfo)
Setup the output's information.
Definition: vtkXMLReader.h:292
Superclass for VTK's XML format readers.
Definition: vtkXMLReader.h:44
virtual void SetupOutputData()
Setup the output's data with allocation.