• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

dox/Filtering/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 "vtkAbstractArray.h" // Needed for inline methods.
00051 
00052 #ifndef VTK_LEGACY_REMOVE
00053 # include "vtkDataArray.h" // Needed for backwards compatibility.
00054 #endif
00055 
00056 class vtkIdList;
00057 
00058 class VTK_FILTERING_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 
00075   void CopyStructure(vtkFieldData*);
00076 
00083   void AllocateArrays(int num);
00084 
00086 
00089   int GetNumberOfArrays()
00090     {
00091       return this->NumberOfActiveArrays;
00092     }
00094 
00097   int AddArray(vtkAbstractArray *array);
00098 
00100 
00101   virtual void RemoveArray(const char *name)
00102     {
00103       int i;
00104       this->GetAbstractArray(name, i);
00105       this->RemoveArray(i);
00106     }
00108 
00112   vtkDataArray *GetArray(int i);
00113 
00118   vtkDataArray *GetArray(const char *arrayName, int &index);
00119 
00121 
00124   vtkDataArray *GetArray(const char *arrayName)
00125     {
00126       int i;
00127       return this->GetArray(arrayName, i);
00128     }
00130 
00134   vtkAbstractArray* GetAbstractArray(int i);
00135 
00139   vtkAbstractArray* GetAbstractArray(const char* arrayName, int &index);
00140 
00142 
00144   vtkAbstractArray* GetAbstractArray(const char* arrayName)
00145     {
00146     int i;
00147     return this->GetAbstractArray(arrayName, i);
00148     }
00150   
00152 
00153   int HasArray(const char *name)
00154     {
00155       int i;
00156       vtkAbstractArray *array = this->GetAbstractArray(name, i);
00157       // assert( i == -1);
00158       return array ? 1 : 0;
00159     }
00161 
00163 
00165   const char* GetArrayName(int i)
00166     {
00167     vtkAbstractArray* da = this->GetAbstractArray(i);
00168     return da ? da->GetName() : 0;
00169     }
00171 
00174   virtual void PassData(vtkFieldData* fd);
00175 
00177 
00182   void CopyFieldOn(const char* name) { this->CopyFieldOnOff(name, 1); }
00183   void CopyFieldOff(const char* name) { this->CopyFieldOnOff(name, 0); }
00185 
00191   virtual void CopyAllOn(int unused=0);
00192 
00198   virtual void CopyAllOff(int unused=0);
00199 
00201   virtual void DeepCopy(vtkFieldData *da);
00202 
00204   virtual void ShallowCopy(vtkFieldData *da);
00205 
00208   void Squeeze();
00209 
00212   void Reset();
00213 
00218   virtual unsigned long GetActualMemorySize();
00219 
00221   unsigned long int GetMTime();
00222   
00230   void GetField(vtkIdList *ptId, vtkFieldData *f);
00231 
00237   int GetArrayContainingComponent(int i, int& arrayComp);
00238 
00245   int GetNumberOfComponents();
00246 
00254   vtkIdType GetNumberOfTuples();
00255 
00261   void SetNumberOfTuples(const vtkIdType number);
00262 
00266   void SetTuple(const vtkIdType i, const vtkIdType j, vtkFieldData* source);
00267 
00270   void InsertTuple(const vtkIdType i, const vtkIdType j, vtkFieldData* source);
00271 
00275   vtkIdType InsertNextTuple(const vtkIdType j, vtkFieldData* source);
00276 
00277   // Following are LEGACY methods. Using these methods for FieldData
00278   // having arrays that are not subclasses of vtkDataArray may
00279   // yield unexpected results.
00280   
00286   VTK_LEGACY(double *GetTuple(const vtkIdType i));
00287 
00292   VTK_LEGACY(void GetTuple(const vtkIdType i, double * tuple));
00293 
00298   VTK_LEGACY(void SetTuple(const vtkIdType i, const double * tuple));
00299 
00304   VTK_LEGACY(void InsertTuple(const vtkIdType i, const double * tuple));
00305 
00310   VTK_LEGACY(vtkIdType InsertNextTuple(const double * tuple));
00311   
00316   VTK_LEGACY(double GetComponent(const vtkIdType i, const int j));
00317 
00323   VTK_LEGACY(void SetComponent(const vtkIdType i, const int j, const double c));
00324   
00330   VTK_LEGACY(void InsertComponent(const vtkIdType i, const int j, const double c));
00331 protected:
00332 
00333   vtkFieldData();
00334   ~vtkFieldData();
00335 
00336   int NumberOfArrays;
00337   int NumberOfActiveArrays;
00338   vtkAbstractArray **Data;
00339 
00341   void SetArray(int i, vtkAbstractArray *array);
00342 
00343   virtual void RemoveArray(int index);
00344 
00346   virtual void InitializeFields();
00347 
00348 //BTX
00349 
00350   struct CopyFieldFlag
00351   {
00352     char* ArrayName;
00353     int IsCopied;
00354   };
00355 
00356   CopyFieldFlag* CopyFieldFlags; //the names of fields not to be copied
00357   int NumberOfFieldFlags; //the number of fields not to be copied
00358   void CopyFieldOnOff(const char* name, int onOff);
00359   void ClearFieldFlags();
00360   int FindFlag(const char* field);
00361   int GetFlag(const char* field);
00362   void CopyFlags(const vtkFieldData* source);
00363   int DoCopyAllOn;
00364   int DoCopyAllOff;
00365 
00366 
00367 private:
00368   vtkFieldData(const vtkFieldData&);  // Not implemented.
00369   void operator=(const vtkFieldData&);  // Not implemented.
00370 
00371 #ifndef VTK_LEGACY_REMOVE
00372   // Must be removed when support for Legacy GetTuple is removed.
00373   int TupleSize; // used for type conversion in Legacy support.
00374   double* Tuple;
00375 #endif
00376 public:
00377 
00378   class VTK_FILTERING_EXPORT BasicIterator
00379   {
00380   public:
00381     BasicIterator();
00382     BasicIterator(const BasicIterator& source);
00383     BasicIterator(const int* list, unsigned int listSize);
00384     BasicIterator& operator=(const BasicIterator& source);
00385     virtual ~BasicIterator();
00386     void PrintSelf(ostream &os, vtkIndent indent);
00387 
00388     int GetListSize() const
00389       {
00390         return this->ListSize;
00391       }
00392     int GetCurrentIndex()
00393       {
00394         return this->List[this->Position];
00395       }
00396     int BeginIndex()
00397       {
00398         this->Position = -1;
00399         return this->NextIndex();
00400       }
00401     int End() const
00402       {
00403         return (this->Position >= this->ListSize);
00404       }
00405     int NextIndex()
00406       {
00407         this->Position++;
00408         return (this->End() ? -1 : this->List[this->Position]);
00409       }
00410     
00411   protected:
00412 
00413     int* List;
00414     int ListSize;
00415     int Position;
00416   };
00417 
00418   class VTK_FILTERING_EXPORT Iterator : public BasicIterator
00419   {
00420   public:
00421 
00422     Iterator(const Iterator& source);
00423     Iterator& operator=(const Iterator& source);
00424     virtual ~Iterator();
00425     Iterator(vtkFieldData* dsa, const int* list=0, 
00426              unsigned int listSize=0);
00427 
00428     vtkDataArray* Begin()
00429       {
00430         this->Position = -1;
00431         return this->Next();
00432       }
00433 
00434     vtkDataArray* Next()
00435       {
00436         this->Position++;
00437         if (this->End())
00438           {
00439           return 0;
00440           }
00441       
00442         // vtkFieldData::GetArray() can return null, which implies that
00443         // a the array at the given index in not a vtkDataArray subclass.
00444         // This iterator skips such arrays.
00445         vtkDataArray* cur =  Fields->GetArray(this->List[this->Position]);
00446         return (cur? cur : this->Next());
00447       }
00448 
00449     void DetachFieldData();
00450 
00451   protected:
00452     vtkFieldData* Fields;
00453     int Detached;
00454   };
00455 
00456 
00457 //ETX
00458 
00459 };
00460 
00461 
00462 #endif

Generated by  doxygen 1.7.1