00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00045 #ifndef __vtkFieldData_h
00046 #define __vtkFieldData_h
00047
00048 #include "vtkObject.h"
00049
00050 #include "vtkAbstractArray.h"
00051
00052 #ifndef VTK_LEGACY_REMOVE
00053 # include "vtkDataArray.h"
00054 #endif
00055
00056 class vtkIdList;
00057
00058 class VTK_FILTERING_EXPORT vtkFieldData : public vtkObject
00059 {
00060 public:
00061 static vtkFieldData *New();
00062
00063 vtkTypeMacro(vtkFieldData,vtkObject);
00064 void PrintSelf(ostream& os, vtkIndent indent);
00065
00068 virtual void Initialize();
00069
00071 int Allocate(const vtkIdType sz, const vtkIdType ext=1000);
00072
00075 void CopyStructure(vtkFieldData*);
00076
00083 void AllocateArrays(int num);
00084
00086
00089 int GetNumberOfArrays()
00090 {
00091 return this->NumberOfActiveArrays;
00092 }
00094
00097 int AddArray(vtkAbstractArray *array);
00098
00100
00101 virtual void RemoveArray(const char *name)
00102 {
00103 int i;
00104 this->GetAbstractArray(name, i);
00105 this->RemoveArray(i);
00106 }
00108
00112 vtkDataArray *GetArray(int i);
00113
00118 vtkDataArray *GetArray(const char *arrayName, int &index);
00119
00121
00124 vtkDataArray *GetArray(const char *arrayName)
00125 {
00126 int i;
00127 return this->GetArray(arrayName, i);
00128 }
00130
00134 vtkAbstractArray* GetAbstractArray(int i);
00135
00139 vtkAbstractArray* GetAbstractArray(const char* arrayName, int &index);
00140
00142
00144 vtkAbstractArray* GetAbstractArray(const char* arrayName)
00145 {
00146 int i;
00147 return this->GetAbstractArray(arrayName, i);
00148 }
00150
00152
00153 int HasArray(const char *name)
00154 {
00155 int i;
00156 vtkAbstractArray *array = this->GetAbstractArray(name, i);
00157
00158 return array ? 1 : 0;
00159 }
00161
00163
00165 const char* GetArrayName(int i)
00166 {
00167 vtkAbstractArray* da = this->GetAbstractArray(i);
00168 return da ? da->GetName() : 0;
00169 }
00171
00174 virtual void PassData(vtkFieldData* fd);
00175
00177
00182 void CopyFieldOn(const char* name) { this->CopyFieldOnOff(name, 1); }
00183 void CopyFieldOff(const char* name) { this->CopyFieldOnOff(name, 0); }
00185
00191 virtual void CopyAllOn(int unused=0);
00192
00198 virtual void CopyAllOff(int unused=0);
00199
00201 virtual void DeepCopy(vtkFieldData *da);
00202
00204 virtual void ShallowCopy(vtkFieldData *da);
00205
00208 void Squeeze();
00209
00212 void Reset();
00213
00218 virtual unsigned long GetActualMemorySize();
00219
00221 unsigned long int GetMTime();
00222
00230 void GetField(vtkIdList *ptId, vtkFieldData *f);
00231
00237 int GetArrayContainingComponent(int i, int& arrayComp);
00238
00245 int GetNumberOfComponents();
00246
00254 vtkIdType GetNumberOfTuples();
00255
00261 void SetNumberOfTuples(const vtkIdType number);
00262
00266 void SetTuple(const vtkIdType i, const vtkIdType j, vtkFieldData* source);
00267
00270 void InsertTuple(const vtkIdType i, const vtkIdType j, vtkFieldData* source);
00271
00275 vtkIdType InsertNextTuple(const vtkIdType j, vtkFieldData* source);
00276
00277
00278
00279
00280
00286 VTK_LEGACY(double *GetTuple(const vtkIdType i));
00287
00292 VTK_LEGACY(void GetTuple(const vtkIdType i, double * tuple));
00293
00298 VTK_LEGACY(void SetTuple(const vtkIdType i, const double * tuple));
00299
00304 VTK_LEGACY(void InsertTuple(const vtkIdType i, const double * tuple));
00305
00310 VTK_LEGACY(vtkIdType InsertNextTuple(const double * tuple));
00311
00316 VTK_LEGACY(double GetComponent(const vtkIdType i, const int j));
00317
00323 VTK_LEGACY(void SetComponent(const vtkIdType i, const int j, const double c));
00324
00326
00331 VTK_LEGACY(void InsertComponent(const vtkIdType i, const int j, const double c));
00332 protected:
00334
00335 vtkFieldData();
00336 ~vtkFieldData();
00337
00338 int NumberOfArrays;
00339 int NumberOfActiveArrays;
00340 vtkAbstractArray **Data;
00341
00343 void SetArray(int i, vtkAbstractArray *array);
00344
00345 virtual void RemoveArray(int index);
00346
00348 virtual void InitializeFields();
00349
00350
00351
00352 struct CopyFieldFlag
00353 {
00354 char* ArrayName;
00355 int IsCopied;
00356 };
00357
00358 CopyFieldFlag* CopyFieldFlags;
00359 int NumberOfFieldFlags;
00360 void CopyFieldOnOff(const char* name, int onOff);
00361 void ClearFieldFlags();
00362 int FindFlag(const char* field);
00363 int GetFlag(const char* field);
00364 void CopyFlags(const vtkFieldData* source);
00365 int DoCopyAllOn;
00366 int DoCopyAllOff;
00367
00368
00369 private:
00370 vtkFieldData(const vtkFieldData&);
00371 void operator=(const vtkFieldData&);
00372
00373 #ifndef VTK_LEGACY_REMOVE
00374
00375 int TupleSize;
00376 double* Tuple;
00377 #endif
00378 public:
00379
00380 class VTK_FILTERING_EXPORT BasicIterator
00381 {
00382 public:
00383 BasicIterator();
00384 BasicIterator(const BasicIterator& source);
00385 BasicIterator(const int* list, unsigned int listSize);
00386 BasicIterator& operator=(const BasicIterator& source);
00387 virtual ~BasicIterator();
00388 void PrintSelf(ostream &os, vtkIndent indent);
00389
00390 int GetListSize() const
00391 {
00392 return this->ListSize;
00393 }
00394 int GetCurrentIndex()
00395 {
00396 return this->List[this->Position];
00397 }
00398 int BeginIndex()
00399 {
00400 this->Position = -1;
00401 return this->NextIndex();
00402 }
00403 int End() const
00404 {
00405 return (this->Position >= this->ListSize);
00406 }
00407 int NextIndex()
00408 {
00409 this->Position++;
00410 return (this->End() ? -1 : this->List[this->Position]);
00411 }
00412
00413 protected:
00414
00415 int* List;
00416 int ListSize;
00417 int Position;
00418 };
00419
00420 class VTK_FILTERING_EXPORT Iterator : public BasicIterator
00421 {
00422 public:
00423
00424 Iterator(const Iterator& source);
00425 Iterator& operator=(const Iterator& source);
00426 virtual ~Iterator();
00427 Iterator(vtkFieldData* dsa, const int* list=0,
00428 unsigned int listSize=0);
00429
00430 vtkDataArray* Begin()
00431 {
00432 this->Position = -1;
00433 return this->Next();
00434 }
00435
00436 vtkDataArray* Next()
00437 {
00438 this->Position++;
00439 if (this->End())
00440 {
00441 return 0;
00442 }
00443
00444
00445
00446
00447 vtkDataArray* cur = Fields->GetArray(this->List[this->Position]);
00448 return (cur? cur : this->Next());
00449 }
00450
00451 void DetachFieldData();
00452
00453 protected:
00454 vtkFieldData* Fields;
00455 int Detached;
00456 };
00457
00458
00459
00460
00461 };
00462
00463
00464 #endif