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 =========================================================================*/
46 #ifndef vtkFieldData_h
47 #define vtkFieldData_h
48 
49 #include "vtkCommonDataModelModule.h" // For export macro
50 #include "vtkObject.h"
51 
52 #include "vtkAbstractArray.h" // Needed for inline methods.
53 
54 class vtkIdList;
55 
56 class VTKCOMMONDATAMODEL_EXPORT vtkFieldData : public vtkObject
57 {
58 public:
59  static vtkFieldData *New();
60 
61  vtkTypeMacro(vtkFieldData,vtkObject);
62  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
63 
68  virtual void Initialize();
69 
74  int Allocate(const vtkIdType sz, const vtkIdType ext=1000);
75 
81  void CopyStructure(vtkFieldData*);
82 
92  void AllocateArrays(int num);
93 
101  {
102  return this->NumberOfActiveArrays;
103  }
104 
110  int AddArray(vtkAbstractArray *array);
111 
113 
116  virtual void RemoveArray(const char *name);
117  virtual void RemoveArray(int index);
119 
125  vtkDataArray *GetArray(int i);
126 
132  vtkDataArray *GetArray(const char *arrayName, int &index);
133 
135 
140  vtkDataArray *GetArray(const char *arrayName)
141  {
142  int i;
143  return this->GetArray(arrayName, i);
144  }
146 
152  vtkAbstractArray* GetAbstractArray(int i);
153 
159  vtkAbstractArray* GetAbstractArray(const char* arrayName, int &index);
160 
162 
166  vtkAbstractArray* GetAbstractArray(const char* arrayName)
167  {
168  int i;
169  return this->GetAbstractArray(arrayName, i);
170  }
172 
174 
177  int HasArray(const char *name)
178  {
179  int i;
180  vtkAbstractArray *array = this->GetAbstractArray(name, i);
181  // assert( i == -1);
182  return array ? 1 : 0;
183  }
185 
187 
192  const char* GetArrayName(int i)
193  {
194  vtkAbstractArray* da = this->GetAbstractArray(i);
195  return da ? da->GetName() : 0;
196  }
198 
203  virtual void PassData(vtkFieldData* fd);
204 
214  void CopyFieldOn(const char* name) { this->CopyFieldOnOff(name, 1); }
215  void CopyFieldOff(const char* name) { this->CopyFieldOnOff(name, 0); }
216 
226  virtual void CopyAllOn(int unused=0);
227 
237  virtual void CopyAllOff(int unused=0);
238 
242  virtual void DeepCopy(vtkFieldData *da);
243 
247  virtual void ShallowCopy(vtkFieldData *da);
248 
252  void Squeeze();
253 
258  void Reset();
259 
266  virtual unsigned long GetActualMemorySize();
267 
271  vtkMTimeType GetMTime() VTK_OVERRIDE;
272 
282  void GetField(vtkIdList *ptId, vtkFieldData *f);
283 
291  int GetArrayContainingComponent(int i, int& arrayComp);
292 
302  int GetNumberOfComponents();
303 
314  vtkIdType GetNumberOfTuples();
315 
324  void SetNumberOfTuples(const vtkIdType number);
325 
331  void SetTuple(const vtkIdType i, const vtkIdType j, vtkFieldData* source);
332 
337  void InsertTuple(const vtkIdType i, const vtkIdType j, vtkFieldData* source);
338 
344  vtkIdType InsertNextTuple(const vtkIdType j, vtkFieldData* source);
345 
346 protected:
347 
348  vtkFieldData();
349  ~vtkFieldData() VTK_OVERRIDE;
350 
351  int NumberOfArrays;
352  int NumberOfActiveArrays;
354 
358  void SetArray(int i, vtkAbstractArray *array);
359 
363  virtual void InitializeFields();
364 
366  {
367  char* ArrayName;
368  int IsCopied;
369  };
370 
371  CopyFieldFlag* CopyFieldFlags; //the names of fields not to be copied
372  int NumberOfFieldFlags; //the number of fields not to be copied
373  void CopyFieldOnOff(const char* name, int onOff);
374  void ClearFieldFlags();
375  int FindFlag(const char* field);
376  int GetFlag(const char* field);
377  void CopyFlags(const vtkFieldData* source);
380 
381 
382 private:
383  vtkFieldData(const vtkFieldData&) VTK_DELETE_FUNCTION;
384  void operator=(const vtkFieldData&) VTK_DELETE_FUNCTION;
385 
386 public:
387 
388  class VTKCOMMONDATAMODEL_EXPORT BasicIterator
389  {
390  public:
391  BasicIterator();
392  BasicIterator(const BasicIterator& source);
393  BasicIterator(const int* list, unsigned int listSize);
394  BasicIterator& operator=(const BasicIterator& source);
395  virtual ~BasicIterator();
396  void PrintSelf(ostream &os, vtkIndent indent);
397 
398  int GetListSize() const
399  {
400  return this->ListSize;
401  }
403  {
404  return this->List[this->Position];
405  }
407  {
408  this->Position = -1;
409  return this->NextIndex();
410  }
411  int End() const
412  {
413  return (this->Position >= this->ListSize);
414  }
415  int NextIndex()
416  {
417  this->Position++;
418  return (this->End() ? -1 : this->List[this->Position]);
419  }
420 
421  protected:
422 
423  int* List;
424  int ListSize;
425  int Position;
426  };
427 
428  class VTKCOMMONDATAMODEL_EXPORT Iterator : public BasicIterator
429  {
430  public:
431 
432  Iterator(const Iterator& source);
433  Iterator& operator=(const Iterator& source);
434  ~Iterator() VTK_OVERRIDE;
435  Iterator(vtkFieldData* dsa, const int* list=0,
436  unsigned int listSize=0);
437 
439  {
440  this->Position = -1;
441  return this->Next();
442  }
443 
445  {
446  this->Position++;
447  if (this->End())
448  {
449  return 0;
450  }
451 
452  // vtkFieldData::GetArray() can return null, which implies that
453  // a the array at the given index in not a vtkDataArray subclass.
454  // This iterator skips such arrays.
455  vtkDataArray* cur = Fields->GetArray(this->List[this->Position]);
456  return (cur? cur : this->Next());
457  }
458 
459  void DetachFieldData();
460 
461  protected:
463  int Detached;
464  };
465 
466 };
467 
468 
469 #endif
vtkFieldData * Fields
Definition: vtkFieldData.h:462
vtkDataArray * GetArray(const char *arrayName)
Return the array with the name given.
Definition: vtkFieldData.h:140
abstract base class for most VTK objects
Definition: vtkObject.h:59
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
Abstract superclass for all arrays.
CopyFieldFlag * CopyFieldFlags
Definition: vtkFieldData.h:371
void DeepCopy(vtkPistonReference *self, vtkPistonReference *other)
int vtkIdType
Definition: vtkType.h:287
vtkTypeUInt64 vtkMTimeType
Definition: vtkType.h:248
void CopyFieldOn(const char *name)
Turn on/off the copying of the field specified by name.
Definition: vtkFieldData.h:214
BasicIterator & operator=(const BasicIterator &source)
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkAbstractArray * GetAbstractArray(const char *arrayName)
Return the array with the name given.
Definition: vtkFieldData.h:166
list of point or cell ids
Definition: vtkIdList.h:36
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
virtual vtkMTimeType GetMTime()
Return this object's modified time.
virtual char * GetName()
Set/get array's name.
int NumberOfFieldFlags
Definition: vtkFieldData.h:372
const char * GetArrayName(int i)
Get the name of ith array.
Definition: vtkFieldData.h:192
int HasArray(const char *name)
Return 1 if an array with the given name could be found.
Definition: vtkFieldData.h:177
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
void CopyFieldOff(const char *name)
Definition: vtkFieldData.h:215
vtkDataArray * Begin()
Definition: vtkFieldData.h:438
int GetNumberOfArrays()
Get the number of arrays of data available.
Definition: vtkFieldData.h:100
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
vtkDataArray * Next()
Definition: vtkFieldData.h:444
represent and manipulate fields of data
Definition: vtkFieldData.h:56