Common/vtkVoidArray.h Source File

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

# Common/vtkVoidArray.h

Go to the documentation of this file.

    00001 /*=========================================================================
    00002
    00003   Program:   Visualization Toolkit
    00004   Module:    $RCSfile: vtkVoidArray.h,v $
    00005   Language:  C++
    00006
    00007   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen
    00008   All rights reserved.
    00009   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
    00010
    00011      This software is distributed WITHOUT ANY WARRANTY; without even
    00012      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
    00013      PURPOSE.  See the above copyright notice for more information.
    00014
    00015 =========================================================================*/
    00042 #ifndef __vtkVoidArray_h
    00043 #define __vtkVoidArray_h
    00044
    00045 #include "vtkDataArray.h"
    00046
    00047 class VTK_COMMON_EXPORT vtkVoidArray : public vtkDataArray
    00048 {
    00049 public:
    00050   static vtkVoidArray *New();
    00051
    00052   vtkTypeRevisionMacro(vtkVoidArray,vtkDataArray);
    00053   void PrintSelf(ostream& os, vtkIndent indent);
    00054
    00057   int Allocate(const vtkIdType sz, const vtkIdType ext=1000);
    00058
    00060   void Initialize();
    00061
    00063   int GetDataType() {return VTK_VOID;};
    00064
    00066   int GetDataTypeSize() { return sizeof(void*); }
    00067
    00069   void SetNumberOfTuples(const vtkIdType number);
    00070
    00072   float *GetTuple(const vtkIdType i);
    00073
    00075
    00076   void GetTuple(const vtkIdType i, float * tuple);
    00077   void GetTuple(const vtkIdType i, double * tuple);
    00079
    00081
    00082   void SetTuple(const vtkIdType i, const float * tuple);
    00083   void SetTuple(const vtkIdType i, const double * tuple);
    00085
    00087
    00089   void InsertTuple(const vtkIdType i, const float * tuple);
    00090   void InsertTuple(const vtkIdType i, const double * tuple);
    00092
    00094
    00096   vtkIdType InsertNextTuple(const float * tuple);
    00097   vtkIdType InsertNextTuple(const double * tuple);
    00099
    00101   void Squeeze() {this->ResizeAndExtend (this->MaxId+1);};
    00102
    00104   virtual void Resize(vtkIdType numTuples);
    00105
    00107   void* GetValue(const vtkIdType id) {return this->Array[id];};
    00108
    00112   void SetNumberOfValues(const vtkIdType number);
    00113
    00116   void SetValue(const vtkIdType id, void *value);
    00117
    00119   void InsertValue(const vtkIdType id, void* p);
    00120
    00123   vtkIdType InsertNextValue(void* v);
    00124
    00126
    00128   void** GetPointer(const vtkIdType id) {return this->Array + id;}
    00129   void *GetVoidPointer(const vtkIdType id) {return this->GetPointer(id);};
    00131
    00135   void** WritePointer(const vtkIdType id, const vtkIdType number);
    00136
    00138   void DeepCopy(vtkDataArray *da);
    00139
    00140
    00141 protected:
    00142   vtkVoidArray();
    00143   ~vtkVoidArray();
    00144
    00145   void** Array;  // pointer to data
    00146   void** ResizeAndExtend(const vtkIdType sz);  // function to resize data
    00147
    00148   int TupleSize; //used for data conversion
    00149   float *Tuple;
    00150 private:
    00151   vtkVoidArray(const vtkVoidArray&);  // Not implemented.
    00152   void operator=(const vtkVoidArray&);  // Not implemented.
    00153 };
    00154
    00155
    00156 inline void vtkVoidArray::SetNumberOfValues(const vtkIdType number)
    00157 {
    00158   this->Allocate(number);
    00159   this->MaxId = number - 1;
    00160 }
    00161
    00162 inline void vtkVoidArray::SetValue(const vtkIdType id, void *value)
    00163 {
    00164   this->Array[id] = value;
    00165 }
    00166
    00167 inline void** vtkVoidArray::WritePointer(const vtkIdType id,
    00168                                          const vtkIdType number)
    00169 {
    00170   vtkIdType newSize=id+number;
    00171   if ( newSize > this->Size )
    00172     {
    00173     this->ResizeAndExtend(newSize);
    00174     }
    00175   if ( (--newSize) > this->MaxId )
    00176     {
    00177     this->MaxId = newSize;
    00178     }
    00179   return this->Array + id;
    00180 }
    00181
    00182 inline void vtkVoidArray::InsertValue(const vtkIdType id, void* p)
    00183 {
    00184   if ( id >= this->Size )
    00185     {
    00186     this->ResizeAndExtend(id+1);
    00187     }
    00188   this->Array[id] = p;
    00189   if ( id > this->MaxId )
    00190     {
    00191     this->MaxId = id;
    00192     }
    00193 }
    00194
    00195 inline vtkIdType vtkVoidArray::InsertNextValue(void* p)
    00196 {
    00197   this->InsertValue (++this->MaxId,p);
    00198   return this->MaxId;
    00199 }
    00200
    00201
    00202 #endif