VTK  9.2.6
vtkXMLHyperTreeGridReader.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkXMLHyperTreeGridReader.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
44 #ifndef vtkXMLHyperTreeGridReader_h
45 #define vtkXMLHyperTreeGridReader_h
46 
47 #include "vtkIOXMLModule.h" // For export macro
48 #include "vtkXMLReader.h"
49 
50 #include <limits.h> // Use internal
51 #include <map> // Use internal
52 
53 class vtkBitArray;
54 class vtkHyperTree;
55 class vtkHyperTreeGrid;
57 class vtkIdTypeArray;
58 
59 class VTKIOXML_EXPORT vtkXMLHyperTreeGridReader : public vtkXMLReader
60 {
61 public:
63  void PrintSelf(ostream& os, vtkIndent indent) override;
65 
67 
70  vtkHyperTreeGrid* GetOutput();
71  vtkHyperTreeGrid* GetOutput(int idx);
73 
75 
79  vtkSetMacro(FixedLevel, unsigned int);
80  vtkGetMacro(FixedLevel, unsigned int);
82 
84 
93  void SetCoordinatesBoundingBox(
94  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax);
95 
96  void SetIndicesBoundingBox(unsigned int imin, unsigned int imax, unsigned int jmin,
97  unsigned int jmax, unsigned int kmin, unsigned int kmax);
98 
99  void ClearAndAddSelectedHT(unsigned int idg, unsigned int fixedLevel = UINT_MAX);
100  void AddSelectedHT(unsigned int idg, unsigned int fixedLevel = UINT_MAX);
102 
103  // These defer to the HyperTreeGrid output.
104  vtkIdType GetNumberOfPoints() const;
105 
106  vtkIdType GetNumberOfPieces() const;
107 
108  void SetupUpdateExtent(int piece, int numberOfPieces);
109 
110  void CopyOutputInformation(vtkInformation* outInfo, int port) override;
111 
112  // The most important stuff is here.
113  // Read the rest of the file and create the HyperTreeGrid.
114  void ReadXMLData() override;
115 
116 protected:
118  ~vtkXMLHyperTreeGridReader() override;
119 
120  // Finalize the selected HyperTrees by, for example, transform
121  // coordinates bounding box in indices coordinates bounding box
122  // after initialize HyperTreeGrid.
123  void CalculateHTs(const vtkHyperTreeGrid* grid);
124 
125  // Return true if HyperTree identified by treeIndx is selected for
126  // the load.
127  bool IsSelectedHT(const vtkHyperTreeGrid* grid, vtkIdType treeIndx) const;
128 
129  // Return the fixedLevel choice for this HyperTree
130  unsigned int GetFixedLevelOfThisHT(unsigned int numberOfLevels, vtkIdType treeIndx) const;
131 
132  const char* GetDataSetName() override;
133 
134  void DestroyPieces();
135 
136  void GetOutputUpdateExtent(int& piece, int& numberOfPieces);
137 
138  // Setup the output with no data available. Used in error cases.
139  void SetupEmptyOutput() override;
140 
141  // Initialize the total number of vertices
142  void SetupOutputTotals();
143 
144  // Initialize global start of next piece
145  void SetupNextPiece();
146 
147  // Initialize current output data
148  void SetupOutputData() override;
149 
150  // Setup the output's information
151  void SetupOutputInformation(vtkInformation* outInfo) override;
152 
153  // Setup the number of pieces
154  void SetupPieces(int numPieces);
155 
156  // Pipeline execute data driver called by vtkXMLReader
157  int ReadPrimaryElement(vtkXMLDataElement* ePrimary) override;
158 
159  // Declare that this reader produces HyperTreeGrids
160  int FillOutputPortInformation(int, vtkInformation*) override;
161 
162  // Read the coordinates describing the grid
163  void ReadGrid(vtkXMLDataElement* elem);
164 
165  //----------- Used for the major version < 1
166 
167  // Recover the structure of the HyperTreeGrid, used by ReadXMLData. File
168  // format version 0.
169  void ReadTrees_0(vtkXMLDataElement* elem);
170 
171  // Used by ReadTopology to recursively build the tree
172  void SubdivideFromDescriptor_0(vtkHyperTreeGridNonOrientedCursor* treeCursor, unsigned int level,
173  unsigned int numChildren, vtkBitArray* desc, vtkIdTypeArray* posByLevel);
174 
175  //---------- Used for other the major version
176 
177  // Recover the structure of the HyperTreeGrid, used by ReadXMLData. File
178  // format version 1.
179  void ReadTrees_1(vtkXMLDataElement* elem);
180 
181  // Recover the structure of the HyperTreeGrid, used by ReadXMLData. File
182  // format version 2.
183  void ReadTrees_2(vtkXMLDataElement* elem);
184 
185  // Number of vertices in HyperTreeGrid being read
188 
189  // Fixed the load maximum level
190  unsigned int FixedLevel;
191 
192  bool Verbose = false;
193 
194  bool FixedHTs = false;
196  {
200  IDS_SELECTED
201  };
202  SelectedType SelectedHTs = ALL;
203 
204  // Selected HTs by coordinates of bounding box
205  double CoordinatesBoundingBox[6];
206  // Selected HTs by indice coordinate of bounding box
207  unsigned int IndicesBoundingBox[6];
208  // Selected HTs by indice of HTs in the map.
209  // The value is the fixedLevel, but if this value is
210  // UINT_MAX, this is FixedLevel that is used.
211  std::map<unsigned int, unsigned int> IdsSelected;
212 
215 
219 
220 private:
222  void operator=(const vtkXMLHyperTreeGridReader&) = delete;
223 };
224 
225 #endif
Read VTK XML HyperTreeGrid files.
virtual const char * GetDataSetName()=0
virtual void SetupEmptyOutput()=0
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()
int vtkIdType
Definition: vtkType.h:332
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:39
virtual void SetupOutputInformation(vtkInformation *vtkNotUsed(outInfo))
Definition: vtkXMLReader.h:227
virtual int ReadPrimaryElement(vtkXMLDataElement *ePrimary)
dynamic, self-adjusting array of bits
Definition: vtkBitArray.h:36
virtual void CopyOutputInformation(vtkInformation *vtkNotUsed(outInfo), int vtkNotUsed(port))
Definition: vtkXMLReader.h:161
A data object structured as a tree.
Definition: vtkHyperTree.h:179
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
static vtkAlgorithm * New()
Superclass for VTK's XML format readers.
Definition: vtkXMLReader.h:49
virtual void SetupOutputData()