VTK  9.0.20200710
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 =========================================================================*/
43 #ifndef vtkFieldData_h
44 #define vtkFieldData_h
45 
46 #include "vtkCommonDataModelModule.h" // For export macro
47 #include "vtkObject.h"
48 
49 #include "vtkAbstractArray.h" // Needed for inline methods.
50 
51 class vtkIdList;
52 
53 class VTKCOMMONDATAMODEL_EXPORT vtkFieldData : public vtkObject
54 {
55 public:
56  static vtkFieldData* New();
57  static vtkFieldData* ExtendedNew();
58 
59  vtkTypeMacro(vtkFieldData, vtkObject);
60  void PrintSelf(ostream& os, vtkIndent indent) override;
61 
66  virtual void Initialize();
67 
72  vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext = 1000);
73 
79  void CopyStructure(vtkFieldData*);
80 
90  void AllocateArrays(int num);
91 
98  int GetNumberOfArrays() { return this->NumberOfActiveArrays; }
99 
105  int AddArray(vtkAbstractArray* array);
106 
110  void NullData(vtkIdType id);
111 
113 
116  virtual void RemoveArray(const char* name);
117  virtual void RemoveArray(int index);
119 
128  vtkDataArray* GetArray(int i);
129 
140  vtkDataArray* GetArray(const char* arrayName, int& index);
141 
143 
152  vtkDataArray* GetArray(const char* arrayName)
153  {
154  int i;
155  return this->GetArray(arrayName, i);
156  }
158 
164  vtkAbstractArray* GetAbstractArray(int i);
165 
172  vtkAbstractArray* GetAbstractArray(const char* arrayName, int& index);
173 
175 
180  vtkAbstractArray* GetAbstractArray(const char* arrayName)
181  {
182  int i;
183  return this->GetAbstractArray(arrayName, i);
184  }
186 
188 
191  int HasArray(const char* name)
192  {
193  int i;
194  vtkAbstractArray* array = this->GetAbstractArray(name, i);
195  // assert( i == -1);
196  return array ? 1 : 0;
197  }
199 
201 
206  const char* GetArrayName(int i)
207  {
208  vtkAbstractArray* da = this->GetAbstractArray(i);
209  return da ? da->GetName() : nullptr;
210  }
212 
217  virtual void PassData(vtkFieldData* fd);
218 
228  void CopyFieldOn(const char* name) { this->CopyFieldOnOff(name, 1); }
229  void CopyFieldOff(const char* name) { this->CopyFieldOnOff(name, 0); }
230 
240  virtual void CopyAllOn(int unused = 0);
241 
251  virtual void CopyAllOff(int unused = 0);
252 
256  virtual void DeepCopy(vtkFieldData* da);
257 
261  virtual void ShallowCopy(vtkFieldData* da);
262 
266  void Squeeze();
267 
272  void Reset();
273 
280  virtual unsigned long GetActualMemorySize();
281 
285  vtkMTimeType GetMTime() override;
286 
296  void GetField(vtkIdList* ptId, vtkFieldData* f);
297 
305  int GetArrayContainingComponent(int i, int& arrayComp);
306 
316  int GetNumberOfComponents();
317 
328  vtkIdType GetNumberOfTuples();
329 
338  void SetNumberOfTuples(const vtkIdType number);
339 
345  void SetTuple(const vtkIdType i, const vtkIdType j, vtkFieldData* source);
346 
351  void InsertTuple(const vtkIdType i, const vtkIdType j, vtkFieldData* source);
352 
358  vtkIdType InsertNextTuple(const vtkIdType j, vtkFieldData* source);
359 
360 protected:
361  vtkFieldData();
362  ~vtkFieldData() override;
363 
367 
371  void SetArray(int i, vtkAbstractArray* array);
372 
376  virtual void InitializeFields();
377 
379  {
380  char* ArrayName;
381  int IsCopied;
382  };
383 
384  CopyFieldFlag* CopyFieldFlags; // the names of fields not to be copied
385  int NumberOfFieldFlags; // the number of fields not to be copied
386  void CopyFieldOnOff(const char* name, int onOff);
387  void ClearFieldFlags();
388  int FindFlag(const char* field);
389  int GetFlag(const char* field);
390  void CopyFlags(const vtkFieldData* source);
393 
394 private:
395  vtkFieldData(const vtkFieldData&) = delete;
396  void operator=(const vtkFieldData&) = delete;
397 
398 public:
399  class VTKCOMMONDATAMODEL_EXPORT BasicIterator
400  {
401  public:
402  BasicIterator();
404  BasicIterator(const int* list, unsigned int listSize);
405  BasicIterator& operator=(const BasicIterator& source);
406  virtual ~BasicIterator();
407  void PrintSelf(ostream& os, vtkIndent indent);
408 
409  int GetListSize() const { return this->ListSize; }
410  int GetCurrentIndex() { return this->List[this->Position]; }
412  {
413  this->Position = -1;
414  return this->NextIndex();
415  }
416  int End() const { return (this->Position >= this->ListSize); }
417  int NextIndex()
418  {
419  this->Position++;
420  return (this->End() ? -1 : this->List[this->Position]);
421  }
422 
423  protected:
424  int* List;
425  int ListSize;
426  int Position;
427  };
428 
429  class VTKCOMMONDATAMODEL_EXPORT Iterator : public BasicIterator
430  {
431  public:
432  Iterator(const Iterator& source);
434  ~Iterator() override;
435  Iterator(vtkFieldData* dsa, const int* list = nullptr, unsigned int listSize = 0);
436 
438  {
439  this->Position = -1;
440  return this->Next();
441  }
442 
444  {
445  this->Position++;
446  if (this->End())
447  {
448  return nullptr;
449  }
450 
451  // vtkFieldData::GetArray() can return null, which implies that
452  // a the array at the given index in not a vtkDataArray subclass.
453  // This iterator skips such arrays.
454  vtkDataArray* cur = Fields->GetArray(this->List[this->Position]);
455  return (cur ? cur : this->Next());
456  }
457 
458  void DetachFieldData();
459 
460  protected:
462  int Detached;
463  };
464 };
465 
466 #endif
vtkAbstractArray::GetName
virtual char * GetName()
vtkFieldData::GetAbstractArray
vtkAbstractArray * GetAbstractArray(const char *arrayName)
Return the array with the name given.
Definition: vtkFieldData.h:180
vtkFieldData::GetArray
vtkDataArray * GetArray(const char *arrayName)
Not recommended for use.
Definition: vtkFieldData.h:152
vtkFieldData::GetArrayName
const char * GetArrayName(int i)
Get the name of ith array.
Definition: vtkFieldData.h:206
vtkIdType
int vtkIdType
Definition: vtkType.h:330
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkFieldData::BasicIterator::ListSize
int ListSize
Definition: vtkFieldData.h:425
vtkFieldData::DoCopyAllOff
int DoCopyAllOff
Definition: vtkFieldData.h:392
vtkFieldData::Iterator::Detached
int Detached
Definition: vtkFieldData.h:462
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:62
vtkFieldData::BasicIterator
Definition: vtkFieldData.h:399
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:49
vtkFieldData::CopyFieldFlags
CopyFieldFlag * CopyFieldFlags
Definition: vtkFieldData.h:384
vtkFieldData::NumberOfActiveArrays
int NumberOfActiveArrays
Definition: vtkFieldData.h:365
vtkAbstractArray.h
vtkFieldData::Iterator::Begin
vtkDataArray * Begin()
Definition: vtkFieldData.h:437
vtkFieldData::CopyFieldFlag::IsCopied
int IsCopied
Definition: vtkFieldData.h:381
vtkFieldData
represent and manipulate fields of data
Definition: vtkFieldData.h:53
vtkFieldData::Iterator::Next
vtkDataArray * Next()
Definition: vtkFieldData.h:443
vtkFieldData::Iterator
Definition: vtkFieldData.h:429
vtkFieldData::NumberOfFieldFlags
int NumberOfFieldFlags
Definition: vtkFieldData.h:385
vtkFieldData::BasicIterator::Position
int Position
Definition: vtkFieldData.h:426
vtkObject::GetMTime
virtual vtkMTimeType GetMTime()
Return this object's modified time.
vtkFieldData::Iterator::Fields
vtkFieldData * Fields
Definition: vtkFieldData.h:461
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkFieldData::BasicIterator::operator=
BasicIterator & operator=(const BasicIterator &source)
vtkX3D::field
Definition: vtkX3D.h:183
vtkFieldData::BasicIterator::List
int * List
Definition: vtkFieldData.h:424
vtkFieldData::HasArray
int HasArray(const char *name)
Return 1 if an array with the given name could be found.
Definition: vtkFieldData.h:191
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:30
vtkFieldData::BasicIterator::GetCurrentIndex
int GetCurrentIndex()
Definition: vtkFieldData.h:410
vtkObject::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkFieldData::CopyFieldOff
void CopyFieldOff(const char *name)
Definition: vtkFieldData.h:229
vtkFieldData::BasicIterator::NextIndex
int NextIndex()
Definition: vtkFieldData.h:417
vtkX3D::name
Definition: vtkX3D.h:225
vtkFieldData::BasicIterator::End
int End() const
Definition: vtkFieldData.h:416
vtkObject.h
vtkAbstractArray
Abstract superclass for all arrays.
Definition: vtkAbstractArray.h:75
vtkFieldData::BasicIterator::BeginIndex
int BeginIndex()
Definition: vtkFieldData.h:411
vtkFieldData::GetNumberOfArrays
int GetNumberOfArrays()
Get the number of arrays of data available.
Definition: vtkFieldData.h:98
vtkFieldData::CopyFieldFlag::ArrayName
char * ArrayName
Definition: vtkFieldData.h:380
vtkParticleTracerBaseNamespace::Position
struct Position_t Position
Definition: vtkParticleTracerBase.h:63
vtkFieldData::CopyFieldFlag
Definition: vtkFieldData.h:378
vtkFieldData::NumberOfArrays
int NumberOfArrays
Definition: vtkFieldData.h:364
source
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
Definition: vtkBoostGraphAdapter.h:959
vtkFieldData::BasicIterator::GetListSize
int GetListSize() const
Definition: vtkFieldData.h:409
vtkFieldData::Data
vtkAbstractArray ** Data
Definition: vtkFieldData.h:366
vtkX3D::index
Definition: vtkX3D.h:252
vtkFieldData::CopyFieldOn
void CopyFieldOn(const char *name)
Turn on/off the copying of the field specified by name.
Definition: vtkFieldData.h:228
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkMTimeType
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:285
vtkFieldData::DoCopyAllOn
int DoCopyAllOn
Definition: vtkFieldData.h:391