Common/vtkLongArray.h Source File

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

# Common/vtkLongArray.h

Go to the documentation of this file.

    00001 /*=========================================================================
    00002
    00003   Program:   Visualization Toolkit
    00004   Module:    $RCSfile: vtkLongArray.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 =========================================================================*/
    00045 #ifndef __vtkLongArray_h
    00046 #define __vtkLongArray_h
    00047
    00048 #include "vtkDataArray.h"
    00049
    00050 class VTK_COMMON_EXPORT vtkLongArray : public vtkDataArray
    00051 {
    00052 public:
    00053   static vtkLongArray *New();
    00054
    00055   vtkTypeRevisionMacro(vtkLongArray,vtkDataArray);
    00056   void PrintSelf(ostream& os, vtkIndent indent);
    00057
    00060   int Allocate(const vtkIdType sz, const vtkIdType ext=1000);
    00061
    00063   void Initialize();
    00064
    00066   void Squeeze() {this->ResizeAndExtend (this->MaxId+1);};
    00067
    00069   virtual void Resize(vtkIdType numTuples);
    00070
    00072   int GetDataType() {return VTK_LONG;};
    00073
    00075   int GetDataTypeSize() { return sizeof(long); }
    00076
    00078   void SetNumberOfTuples(const vtkIdType number);
    00079
    00082   float *GetTuple(const vtkIdType i);
    00083
    00085
    00086   void GetTuple(const vtkIdType i, float * tuple);
    00087   void GetTuple(const vtkIdType i, double * tuple);
    00089
    00091
    00092   void SetTuple(const vtkIdType i, const float * tuple);
    00093   void SetTuple(const vtkIdType i, const double * tuple);
    00095
    00097
    00099   void InsertTuple(const vtkIdType i, const float * tuple);
    00100   void InsertTuple(const vtkIdType i, const double * tuple);
    00102
    00104
    00106   vtkIdType InsertNextTuple(const float * tuple);
    00107   vtkIdType InsertNextTuple(const double * tuple);
    00109
    00111   long GetValue(const vtkIdType id) {return this->Array[id];};
    00112
    00116   void SetNumberOfValues(const vtkIdType number);
    00117
    00119
    00121   void SetValue(const vtkIdType id, const long value)
    00122     { this->Array[id] = value;};
    00124
    00126   void InsertValue(const vtkIdType id, const long i);
    00127
    00130   vtkIdType InsertNextValue(const long);
    00131
    00135   float GetComponent(const vtkIdType i, const int j);
    00136
    00141   void SetComponent(const vtkIdType i, const int j, float c);
    00142
    00146   virtual void InsertComponent(const vtkIdType i, const int j, float c);
    00147
    00149
    00151   long *GetPointer(const vtkIdType id) {return this->Array + id;}
    00152   void *GetVoidPointer(const vtkIdType id)
    00153     {return (void *)this->GetPointer(id);};
    00155
    00159   long *WritePointer(const vtkIdType id, const vtkIdType number);
    00160
    00162   void DeepCopy(vtkDataArray *da);
    00163
    00165
    00171   void SetArray(long* array, vtkIdType size, int save);
    00172   void SetVoidArray(void *array, vtkIdType size, int save)
    00173     {this->SetArray((long*)array, size, save);};
    00175
    00176 protected:
    00177   vtkLongArray(vtkIdType numComp=1);
    00178   ~vtkLongArray();
    00179
    00180   long *Array;   // pointer to data
    00181   long *ResizeAndExtend(const vtkIdType sz);  // function to resize data
    00182
    00183   int TupleSize; //used for data conversion
    00184   float *Tuple;
    00185
    00186   int SaveUserArray;
    00187 private:
    00188   vtkLongArray(const vtkLongArray&);  // Not implemented.
    00189   void operator=(const vtkLongArray&);  // Not implemented.
    00190 };
    00191
    00192 inline void vtkLongArray::SetNumberOfValues(const vtkIdType number)
    00193 {
    00194   this->Allocate(number);
    00195   this->MaxId = number - 1;
    00196 }
    00197
    00198 inline long *vtkLongArray::WritePointer(const vtkIdType id,
    00199                                         const vtkIdType number)
    00200 {
    00201   vtkIdType newSize=id+number;
    00202   if ( newSize > this->Size )
    00203     {
    00204     this->ResizeAndExtend(newSize);
    00205     }
    00206   if ( (--newSize) > this->MaxId )
    00207     {
    00208     this->MaxId = newSize;
    00209     }
    00210   return this->Array + id;
    00211 }
    00212
    00213 inline void vtkLongArray::InsertValue(const vtkIdType id, const long i)
    00214 {
    00215   if ( id >= this->Size )
    00216     {
    00217     this->ResizeAndExtend(id+1);
    00218     }
    00219   this->Array[id] = i;
    00220   if ( id > this->MaxId )
    00221     {
    00222     this->MaxId = id;
    00223     }
    00224 }
    00225
    00226 inline vtkIdType vtkLongArray::InsertNextValue(const long i)
    00227 {
    00228   this->InsertValue (++this->MaxId,i);
    00229   return this->MaxId;
    00230 }
    00231
    00232
    00233 #endif