VTK
vtkAbstractArray.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkAbstractArray.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 //
46 #ifndef __vtkAbstractArray_h
47 #define __vtkAbstractArray_h
48 
49 #include "vtkObject.h"
50 #include "vtkVariant.h" // for variant arguments
51 
52 class vtkArrayIterator;
53 class vtkDataArray;
54 class vtkIdList;
55 class vtkIdTypeArray;
56 class vtkInformation;
58 
60 {
61 public:
62  vtkTypeMacro(vtkAbstractArray,vtkObject);
63  void PrintSelf(ostream& os, vtkIndent indent);
64 
67  virtual int Allocate(vtkIdType sz, vtkIdType ext=1000) = 0;
68 
70  virtual void Initialize() = 0;
71 
74  virtual int GetDataType() =0;
75 
77 
80  virtual int GetDataTypeSize() = 0;
81  static int GetDataTypeSize(int type);
83 
88  virtual int GetElementComponentSize() = 0;
89 
91 
93  vtkSetClampMacro(NumberOfComponents, int, 1, VTK_LARGE_INTEGER);
94  int GetNumberOfComponents() { return this->NumberOfComponents; }
96 
98  void SetComponentName( vtkIdType component, const char *name );
99 
102  const char* GetComponentName( vtkIdType component );
103 
105  bool HasAComponentName();
106 
110  int CopyComponentNames( vtkAbstractArray *da );
111 
117  virtual void SetNumberOfTuples(vtkIdType number) = 0;
118 
120 
121  vtkIdType GetNumberOfTuples()
122  {return (this->MaxId + 1)/this->NumberOfComponents;}
124 
130  virtual void SetTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source) = 0;
131 
135  virtual void InsertTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source) = 0;
136 
140  virtual vtkIdType InsertNextTuple(vtkIdType j, vtkAbstractArray* source) = 0;
141 
145  virtual void GetTuples(vtkIdList *ptIds, vtkAbstractArray* output);
146 
150  virtual void GetTuples(vtkIdType p1, vtkIdType p2, vtkAbstractArray *output);
151 
154  virtual void *GetVoidPointer(vtkIdType id) = 0;
155 
160  virtual void DeepCopy(vtkAbstractArray* da);
161 
163 
167  virtual void InterpolateTuple(vtkIdType i, vtkIdList *ptIndices,
168  vtkAbstractArray* source, double* weights) = 0;
170 
172 
177  virtual void InterpolateTuple(vtkIdType i,
178  vtkIdType id1, vtkAbstractArray* source1,
179  vtkIdType id2, vtkAbstractArray* source2, double t) =0;
181 
184  virtual void Squeeze() = 0;
185 
188  virtual int Resize(vtkIdType numTuples) = 0;
189 
191 
192  void Reset()
193  {this->MaxId = -1;}
195 
197 
198  vtkIdType GetSize()
199  {return this->Size;}
201 
203 
204  vtkIdType GetMaxId()
205  {return this->MaxId;}
207 
209 
215  virtual void SetVoidArray(void *vtkNotUsed(array),
216  vtkIdType vtkNotUsed(size),
217  int vtkNotUsed(save)) =0;
219 
223  virtual void ExportToVoidPointer(void *vtkNotUsed(out_ptr)) {}
224 
231  virtual unsigned long GetActualMemorySize() = 0;
232 
234 
235  vtkSetStringMacro(Name);
236  vtkGetStringMacro(Name);
238 
240 
241  virtual const char *GetDataTypeAsString( void )
242  { return vtkImageScalarTypeNameMacro( this->GetDataType() ); }
244 
250  static vtkAbstractArray* CreateArray(int dataType);
251 
254  virtual int IsNumeric() = 0;
255 
258  virtual vtkArrayIterator* NewIterator() = 0;
259 
261 
265  virtual vtkIdType GetDataSize()
266  {
267  return this->GetNumberOfComponents() * this->GetNumberOfTuples();
268  }
270 
272 
273  virtual vtkIdType LookupValue(vtkVariant value) = 0;
274  virtual void LookupValue(vtkVariant value, vtkIdList* ids) = 0;
276 
278  virtual vtkVariant GetVariantValue(vtkIdType idx);
279 
282  virtual void InsertVariantValue(vtkIdType idx, vtkVariant value);
283 
286  virtual void SetVariantValue(vtkIdType idx, vtkVariant value) = 0;
287 
294  virtual void DataChanged() = 0;
295 
299  virtual void ClearLookup() = 0;
300 
301  // TODO: Implement these lookup functions also.
302  //virtual void LookupRange(vtkVariant min, vtkVariant max, vtkIdList* ids,
303  // bool includeMin = true, bool includeMax = true) = 0;
304  //virtual void LookupGreaterThan(vtkVariant min, vtkIdList* ids, bool includeMin = false) = 0;
305  //virtual void LookupLessThan(vtkVariant max, vtkIdList* ids, bool includeMax = false) = 0;
306 
310  vtkInformation* GetInformation();
312 
314  bool HasInformation(){ return this->Information!=0; }
315  //BTX
317 
318 
325  virtual int CopyInformation(vtkInformation *infoFrom, int deep=1);
326  //ETX
328 
331  static vtkInformationIntegerKey* GUI_HIDE();
332 
333 protected:
337  virtual void SetInformation( vtkInformation* );
338 
339  // Construct object with default tuple dimension (number of components) of 1.
340  vtkAbstractArray(vtkIdType numComp=1);
341  ~vtkAbstractArray();
342 
343  vtkIdType Size; // allocated size of data
344  vtkIdType MaxId; // maximum index inserted thus far
345  int NumberOfComponents; // the number of components per tuple
346 
347  char* Name;
348 
349  bool RebuildArray; // whether to rebuild the fast lookup data structure.
350 
352 
353  //BTX
354  class vtkInternalComponentNames;
355  vtkInternalComponentNames* ComponentNames; //names for each component
356  //ETX
357 
358 private:
359  vtkAbstractArray(const vtkAbstractArray&); // Not implemented.
360  void operator=(const vtkAbstractArray&); // Not implemented.
361 };
362 
363 #endif