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

Common/vtkDataArray.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkDataArray.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 =========================================================================*/
00075 #ifndef __vtkDataArray_h
00076 #define __vtkDataArray_h
00077 
00078 #include "vtkObject.h"
00079 #include "vtkLargeInteger.h"
00080 
00081 class vtkFloatArray;
00082 class vtkLookupTable;
00083 class vtkIdList;
00084 
00085 class VTK_COMMON_EXPORT vtkDataArray : public vtkObject 
00086 {
00087 public:
00088   vtkTypeMacro(vtkDataArray,vtkObject);
00089   void PrintSelf(ostream& os, vtkIndent indent);
00090 
00092 
00094   virtual int Allocate(const vtkIdType sz, const vtkIdType ext=1000) = 0;
00095   virtual void Initialize() = 0;
00097 
00101   virtual vtkDataArray *MakeObject() = 0;
00102 
00105   virtual int GetDataType() = 0;
00106 
00108 
00110   vtkSetClampMacro(NumberOfComponents,int,1,VTK_LARGE_INTEGER);
00111   int GetNumberOfComponents() {return this->NumberOfComponents;};
00113 
00116   virtual void SetNumberOfTuples(const vtkIdType number) = 0;
00117 
00119 
00120   vtkIdType GetNumberOfTuples() 
00121     {return (this->MaxId + 1)/this->NumberOfComponents;}
00123 
00128   virtual float *GetTuple(const vtkIdType i) = 0;
00129 
00131 
00134   virtual void GetTuple(const vtkIdType i, float * tuple) = 0;
00135   virtual void GetTuple(const vtkIdType i, double * tuple);
00137 
00139 
00142   float GetTuple1(const vtkIdType i);
00143   float* GetTuple2(const vtkIdType i);
00144   float* GetTuple3(const vtkIdType i);
00145   float* GetTuple4(const vtkIdType i);
00146   float* GetTuple9(const vtkIdType i);
00148 
00152   void GetTuples(vtkIdList *ptIds, vtkDataArray *output);
00153 
00157   void GetTuples(vtkIdType p1, vtkIdType p2, vtkDataArray *output);
00158 
00160 
00163   virtual void SetTuple(const vtkIdType i, const float * tuple) = 0;
00164   virtual void SetTuple(const vtkIdType i, const double * tuple);
00166 
00168 
00171   void SetTuple1(const vtkIdType i, float value);
00172   void SetTuple2(const vtkIdType i, float val0, float val1);
00173   void SetTuple3(const vtkIdType i, float val0, float val1, float val2);
00174   void SetTuple4(const vtkIdType i, float val0, float val1, float val2,
00175                  float val3);
00176   void SetTuple9(const vtkIdType i, float val0, float val1, float val2,
00177                  float val3, float val4, float val5, float val6,
00178                  float val7, float val8);
00180 
00182 
00184   virtual void InsertTuple(const vtkIdType i, const float * tuple) = 0;
00185   virtual void InsertTuple(const vtkIdType i, const double * tuple);
00187 
00189 
00192   void InsertTuple1(const vtkIdType i, float value);
00193   void InsertTuple2(const vtkIdType i, float val0, float val1);
00194   void InsertTuple3(const vtkIdType i, float val0, float val1, float val2);
00195   void InsertTuple4(const vtkIdType i, float val0, float val1, float val2,
00196                     float val3);
00197   void InsertTuple9(const vtkIdType i, float val0, float val1, float val2,
00198                     float val3, float val4, float val5, float val6,
00199                     float val7, float val8);
00201 
00203 
00206   virtual vtkIdType InsertNextTuple(const float * tuple) = 0;
00207   virtual vtkIdType InsertNextTuple(const double * tuple);
00209 
00211 
00214   void InsertNextTuple1(float value);
00215   void InsertNextTuple2(float val0, float val1);
00216   void InsertNextTuple3(float val0, float val1, float val2);
00217   void InsertNextTuple4(float val0, float val1, float val2,
00218                         float val3);
00219   void InsertNextTuple9(float val0, float val1, float val2,
00220                         float val3, float val4, float val5, float val6,
00221                         float val7, float val8);
00223 
00227   virtual float GetComponent(const vtkIdType i, const int j);
00228 
00233   virtual void SetComponent(const vtkIdType i, const int j, const float c);
00234 
00238   virtual void InsertComponent(const vtkIdType i, const int j, const float c);
00239 
00241 
00247   virtual void GetData(vtkIdType tupleMin, vtkIdType tupleMax, int compMin,
00248                        int compMax, vtkFloatArray* data);
00250 
00253   virtual void DeepCopy(vtkDataArray *da);
00254 
00259   virtual void FillComponent(const int j, const float c);
00260 
00262 
00268   virtual void CopyComponent(const int j, vtkDataArray *from,
00269                              const int fromComponent);
00271 
00274   virtual void *GetVoidPointer(const vtkIdType id) = 0;
00275 
00277   virtual void Squeeze() = 0;
00278 
00280   virtual void Resize(vtkIdType numTuples) = 0;
00281 
00283 
00284   void Reset() 
00285     {this->MaxId = -1;}
00287 
00289 
00290   vtkIdType GetSize() 
00291     {return this->Size;}
00293   
00295 
00296   vtkIdType GetMaxId() 
00297     {return this->MaxId;}
00299 
00301 
00307   virtual void SetVoidArray(void *vtkNotUsed(array),
00308                             vtkIdType vtkNotUsed(size),
00309                             int vtkNotUsed(save)) {};
00311 
00318   unsigned long GetActualMemorySize();
00319   
00322   void CreateDefaultLookupTable();
00323 
00325 
00326   void SetLookupTable(vtkLookupTable *lut);
00327   vtkGetObjectMacro(LookupTable,vtkLookupTable);
00329   
00331 
00332   void SetName(const char* name);
00333   const char* GetName();
00335 
00337 
00339   void GetRange(float range[2], int comp)
00340     {
00341       this->ComputeRange(comp);
00342       memcpy(range, this->Range, 2*sizeof(float));
00343     }
00344   float* GetRange(int comp)
00345     {
00346       this->ComputeRange(comp);
00347       return this->Range;
00348     }
00350 
00351   virtual void ComputeRange(int comp);
00353 
00355   float* GetRange()
00356     {
00357       this->ComputeRange(0);
00358       return this->Range;
00359     }
00360   void GetRange(float range[2])
00361     {
00362       this->GetRange(range,0);
00363     }
00365 
00367 
00370   void GetDataTypeRange(double range[2]);
00371   double GetDataTypeMin();
00372   double GetDataTypeMax();
00374 
00377   virtual float GetMaxNorm();
00378 
00384   static vtkDataArray* CreateDataArray(int dataType);
00385 
00386 protected:
00387   // Construct object with default tuple dimension (number of components) of 1.
00388   vtkDataArray(vtkIdType numComp=1);
00389   ~vtkDataArray();
00390 
00391   vtkLookupTable *LookupTable;
00392 
00393   vtkIdType Size;      // allocated size of data
00394   vtkIdType MaxId;     // maximum index inserted thus far
00395   int NumberOfComponents; // the number of components per tuple
00396 
00397   char* Name;
00398 
00399 private:
00400   float Range[2];
00401   int ComponentForLastRange;
00402   vtkTimeStamp ComputeTimeForLastRange;
00403 
00404   float* GetTupleN(const vtkIdType i, int n);
00405   
00406 private:
00407   vtkDataArray(const vtkDataArray&);  // Not implemented.
00408   void operator=(const vtkDataArray&);  // Not implemented.
00409 };
00410 
00411 #endif

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