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) = 0;
322 
325  virtual void SetVariantValue(vtkIdType idx, vtkVariant value) = 0;
326 
333  virtual void DataChanged() = 0;
334 
338  virtual void ClearLookup() = 0;
339 
341 
383  virtual void GetProminentComponentValues(int comp, vtkVariantArray* values,
384  double uncertainty = 1.e-6, double minimumProminence = 1.e-3);
386 
387  // TODO: Implement these lookup functions also.
388  //virtual void LookupRange(vtkVariant min, vtkVariant max, vtkIdList* ids,
389  // bool includeMin = true, bool includeMax = true) = 0;
390  //virtual void LookupGreaterThan(vtkVariant min, vtkIdList* ids, bool includeMin = false) = 0;
391  //virtual void LookupLessThan(vtkVariant max, vtkIdList* ids, bool includeMax = false) = 0;
392 
396  vtkInformation* GetInformation();
398 
400  bool HasInformation(){ return this->Information!=0; }
401  //BTX
403 
404 
411  virtual int CopyInformation(vtkInformation *infoFrom, int deep=1);
412  //ETX
414 
417  static vtkInformationIntegerKey* GUI_HIDE();
418 
431  static vtkInformationInformationVectorKey* PER_COMPONENT();
432 
437  static vtkInformationVariantVectorKey* DISCRETE_VALUES();
438 
445  static vtkInformationDoubleVectorKey* DISCRETE_VALUE_SAMPLE_PARAMETERS();
446 
447  // Deprecated. Use vtkAbstractArray::MaxDiscreteValues instead.
448  enum {
449  MAX_DISCRETE_VALUES = 32
450  };
451 
453 
455  vtkGetMacro(MaxDiscreteValues, unsigned int);
456  vtkSetMacro(MaxDiscreteValues, unsigned int);
458 
459  enum {
460  AbstractArray = 0,
464  MappedDataArray
465  };
466 
468 
469  virtual int GetArrayType()
470  {
471  return AbstractArray;
472  }
474 
475 protected:
476  // Construct object with default tuple dimension (number of components) of 1.
478  ~vtkAbstractArray();
479 
483  virtual void SetInformation( vtkInformation* );
484 
492  virtual void UpdateDiscreteValueSet(double uncertainty, double minProminence);
493 
494  vtkIdType Size; // allocated size of data
495  vtkIdType MaxId; // maximum index inserted thus far
496  int NumberOfComponents; // the number of components per tuple
497 
498  // maximum number of prominent values before array is considered continuous.
499  unsigned int MaxDiscreteValues;
500 
501  char* Name;
502 
503  bool RebuildArray; // whether to rebuild the fast lookup data structure.
504 
506 
507  //BTX
508  class vtkInternalComponentNames;
509  vtkInternalComponentNames* ComponentNames; //names for each component
510  //ETX
511 
512 private:
513  vtkAbstractArray(const vtkAbstractArray&); // Not implemented.
514  void operator=(const vtkAbstractArray&); // Not implemented.
515 };
516 
517 #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:130
void DeepCopy(vtkPistonReference *self, vtkPistonReference *other)
virtual int GetArrayType()
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:247
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