VTK  9.3.1
vtkChacoReader.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-FileCopyrightText: Copyright (c) Sandia Corporation
3 // SPDX-License-Identifier: BSD-3-Clause
4 
21 #ifndef vtkChacoReader_h
22 #define vtkChacoReader_h
23 
24 #include "vtkIOGeometryModule.h" // For export macro
26 
27 VTK_ABI_NAMESPACE_BEGIN
28 class VTKIOGEOMETRY_EXPORT vtkChacoReader : public vtkUnstructuredGridAlgorithm
29 {
30 public:
31  static vtkChacoReader* New();
33  void PrintSelf(ostream& os, vtkIndent indent) override;
34 
40  vtkSetStringMacro(BaseName);
41  vtkGetStringMacro(BaseName);
42 
50  vtkSetMacro(GenerateGlobalElementIdArray, vtkTypeBool);
51  vtkGetMacro(GenerateGlobalElementIdArray, vtkTypeBool);
52  vtkBooleanMacro(GenerateGlobalElementIdArray, vtkTypeBool);
53 
54  static const char* GetGlobalElementIdArrayName() { return "GlobalElementId"; }
55 
64  vtkSetMacro(GenerateGlobalNodeIdArray, vtkTypeBool);
65  vtkGetMacro(GenerateGlobalNodeIdArray, vtkTypeBool);
66  vtkBooleanMacro(GenerateGlobalNodeIdArray, vtkTypeBool);
67 
68  static const char* GetGlobalNodeIdArrayName() { return "GlobalNodeId"; }
69 
76  vtkSetMacro(GenerateVertexWeightArrays, vtkTypeBool);
77  vtkGetMacro(GenerateVertexWeightArrays, vtkTypeBool);
78  vtkBooleanMacro(GenerateVertexWeightArrays, vtkTypeBool);
79 
85  vtkGetMacro(NumberOfVertexWeights, int);
86 
95  const char* GetVertexWeightArrayName(int weight);
96 
106  vtkSetMacro(GenerateEdgeWeightArrays, vtkTypeBool);
107  vtkGetMacro(GenerateEdgeWeightArrays, vtkTypeBool);
108  vtkBooleanMacro(GenerateEdgeWeightArrays, vtkTypeBool);
109 
115  vtkGetMacro(NumberOfEdgeWeights, int);
116 
125  const char* GetEdgeWeightArrayName(int weight);
126 
128 
131  vtkGetMacro(Dimensionality, int);
132  vtkGetMacro(NumberOfEdges, vtkIdType);
133  vtkGetMacro(NumberOfVertices, vtkIdType);
135 
142  vtkGetMacro(NumberOfCellWeightArrays, int);
143 
150  vtkGetMacro(NumberOfPointWeightArrays, int);
151 
152 protected:
153  vtkChacoReader();
154  ~vtkChacoReader() override;
155 
156  int BuildOutputGrid(vtkUnstructuredGrid* gr);
157 
158  // methods for parsing Chaco files
159 
160  void CloseCurrentFile();
161  int OpenCurrentFile();
162 
163  int InputGeom(vtkIdType nvtxs, int igeom, double* x, double* y, double* z);
164  int InputGraph1();
165  int InputGraph2(vtkIdType** start, vtkIdType** adjacency, double** vweights, double** eweights);
166  int GetCoordsMetadata();
167  void GetGraphMetadata();
168 
169  // methods for creating vtkUnstructuredGrid from Chaco file data
170 
171  int ReadFile(vtkUnstructuredGrid* output);
172  void AddElementIds(vtkUnstructuredGrid* output);
173  void AddNodeIds(vtkUnstructuredGrid* output);
174 
175  void MakeWeightArrayNames(int nv, int ne);
176 
177  // Parameters for controlling what is read in.
178  char* BaseName;
181 
184 
188  vtkSetStringMacro(CurrentBaseName);
189 
190  char** VarrayName;
191  char** EarrayName;
192 
193  //----------------------------------------------------------------------
194  // The following metadata is read during RequestInformation. If you
195  // add new metadata, you must modify vtkPChacoReader::RequestInformation
196  // to include it when process 0 broadcasts the metadata.
197 
201  int NumberOfVertexWeights; // in file
202  int NumberOfEdgeWeights; // in file
204 
205  //----------------------------------------------------------------------
206 
207  int NumberOfPointWeightArrays; // in output unstructured grid
208  int NumberOfCellWeightArrays; // in output unstructured grid
209 
210  // Keep the points and cells
211  // around so they don't need to be re-read when the
212  // options change.
214 
215  // Should I re-read in the geometry and topology of the dataset
217 
220 
221 private:
222  vtkChacoReader(const vtkChacoReader&) = delete;
223  void operator=(const vtkChacoReader&) = delete;
224 
225  double ReadVal(FILE* infile, int* end_flag);
226  vtkIdType ReadInt(FILE* infile, int* end_flag);
227  void FlushLine(FILE* infile);
228  void ResetInputBuffers();
229 
230  char Line[200];
231  const int Line_length = 200;
232  int Offset;
233  int Break_pnt;
234  int Save_pnt;
235 
236  void ClearWeightArrayNames();
237 };
238 
239 VTK_ABI_NAMESPACE_END
240 #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:315
int vtkTypeBool
Definition: vtkABI.h:64
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:28
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