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 
00008 Copyright (c) 1993-2001 Ken Martin, Will Schroeder, Bill Lorensen 
00009 All rights reserved.
00010 
00011 Redistribution and use in source and binary forms, with or without
00012 modification, are permitted provided that the following conditions are met:
00013 
00014  * Redistributions of source code must retain the above copyright notice,
00015    this list of conditions and the following disclaimer.
00016 
00017  * Redistributions in binary form must reproduce the above copyright notice,
00018    this list of conditions and the following disclaimer in the documentation
00019    and/or other materials provided with the distribution.
00020 
00021  * Neither name of Ken Martin, Will Schroeder, or Bill Lorensen nor the names
00022    of any contributors may be used to endorse or promote products derived
00023    from this software without specific prior written permission.
00024 
00025  * Modified source versions must be plainly marked as such, and must not be
00026    misrepresented as being the original software.
00027 
00028 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
00029 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00030 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00031 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
00032 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00033 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00034 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00035 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00036 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00037 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00038 
00039 =========================================================================*/
00073 #ifndef __vtkFieldData_h
00074 #define __vtkFieldData_h
00075 
00076 #include "vtkDataArray.h"
00077 #include "vtkIdList.h"
00078 
00079 class VTK_COMMON_EXPORT vtkFieldData : public vtkObject
00080 {
00081 public:
00082   static vtkFieldData *New();
00083 
00084   vtkTypeMacro(vtkFieldData,vtkObject);
00085   void PrintSelf(ostream& os, vtkIndent indent);
00086 
00088   virtual void Initialize();
00089 
00091   int Allocate(const vtkIdType sz, const vtkIdType ext=1000);
00092 
00095   vtkFieldData *MakeObject();
00096 
00103   void AllocateArrays(int num);
00104 
00105 #ifndef VTK_REMOVE_LEGACY_CODE
00106   void SetNumberOfArrays(int num)
00107     {
00108       vtkWarningMacro("This method will be deprecated. Please use "
00109                       "AllocateArrays() instead.");
00110       this->AllocateArrays(num);
00111     }
00112 #endif
00113 
00117   int GetNumberOfArrays();
00118 
00121   int AddArray(vtkDataArray *array);
00122 
00124 
00125   virtual void RemoveArray(const char *name)
00126     {
00127       int i;
00128       this->GetArray(name, i);
00129       this->RemoveArray(i);
00130     }
00132 
00135   vtkDataArray *GetArray(int i);
00136 
00139   vtkDataArray *GetArray(const char *arrayName, int &index);
00140 
00141   // Return the array with the name given. Returns NULL is array not found.
00142   vtkDataArray *GetArray(const char *arrayName);
00143 
00145 
00147   const char* GetArrayName(int i)
00148     {
00149       vtkDataArray* da;
00150       if ((da=this->GetArray(i)))
00151         {
00152         return da->GetName();
00153         }
00154       else
00155         {
00156         return 0;
00157         }
00158     }
00160 
00163   virtual void PassData(vtkFieldData* fd);
00164 
00166 
00171   void CopyFieldOn(const char* name) { this->CopyFieldOnOff(name, 1); }
00172   void CopyFieldOff(const char* name) { this->CopyFieldOnOff(name, 0); }
00174 
00180   virtual void CopyAllOn();
00181 
00187   virtual void CopyAllOff();
00188 
00190   virtual void DeepCopy(vtkFieldData *da);
00191 
00193   virtual void ShallowCopy(vtkFieldData *da);
00194 
00197   void Squeeze();
00198 
00201   void Reset();
00202 
00207   virtual unsigned long GetActualMemorySize();
00208 
00210   unsigned long int GetMTime();
00211   
00218   void GetField(vtkIdList *ptId, vtkFieldData *f);
00219 
00228   int GetArrayContainingComponent(int i, int& arrayComp);
00229 
00236   int GetNumberOfComponents();
00237 
00245   vtkIdType GetNumberOfTuples();
00246 
00252   void SetNumberOfTuples(const vtkIdType number);
00253 
00260   float *GetTuple(const vtkIdType i);
00261 
00268   void GetTuple(const vtkIdType i, float * tuple);
00269 
00276   void SetTuple(const vtkIdType i, const float * tuple);
00277 
00284   void InsertTuple(const vtkIdType i, const float * tuple);
00285 
00292   vtkIdType InsertNextTuple(const float * tuple);
00293 
00299   float GetComponent(const vtkIdType i, const int j);
00300 
00308   void SetComponent(const vtkIdType i, const int j, const float c);
00309   
00317   void InsertComponent(const vtkIdType i, const int j, const float c);
00318 
00319 protected:
00320 
00321   vtkFieldData();
00322   ~vtkFieldData();
00323 
00324   int NumberOfArrays;
00325   int NumberOfActiveArrays;
00326   vtkDataArray **Data;
00327 
00328   int TupleSize; //used for type conversion
00329   float *Tuple;
00330 
00332   void SetArray(int i, vtkDataArray *array);
00333 
00334   virtual void RemoveArray(int index);
00335 
00336 //BTX
00337 
00338 public:
00339 
00340   class VTK_COMMON_EXPORT BasicIterator
00341   {
00342   public:
00343     BasicIterator();
00344     BasicIterator(const BasicIterator& source);
00345     BasicIterator(const int* list, unsigned int listSize);
00346     BasicIterator& operator=(const BasicIterator& source);
00347     virtual ~BasicIterator();
00348 
00349     int GetListSize() const
00350       {
00351         return this->ListSize;
00352       }
00353     int GetCurrentIndex()
00354       {
00355         return this->List[this->Position];
00356       }
00357     int BeginIndex()
00358       {
00359         this->Position = -1;
00360         return this->NextIndex();
00361       }
00362     int End() const
00363       {
00364         return (this->Position >= this->ListSize);
00365       }
00366     int NextIndex()
00367       {
00368         this->Position++;
00369         return (this->End() ? -1 : this->List[this->Position]);
00370       }
00371     
00372   protected:
00373     int IsInList(int index);
00374 
00375     int* List;
00376     int ListSize;
00377     int Position;
00378   };
00379 
00380   class VTK_COMMON_EXPORT Iterator : public BasicIterator
00381   {
00382   public:
00383 
00384     Iterator();
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   struct CopyFieldFlag
00412   {
00413     char* ArrayName;
00414     int IsCopied;
00415   };
00416 
00417   CopyFieldFlag* CopyFieldFlags; //the names of fields not to be copied
00418   int NumberOfFieldFlags; //the number of fields not to be copied
00419   void CopyFieldOnOff(const char* name, int onOff);
00420   void ClearFieldFlags();
00421   int FindFlag(const char* field);
00422   int GetFlag(const char* field);
00423   void CopyFlags(const vtkFieldData* source);
00424   int DoCopyAllOn;
00425   int DoCopyAllOff;
00426 
00427 //ETX
00428 
00429 private:
00430   vtkFieldData(const vtkFieldData&);  // Not implemented.
00431   void operator=(const vtkFieldData&);  // Not implemented.
00432 };
00433 
00434 
00435 #endif

Generated on Thu Mar 28 14:19:15 2002 for VTK by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001