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 
35 #ifndef __vtkChacoReader_h
36 #define __vtkChacoReader_h
37 
39 
41 {
42 public:
43  static vtkChacoReader *New();
45  void PrintSelf(ostream& os, vtkIndent indent);
46 
50  vtkSetStringMacro(BaseName);
51  vtkGetStringMacro(BaseName);
52 
58  vtkSetMacro(GenerateGlobalElementIdArray, int);
59  vtkGetMacro(GenerateGlobalElementIdArray, int);
60  vtkBooleanMacro(GenerateGlobalElementIdArray, int);
61 
62  static const char *GetGlobalElementIdArrayName() { return "GlobalElementId"; }
63 
70  vtkSetMacro(GenerateGlobalNodeIdArray, int);
71  vtkGetMacro(GenerateGlobalNodeIdArray, int);
72  vtkBooleanMacro(GenerateGlobalNodeIdArray, int);
73 
74  static const char *GetGlobalNodeIdArrayName() { return "GlobalNodeId"; }
75 
79  vtkSetMacro(GenerateVertexWeightArrays, int);
80  vtkGetMacro(GenerateVertexWeightArrays, int);
81  vtkBooleanMacro(GenerateVertexWeightArrays, int);
82 
86  vtkGetMacro(NumberOfVertexWeights, int);
87 
94  const char *GetVertexWeightArrayName(int weight);
95 
102  vtkSetMacro(GenerateEdgeWeightArrays, int);
103  vtkGetMacro(GenerateEdgeWeightArrays, int);
104  vtkBooleanMacro(GenerateEdgeWeightArrays, int);
105 
109  vtkGetMacro(NumberOfEdgeWeights, int);
110 
117  const char *GetEdgeWeightArrayName(int weight);
118 
120 
121  vtkGetMacro(Dimensionality, int);
122  vtkGetMacro(NumberOfEdges, vtkIdType);
123  vtkGetMacro(NumberOfVertices, vtkIdType);
125 
130  vtkGetMacro(NumberOfCellWeightArrays, int);
131 
136  vtkGetMacro(NumberOfPointWeightArrays, int);
137 
138 protected:
139  vtkChacoReader();
140  ~vtkChacoReader();
141 
142  int BuildOutputGrid(vtkUnstructuredGrid *gr);
143 
144  // methods for parsing Chaco files
145 
146  void CloseCurrentFile();
147  int OpenCurrentFile();
148 
149  int InputGeom(vtkIdType nvtxs, int igeom, double *x, double *y, double *z);
150  int InputGraph1();
151  int InputGraph2( vtkIdType **start, vtkIdType **adjacency, double **vweights,
152  double **eweights);
153  int GetCoordsMetadata();
154  void GetGraphMetadata();
155 
156  // methods for creating vtkUnstructuredGrid from Chaco file data
157 
158  int ReadFile(vtkUnstructuredGrid* output);
159  void AddElementIds(vtkUnstructuredGrid* output);
160  void AddNodeIds(vtkUnstructuredGrid* output);
161 
162  void MakeWeightArrayNames(int nv, int ne);
163 
164  // Parameters for controlling what is read in.
165  char *BaseName;
168 
171 
175  vtkSetStringMacro(CurrentBaseName);
176 
177  char **VarrayName;
178  char **EarrayName;
179 
180  //----------------------------------------------------------------------
181  // The following metadata is read during RequestInformation. If you
182  // add new metadata, you must modify vtkPChacoReader::RequestInformation
183  // to include it when process 0 broadcasts the metadata.
184 
188  int NumberOfVertexWeights; // in file
189  int NumberOfEdgeWeights; // in file
191 
192  //----------------------------------------------------------------------
193 
194  int NumberOfPointWeightArrays; // in output unstuctured grid
195  int NumberOfCellWeightArrays; // in output unstuctured grid
196 
197  // Keep the points and cells
198  // around so they don't need to be re-read when the
199  // options change.
201 
202  // Should I re-read in the geometry and topology of the dataset
204 
205  int RequestInformation(
207  int RequestData(
209 
210 private:
211  vtkChacoReader(const vtkChacoReader&); // Not implemented
212  void operator=(const vtkChacoReader&); // Not implemented
213 
214  double ReadVal(FILE *infile, int *end_flag);
215  vtkIdType ReadInt(FILE *infile, int *end_flag);
216  void FlushLine( FILE *infile);
217  void ResetInputBuffers();
218 
219  char *Line;
220  int Line_length;
221  int Offset;
222  int Break_pnt;
223  int Save_pnt;
224 
225  void ClearWeightArrayNames();
226 };
227 
228 #endif
int GenerateGlobalNodeIdArray
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
int GraphFileHasVertexNumbers
Store vtkAlgorithm input/output information.
char * CurrentBaseName
static vtkUnstructuredGridAlgorithm * New()
virtual int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
int vtkIdType
Definition: vtkType.h:255
int GenerateEdgeWeightArrays
a simple class to control print indentation
Definition: vtkIndent.h:37
dataset represents arbitrary combinations of all possible cell types
void PrintSelf(ostream &os, vtkIndent indent)
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
int GenerateVertexWeightArrays
static const char * GetGlobalNodeIdArrayName()
Store zero or more vtkInformation instances.
#define VTK_IO_EXPORT
static const char * GetGlobalElementIdArrayName()
vtkIdType NumberOfEdges
int GenerateGlobalElementIdArray
vtkUnstructuredGrid * DataCache