Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | 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 =========================================================================*/
00045 #ifndef __vtkFieldData_h
00046 #define __vtkFieldData_h
00047 
00048 #include "vtkObject.h"
00049 
00050 #include "vtkDataArray.h" // Needed for inline methods
00051 
00052 class vtkIdList;
00053 
00054 class VTK_FILTERING_EXPORT vtkFieldData : public vtkObject
00055 {
00056 public:
00057   static vtkFieldData *New();
00058 
00059   vtkTypeRevisionMacro(vtkFieldData,vtkObject);
00060   void PrintSelf(ostream& os, vtkIndent indent);
00061 
00064   virtual void Initialize();
00065 
00067   int Allocate(const vtkIdType sz, const vtkIdType ext=1000);
00068 
00071   void CopyStructure(vtkFieldData*);
00072 
00079   void AllocateArrays(int num);
00080 
00082 
00085   int GetNumberOfArrays()
00086     {
00087       return this->NumberOfActiveArrays;
00088     }
00090 
00093   int AddArray(vtkDataArray *array);
00094 
00096 
00097   virtual void RemoveArray(const char *name)
00098     {
00099       int i;
00100       this->GetArray(name, i);
00101       this->RemoveArray(i);
00102     }
00104 
00107   vtkDataArray *GetArray(int i);
00108 
00111   vtkDataArray *GetArray(const char *arrayName, int &index);
00112 
00114 
00116   vtkDataArray *GetArray(const char *arrayName)
00117     {
00118       int i;
00119       return this->GetArray(arrayName, i);
00120     }
00122 
00124 
00125   int HasArray(const char *name)
00126     {
00127       int i;
00128       vtkDataArray *array = this->GetArray(name, i);
00129       // assert( i == -1);
00130       return array ? 1 : 0;
00131     }
00133 
00135 
00137   const char* GetArrayName(int i)
00138     {
00139     vtkDataArray* da = this->GetArray(i);
00140     return da ? da->GetName() : 0;
00141     }
00143 
00146   virtual void PassData(vtkFieldData* fd);
00147 
00149 
00154   void CopyFieldOn(const char* name) { this->CopyFieldOnOff(name, 1); }
00155   void CopyFieldOff(const char* name) { this->CopyFieldOnOff(name, 0); }
00157 
00163   virtual void CopyAllOn();
00164 
00170   virtual void CopyAllOff();
00171 
00173   virtual void DeepCopy(vtkFieldData *da);
00174 
00176   virtual void ShallowCopy(vtkFieldData *da);
00177 
00180   void Squeeze();
00181 
00184   void Reset();
00185 
00190   virtual unsigned long GetActualMemorySize();
00191 
00193   unsigned long int GetMTime();
00194   
00202   void GetField(vtkIdList *ptId, vtkFieldData *f);
00203 
00212   int GetArrayContainingComponent(int i, int& arrayComp);
00213 
00220   int GetNumberOfComponents();
00221 
00229   vtkIdType GetNumberOfTuples();
00230 
00236   void SetNumberOfTuples(const vtkIdType number);
00237 
00244   double *GetTuple(const vtkIdType i);
00245 
00252   void GetTuple(const vtkIdType i, double * tuple);
00253 
00260   void SetTuple(const vtkIdType i, const double * tuple);
00261 
00268   void InsertTuple(const vtkIdType i, const double * tuple);
00269 
00276   vtkIdType InsertNextTuple(const double * tuple);
00277 
00283   double GetComponent(const vtkIdType i, const int j);
00284 
00292   void SetComponent(const vtkIdType i, const int j, const double c);
00293   
00301   void InsertComponent(const vtkIdType i, const int j, const double c);
00302 
00303 protected:
00304 
00305   vtkFieldData();
00306   ~vtkFieldData();
00307 
00308   int NumberOfArrays;
00309   int NumberOfActiveArrays;
00310   vtkDataArray **Data;
00311 
00312   int TupleSize; //used for type conversion
00313   double *Tuple;
00314 
00316   void SetArray(int i, vtkDataArray *array);
00317 
00318   virtual void RemoveArray(int index);
00319 
00321   virtual void InitializeFields();
00322 
00323 //BTX
00324 
00325   struct CopyFieldFlag
00326   {
00327     char* ArrayName;
00328     int IsCopied;
00329   };
00330 
00331   CopyFieldFlag* CopyFieldFlags; //the names of fields not to be copied
00332   int NumberOfFieldFlags; //the number of fields not to be copied
00333   void CopyFieldOnOff(const char* name, int onOff);
00334   void ClearFieldFlags();
00335   int FindFlag(const char* field);
00336   int GetFlag(const char* field);
00337   void CopyFlags(const vtkFieldData* source);
00338   int DoCopyAllOn;
00339   int DoCopyAllOff;
00340 
00341 
00342 private:
00343   vtkFieldData(const vtkFieldData&);  // Not implemented.
00344   void operator=(const vtkFieldData&);  // Not implemented.
00345 
00346 public:
00347 
00348   class VTK_FILTERING_EXPORT BasicIterator
00349   {
00350   public:
00351     BasicIterator();
00352     BasicIterator(const BasicIterator& source);
00353     BasicIterator(const int* list, unsigned int listSize);
00354     BasicIterator& operator=(const BasicIterator& source);
00355     virtual ~BasicIterator();
00356 
00357     int GetListSize() const
00358       {
00359         return this->ListSize;
00360       }
00361     int GetCurrentIndex()
00362       {
00363         return this->List[this->Position];
00364       }
00365     int BeginIndex()
00366       {
00367         this->Position = -1;
00368         return this->NextIndex();
00369       }
00370     int End() const
00371       {
00372         return (this->Position >= this->ListSize);
00373       }
00374     int NextIndex()
00375       {
00376         this->Position++;
00377         return (this->End() ? -1 : this->List[this->Position]);
00378       }
00379     
00380   protected:
00381 
00382     int* List;
00383     int ListSize;
00384     int Position;
00385   };
00386 
00387   class VTK_FILTERING_EXPORT Iterator : public BasicIterator
00388   {
00389   public:
00390 
00391     Iterator(const Iterator& source);
00392     Iterator& operator=(const Iterator& source);
00393     virtual ~Iterator();
00394     Iterator(vtkFieldData* dsa, const int* list=0, 
00395              unsigned int listSize=0);
00396 
00397     vtkDataArray* Begin()
00398       {
00399         this->Position = -1;
00400         return this->Next();
00401       }
00402 
00403     vtkDataArray* Next()
00404       {
00405         this->Position++;
00406         return (this->End() ? 0 : 
00407                 Fields->GetArray(this->List[this->Position]));
00408       }
00409 
00410     void DetachFieldData();
00411 
00412   protected:
00413     vtkFieldData* Fields;
00414     int Detached;
00415   };
00416 
00417 
00418 //ETX
00419 
00420 };
00421 
00422 
00423 #endif

Generated on Mon Jan 21 23:07:19 2008 for VTK by  doxygen 1.4.3-20050530