VTK  9.2.6
vtkChacoReader.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkChacoReader.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 =========================================================================*/
15 /*----------------------------------------------------------------------------
16  Copyright (c) Sandia Corporation
17  See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
18 ----------------------------------------------------------------------------*/
19 
36 #ifndef vtkChacoReader_h
37 #define vtkChacoReader_h
38 
39 #include "vtkIOGeometryModule.h" // For export macro
41 
42 class VTKIOGEOMETRY_EXPORT vtkChacoReader : public vtkUnstructuredGridAlgorithm
43 {
44 public:
45  static vtkChacoReader* New();
47  void PrintSelf(ostream& os, vtkIndent indent) override;
48 
54  vtkSetStringMacro(BaseName);
55  vtkGetStringMacro(BaseName);
56 
64  vtkSetMacro(GenerateGlobalElementIdArray, vtkTypeBool);
65  vtkGetMacro(GenerateGlobalElementIdArray, vtkTypeBool);
66  vtkBooleanMacro(GenerateGlobalElementIdArray, vtkTypeBool);
67 
68  static const char* GetGlobalElementIdArrayName() { return "GlobalElementId"; }
69 
78  vtkSetMacro(GenerateGlobalNodeIdArray, vtkTypeBool);
79  vtkGetMacro(GenerateGlobalNodeIdArray, vtkTypeBool);
80  vtkBooleanMacro(GenerateGlobalNodeIdArray, vtkTypeBool);
81 
82  static const char* GetGlobalNodeIdArrayName() { return "GlobalNodeId"; }
83 
90  vtkSetMacro(GenerateVertexWeightArrays, vtkTypeBool);
91  vtkGetMacro(GenerateVertexWeightArrays, vtkTypeBool);
92  vtkBooleanMacro(GenerateVertexWeightArrays, vtkTypeBool);
93 
99  vtkGetMacro(NumberOfVertexWeights, int);
100 
109  const char* GetVertexWeightArrayName(int weight);
110 
120  vtkSetMacro(GenerateEdgeWeightArrays, vtkTypeBool);
121  vtkGetMacro(GenerateEdgeWeightArrays, vtkTypeBool);
122  vtkBooleanMacro(GenerateEdgeWeightArrays, vtkTypeBool);
123 
129  vtkGetMacro(NumberOfEdgeWeights, int);
130 
139  const char* GetEdgeWeightArrayName(int weight);
140 
142 
145  vtkGetMacro(Dimensionality, int);
146  vtkGetMacro(NumberOfEdges, vtkIdType);
147  vtkGetMacro(NumberOfVertices, vtkIdType);
149 
156  vtkGetMacro(NumberOfCellWeightArrays, int);
157 
164  vtkGetMacro(NumberOfPointWeightArrays, int);
165 
166 protected:
167  vtkChacoReader();
168  ~vtkChacoReader() override;
169 
170  int BuildOutputGrid(vtkUnstructuredGrid* gr);
171 
172  // methods for parsing Chaco files
173 
174  void CloseCurrentFile();
175  int OpenCurrentFile();
176 
177  int InputGeom(vtkIdType nvtxs, int igeom, double* x, double* y, double* z);
178  int InputGraph1();
179  int InputGraph2(vtkIdType** start, vtkIdType** adjacency, double** vweights, double** eweights);
180  int GetCoordsMetadata();
181  void GetGraphMetadata();
182 
183  // methods for creating vtkUnstructuredGrid from Chaco file data
184 
185  int ReadFile(vtkUnstructuredGrid* output);
186  void AddElementIds(vtkUnstructuredGrid* output);
187  void AddNodeIds(vtkUnstructuredGrid* output);
188 
189  void MakeWeightArrayNames(int nv, int ne);
190 
191  // Parameters for controlling what is read in.
192  char* BaseName;
195 
198 
202  vtkSetStringMacro(CurrentBaseName);
203 
204  char** VarrayName;
205  char** EarrayName;
206 
207  //----------------------------------------------------------------------
208  // The following metadata is read during RequestInformation. If you
209  // add new metadata, you must modify vtkPChacoReader::RequestInformation
210  // to include it when process 0 broadcasts the metadata.
211 
215  int NumberOfVertexWeights; // in file
216  int NumberOfEdgeWeights; // in file
218 
219  //----------------------------------------------------------------------
220 
221  int NumberOfPointWeightArrays; // in output unstructured grid
222  int NumberOfCellWeightArrays; // in output unstructured grid
223 
224  // Keep the points and cells
225  // around so they don't need to be re-read when the
226  // options change.
228 
229  // Should I re-read in the geometry and topology of the dataset
231 
234 
235 private:
236  vtkChacoReader(const vtkChacoReader&) = delete;
237  void operator=(const vtkChacoReader&) = delete;
238 
239  double ReadVal(FILE* infile, int* end_flag);
240  vtkIdType ReadInt(FILE* infile, int* end_flag);
241  void FlushLine(FILE* infile);
242  void ResetInputBuffers();
243 
244  char Line[200];
245  const int Line_length = 200;
246  int Offset;
247  int Break_pnt;
248  int Save_pnt;
249 
250  void ClearWeightArrayNames();
251 };
252 
253 #endif
vtkTypeBool GenerateEdgeWeightArrays
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
This is called by the superclass.
int GraphFileHasVertexNumbers
Store vtkAlgorithm input/output information.
char * CurrentBaseName
static vtkUnstructuredGridAlgorithm * New()
vtkTypeBool GenerateGlobalElementIdArray
virtual int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
vtkTypeBool GenerateGlobalNodeIdArray
int vtkIdType
Definition: vtkType.h:332
int vtkTypeBool
Definition: vtkABI.h:69
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
a simple class to control print indentation
Definition: vtkIndent.h:39
dataset represents arbitrary combinations of all possible cell types
Superclass for algorithms that produce only unstructured grid as output.
FILE * CurrentGeometryFP
Read a Chaco file and create a vtkUnstructuredGrid.
int NumberOfPointWeightArrays
int NumberOfCellWeightArrays
vtkIdType NumberOfVertices
static const char * GetGlobalNodeIdArrayName()
Store zero or more vtkInformation instances.
static const char * GetGlobalElementIdArrayName()
vtkIdType NumberOfEdges
vtkTypeBool GenerateVertexWeightArrays
vtkUnstructuredGrid * DataCache