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 
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 
199  {return this->Size;}
201 
203 
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 
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 
308 
311  vtkInformation* GetInformation();
312  // Description:
313  // Inquire if this array has an instance of vtkInformation
314  // already associated with it.
315  bool HasInformation(){ return this->Information!=0; }
316  //BTX
317  // Description:
318  // Copy information instance. Arrays use information objects
319  // in a variety of ways. It is important to have flexibility in
320  // this regard because certain keys should not be coppied, while
321  // others must be.
322  //
323  // NOTE: Subclasses must always call their superclass's CopyInformation
324  // method, so that all classes in the hierarchy get a chance to remove
325  // keys they do not wish to be coppied. The subclass will not need to
326  // explicilty copy the keys as it's handled here.
327  virtual int CopyInformation(vtkInformation *infoFrom, int deep=1);
328  //ETX
330 
333  static vtkInformationIntegerKey* GUI_HIDE();
334 
335 protected:
339  virtual void SetInformation( vtkInformation* );
340 
341  // Construct object with default tuple dimension (number of components) of 1.
342  vtkAbstractArray(vtkIdType numComp=1);
343  ~vtkAbstractArray();
344 
345  vtkIdType Size; // allocated size of data
346  vtkIdType MaxId; // maximum index inserted thus far
347  int NumberOfComponents; // the number of components per tuple
348 
349  char* Name;
350 
351  bool RebuildArray; // whether to rebuild the fast lookup data structure.
352 
354 
355  //BTX
356  class vtkInternalComponentNames;
357  vtkInternalComponentNames* ComponentNames; //names for each component
358  //ETX
359 
360 private:
361  vtkAbstractArray(const vtkAbstractArray&); // Not implemented.
362  void operator=(const vtkAbstractArray&); // Not implemented.
363 };
364 
365 #endif
vtkIdType GetMaxId()
abstract base class for most VTK objects
Definition: vtkObject.h:60
Store vtkAlgorithm input/output information.
vtkIdType GetNumberOfTuples()
Abstract superclass for all arrays.
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:255
A atomic type representing the union of many types.
Definition: vtkVariant.h:72
virtual vtkIdType GetDataSize()
vtkInformation * Information
virtual void ExportToVoidPointer(void *vtkNotUsed(out_ptr))
virtual void PrintSelf(ostream &os, vtkIndent indent)
a simple class to control print indentation
Definition: vtkIndent.h:37
list of point or cell ids
Definition: vtkIdList.h:34
Key for integer values in vtkInformation.
virtual const char * GetDataTypeAsString(void)
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:53
#define VTK_COMMON_EXPORT
Abstract superclass to iterate over elements in an vtkAbstractArray.
vtkInternalComponentNames * ComponentNames
void save(Archiver &ar, const vtkVariant &variant, const unsigned int vtkNotUsed(version))
#define VTK_LARGE_INTEGER
Definition: vtkType.h:148