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 
36 #ifndef vtkChacoReader_h
37 #define vtkChacoReader_h
38 
39 #include "vtkIOGeometryModule.h" // For export macro
41 
42 class VTKIOGEOMETRY_EXPORT vtkChacoReader : public vtkUnstructuredGridAlgorithm
43 {
44 public:
45  static vtkChacoReader *New();
47  void PrintSelf(ostream& os, vtkIndent indent) override;
48 
54  vtkSetStringMacro(BaseName);
55  vtkGetStringMacro(BaseName);
56 
64  vtkSetMacro(GenerateGlobalElementIdArray, vtkTypeBool);
65  vtkGetMacro(GenerateGlobalElementIdArray, vtkTypeBool);
66  vtkBooleanMacro(GenerateGlobalElementIdArray, vtkTypeBool);
67 
68  static const char *GetGlobalElementIdArrayName() { return "GlobalElementId"; }
69 
78  vtkSetMacro(GenerateGlobalNodeIdArray, vtkTypeBool);
79  vtkGetMacro(GenerateGlobalNodeIdArray, vtkTypeBool);
80  vtkBooleanMacro(GenerateGlobalNodeIdArray, vtkTypeBool);
81 
82  static const char *GetGlobalNodeIdArrayName() { return "GlobalNodeId"; }
83 
90  vtkSetMacro(GenerateVertexWeightArrays, vtkTypeBool);
91  vtkGetMacro(GenerateVertexWeightArrays, vtkTypeBool);
92  vtkBooleanMacro(GenerateVertexWeightArrays, vtkTypeBool);
93 
99  vtkGetMacro(NumberOfVertexWeights, int);
100 
109  const char *GetVertexWeightArrayName(int weight);
110 
120  vtkSetMacro(GenerateEdgeWeightArrays, vtkTypeBool);
121  vtkGetMacro(GenerateEdgeWeightArrays, vtkTypeBool);
122  vtkBooleanMacro(GenerateEdgeWeightArrays, vtkTypeBool);
123 
129  vtkGetMacro(NumberOfEdgeWeights, int);
130 
139  const char *GetEdgeWeightArrayName(int weight);
140 
142 
145  vtkGetMacro(Dimensionality, int);
146  vtkGetMacro(NumberOfEdges, vtkIdType);
147  vtkGetMacro(NumberOfVertices, vtkIdType);
149 
156  vtkGetMacro(NumberOfCellWeightArrays, int);
157 
164  vtkGetMacro(NumberOfPointWeightArrays, int);
165 
166 protected:
167  vtkChacoReader();
168  ~vtkChacoReader() override;
169 
170  int BuildOutputGrid(vtkUnstructuredGrid *gr);
171 
172  // methods for parsing Chaco files
173 
174  void CloseCurrentFile();
175  int OpenCurrentFile();
176 
177  int InputGeom(vtkIdType nvtxs, int igeom, double *x, double *y, double *z);
178  int InputGraph1();
179  int InputGraph2( vtkIdType **start, vtkIdType **adjacency, double **vweights,
180  double **eweights);
181  int GetCoordsMetadata();
182  void GetGraphMetadata();
183 
184  // methods for creating vtkUnstructuredGrid from Chaco file data
185 
186  int ReadFile(vtkUnstructuredGrid* output);
187  void AddElementIds(vtkUnstructuredGrid* output);
188  void AddNodeIds(vtkUnstructuredGrid* output);
189 
190  void MakeWeightArrayNames(int nv, int ne);
191 
192  // Parameters for controlling what is read in.
193  char *BaseName;
196 
199 
203  vtkSetStringMacro(CurrentBaseName);
204 
205  char **VarrayName;
206  char **EarrayName;
207 
208  //----------------------------------------------------------------------
209  // The following metadata is read during RequestInformation. If you
210  // add new metadata, you must modify vtkPChacoReader::RequestInformation
211  // to include it when process 0 broadcasts the metadata.
212 
216  int NumberOfVertexWeights; // in file
217  int NumberOfEdgeWeights; // in file
219 
220  //----------------------------------------------------------------------
221 
222  int NumberOfPointWeightArrays; // in output unstructured grid
223  int NumberOfCellWeightArrays; // in output unstructured grid
224 
225  // Keep the points and cells
226  // around so they don't need to be re-read when the
227  // options change.
229 
230  // Should I re-read in the geometry and topology of the dataset
232 
233  int RequestInformation(
235  int RequestData(
237 
238 private:
239  vtkChacoReader(const vtkChacoReader&) = delete;
240  void operator=(const vtkChacoReader&) = delete;
241 
242  double ReadVal(FILE *infile, int *end_flag);
243  vtkIdType ReadInt(FILE *infile, int *end_flag);
244  void FlushLine( FILE *infile);
245  void ResetInputBuffers();
246 
247  char *Line;
248  int Line_length;
249  int Offset;
250  int Break_pnt;
251  int Save_pnt;
252 
253  void ClearWeightArrayNames();
254 };
255 
256 #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:347
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:39
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