VTK  9.0.1
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 =========================================================================*/
41 #ifndef vtkXMLHyperTreeGridReader_h
42 #define vtkXMLHyperTreeGridReader_h
43 
44 #include "vtkIOXMLModule.h" // For export macro
45 #include "vtkXMLReader.h"
46 
47 #include <limits.h> // Use internal
48 #include <map> // Use internal
49 
50 class vtkBitArray;
51 class vtkHyperTree;
52 class vtkHyperTreeGrid;
54 class vtkIdTypeArray;
55 
56 class VTKIOXML_EXPORT vtkXMLHyperTreeGridReader : public vtkXMLReader
57 {
58 public:
60  void PrintSelf(ostream& os, vtkIndent indent) override;
62 
64 
67  vtkHyperTreeGrid* GetOutput();
68  vtkHyperTreeGrid* GetOutput(int idx);
70 
72 
76  vtkSetMacro(FixedLevel, unsigned int);
77  vtkGetMacro(FixedLevel, unsigned int);
79 
81 
90  void SetCoordinatesBoundingBox(
91  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax);
92 
93  void SetIndicesBoundingBox(unsigned int imin, unsigned int imax, unsigned int jmin,
94  unsigned int jmax, unsigned int kmin, unsigned int kmax);
95 
96  void ClearAndAddSelectedHT(unsigned int idg, unsigned int fixedLevel = UINT_MAX);
97  void AddSelectedHT(unsigned int idg, unsigned int fixedLevel = UINT_MAX);
99 
100  // These defer to the HyperTreeGrid output.
101  vtkIdType GetNumberOfPoints();
102 
103  vtkIdType GetNumberOfPieces();
104 
105  void SetupUpdateExtent(int piece, int numberOfPieces);
106 
107  void CopyOutputInformation(vtkInformation* outInfo, int port) override;
108 
109  // The most important stuff is here.
110  // Read the rest of the file and create the HyperTreeGrid.
111  void ReadXMLData() override;
112 
113 protected:
115  ~vtkXMLHyperTreeGridReader() override;
116 
117  // Finalize the selected HyperTrees by, for example, transform
118  // coordinates bounding box in indices coordinates bounding box
119  // after initialize HyperTreeGrid.
120  void CalculateHTs(const vtkHyperTreeGrid* grid);
121 
122  // Return true if HyperTree identified by treeIndx is selected for
123  // the load.
124  bool IsSelectedHT(const vtkHyperTreeGrid* grid, unsigned int treeIndx) const;
125 
126  // Return the fixedLevel choice for this HyperTree
127  vtkIdType GetFixedLevelOfThisHT(vtkIdType numberOfLevels, unsigned int treeIndx) const;
128 
129  const char* GetDataSetName() override;
130 
131  void DestroyPieces();
132 
133  void GetOutputUpdateExtent(int& piece, int& numberOfPieces);
134 
135  // Setup the output with no data available. Used in error cases.
136  void SetupEmptyOutput() override;
137 
138  // Initialize the total number of vertices
139  void SetupOutputTotals();
140 
141  // Initialize global start of next piece
142  void SetupNextPiece();
143 
144  // Initialize current output data
145  void SetupOutputData() override;
146 
147  // Setup the output's information
148  void SetupOutputInformation(vtkInformation* outInfo) override;
149 
150  // Setup the number of pieces
151  void SetupPieces(int numPieces);
152 
153  // Pipeline execute data driver called by vtkXMLReader
154  int ReadPrimaryElement(vtkXMLDataElement* ePrimary) override;
155 
156  // Declare that this reader produces HyperTreeGrids
157  int FillOutputPortInformation(int, vtkInformation*) override;
158 
159  // Read the coordinates describing the grid
160  void ReadGrid(vtkXMLDataElement* elem);
161 
162  //----------- Used for the major version < 1
163 
164  // Recover the structure of the HyperTreeGrid, used by ReadXMLData.
165  void ReadTrees_0(vtkXMLDataElement* elem);
166 
167  // Used by ReadTopology to recursively build the tree
168  void SubdivideFromDescriptor_0(vtkHyperTreeGridNonOrientedCursor* treeCursor, unsigned int level,
169  int numChildren, vtkBitArray* desc, vtkIdTypeArray* posByLevel);
170 
171  //---------- Used for other the major version
172 
173  // Recover the structure of the HyperTreeGrid, used by ReadXMLData.
174  void ReadTrees_1(vtkXMLDataElement* elem);
175 
176  // Number of vertices in HyperTreeGrid being read
179 
180  // Fixed the load maximum level
181  unsigned int FixedLevel = UINT_MAX;
182 
183  bool Verbose = false;
184 
185  bool FixedHTs = false;
187  {
191  IDS_SELECTED
192  };
193  SelectedType SelectedHTs = ALL;
194 
195  // Selected HTs by coordinates of bounding box
196  double CoordinatesBoundingBox[6];
197  // Selected HTs by indice coordinate of bounding box
198  unsigned int IndicesBoundingBox[6];
199  // Selected HTs by indice of HTs in the map.
200  // The value is the fixedLevel, but if this value is
201  // UINT_MAX, this is FixedLevel that is used.
202  std::map<unsigned int, unsigned int> IdsSelected;
203 
206 
208  int EndPiece;
209  int Piece;
210 
211 private:
213  void operator=(const vtkXMLHyperTreeGridReader&) = delete;
214 };
215 
216 #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:338
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:33
virtual void SetupOutputInformation(vtkInformation *vtkNotUsed(outInfo))
Definition: vtkXMLReader.h:201
virtual int ReadPrimaryElement(vtkXMLDataElement *ePrimary)
dynamic, self-adjusting array of bits
Definition: vtkBitArray.h:33
virtual void CopyOutputInformation(vtkInformation *vtkNotUsed(outInfo), int vtkNotUsed(port))
Definition: vtkXMLReader.h:135
A data object structured as a tree.
Definition: vtkHyperTree.h:178
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&#39;s XML format readers.
Definition: vtkXMLReader.h:43
virtual void SetupOutputData()