VTK
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,
177  double **eweights);
178  int GetCoordsMetadata();
179  void GetGraphMetadata();
180 
181  // methods for creating vtkUnstructuredGrid from Chaco file data
182 
183  int ReadFile(vtkUnstructuredGrid* output);
184  void AddElementIds(vtkUnstructuredGrid* output);
185  void AddNodeIds(vtkUnstructuredGrid* output);
186 
187  void MakeWeightArrayNames(int nv, int ne);
188 
189  // Parameters for controlling what is read in.
190  char *BaseName;
193 
196 
200  vtkSetStringMacro(CurrentBaseName);
201 
202  char **VarrayName;
203  char **EarrayName;
204 
205  //----------------------------------------------------------------------
206  // The following metadata is read during RequestInformation. If you
207  // add new metadata, you must modify vtkPChacoReader::RequestInformation
208  // to include it when process 0 broadcasts the metadata.
209 
213  int NumberOfVertexWeights; // in file
214  int NumberOfEdgeWeights; // in file
216 
217  //----------------------------------------------------------------------
218 
219  int NumberOfPointWeightArrays; // in output unstuctured grid
220  int NumberOfCellWeightArrays; // in output unstuctured grid
221 
222  // Keep the points and cells
223  // around so they don't need to be re-read when the
224  // options change.
226 
227  // Should I re-read in the geometry and topology of the dataset
229 
230  int RequestInformation(
232  int RequestData(
234 
235 private:
236  vtkChacoReader(const vtkChacoReader&) = delete;
237  void operator=(const vtkChacoReader&) = delete;
238 
239  double ReadVal(FILE *infile, int *end_flag);
240  vtkIdType ReadInt(FILE *infile, int *end_flag);
241  void FlushLine( FILE *infile);
242  void ResetInputBuffers();
243 
244  char *Line;
245  int Line_length;
246  int Offset;
247  int Break_pnt;
248  int Save_pnt;
249 
250  void ClearWeightArrayNames();
251 };
252 
253 #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:345
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