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 "vtkCommonCoreModule.h" // For export macro
50 #include "vtkObject.h"
51 #include "vtkVariant.h" // for variant arguments
52 
53 class vtkArrayIterator;
54 class vtkDataArray;
55 class vtkIdList;
56 class vtkIdTypeArray;
57 class vtkInformation;
62 class vtkVariantArray;
63 
65 {
66 public:
68 
69  vtkTypeMacro(vtkAbstractArray,vtkObject);
70  void PrintSelf(ostream& os, vtkIndent indent);
71 
74  virtual int Allocate(vtkIdType sz, vtkIdType ext=1000) = 0;
75 
77  virtual void Initialize() = 0;
78 
81  virtual int GetDataType() =0;
82 
84 
87  virtual int GetDataTypeSize() = 0;
88  static int GetDataTypeSize(int type);
90 
95  virtual int GetElementComponentSize() = 0;
96 
98 
100  vtkSetClampMacro(NumberOfComponents, int, 1, VTK_INT_MAX);
101  int GetNumberOfComponents() { return this->NumberOfComponents; }
103 
105  void SetComponentName( vtkIdType component, const char *name );
106 
109  const char* GetComponentName( vtkIdType component );
110 
112  bool HasAComponentName();
113 
117  int CopyComponentNames( vtkAbstractArray *da );
118 
124  virtual void SetNumberOfTuples(vtkIdType number) = 0;
125 
127 
129  {return (this->MaxId + 1)/this->NumberOfComponents;}
131 
137  virtual void SetTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source) = 0;
138 
142  virtual void InsertTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source) = 0;
143 
145 
148  virtual void InsertTuples(vtkIdList *dstIds, vtkIdList *srcIds,
149  vtkAbstractArray* source) = 0;
151 
153 
156  virtual void InsertTuples(vtkIdType dstStart, vtkIdType n, vtkIdType srcStart,
157  vtkAbstractArray* source) = 0;
159 
163  virtual vtkIdType InsertNextTuple(vtkIdType j, vtkAbstractArray* source) = 0;
164 
168  virtual void GetTuples(vtkIdList *ptIds, vtkAbstractArray* output);
169 
173  virtual void GetTuples(vtkIdType p1, vtkIdType p2, vtkAbstractArray *output);
174 
184  virtual bool HasStandardMemoryLayout();
185 
190  virtual void *GetVoidPointer(vtkIdType id) = 0;
191 
196  virtual void DeepCopy(vtkAbstractArray* da);
197 
199 
203  virtual void InterpolateTuple(vtkIdType i, vtkIdList *ptIndices,
204  vtkAbstractArray* source, double* weights) = 0;
206 
208 
213  virtual void InterpolateTuple(vtkIdType i,
214  vtkIdType id1, vtkAbstractArray* source1,
215  vtkIdType id2, vtkAbstractArray* source2, double t) =0;
217 
220  virtual void Squeeze() = 0;
221 
224  virtual int Resize(vtkIdType numTuples) = 0;
225 
227 
228  void Reset()
229  {
230  this->MaxId = -1;
231  this->DataChanged();
232  }
234 
236 
238  {return this->Size;}
240 
242 
244  {return this->MaxId;}
246 
248 
254  virtual void SetVoidArray(void *vtkNotUsed(array),
255  vtkIdType vtkNotUsed(size),
256  int vtkNotUsed(save)) =0;
258 
262  virtual void ExportToVoidPointer(void *vtkNotUsed(out_ptr)) {}
263 
270  virtual unsigned long GetActualMemorySize() = 0;
271 
273 
274  vtkSetStringMacro(Name);
275  vtkGetStringMacro(Name);
277 
279 
280  virtual const char *GetDataTypeAsString( void )
281  { return vtkImageScalarTypeNameMacro( this->GetDataType() ); }
283 
289  static vtkAbstractArray* CreateArray(int dataType);
290 
293  virtual int IsNumeric() = 0;
294 
297  virtual vtkArrayIterator* NewIterator() = 0;
298 
300 
305  {
306  return this->GetNumberOfComponents() * this->GetNumberOfTuples();
307  }
309 
311 
312  virtual vtkIdType LookupValue(vtkVariant value) = 0;
313  virtual void LookupValue(vtkVariant value, vtkIdList* ids) = 0;
315 
317  virtual vtkVariant GetVariantValue(vtkIdType idx);
318 
321  virtual void InsertVariantValue(vtkIdType idx, vtkVariant value);
322 
325  virtual void SetVariantValue(vtkIdType idx, vtkVariant value) = 0;
326 
333  virtual void DataChanged() = 0;
334 
338  virtual void ClearLookup() = 0;
339 
341 
382  virtual void GetProminentComponentValues(int comp, vtkVariantArray* values,
383  double uncertainty = 1.e-6, double minimumProminence = 1.e-3);
385 
386  // TODO: Implement these lookup functions also.
387  //virtual void LookupRange(vtkVariant min, vtkVariant max, vtkIdList* ids,
388  // bool includeMin = true, bool includeMax = true) = 0;
389  //virtual void LookupGreaterThan(vtkVariant min, vtkIdList* ids, bool includeMin = false) = 0;
390  //virtual void LookupLessThan(vtkVariant max, vtkIdList* ids, bool includeMax = false) = 0;
391 
395  vtkInformation* GetInformation();
397 
399  bool HasInformation(){ return this->Information!=0; }
400  //BTX
402 
403 
410  virtual int CopyInformation(vtkInformation *infoFrom, int deep=1);
411  //ETX
413 
416  static vtkInformationIntegerKey* GUI_HIDE();
417 
430  static vtkInformationInformationVectorKey* PER_COMPONENT();
431 
436  static vtkInformationVariantVectorKey* DISCRETE_VALUES();
437 
444  static vtkInformationDoubleVectorKey* DISCRETE_VALUE_SAMPLE_PARAMETERS();
445 
446  // Deprecated. Use vtkAbstractArray::MaxDiscreteValues instead.
447  enum {
448  MAX_DISCRETE_VALUES = 32
449  };
450 
452 
454  vtkGetMacro(MaxDiscreteValues, unsigned int);
455  vtkSetMacro(MaxDiscreteValues, unsigned int);
457 
458  enum {
459  AbstractArray = 0,
463  MappedDataArray
464  };
465 
467 
468  virtual int GetArrayType()
469  {
470  return AbstractArray;
471  }
473 
474 protected:
475  // Construct object with default tuple dimension (number of components) of 1.
477  ~vtkAbstractArray();
478 
482  virtual void SetInformation( vtkInformation* );
483 
491  virtual void UpdateDiscreteValueSet(double uncertainty, double minProminence);
492 
493  vtkIdType Size; // allocated size of data
494  vtkIdType MaxId; // maximum index inserted thus far
495  int NumberOfComponents; // the number of components per tuple
496 
497  // maximum number of prominent values before array is considered continuous.
498  unsigned int MaxDiscreteValues;
499 
500  char* Name;
501 
502  bool RebuildArray; // whether to rebuild the fast lookup data structure.
503 
505 
506  //BTX
507  class vtkInternalComponentNames;
508  vtkInternalComponentNames* ComponentNames; //names for each component
509  //ETX
510 
511 private:
512  vtkAbstractArray(const vtkAbstractArray&); // Not implemented.
513  void operator=(const vtkAbstractArray&); // Not implemented.
514 };
515 
516 #endif
vtkIdType GetMaxId()
abstract base class for most VTK objects
Definition: vtkObject.h:61
An array holding vtkVariants.
Store vtkAlgorithm input/output information.
vtkIdType GetNumberOfTuples()
Abstract superclass for all arrays.
#define VTKCOMMONCORE_EXPORT
#define VTK_INT_MAX
Definition: vtkType.h:132
void DeepCopy(vtkPistonReference *self, vtkPistonReference *other)
virtual int GetArrayType()
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:275
A atomic type representing the union of many types.
Definition: vtkVariant.h:78
virtual vtkIdType GetDataSize()
vtkInformation * Information
virtual void ExportToVoidPointer(void *vtkNotUsed(out_ptr))
Key for double vector values.
virtual void PrintSelf(ostream &os, vtkIndent indent)
a simple class to control print indentation
Definition: vtkIndent.h:38
list of point or cell ids
Definition: vtkIdList.h:35
Key for integer values in vtkInformation.
virtual const char * GetDataTypeAsString(void)
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
static void InsertTuples(vtkDataArray *dst, vtkIdType dstStart, vtkIdType n, vtkIdType srcStart, vtkAbstractArray *source)
Abstract superclass to iterate over elements in an vtkAbstractArray.
void save(Archiver &ar, const vtkUnicodeString &str, const unsigned int vtkNotUsed(version))
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
vtkInternalComponentNames * ComponentNames
unsigned int MaxDiscreteValues