VTK: IO/Geometry/vtkChacoReader.h Source File

| 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
25 #include "vtkUnstructuredGridAlgorithm.h"
26
27 VTK_ABI_NAMESPACE_BEGIN
28 class VTKIOGEOMETRY_EXPORT vtkChacoReader : public vtkUnstructuredGridAlgorithm
29 {
30 public:
31 static vtkChacoReader* New();
32 vtkTypeMacro(vtkChacoReader, vtkUnstructuredGridAlgorithm);
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;
179 vtkTypeBool GenerateGlobalElementIdArray;
180 vtkTypeBool GenerateGlobalNodeIdArray;
181
182 vtkTypeBool GenerateVertexWeightArrays;
183 vtkTypeBool GenerateEdgeWeightArrays;
184
185 FILE* CurrentGeometryFP;
186 FILE* CurrentGraphFP;
187 char* CurrentBaseName;
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
198 int Dimensionality;
199 vtkIdType NumberOfVertices;
200 vtkIdType NumberOfEdges;
201 int NumberOfVertexWeights; // in file
202 int NumberOfEdgeWeights; // in file
203 int GraphFileHasVertexNumbers;
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.
213 vtkUnstructuredGrid* DataCache;
214
215 // Should I re-read in the geometry and topology of the dataset
216 int RemakeDataCacheFlag;
217
218 int RequestInformation(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
219 int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
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
vtkChacoReader
Read a Chaco file and create a vtkUnstructuredGrid.
Definition: vtkChacoReader.h:29
vtkChacoReader::~vtkChacoReader
~vtkChacoReader() override
vtkChacoReader::ReadFile
int ReadFile(vtkUnstructuredGrid *output)
vtkChacoReader::EarrayName
char ** EarrayName
Definition: vtkChacoReader.h:191
vtkChacoReader::VarrayName
char ** VarrayName
Definition: vtkChacoReader.h:188
vtkChacoReader::GenerateVertexWeightArrays
vtkTypeBool GenerateVertexWeightArrays
Definition: vtkChacoReader.h:182
vtkChacoReader::NumberOfCellWeightArrays
int NumberOfCellWeightArrays
Definition: vtkChacoReader.h:208
vtkChacoReader::Dimensionality
int Dimensionality
Definition: vtkChacoReader.h:198
vtkChacoReader::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkChacoReader::MakeWeightArrayNames
void MakeWeightArrayNames(int nv, int ne)
vtkChacoReader::RequestData
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.
vtkChacoReader::InputGeom
int InputGeom(vtkIdType nvtxs, int igeom, double *x, double *y, double *z)
vtkChacoReader::BuildOutputGrid
int BuildOutputGrid(vtkUnstructuredGrid *gr)
vtkChacoReader::GetVertexWeightArrayName
const char * GetVertexWeightArrayName(int weight)
This method returns the name of the selected Vertex weight point array.
vtkChacoReader::OpenCurrentFile
int OpenCurrentFile()
vtkChacoReader::RemakeDataCacheFlag
int RemakeDataCacheFlag
Definition: vtkChacoReader.h:216
vtkChacoReader::NumberOfPointWeightArrays
int NumberOfPointWeightArrays
Definition: vtkChacoReader.h:207
vtkChacoReader::GetEdgeWeightArrayName
const char * GetEdgeWeightArrayName(int weight)
This method returns the name of the selected Edge weight cell array.
vtkChacoReader::GetCoordsMetadata
int GetCoordsMetadata()
vtkChacoReader::AddElementIds
void AddElementIds(vtkUnstructuredGrid *output)
vtkChacoReader::CloseCurrentFile
void CloseCurrentFile()
vtkChacoReader::GraphFileHasVertexNumbers
int GraphFileHasVertexNumbers
Definition: vtkChacoReader.h:203
vtkChacoReader::DataCache
vtkUnstructuredGrid * DataCache
Definition: vtkChacoReader.h:213
vtkChacoReader::GetGlobalNodeIdArrayName
static const char * GetGlobalNodeIdArrayName()
Definition: vtkChacoReader.h:68
vtkChacoReader::vtkChacoReader
vtkChacoReader()
vtkChacoReader::InputGraph2
int InputGraph2(vtkIdType **start, vtkIdType **adjacency, double **vweights, double **eweights)
vtkChacoReader::GenerateGlobalNodeIdArray
vtkTypeBool GenerateGlobalNodeIdArray
Definition: vtkChacoReader.h:180
vtkChacoReader::New
static vtkChacoReader * New()
vtkChacoReader::GenerateGlobalElementIdArray
vtkTypeBool GenerateGlobalElementIdArray
Definition: vtkChacoReader.h:179
vtkChacoReader::NumberOfVertices
vtkIdType NumberOfVertices
Definition: vtkChacoReader.h:199
vtkChacoReader::NumberOfEdgeWeights
int NumberOfEdgeWeights
Definition: vtkChacoReader.h:202
vtkChacoReader::GetGlobalElementIdArrayName
static const char * GetGlobalElementIdArrayName()
Definition: vtkChacoReader.h:54
vtkChacoReader::RequestInformation
int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
vtkChacoReader::GenerateEdgeWeightArrays
vtkTypeBool GenerateEdgeWeightArrays
Definition: vtkChacoReader.h:183
vtkChacoReader::GetGraphMetadata
void GetGraphMetadata()
vtkChacoReader::CurrentBaseName
char * CurrentBaseName
Definition: vtkChacoReader.h:187
vtkChacoReader::InputGraph1
int InputGraph1()
vtkChacoReader::NumberOfVertexWeights
int NumberOfVertexWeights
Definition: vtkChacoReader.h:201
vtkChacoReader::CurrentGeometryFP
FILE * CurrentGeometryFP
Definition: vtkChacoReader.h:185
vtkChacoReader::CurrentGraphFP
FILE * CurrentGraphFP
Definition: vtkChacoReader.h:186
vtkChacoReader::NumberOfEdges
vtkIdType NumberOfEdges
Definition: vtkChacoReader.h:200
vtkChacoReader::BaseName
char * BaseName
Definition: vtkChacoReader.h:178
vtkChacoReader::AddNodeIds
void AddNodeIds(vtkUnstructuredGrid *output)
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:40
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:72
vtkUnstructuredGridAlgorithm
Superclass for algorithms that produce only unstructured grid as output.
Definition: vtkUnstructuredGridAlgorithm.h:30
vtkUnstructuredGrid
dataset represents arbitrary combinations of all possible cell types
Definition: vtkUnstructuredGrid.h:99
vtkX3D::weight
@ weight
Definition: vtkX3D.h:532
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:64
vtkIdType
int vtkIdType
Definition: vtkType.h:315
vtkUnstructuredGridAlgorithm.h