Main Page | Directories | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

vtkFieldData.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkFieldData.h,v $
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 =========================================================================*/
00055 #ifndef __vtkFieldData_h
00056 #define __vtkFieldData_h
00057 
00058 #include "vtkObject.h"
00059 
00060 #include "vtkDataArray.h" // Needed for inline methods
00061 
00062 class vtkIdList;
00063 
00064 class VTK_FILTERING_EXPORT vtkFieldData : public vtkObject
00065 {
00066 public:
00067   static vtkFieldData *New();
00068 
00069   vtkTypeRevisionMacro(vtkFieldData,vtkObject);
00070   void PrintSelf(ostream& os, vtkIndent indent);
00071 
00074   virtual void Initialize();
00075 
00077   int Allocate(const vtkIdType sz, const vtkIdType ext=1000);
00078 
00081   void CopyStructure(vtkFieldData*);
00082 
00089   void AllocateArrays(int num);
00090 
00094   int GetNumberOfArrays();
00095 
00098   int AddArray(vtkDataArray *array);
00099 
00101 
00102   virtual void RemoveArray(const char *name)
00103     {
00104       int i;
00105       this->GetArray(name, i);
00106       this->RemoveArray(i);
00107     }
00109 
00112   vtkDataArray *GetArray(int i);
00113 
00116   vtkDataArray *GetArray(const char *arrayName, int &index);
00117 
00118   // Return the array with the name given. Returns NULL is array not found.
00119   vtkDataArray *GetArray(const char *arrayName);
00120 
00122 
00124   const char* GetArrayName(int i)
00125     {
00126     vtkDataArray* da = this->GetArray(i);
00127     if (da)
00128       {
00129       return da->GetName();
00130       }
00131     else
00132       {
00133       return 0;
00134       }
00135     }
00137 
00140   virtual void PassData(vtkFieldData* fd);
00141 
00143 
00148   void CopyFieldOn(const char* name) { this->CopyFieldOnOff(name, 1); }
00149   void CopyFieldOff(const char* name) { this->CopyFieldOnOff(name, 0); }
00151 
00157   virtual void CopyAllOn();
00158 
00164   virtual void CopyAllOff();
00165 
00167   virtual void DeepCopy(vtkFieldData *da);
00168 
00170   virtual void ShallowCopy(vtkFieldData *da);
00171 
00174   void Squeeze();
00175 
00178   void Reset();
00179 
00184   virtual unsigned long GetActualMemorySize();
00185 
00187   unsigned long int GetMTime();
00188   
00196   void GetField(vtkIdList *ptId, vtkFieldData *f);
00197 
00206   int GetArrayContainingComponent(int i, int& arrayComp);
00207 
00214   int GetNumberOfComponents();
00215 
00223   vtkIdType GetNumberOfTuples();
00224 
00230   void SetNumberOfTuples(const vtkIdType number);
00231 
00238   double *GetTuple(const vtkIdType i);
00239 
00246   void GetTuple(const vtkIdType i, double * tuple);
00247 
00254   void SetTuple(const vtkIdType i, const double * tuple);
00255 
00262   void InsertTuple(const vtkIdType i, const double * tuple);
00263 
00270   vtkIdType InsertNextTuple(const double * tuple);
00271 
00277   double GetComponent(const vtkIdType i, const int j);
00278 
00286   void SetComponent(const vtkIdType i, const int j, const double c);
00287   
00295   void InsertComponent(const vtkIdType i, const int j, const double c);
00296 
00297 protected:
00298 
00299   vtkFieldData();
00300   ~vtkFieldData();
00301 
00302   int NumberOfArrays;
00303   int NumberOfActiveArrays;
00304   vtkDataArray **Data;
00305 
00306   int TupleSize; //used for type conversion
00307   double *Tuple;
00308 
00310   void SetArray(int i, vtkDataArray *array);
00311 
00312   virtual void RemoveArray(int index);
00313 
00315   virtual void InitializeFields();
00316 
00317 //BTX
00318 
00319   struct CopyFieldFlag
00320   {
00321     char* ArrayName;
00322     int IsCopied;
00323   };
00324 
00325   CopyFieldFlag* CopyFieldFlags; //the names of fields not to be copied
00326   int NumberOfFieldFlags; //the number of fields not to be copied
00327   void CopyFieldOnOff(const char* name, int onOff);
00328   void ClearFieldFlags();
00329   int FindFlag(const char* field);
00330   int GetFlag(const char* field);
00331   void CopyFlags(const vtkFieldData* source);
00332   int DoCopyAllOn;
00333   int DoCopyAllOff;
00334 
00335 
00336 private:
00337   vtkFieldData(const vtkFieldData&);  // Not implemented.
00338   void operator=(const vtkFieldData&);  // Not implemented.
00339 
00340 public:
00341 
00342   class VTK_FILTERING_EXPORT BasicIterator
00343   {
00344   public:
00345     BasicIterator();
00346     BasicIterator(const BasicIterator& source);
00347     BasicIterator(const int* list, unsigned int listSize);
00348     BasicIterator& operator=(const BasicIterator& source);
00349     virtual ~BasicIterator();
00350 
00351     int GetListSize() const
00352       {
00353         return this->ListSize;
00354       }
00355     int GetCurrentIndex()
00356       {
00357         return this->List[this->Position];
00358       }
00359     int BeginIndex()
00360       {
00361         this->Position = -1;
00362         return this->NextIndex();
00363       }
00364     int End() const
00365       {
00366         return (this->Position >= this->ListSize);
00367       }
00368     int NextIndex()
00369       {
00370         this->Position++;
00371         return (this->End() ? -1 : this->List[this->Position]);
00372       }
00373     
00374   protected:
00375 
00376     int* List;
00377     int ListSize;
00378     int Position;
00379   };
00380 
00381   class VTK_FILTERING_EXPORT Iterator : public BasicIterator
00382   {
00383   public:
00384 
00385     Iterator(const Iterator& source);
00386     Iterator& operator=(const Iterator& source);
00387     virtual ~Iterator();
00388     Iterator(vtkFieldData* dsa, const int* list=0, 
00389              unsigned int listSize=0);
00390 
00391     vtkDataArray* Begin()
00392       {
00393         this->Position = -1;
00394         return this->Next();
00395       }
00396 
00397     vtkDataArray* Next()
00398       {
00399         this->Position++;
00400         return (this->End() ? 0 : 
00401                 Fields->GetArray(this->List[this->Position]));
00402       }
00403 
00404     void DetachFieldData();
00405 
00406   protected:
00407     vtkFieldData* Fields;
00408     int Detached;
00409   };
00410 
00411 
00412 //ETX
00413 
00414 };
00415 
00416 
00417 #endif