VTK  9.5.20250904
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
30VTK_ABI_NAMESPACE_BEGIN
31class VTKIOGEOMETRY_EXPORT vtkChacoReader : public vtkUnstructuredGridAlgorithm
32{
33public:
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
155protected:
157 ~vtkChacoReader() override;
158
160
161 // methods for parsing Chaco files
162
165
166 int InputGeom(vtkIdType nvtxs, int igeom, double* x, double* y, double* z);
168 int InputGraph2(vtkIdType** start, vtkIdType** adjacency, double** vweights, double** eweights);
171
172 // methods for creating vtkUnstructuredGrid from Chaco file data
173
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
224private:
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
242VTK_ABI_NAMESPACE_END
243#endif
Read a Chaco file and create a vtkUnstructuredGrid.
~vtkChacoReader() override
int ReadFile(vtkUnstructuredGrid *output)
const char * GetVertexWeightArrayName(int weight)
This method returns the name of the selected Vertex weight point array.
vtkTypeBool GenerateVertexWeightArrays
const char * GetEdgeWeightArrayName(int weight)
This method returns the name of the selected Edge weight cell array.
static const char * GetGlobalNodeIdArrayName()
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void MakeWeightArrayNames(int nv, int ne)
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.
std::vector< std::string > EarrayName
int InputGeom(vtkIdType nvtxs, int igeom, double *x, double *y, double *z)
int BuildOutputGrid(vtkUnstructuredGrid *gr)
int OpenCurrentFile()
std::vector< std::string > VarrayName
int GetCoordsMetadata()
void AddElementIds(vtkUnstructuredGrid *output)
void CloseCurrentFile()
vtkUnstructuredGrid * DataCache
int InputGraph2(vtkIdType **start, vtkIdType **adjacency, double **vweights, double **eweights)
vtkTypeBool GenerateGlobalNodeIdArray
vtkTypeBool GenerateGlobalElementIdArray
vtkIdType NumberOfVertices
static vtkChacoReader * New()
int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
vtkTypeBool GenerateEdgeWeightArrays
void GetGraphMetadata()
static const char * GetGlobalElementIdArrayName()
vtkIdType NumberOfEdges
void AddNodeIds(vtkUnstructuredGrid *output)
a simple class to control print indentation
Definition vtkIndent.h:108
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
Superclass for algorithms that produce only unstructured grid as output.
dataset represents arbitrary combinations of all possible cell types
int vtkTypeBool
Definition vtkABI.h:64
int vtkIdType
Definition vtkType.h:332