vtkFieldData.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00049 #ifndef __vtkFieldData_h
00050 #define __vtkFieldData_h
00051
00052 #include "vtkObject.h"
00053
00054 #include "vtkDataArray.h"
00055
00056 class vtkIdList;
00057
00058 class VTK_COMMON_EXPORT vtkFieldData : public vtkObject
00059 {
00060 public:
00061 static vtkFieldData *New();
00062
00063 vtkTypeRevisionMacro(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
00073 #ifndef VTK_REMOVE_LEGACY_CODE
00074
00075 virtual vtkFieldData* MakeObject();
00076 #endif
00077
00080 void CopyStructure(vtkFieldData*);
00081
00088 void AllocateArrays(int num);
00089
00090 #ifndef VTK_REMOVE_LEGACY_CODE
00091 void SetNumberOfArrays(int num)
00092 {
00093 vtkWarningMacro("This method will be deprecated. Please use "
00094 "AllocateArrays() instead.");
00095 this->AllocateArrays(num);
00096 }
00097 #endif
00098
00102 int GetNumberOfArrays();
00103
00106 int AddArray(vtkDataArray *array);
00107
00109
00110 virtual void RemoveArray(const char *name)
00111 {
00112 int i;
00113 this->GetArray(name, i);
00114 this->RemoveArray(i);
00115 }
00117
00120 vtkDataArray *GetArray(int i);
00121
00124 vtkDataArray *GetArray(const char *arrayName, int &index);
00125
00126
00127 vtkDataArray *GetArray(const char *arrayName);
00128
00130
00132 const char* GetArrayName(int i)
00133 {
00134 vtkDataArray* da = this->GetArray(i);
00135 if (da)
00136 {
00137 return da->GetName();
00138 }
00139 else
00140 {
00141 return 0;
00142 }
00143 }
00145
00148 virtual void PassData(vtkFieldData* fd);
00149
00151
00156 void CopyFieldOn(const char* name) { this->CopyFieldOnOff(name, 1); }
00157 void CopyFieldOff(const char* name) { this->CopyFieldOnOff(name, 0); }
00159
00165 virtual void CopyAllOn();
00166
00172 virtual void CopyAllOff();
00173
00175 virtual void DeepCopy(vtkFieldData *da);
00176
00178 virtual void ShallowCopy(vtkFieldData *da);
00179
00182 void Squeeze();
00183
00186 void Reset();
00187
00192 virtual unsigned long GetActualMemorySize();
00193
00195 unsigned long int GetMTime();
00196
00204 void GetField(vtkIdList *ptId, vtkFieldData *f);
00205
00214 int GetArrayContainingComponent(int i, int& arrayComp);
00215
00222 int GetNumberOfComponents();
00223
00231 vtkIdType GetNumberOfTuples();
00232
00238 void SetNumberOfTuples(const vtkIdType number);
00239
00246 float *GetTuple(const vtkIdType i);
00247
00254 void GetTuple(const vtkIdType i, float * tuple);
00255
00262 void SetTuple(const vtkIdType i, const float * tuple);
00263
00270 void InsertTuple(const vtkIdType i, const float * tuple);
00271
00278 vtkIdType InsertNextTuple(const float * tuple);
00279
00285 float GetComponent(const vtkIdType i, const int j);
00286
00294 void SetComponent(const vtkIdType i, const int j, const float c);
00295
00303 void InsertComponent(const vtkIdType i, const int j, const float c);
00304
00305 protected:
00306
00307 vtkFieldData();
00308 ~vtkFieldData();
00309
00310 int NumberOfArrays;
00311 int NumberOfActiveArrays;
00312 vtkDataArray **Data;
00313
00314 int TupleSize;
00315 float *Tuple;
00316
00318 void SetArray(int i, vtkDataArray *array);
00319
00320 virtual void RemoveArray(int index);
00321
00323 virtual void InitializeFields();
00324
00325
00326
00327 struct CopyFieldFlag
00328 {
00329 char* ArrayName;
00330 int IsCopied;
00331 };
00332
00333 CopyFieldFlag* CopyFieldFlags;
00334 int NumberOfFieldFlags;
00335 void CopyFieldOnOff(const char* name, int onOff);
00336 void ClearFieldFlags();
00337 int FindFlag(const char* field);
00338 int GetFlag(const char* field);
00339 void CopyFlags(const vtkFieldData* source);
00340 int DoCopyAllOn;
00341 int DoCopyAllOff;
00342
00343
00344 private:
00345 vtkFieldData(const vtkFieldData&);
00346 void operator=(const vtkFieldData&);
00347
00348 public:
00349
00350 class VTK_COMMON_EXPORT BasicIterator
00351 {
00352 public:
00353 BasicIterator();
00354 BasicIterator(const BasicIterator& source);
00355 BasicIterator(const int* list, unsigned int listSize);
00356 BasicIterator& operator=(const BasicIterator& source);
00357 virtual ~BasicIterator();
00358
00359 int GetListSize() const
00360 {
00361 return this->ListSize;
00362 }
00363 int GetCurrentIndex()
00364 {
00365 return this->List[this->Position];
00366 }
00367 int BeginIndex()
00368 {
00369 this->Position = -1;
00370 return this->NextIndex();
00371 }
00372 int End() const
00373 {
00374 return (this->Position >= this->ListSize);
00375 }
00376 int NextIndex()
00377 {
00378 this->Position++;
00379 return (this->End() ? -1 : this->List[this->Position]);
00380 }
00381
00382 protected:
00383
00384 int* List;
00385 int ListSize;
00386 int Position;
00387 };
00388
00389 class VTK_COMMON_EXPORT Iterator : public BasicIterator
00390 {
00391 public:
00392
00393 Iterator(const Iterator& source);
00394 Iterator& operator=(const Iterator& source);
00395 virtual ~Iterator();
00396 Iterator(vtkFieldData* dsa, const int* list=0,
00397 unsigned int listSize=0);
00398
00399 vtkDataArray* Begin()
00400 {
00401 this->Position = -1;
00402 return this->Next();
00403 }
00404
00405 vtkDataArray* Next()
00406 {
00407 this->Position++;
00408 return (this->End() ? 0 :
00409 Fields->GetArray(this->List[this->Position]));
00410 }
00411
00412 void DetachFieldData();
00413
00414 protected:
00415 vtkFieldData* Fields;
00416 int Detached;
00417 };
00418
00419
00420
00421
00422 };
00423
00424
00425 #endif