VTK
vtkFieldDataToAttributeDataFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkFieldDataToAttributeDataFilter.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 =========================================================================*/
57 #ifndef __vtkFieldDataToAttributeDataFilter_h
58 #define __vtkFieldDataToAttributeDataFilter_h
59 
60 #include "vtkDataSetAlgorithm.h"
61 
62 #define VTK_DATA_OBJECT_FIELD 0
63 #define VTK_POINT_DATA_FIELD 1
64 #define VTK_CELL_DATA_FIELD 2
65 
66 #define VTK_CELL_DATA 0
67 #define VTK_POINT_DATA 1
68 
69 class vtkDataArray;
71 class vtkFieldData;
72 
74 {
75 public:
76  void PrintSelf(ostream& os, vtkIndent indent);
78 
82 
84 
88  vtkSetMacro(InputField,int);
89  vtkGetMacro(InputField,int);
90  void SetInputFieldToDataObjectField()
91  {this->SetInputField(VTK_DATA_OBJECT_FIELD);};
92  void SetInputFieldToPointDataField()
93  {this->SetInputField(VTK_POINT_DATA_FIELD);};
94  void SetInputFieldToCellDataField()
95  {this->SetInputField(VTK_CELL_DATA_FIELD);};
97 
99 
101  vtkSetMacro(OutputAttributeData,int);
102  vtkGetMacro(OutputAttributeData,int);
103  void SetOutputAttributeDataToCellData()
104  {this->SetOutputAttributeData(VTK_CELL_DATA);};
105  void SetOutputAttributeDataToPointData()
106  {this->SetOutputAttributeData(VTK_POINT_DATA);};
108 
110 
115  void SetScalarComponent(int comp, const char *arrayName, int arrayComp,
116  int min, int max, int normalize);
117  void SetScalarComponent(int comp, const char *arrayName, int arrayComp)
118  {this->SetScalarComponent(comp, arrayName, arrayComp, -1, -1, this->DefaultNormalize);};
119  const char *GetScalarComponentArrayName(int comp);
120  int GetScalarComponentArrayComponent(int comp);
121  int GetScalarComponentMinRange(int comp);
122  int GetScalarComponentMaxRange(int comp);
123  int GetScalarComponentNormalizeFlag(int comp);
125 
127 
132  void SetVectorComponent(int comp, const char *arrayName, int arrayComp,
133  int min, int max, int normalize);
134  void SetVectorComponent(int comp, const char *arrayName, int arrayComp)
135  {this->SetVectorComponent(comp, arrayName, arrayComp, -1, -1, this->DefaultNormalize);};
136  const char *GetVectorComponentArrayName(int comp);
137  int GetVectorComponentArrayComponent(int comp);
138  int GetVectorComponentMinRange(int comp);
139  int GetVectorComponentMaxRange(int comp);
140  int GetVectorComponentNormalizeFlag(int comp);
142 
144 
149  void SetNormalComponent(int comp, const char *arrayName, int arrayComp,
150  int min, int max, int normalize);
151  void SetNormalComponent(int comp, const char *arrayName, int arrayComp)
152  {this->SetNormalComponent(comp, arrayName, arrayComp, -1, -1, this->DefaultNormalize);};
153  const char *GetNormalComponentArrayName(int comp);
154  int GetNormalComponentArrayComponent(int comp);
155  int GetNormalComponentMinRange(int comp);
156  int GetNormalComponentMaxRange(int comp);
157  int GetNormalComponentNormalizeFlag(int comp);
159 
161 
166  void SetTensorComponent(int comp, const char *arrayName, int arrayComp,
167  int min, int max, int normalize);
168  void SetTensorComponent(int comp, const char *arrayName, int arrayComp)
169  {this->SetTensorComponent(comp, arrayName, arrayComp, -1, -1, this->DefaultNormalize);};
170  const char *GetTensorComponentArrayName(int comp);
171  int GetTensorComponentArrayComponent(int comp);
172  int GetTensorComponentMinRange(int comp);
173  int GetTensorComponentMaxRange(int comp);
174  int GetTensorComponentNormalizeFlag(int comp);
176 
178 
183  void SetTCoordComponent(int comp, const char *arrayName, int arrayComp,
184  int min, int max, int normalize);
185  void SetTCoordComponent(int comp, const char *arrayName, int arrayComp)
186  {this->SetTCoordComponent(comp, arrayName, arrayComp, -1, -1, this->DefaultNormalize);};
187  const char *GetTCoordComponentArrayName(int comp);
188  int GetTCoordComponentArrayComponent(int comp);
189  int GetTCoordComponentMinRange(int comp);
190  int GetTCoordComponentMaxRange(int comp);
191  int GetTCoordComponentNormalizeFlag(int comp);
193 
195 
197  vtkSetMacro(DefaultNormalize,int);
198  vtkGetMacro(DefaultNormalize,int);
199  vtkBooleanMacro(DefaultNormalize,int);
201 
202  // Helper functions, made public to support other classes
203 
207  static int GetComponentsType(int numComp, vtkDataArray **arrays);
208 
210 
214  static int ConstructArray(vtkDataArray *da, int comp, vtkDataArray *frray,
215  int fieldComp, vtkIdType min, vtkIdType max,
216  int normalize);
218 
221  static vtkDataArray *GetFieldArray(vtkFieldData *fd, char *name, int comp);
222 
224  static void SetArrayName(vtkObject *self, char* &name, const char *newName);
225 
226 //BTX
228 
230  static int UpdateComponentRange(vtkDataArray *da, vtkIdType compRange[2]);
231 //ETX
233 
236 
237 protected:
240 
241  virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *); //generate output data
242 
245 
246  int NumberOfScalarComponents; //the number of components to fill-in
247  char *ScalarArrays[4]; //the name of the arrays used to construct the scalar
248  int ScalarArrayComponents[4]; //the components of the arrays used to construct
249  vtkIdType ScalarComponentRange[4][2]; //the range of the components to use
250  int ScalarNormalize[4]; //flags control normalization
251 
252  char *VectorArrays[3]; //the name of the arrays used to construct the vectors
253  int VectorArrayComponents[3]; //the components of the arrays used to construct
254  vtkIdType VectorComponentRange[3][2]; //the range of the components to use
255  int VectorNormalize[3]; //flags control normalization
256 
257  char *GhostLevelArray; //the name of the array used to construct the ghost levels
258  int GhostLevelArrayComponent; //the component of the array used to construct
259  vtkIdType GhostLevelComponentRange[2]; //the range of the components to use
260  int GhostLevelNormalize; //flags control normalization
261 
262  char *NormalArrays[3]; //the name of the arrays used to construct the normals
263  int NormalArrayComponents[3]; //the components of the arrays used to construct
264  vtkIdType NormalComponentRange[3][2]; //the range of the components to use
265  int NormalNormalize[3]; //flags control normalization
266 
267  char *TensorArrays[9]; //the name of the arrays used to construct the tensors
268  int TensorArrayComponents[9]; //the components of the arrays used to construct
269  vtkIdType TensorComponentRange[9][2]; //the range of the components to use
270  int TensorNormalize[9]; //flags control normalization
271 
272  int NumberOfTCoordComponents; //the number of components to fill-in
273  char *TCoordArrays[3]; //the name of the arrays used to construct the tcoords
274  int TCoordArrayComponents[3]; //the components of the arrays used to construct
275  vtkIdType TCoordComponentRange[3][2]; //the range of the components to use
276  int TCoordNormalize[3]; //flags control normalization
277 
279 
280  void ConstructScalars(int num, vtkFieldData *fd, vtkDataSetAttributes *attr,
281  vtkIdType componentRange[4][2], char *arrays[4],
282  int arrayComponents[4], int normalize[4], int numComp);
283  void ConstructVectors(int num, vtkFieldData *fd, vtkDataSetAttributes *attr,
284  vtkIdType componentRange[3][2], char *arrays[3],
285  int arrayComponents[3], int normalize[3]);
286  void ConstructGhostLevels(int num, vtkFieldData *fd,
287  vtkDataSetAttributes *attr,
288  vtkIdType componentRange[2],
289  char *array, int arrayComponent, int normalize);
290  void ConstructNormals(int num, vtkFieldData *fd, vtkDataSetAttributes *attr,
291  vtkIdType componentRange[3][2], char *arrays[3],
292  int arrayComponents[3], int normalize[3]);
293  void ConstructTCoords(int num, vtkFieldData *fd, vtkDataSetAttributes *attr,
294  vtkIdType componentRange[3][2], char *arrays[3],
295  int arrayComponents[3], int normalize[3], int numComp);
296  void ConstructTensors(int num, vtkFieldData *fd, vtkDataSetAttributes *attr,
297  vtkIdType componentRange[9][2], char *arrays[9],
298  int arrayComponents[9], int normalize[9]);
299  void ConstructFieldData(int num, vtkDataSetAttributes *attr);
300 
301 private:
303  void operator=(const vtkFieldDataToAttributeDataFilter&); // Not implemented.
304 };
305 
306 #endif
307 
308