VTK  9.7.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 #include <string> // For std::string
28 #include <vector> // For std::vector
29 
30 VTK_ABI_NAMESPACE_BEGIN
31 class VTKIOGEOMETRY_EXPORT vtkChacoReader : public vtkUnstructuredGridAlgorithm
32 {
33 public:
34  static vtkChacoReader* New();
36  void PrintSelf(ostream& os, vtkIndent indent) override;
37 
43  vtkSetStringMacro(BaseName);
44  vtkGetStringMacro(BaseName);
45 
53  vtkSetMacro(GenerateGlobalElementIdArray, vtkTypeBool);
54  vtkGetMacro(GenerateGlobalElementIdArray, vtkTypeBool);
55  vtkBooleanMacro(GenerateGlobalElementIdArray, vtkTypeBool);
56 
57  static const char* GetGlobalElementIdArrayName() { return "GlobalElementId"; }
58 
67  vtkSetMacro(GenerateGlobalNodeIdArray, vtkTypeBool);
68  vtkGetMacro(GenerateGlobalNodeIdArray, vtkTypeBool);
69  vtkBooleanMacro(GenerateGlobalNodeIdArray, vtkTypeBool);
70 
71  static const char* GetGlobalNodeIdArrayName() { return "GlobalNodeId"; }
72 
79  vtkSetMacro(GenerateVertexWeightArrays, vtkTypeBool);
80  vtkGetMacro(GenerateVertexWeightArrays, vtkTypeBool);
81  vtkBooleanMacro(GenerateVertexWeightArrays, vtkTypeBool);
82 
88  vtkGetMacro(NumberOfVertexWeights, int);
89 
98  const char* GetVertexWeightArrayName(int weight);
99 
109  vtkSetMacro(GenerateEdgeWeightArrays, vtkTypeBool);
110  vtkGetMacro(GenerateEdgeWeightArrays, vtkTypeBool);
111  vtkBooleanMacro(GenerateEdgeWeightArrays, vtkTypeBool);
112 
118  vtkGetMacro(NumberOfEdgeWeights, int);
119 
128  const char* GetEdgeWeightArrayName(int weight);
129 
131 
134  vtkGetMacro(Dimensionality, int);
135  vtkGetMacro(NumberOfEdges, vtkIdType);
136  vtkGetMacro(NumberOfVertices, vtkIdType);
138 
145  vtkGetMacro(NumberOfCellWeightArrays, int);
146 
153  vtkGetMacro(NumberOfPointWeightArrays, int);
154 
155 protected:
156  vtkChacoReader();
157  ~vtkChacoReader() override;
158 
159  int BuildOutputGrid(vtkUnstructuredGrid* gr);
160 
161  // methods for parsing Chaco files
162 
163  void CloseCurrentFile();
164  int OpenCurrentFile();
165 
166  int InputGeom(vtkIdType nvtxs, int igeom, double* x, double* y, double* z);
167  int InputGraph1();
168  int InputGraph2(vtkIdType** start, vtkIdType** adjacency, double** vweights, double** eweights);
169  int GetCoordsMetadata();
170  void GetGraphMetadata();
171 
172  // methods for creating vtkUnstructuredGrid from Chaco file data
173 
174  int ReadFile(vtkUnstructuredGrid* output);
175  void AddElementIds(vtkUnstructuredGrid* output);
176  void AddNodeIds(vtkUnstructuredGrid* output);
177 
178  void MakeWeightArrayNames(int nv, int ne);
179 
180  // Parameters for controlling what is read in.
181  char* BaseName;
184 
187 
191  vtkSetStringMacro(CurrentBaseName);
192 
193  std::vector<std::string> VarrayName;
194  std::vector<std::string> EarrayName;
195 
196  //----------------------------------------------------------------------
197  // The following metadata is read during RequestInformation. If you
198  // add new metadata, you must modify vtkPChacoReader::RequestInformation
199  // to include it when process 0 broadcasts the metadata.
200 
204  int NumberOfVertexWeights; // in file
205  int NumberOfEdgeWeights; // in file
207 
208  //----------------------------------------------------------------------
209 
210  int NumberOfPointWeightArrays; // in output unstructured grid
211  int NumberOfCellWeightArrays; // in output unstructured grid
212 
213  // Keep the points and cells
214  // around so they don't need to be re-read when the
215  // options change.
217 
218  // Should I re-read in the geometry and topology of the dataset
220 
223 
224 private:
225  vtkChacoReader(const vtkChacoReader&) = delete;
226  void operator=(const vtkChacoReader&) = delete;
227 
228  double ReadVal(FILE* infile, int* end_flag);
229  vtkIdType ReadInt(FILE* infile, int* end_flag);
230  void FlushLine(FILE* infile);
231  void ResetInputBuffers();
232 
233  char Line[200];
234  const int Line_length = 200;
235  int Offset;
236  int Break_pnt;
237  int Save_pnt;
238 
239  void ClearWeightArrayNames();
240 };
241 
242 VTK_ABI_NAMESPACE_END
243 #endif
vtkTypeBool GenerateEdgeWeightArrays
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
This is called by the superclass.
std::vector< std::string > VarrayName
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:363
std::vector< std::string > EarrayName
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