Common/vtkFieldData.h Source File

Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members File Members Related Pages

# Common/vtkFieldData.h

Go to the documentation of this file.

    00001 /*=========================================================================
    00002
    00003   Program:   Visualization Toolkit
    00004   Module:    $RCSfile: vtkFieldData.h,v $
    00005   Language:  C++
    00006
    00007   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen
    00008   All rights reserved.
    00009   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
    00010
    00011      This software is distributed WITHOUT ANY WARRANTY; without even
    00012      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
    00013      PURPOSE.  See the above copyright notice for more information.
    00014
    00015 =========================================================================*/
    00061 #ifndef __vtkFieldData_h
    00062 #define __vtkFieldData_h
    00063
    00064 #include "vtkObject.h"
    00065
    00066 #include "vtkDataArray.h" // Needed for inline methods
    00067
    00068 class vtkIdList;
    00069
    00070 class VTK_COMMON_EXPORT vtkFieldData : public vtkObject
    00071 {
    00072 public:
    00073   static vtkFieldData *New();
    00074
    00075   vtkTypeRevisionMacro(vtkFieldData,vtkObject);
    00076   void PrintSelf(ostream& os, vtkIndent indent);
    00077
    00080   virtual void Initialize();
    00081
    00083   int Allocate(const vtkIdType sz, const vtkIdType ext=1000);
    00084
    00085 #ifndef VTK_REMOVE_LEGACY_CODE
    00086
    00087   virtual vtkFieldData* MakeObject();
    00088 #endif
    00089
    00092   void CopyStructure(vtkFieldData*);
    00093
    00100   void AllocateArrays(int num);
    00101
    00102 #ifndef VTK_REMOVE_LEGACY_CODE
    00103   void SetNumberOfArrays(int num)
    00104     {
    00105       vtkWarningMacro("This method will be deprecated. Please use "
    00106                       "AllocateArrays() instead.");
    00107       this->AllocateArrays(num);
    00108     }
    00109 #endif
    00110
    00114   int GetNumberOfArrays();
    00115
    00118   int AddArray(vtkDataArray *array);
    00119
    00121
    00122   virtual void RemoveArray(const char *name)
    00123     {
    00124       int i;
    00125       this->GetArray(name, i);
    00126       this->RemoveArray(i);
    00127     }
    00129
    00132   vtkDataArray *GetArray(int i);
    00133
    00136   vtkDataArray *GetArray(const char *arrayName, int &index);
    00137
    00138   // Return the array with the name given. Returns NULL is array not found.
    00139   vtkDataArray *GetArray(const char *arrayName);
    00140
    00142
    00144   const char* GetArrayName(int i)
    00145     {
    00146     vtkDataArray* da = this->GetArray(i);
    00147     if (da)
    00148       {
    00149       return da->GetName();
    00150       }
    00151     else
    00152       {
    00153       return 0;
    00154       }
    00155     }
    00157
    00160   virtual void PassData(vtkFieldData* fd);
    00161
    00163
    00168   void CopyFieldOn(const char* name) { this->CopyFieldOnOff(name, 1); }
    00169   void CopyFieldOff(const char* name) { this->CopyFieldOnOff(name, 0); }
    00171
    00177   virtual void CopyAllOn();
    00178
    00184   virtual void CopyAllOff();
    00185
    00187   virtual void DeepCopy(vtkFieldData *da);
    00188
    00190   virtual void ShallowCopy(vtkFieldData *da);
    00191
    00194   void Squeeze();
    00195
    00198   void Reset();
    00199
    00204   virtual unsigned long GetActualMemorySize();
    00205
    00207   unsigned long int GetMTime();
    00208
    00216   void GetField(vtkIdList *ptId, vtkFieldData *f);
    00217
    00226   int GetArrayContainingComponent(int i, int& arrayComp);
    00227
    00234   int GetNumberOfComponents();
    00235
    00243   vtkIdType GetNumberOfTuples();
    00244
    00250   void SetNumberOfTuples(const vtkIdType number);
    00251
    00258   float *GetTuple(const vtkIdType i);
    00259
    00266   void GetTuple(const vtkIdType i, float * tuple);
    00267
    00274   void SetTuple(const vtkIdType i, const float * tuple);
    00275
    00282   void InsertTuple(const vtkIdType i, const float * tuple);
    00283
    00290   vtkIdType InsertNextTuple(const float * tuple);
    00291
    00297   float GetComponent(const vtkIdType i, const int j);
    00298
    00306   void SetComponent(const vtkIdType i, const int j, const float c);
    00307
    00315   void InsertComponent(const vtkIdType i, const int j, const float c);
    00316
    00317 protected:
    00318
    00319   vtkFieldData();
    00320   ~vtkFieldData();
    00321
    00322   int NumberOfArrays;
    00323   int NumberOfActiveArrays;
    00324   vtkDataArray **Data;
    00325
    00326   int TupleSize; //used for type conversion
    00327   float *Tuple;
    00328
    00330   void SetArray(int i, vtkDataArray *array);
    00331
    00332   virtual void RemoveArray(int index);
    00333
    00335   virtual void InitializeFields();
    00336
    00337 //BTX
    00338
    00339   struct CopyFieldFlag
    00340   {
    00341     char* ArrayName;
    00342     int IsCopied;
    00343   };
    00344
    00345   CopyFieldFlag* CopyFieldFlags; //the names of fields not to be copied
    00346   int NumberOfFieldFlags; //the number of fields not to be copied
    00347   void CopyFieldOnOff(const char* name, int onOff);
    00348   void ClearFieldFlags();
    00349   int FindFlag(const char* field);
    00350   int GetFlag(const char* field);
    00351   void CopyFlags(const vtkFieldData* source);
    00352   int DoCopyAllOn;
    00353   int DoCopyAllOff;
    00354
    00355
    00356 private:
    00357   vtkFieldData(const vtkFieldData&);  // Not implemented.
    00358   void operator=(const vtkFieldData&);  // Not implemented.
    00359
    00360 public:
    00361
    00362   class VTK_COMMON_EXPORT BasicIterator
    00363   {
    00364   public:
    00365     BasicIterator();
    00366     BasicIterator(const BasicIterator& source);
    00367     BasicIterator(const int* list, unsigned int listSize);
    00368     BasicIterator& operator=(const BasicIterator& source);
    00369     virtual ~BasicIterator();
    00370
    00371     int GetListSize() const
    00372       {
    00373         return this->ListSize;
    00374       }
    00375     int GetCurrentIndex()
    00376       {
    00377         return this->List[this->Position];
    00378       }
    00379     int BeginIndex()
    00380       {
    00381         this->Position = -1;
    00382         return this->NextIndex();
    00383       }
    00384     int End() const
    00385       {
    00386         return (this->Position >= this->ListSize);
    00387       }
    00388     int NextIndex()
    00389       {
    00390         this->Position++;
    00391         return (this->End() ? -1 : this->List[this->Position]);
    00392       }
    00393
    00394   protected:
    00395
    00396     int* List;
    00397     int ListSize;
    00398     int Position;
    00399   };
    00400
    00401   class VTK_COMMON_EXPORT Iterator : public BasicIterator
    00402   {
    00403   public:
    00404
    00405     Iterator(const Iterator& source);
    00406     Iterator& operator=(const Iterator& source);
    00407     virtual ~Iterator();
    00408     Iterator(vtkFieldData* dsa, const int* list=0,
    00409              unsigned int listSize=0);
    00410
    00411     vtkDataArray* Begin()
    00412       {
    00413         this->Position = -1;
    00414         return this->Next();
    00415       }
    00416
    00417     vtkDataArray* Next()
    00418       {
    00419         this->Position++;
    00420         return (this->End() ? 0 :
    00421                 Fields->GetArray(this->List[this->Position]));
    00422       }
    00423
    00424     void DetachFieldData();
    00425
    00426   protected:
    00427     vtkFieldData* Fields;
    00428     int Detached;
    00429   };
    00430
    00431
    00432 //ETX
    00433
    00434 };
    00435
    00436
    00437 #endif