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
54class vtkIdList;
55
56class VTKCOMMONDATAMODEL_EXPORT vtkFieldData : public vtkObject
57{
58public:
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
82
92 void AllocateArrays(int num);
93
101 {
102 return this->NumberOfActiveArrays;
103 }
104
111
113
116 virtual void RemoveArray(const char *name);
117 virtual void RemoveArray(int index);
119
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
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
346protected:
347
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 {
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);
375 int FindFlag(const char* field);
376 int GetFlag(const char* field);
380
381
382private:
383 vtkFieldData(const vtkFieldData&) VTK_DELETE_FUNCTION;
384 void operator=(const vtkFieldData&) VTK_DELETE_FUNCTION;
385
386public:
387
388 class VTKCOMMONDATAMODEL_EXPORT BasicIterator
389 {
390 public:
393 BasicIterator(const int* list, unsigned int listSize);
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 }
416 {
417 this->Position++;
418 return (this->End() ? -1 : this->List[this->Position]);
419 }
420
421 protected:
422
423 int* List;
426 };
427
428 class VTKCOMMONDATAMODEL_EXPORT Iterator : public BasicIterator
429 {
430 public:
431
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
460
461 protected:
464 };
465
466};
467
468
469#endif
Abstract superclass for all arrays.
virtual char * GetName()
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:55
BasicIterator(const BasicIterator &source)
BasicIterator & operator=(const BasicIterator &source)
BasicIterator(const int *list, unsigned int listSize)
void PrintSelf(ostream &os, vtkIndent indent)
vtkFieldData * Fields
Definition: vtkFieldData.h:462
vtkDataArray * Next()
Definition: vtkFieldData.h:444
Iterator & operator=(const Iterator &source)
Iterator(const Iterator &source)
represent and manipulate fields of data
Definition: vtkFieldData.h:57
int GetFlag(const char *field)
int GetNumberOfArrays()
Get the number of arrays of data available.
Definition: vtkFieldData.h:100
virtual void DeepCopy(vtkFieldData *da)
Copy a field by creating new data arrays (i.e., duplicate storage).
int AddArray(vtkAbstractArray *array)
Add an array to the array list.
void CopyFlags(const vtkFieldData *source)
void Reset()
Resets each data array in the field (Reset() does not release memory but it makes the arrays look lik...
vtkAbstractArray * GetAbstractArray(const char *arrayName)
Return the array with the name given.
Definition: vtkFieldData.h:166
void AllocateArrays(int num)
AllocateOfArrays actually sets the number of vtkAbstractArray pointers in the vtkFieldData object,...
virtual void RemoveArray(int index)
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
int Allocate(const vtkIdType sz, const vtkIdType ext=1000)
Allocate data for each array.
vtkMTimeType GetMTime() override
Check object's components for modified times.
virtual void RemoveArray(const char *name)
Remove an array (with the given name or index) from the list of arrays.
virtual void CopyAllOn(int unused=0)
Turn on copying of all data.
CopyFieldFlag * CopyFieldFlags
Definition: vtkFieldData.h:371
virtual unsigned long GetActualMemorySize()
Return the memory in kibibytes (1024 bytes) consumed by this field data.
void ClearFieldFlags()
int FindFlag(const char *field)
virtual void Initialize()
Release all data but do not delete object.
vtkDataArray * GetArray(int i)
Return the ith array in the field.
virtual void CopyAllOff(int unused=0)
Turn off copying of all data.
const char * GetArrayName(int i)
Get the name of ith array.
Definition: vtkFieldData.h:192
virtual void ShallowCopy(vtkFieldData *da)
Copy a field by reference counting the data arrays.
void CopyFieldOn(const char *name)
Turn on/off the copying of the field specified by name.
Definition: vtkFieldData.h:214
void CopyFieldOff(const char *name)
Definition: vtkFieldData.h:215
vtkDataArray * GetArray(const char *arrayName, int &index)
Return the array with the name given.
static vtkFieldData * New()
void Squeeze()
Squeezes each data array in the field (Squeeze() reclaims unused memory.)
vtkAbstractArray * GetAbstractArray(int i)
Returns the ith array in the field.
void CopyFieldOnOff(const char *name, int onOff)
virtual void PassData(vtkFieldData *fd)
Pass entire arrays of input data through to output.
vtkDataArray * GetArray(const char *arrayName)
Return the array with the name given.
Definition: vtkFieldData.h:140
void CopyStructure(vtkFieldData *)
Copy data array structure from a given field.
vtkAbstractArray * GetAbstractArray(const char *arrayName, int &index)
Return the array with the name given.
int HasArray(const char *name)
Return 1 if an array with the given name could be found.
Definition: vtkFieldData.h:177
int NumberOfFieldFlags
Definition: vtkFieldData.h:372
list of point or cell ids
Definition: vtkIdList.h:37
a simple class to control print indentation
Definition: vtkIndent.h:40
abstract base class for most VTK objects
Definition: vtkObject.h:60
@ field
Definition: vtkX3D.h:177
@ name
Definition: vtkX3D.h:219
@ index
Definition: vtkX3D.h:246
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
int vtkIdType
Definition: vtkType.h:287
vtkTypeUInt64 vtkMTimeType
Definition: vtkType.h:248