VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkFieldData.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00045 #ifndef __vtkFieldData_h 00046 #define __vtkFieldData_h 00047 00048 #include "vtkCommonDataModelModule.h" // For export macro 00049 #include "vtkObject.h" 00050 00051 #include "vtkAbstractArray.h" // Needed for inline methods. 00052 00053 class vtkIdList; 00054 00055 class VTKCOMMONDATAMODEL_EXPORT vtkFieldData : public vtkObject 00056 { 00057 public: 00058 static vtkFieldData *New(); 00059 00060 vtkTypeMacro(vtkFieldData,vtkObject); 00061 void PrintSelf(ostream& os, vtkIndent indent); 00062 00065 virtual void Initialize(); 00066 00068 int Allocate(const vtkIdType sz, const vtkIdType ext=1000); 00069 00072 void CopyStructure(vtkFieldData*); 00073 00080 void AllocateArrays(int num); 00081 00083 00086 int GetNumberOfArrays() 00087 { 00088 return this->NumberOfActiveArrays; 00089 } 00091 00095 int AddArray(vtkAbstractArray *array); 00096 00098 00099 virtual void RemoveArray(const char *name) 00100 { 00101 int i; 00102 this->GetAbstractArray(name, i); 00103 this->RemoveArray(i); 00104 } 00106 00110 vtkDataArray *GetArray(int i); 00111 00116 vtkDataArray *GetArray(const char *arrayName, int &index); 00117 00119 00122 vtkDataArray *GetArray(const char *arrayName) 00123 { 00124 int i; 00125 return this->GetArray(arrayName, i); 00126 } 00128 00132 vtkAbstractArray* GetAbstractArray(int i); 00133 00137 vtkAbstractArray* GetAbstractArray(const char* arrayName, int &index); 00138 00140 00142 vtkAbstractArray* GetAbstractArray(const char* arrayName) 00143 { 00144 int i; 00145 return this->GetAbstractArray(arrayName, i); 00146 } 00148 00150 00151 int HasArray(const char *name) 00152 { 00153 int i; 00154 vtkAbstractArray *array = this->GetAbstractArray(name, i); 00155 // assert( i == -1); 00156 return array ? 1 : 0; 00157 } 00159 00161 00163 const char* GetArrayName(int i) 00164 { 00165 vtkAbstractArray* da = this->GetAbstractArray(i); 00166 return da ? da->GetName() : 0; 00167 } 00169 00172 virtual void PassData(vtkFieldData* fd); 00173 00175 00180 void CopyFieldOn(const char* name) { this->CopyFieldOnOff(name, 1); } 00181 void CopyFieldOff(const char* name) { this->CopyFieldOnOff(name, 0); } 00183 00189 virtual void CopyAllOn(int unused=0); 00190 00196 virtual void CopyAllOff(int unused=0); 00197 00199 virtual void DeepCopy(vtkFieldData *da); 00200 00202 virtual void ShallowCopy(vtkFieldData *da); 00203 00206 void Squeeze(); 00207 00210 void Reset(); 00211 00216 virtual unsigned long GetActualMemorySize(); 00217 00219 unsigned long int GetMTime(); 00220 00228 void GetField(vtkIdList *ptId, vtkFieldData *f); 00229 00235 int GetArrayContainingComponent(int i, int& arrayComp); 00236 00243 int GetNumberOfComponents(); 00244 00252 vtkIdType GetNumberOfTuples(); 00253 00259 void SetNumberOfTuples(const vtkIdType number); 00260 00264 void SetTuple(const vtkIdType i, const vtkIdType j, vtkFieldData* source); 00265 00268 void InsertTuple(const vtkIdType i, const vtkIdType j, vtkFieldData* source); 00269 00273 vtkIdType InsertNextTuple(const vtkIdType j, vtkFieldData* source); 00274 00275 protected: 00276 00277 vtkFieldData(); 00278 ~vtkFieldData(); 00279 00280 int NumberOfArrays; 00281 int NumberOfActiveArrays; 00282 vtkAbstractArray **Data; 00283 00285 void SetArray(int i, vtkAbstractArray *array); 00286 00287 virtual void RemoveArray(int index); 00288 00290 virtual void InitializeFields(); 00291 00292 //BTX 00293 00294 struct CopyFieldFlag 00295 { 00296 char* ArrayName; 00297 int IsCopied; 00298 }; 00299 00300 CopyFieldFlag* CopyFieldFlags; //the names of fields not to be copied 00301 int NumberOfFieldFlags; //the number of fields not to be copied 00302 void CopyFieldOnOff(const char* name, int onOff); 00303 void ClearFieldFlags(); 00304 int FindFlag(const char* field); 00305 int GetFlag(const char* field); 00306 void CopyFlags(const vtkFieldData* source); 00307 int DoCopyAllOn; 00308 int DoCopyAllOff; 00309 00310 00311 private: 00312 vtkFieldData(const vtkFieldData&); // Not implemented. 00313 void operator=(const vtkFieldData&); // Not implemented. 00314 00315 public: 00316 00317 class VTKCOMMONDATAMODEL_EXPORT BasicIterator 00318 { 00319 public: 00320 BasicIterator(); 00321 BasicIterator(const BasicIterator& source); 00322 BasicIterator(const int* list, unsigned int listSize); 00323 BasicIterator& operator=(const BasicIterator& source); 00324 virtual ~BasicIterator(); 00325 void PrintSelf(ostream &os, vtkIndent indent); 00326 00327 int GetListSize() const 00328 { 00329 return this->ListSize; 00330 } 00331 int GetCurrentIndex() 00332 { 00333 return this->List[this->Position]; 00334 } 00335 int BeginIndex() 00336 { 00337 this->Position = -1; 00338 return this->NextIndex(); 00339 } 00340 int End() const 00341 { 00342 return (this->Position >= this->ListSize); 00343 } 00344 int NextIndex() 00345 { 00346 this->Position++; 00347 return (this->End() ? -1 : this->List[this->Position]); 00348 } 00349 00350 protected: 00351 00352 int* List; 00353 int ListSize; 00354 int Position; 00355 }; 00356 00357 class VTKCOMMONDATAMODEL_EXPORT Iterator : public BasicIterator 00358 { 00359 public: 00360 00361 Iterator(const Iterator& source); 00362 Iterator& operator=(const Iterator& source); 00363 virtual ~Iterator(); 00364 Iterator(vtkFieldData* dsa, const int* list=0, 00365 unsigned int listSize=0); 00366 00367 vtkDataArray* Begin() 00368 { 00369 this->Position = -1; 00370 return this->Next(); 00371 } 00372 00373 vtkDataArray* Next() 00374 { 00375 this->Position++; 00376 if (this->End()) 00377 { 00378 return 0; 00379 } 00380 00381 // vtkFieldData::GetArray() can return null, which implies that 00382 // a the array at the given index in not a vtkDataArray subclass. 00383 // This iterator skips such arrays. 00384 vtkDataArray* cur = Fields->GetArray(this->List[this->Position]); 00385 return (cur? cur : this->Next()); 00386 } 00387 00388 void DetachFieldData(); 00389 00390 protected: 00391 vtkFieldData* Fields; 00392 int Detached; 00393 }; 00394 00395 00396 //ETX 00397 00398 }; 00399 00400 00401 #endif