VTK
vtkFieldData.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkFieldData.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 =========================================================================*/
45 #ifndef vtkFieldData_h
46 #define vtkFieldData_h
47 
48 #include "vtkCommonDataModelModule.h" // For export macro
49 #include "vtkObject.h"
50 
51 #include "vtkAbstractArray.h" // Needed for inline methods.
52 
53 class vtkIdList;
54 
56 {
57 public:
58  static vtkFieldData *New();
59 
60  vtkTypeMacro(vtkFieldData,vtkObject);
61  void PrintSelf(ostream& os, vtkIndent indent);
62 
65  virtual void Initialize();
66 
68  int Allocate(const vtkIdType sz, const vtkIdType ext=1000);
69 
72  void CopyStructure(vtkFieldData*);
73 
80  void AllocateArrays(int num);
81 
83 
87  {
88  return this->NumberOfActiveArrays;
89  }
91 
95  int AddArray(vtkAbstractArray *array);
96 
98 
99  virtual void RemoveArray(const char *name)
100  {
101  int i;
102  this->GetAbstractArray(name, i);
103  this->RemoveArray(i);
104  }
106 
110  vtkDataArray *GetArray(int i);
111 
116  vtkDataArray *GetArray(const char *arrayName, int &index);
117 
119 
122  vtkDataArray *GetArray(const char *arrayName)
123  {
124  int i;
125  return this->GetArray(arrayName, i);
126  }
128 
132  vtkAbstractArray* GetAbstractArray(int i);
133 
137  vtkAbstractArray* GetAbstractArray(const char* arrayName, int &index);
138 
140 
142  vtkAbstractArray* GetAbstractArray(const char* arrayName)
143  {
144  int i;
145  return this->GetAbstractArray(arrayName, i);
146  }
148 
150 
151  int HasArray(const char *name)
152  {
153  int i;
154  vtkAbstractArray *array = this->GetAbstractArray(name, i);
155  // assert( i == -1);
156  return array ? 1 : 0;
157  }
159 
161 
163  const char* GetArrayName(int i)
164  {
165  vtkAbstractArray* da = this->GetAbstractArray(i);
166  return da ? da->GetName() : 0;
167  }
169 
172  virtual void PassData(vtkFieldData* fd);
173 
175 
180  void CopyFieldOn(const char* name) { this->CopyFieldOnOff(name, 1); }
181  void CopyFieldOff(const char* name) { this->CopyFieldOnOff(name, 0); }
183 
189  virtual void CopyAllOn(int unused=0);
190 
196  virtual void CopyAllOff(int unused=0);
197 
199  virtual void DeepCopy(vtkFieldData *da);
200 
202  virtual void ShallowCopy(vtkFieldData *da);
203 
206  void Squeeze();
207 
210  void Reset();
211 
216  virtual unsigned long GetActualMemorySize();
217 
219  unsigned long int GetMTime();
220 
228  void GetField(vtkIdList *ptId, vtkFieldData *f);
229 
235  int GetArrayContainingComponent(int i, int& arrayComp);
236 
243  int GetNumberOfComponents();
244 
252  vtkIdType GetNumberOfTuples();
253 
259  void SetNumberOfTuples(const vtkIdType number);
260 
264  void SetTuple(const vtkIdType i, const vtkIdType j, vtkFieldData* source);
265 
268  void InsertTuple(const vtkIdType i, const vtkIdType j, vtkFieldData* source);
269 
273  vtkIdType InsertNextTuple(const vtkIdType j, vtkFieldData* source);
274 
275 protected:
276 
277  vtkFieldData();
278  ~vtkFieldData();
279 
283 
285  void SetArray(int i, vtkAbstractArray *array);
286 
287  virtual void RemoveArray(int index);
288 
290  virtual void InitializeFields();
291 
292 //BTX
293 
295  {
296  char* ArrayName;
297  int IsCopied;
298  };
299 
300  CopyFieldFlag* CopyFieldFlags; //the names of fields not to be copied
301  int NumberOfFieldFlags; //the number of fields not to be copied
302  void CopyFieldOnOff(const char* name, int onOff);
303  void ClearFieldFlags();
304  int FindFlag(const char* field);
305  int GetFlag(const char* field);
306  void CopyFlags(const vtkFieldData* source);
309 
310 
311 private:
312  vtkFieldData(const vtkFieldData&); // Not implemented.
313  void operator=(const vtkFieldData&); // Not implemented.
314 
315 public:
316 
318  {
319  public:
320  BasicIterator();
322  BasicIterator(const int* list, unsigned int listSize);
323  BasicIterator& operator=(const BasicIterator& source);
324  virtual ~BasicIterator();
325  void PrintSelf(ostream &os, vtkIndent indent);
326 
327  int GetListSize() const
328  {
329  return this->ListSize;
330  }
332  {
333  return this->List[this->Position];
334  }
336  {
337  this->Position = -1;
338  return this->NextIndex();
339  }
340  int End() const
341  {
342  return (this->Position >= this->ListSize);
343  }
344  int NextIndex()
345  {
346  this->Position++;
347  return (this->End() ? -1 : this->List[this->Position]);
348  }
349 
350  protected:
351 
352  int* List;
353  int ListSize;
354  int Position;
355  };
356 
358  {
359  public:
360 
361  Iterator(const Iterator& source);
362  Iterator& operator=(const Iterator& source);
363  virtual ~Iterator();
364  Iterator(vtkFieldData* dsa, const int* list=0,
365  unsigned int listSize=0);
366 
368  {
369  this->Position = -1;
370  return this->Next();
371  }
372 
374  {
375  this->Position++;
376  if (this->End())
377  {
378  return 0;
379  }
380 
381  // vtkFieldData::GetArray() can return null, which implies that
382  // a the array at the given index in not a vtkDataArray subclass.
383  // This iterator skips such arrays.
384  vtkDataArray* cur = Fields->GetArray(this->List[this->Position]);
385  return (cur? cur : this->Next());
386  }
387 
388  void DetachFieldData();
389 
390  protected:
392  int Detached;
393  };
394 
395 
396 //ETX
397 
398 };
399 
400 
401 #endif
vtkFieldData * Fields
Definition: vtkFieldData.h:391
vtkDataArray * GetArray(const char *arrayName)
Definition: vtkFieldData.h:122
abstract base class for most VTK objects
Definition: vtkObject.h:61
Abstract superclass for all arrays.
CopyFieldFlag * CopyFieldFlags
Definition: vtkFieldData.h:300
void DeepCopy(vtkPistonReference *self, vtkPistonReference *other)
int vtkIdType
Definition: vtkType.h:275
void CopyFieldOn(const char *name)
Definition: vtkFieldData.h:180
BasicIterator & operator=(const BasicIterator &source)
virtual void PrintSelf(ostream &os, vtkIndent indent)
virtual unsigned long GetMTime()
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkAbstractArray * GetAbstractArray(const char *arrayName)
Definition: vtkFieldData.h:142
list of point or cell ids
Definition: vtkIdList.h:35
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
virtual char * GetName()
int NumberOfFieldFlags
Definition: vtkFieldData.h:301
const char * GetArrayName(int i)
Definition: vtkFieldData.h:163
int HasArray(const char *name)
Definition: vtkFieldData.h:151
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
int NumberOfActiveArrays
Definition: vtkFieldData.h:281
void CopyFieldOff(const char *name)
Definition: vtkFieldData.h:181
vtkAbstractArray ** Data
Definition: vtkFieldData.h:282
vtkDataArray * Begin()
Definition: vtkFieldData.h:367
int GetNumberOfArrays()
Definition: vtkFieldData.h:86
static vtkObject * New()
virtual void RemoveArray(const char *name)
Definition: vtkFieldData.h:99
#define VTKCOMMONDATAMODEL_EXPORT
vtkDataArray * Next()
Definition: vtkFieldData.h:373
represent and manipulate fields of data
Definition: vtkFieldData.h:55