VTK  9.0.1
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 
33 #ifndef vtkChacoReader_h
34 #define vtkChacoReader_h
35 
36 #include "vtkIOGeometryModule.h" // For export macro
38 
39 class VTKIOGEOMETRY_EXPORT vtkChacoReader : public vtkUnstructuredGridAlgorithm
40 {
41 public:
42  static vtkChacoReader* New();
44  void PrintSelf(ostream& os, vtkIndent indent) override;
45 
51  vtkSetStringMacro(BaseName);
52  vtkGetStringMacro(BaseName);
53 
61  vtkSetMacro(GenerateGlobalElementIdArray, vtkTypeBool);
62  vtkGetMacro(GenerateGlobalElementIdArray, vtkTypeBool);
63  vtkBooleanMacro(GenerateGlobalElementIdArray, vtkTypeBool);
64 
65  static const char* GetGlobalElementIdArrayName() { return "GlobalElementId"; }
66 
75  vtkSetMacro(GenerateGlobalNodeIdArray, vtkTypeBool);
76  vtkGetMacro(GenerateGlobalNodeIdArray, vtkTypeBool);
77  vtkBooleanMacro(GenerateGlobalNodeIdArray, vtkTypeBool);
78 
79  static const char* GetGlobalNodeIdArrayName() { return "GlobalNodeId"; }
80 
87  vtkSetMacro(GenerateVertexWeightArrays, vtkTypeBool);
88  vtkGetMacro(GenerateVertexWeightArrays, vtkTypeBool);
89  vtkBooleanMacro(GenerateVertexWeightArrays, vtkTypeBool);
90 
96  vtkGetMacro(NumberOfVertexWeights, int);
97 
106  const char* GetVertexWeightArrayName(int weight);
107 
117  vtkSetMacro(GenerateEdgeWeightArrays, vtkTypeBool);
118  vtkGetMacro(GenerateEdgeWeightArrays, vtkTypeBool);
119  vtkBooleanMacro(GenerateEdgeWeightArrays, vtkTypeBool);
120 
126  vtkGetMacro(NumberOfEdgeWeights, int);
127 
136  const char* GetEdgeWeightArrayName(int weight);
137 
139 
142  vtkGetMacro(Dimensionality, int);
143  vtkGetMacro(NumberOfEdges, vtkIdType);
144  vtkGetMacro(NumberOfVertices, vtkIdType);
146 
153  vtkGetMacro(NumberOfCellWeightArrays, int);
154 
161  vtkGetMacro(NumberOfPointWeightArrays, int);
162 
163 protected:
164  vtkChacoReader();
165  ~vtkChacoReader() override;
166 
167  int BuildOutputGrid(vtkUnstructuredGrid* gr);
168 
169  // methods for parsing Chaco files
170 
171  void CloseCurrentFile();
172  int OpenCurrentFile();
173 
174  int InputGeom(vtkIdType nvtxs, int igeom, double* x, double* y, double* z);
175  int InputGraph1();
176  int InputGraph2(vtkIdType** start, vtkIdType** adjacency, double** vweights, double** eweights);
177  int GetCoordsMetadata();
178  void GetGraphMetadata();
179 
180  // methods for creating vtkUnstructuredGrid from Chaco file data
181 
182  int ReadFile(vtkUnstructuredGrid* output);
183  void AddElementIds(vtkUnstructuredGrid* output);
184  void AddNodeIds(vtkUnstructuredGrid* output);
185 
186  void MakeWeightArrayNames(int nv, int ne);
187 
188  // Parameters for controlling what is read in.
189  char* BaseName;
192 
195 
199  vtkSetStringMacro(CurrentBaseName);
200 
201  char** VarrayName;
202  char** EarrayName;
203 
204  //----------------------------------------------------------------------
205  // The following metadata is read during RequestInformation. If you
206  // add new metadata, you must modify vtkPChacoReader::RequestInformation
207  // to include it when process 0 broadcasts the metadata.
208 
212  int NumberOfVertexWeights; // in file
213  int NumberOfEdgeWeights; // in file
215 
216  //----------------------------------------------------------------------
217 
218  int NumberOfPointWeightArrays; // in output unstructured grid
219  int NumberOfCellWeightArrays; // in output unstructured grid
220 
221  // Keep the points and cells
222  // around so they don't need to be re-read when the
223  // options change.
225 
226  // Should I re-read in the geometry and topology of the dataset
228 
231 
232 private:
233  vtkChacoReader(const vtkChacoReader&) = delete;
234  void operator=(const vtkChacoReader&) = delete;
235 
236  double ReadVal(FILE* infile, int* end_flag);
237  vtkIdType ReadInt(FILE* infile, int* end_flag);
238  void FlushLine(FILE* infile);
239  void ResetInputBuffers();
240 
241  char* Line;
242  int Line_length;
243  int Offset;
244  int Break_pnt;
245  int Save_pnt;
246 
247  void ClearWeightArrayNames();
248 };
249 
250 #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:338
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:33
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