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 
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  {this->MaxId = -1;}
231 
233 
235  {return this->Size;}
237 
239 
241  {return this->MaxId;}
243 
245 
251  virtual void SetVoidArray(void *vtkNotUsed(array),
253  int vtkNotUsed(save)) =0;
255 
259  virtual void ExportToVoidPointer(void *vtkNotUsed(out_ptr)) {}
260 
267  virtual unsigned long GetActualMemorySize() = 0;
268 
270 
271  vtkSetStringMacro(Name);
272  vtkGetStringMacro(Name);
274 
276 
277  virtual const char *GetDataTypeAsString( void )
278  { return vtkImageScalarTypeNameMacro( this->GetDataType() ); }
280 
286  static vtkAbstractArray* CreateArray(int dataType);
287 
290  virtual int IsNumeric() = 0;
291 
294  virtual vtkArrayIterator* NewIterator() = 0;
295 
297 
302  {
303  return this->GetNumberOfComponents() * this->GetNumberOfTuples();
304  }
306 
308 
309  virtual vtkIdType LookupValue(vtkVariant value) = 0;
310  virtual void LookupValue(vtkVariant value, vtkIdList* ids) = 0;
312 
314  virtual vtkVariant GetVariantValue(vtkIdType idx);
315 
318  virtual void InsertVariantValue(vtkIdType idx, vtkVariant value);
319 
322  virtual void SetVariantValue(vtkIdType idx, vtkVariant value) = 0;
323 
330  virtual void DataChanged() = 0;
331 
335  virtual void ClearLookup() = 0;
336 
338 
380  virtual void GetProminentComponentValues(int comp, vtkVariantArray* values,
381  double uncertainty = 1.e-6, double minimumProminence = 1.e-3);
383 
384  // TODO: Implement these lookup functions also.
385  //virtual void LookupRange(vtkVariant min, vtkVariant max, vtkIdList* ids,
386  // bool includeMin = true, bool includeMax = true) = 0;
387  //virtual void LookupGreaterThan(vtkVariant min, vtkIdList* ids, bool includeMin = false) = 0;
388  //virtual void LookupLessThan(vtkVariant max, vtkIdList* ids, bool includeMax = false) = 0;
389 
393  vtkInformation* GetInformation();
395 
397  bool HasInformation(){ return this->Information!=0; }
398  //BTX
400 
401 
408  virtual int CopyInformation(vtkInformation *infoFrom, int deep=1);
409  //ETX
411 
414  static vtkInformationIntegerKey* GUI_HIDE();
415 
428  static vtkInformationInformationVectorKey* PER_COMPONENT();
429 
434  static vtkInformationVariantVectorKey* DISCRETE_VALUES();
435 
442  static vtkInformationDoubleVectorKey* DISCRETE_VALUE_SAMPLE_PARAMETERS();
443 
444  // Deprecated. Use vtkAbstractArray::MaxDiscreteValues instead.
445  enum {
446  MAX_DISCRETE_VALUES = 32
447  };
448 
450 
452  vtkGetMacro(MaxDiscreteValues, unsigned int);
453  vtkSetMacro(MaxDiscreteValues, unsigned int);
455 
456  enum {
457  AbstractArray = 0,
461  MappedDataArray
462  };
463 
465 
466  virtual int GetArrayType()
467  {
468  return AbstractArray;
469  }
471 
472 protected:
473  // Construct object with default tuple dimension (number of components) of 1.
475  ~vtkAbstractArray();
476 
480  virtual void SetInformation( vtkInformation* );
481 
489  virtual void UpdateDiscreteValueSet(double uncertainty, double minProminence);
490 
491  vtkIdType Size; // allocated size of data
492  vtkIdType MaxId; // maximum index inserted thus far
493  int NumberOfComponents; // the number of components per tuple
494 
495  // maximum number of prominent values before array is considered continuous.
496  unsigned int MaxDiscreteValues;
497 
498  char* Name;
499 
500  bool RebuildArray; // whether to rebuild the fast lookup data structure.
501 
503 
504  //BTX
505  class vtkInternalComponentNames;
506  vtkInternalComponentNames* ComponentNames; //names for each component
507  //ETX
508 
509 private:
510  vtkAbstractArray(const vtkAbstractArray&); // Not implemented.
511  void operator=(const vtkAbstractArray&); // Not implemented.
512 };
513 
514 #endif
vtkIdType GetMaxId()
GLsizeiptr size
Definition: vtkgl.h:11843
#define vtkNotUsed(x)
Definition: vtkSetGet.h:547
GLuint GLuint GLsizei GLenum type
Definition: vtkgl.h:11315
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
#define vtkGetMacro(name, type)
Definition: vtkSetGet.h:83
void DeepCopy(vtkPistonReference *self, vtkPistonReference *other)
#define vtkSetClampMacro(name, type, min, max)
Definition: vtkSetGet.h:133
virtual int GetArrayType()
dynamic, self-adjusting array of vtkIdType
GLsizei const GLfloat * value
Definition: vtkgl.h:12021
int vtkIdType
Definition: vtkType.h:281
GLdouble GLdouble t
Definition: vtkgl.h:11602
GLuint * ids
Definition: vtkgl.h:11831
#define vtkSetStringMacro(name)
Definition: vtkSetGet.h:94
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:632
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.
GLuint const GLchar * name
Definition: vtkgl.h:11983
virtual void PrintSelf(ostream &os, vtkIndent indent)
const GLbyte * weights
Definition: vtkgl.h:12766
a simple class to control print indentation
Definition: vtkIndent.h:38
GLboolean GLenum GLenum GLvoid * values
Definition: vtkgl.h:11354
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:53
static void InsertTuples(vtkDataArray *dst, vtkIdType dstStart, vtkIdType n, vtkIdType srcStart, vtkAbstractArray *source)
Abstract superclass to iterate over elements in an vtkAbstractArray.
#define vtkGetStringMacro(name)
Definition: vtkSetGet.h:120
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
GLclampd n
Definition: vtkgl.h:14370
#define vtkImageScalarTypeNameMacro(type)
Definition: vtkSetGet.h:41
unsigned int MaxDiscreteValues
#define vtkSetMacro(name, type)
Definition: vtkSetGet.h:69