VTK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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  void PrintSelf(ostream& os, vtkIndent indent);
69 
72  virtual int Allocate(vtkIdType sz, vtkIdType ext=1000) = 0;
73 
75  virtual void Initialize() = 0;
76 
79  virtual int GetDataType() =0;
80 
82 
85  virtual int GetDataTypeSize() = 0;
86  static int GetDataTypeSize(int type);
88 
93  virtual int GetElementComponentSize() = 0;
94 
96 
98  vtkSetClampMacro(NumberOfComponents, int, 1, VTK_INT_MAX);
99  int GetNumberOfComponents() { return this->NumberOfComponents; }
101 
103  void SetComponentName( vtkIdType component, const char *name );
104 
107  const char* GetComponentName( vtkIdType component );
108 
110  bool HasAComponentName();
111 
115  int CopyComponentNames( vtkAbstractArray *da );
116 
122  virtual void SetNumberOfTuples(vtkIdType number) = 0;
123 
125 
127  {return (this->MaxId + 1)/this->NumberOfComponents;}
129 
135  virtual void SetTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source) = 0;
136 
140  virtual void InsertTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source) = 0;
141 
143 
146  virtual void InsertTuples(vtkIdList *dstIds, vtkIdList *srcIds,
147  vtkAbstractArray* source) = 0;
149 
153  virtual vtkIdType InsertNextTuple(vtkIdType j, vtkAbstractArray* source) = 0;
154 
158  virtual void GetTuples(vtkIdList *ptIds, vtkAbstractArray* output);
159 
163  virtual void GetTuples(vtkIdType p1, vtkIdType p2, vtkAbstractArray *output);
164 
174  virtual bool HasStandardMemoryLayout();
175 
180  virtual void *GetVoidPointer(vtkIdType id) = 0;
181 
186  virtual void DeepCopy(vtkAbstractArray* da);
187 
189 
193  virtual void InterpolateTuple(vtkIdType i, vtkIdList *ptIndices,
194  vtkAbstractArray* source, double* weights) = 0;
196 
198 
203  virtual void InterpolateTuple(vtkIdType i,
204  vtkIdType id1, vtkAbstractArray* source1,
205  vtkIdType id2, vtkAbstractArray* source2, double t) =0;
207 
210  virtual void Squeeze() = 0;
211 
214  virtual int Resize(vtkIdType numTuples) = 0;
215 
217 
218  void Reset()
219  {this->MaxId = -1;}
221 
223 
225  {return this->Size;}
227 
229 
231  {return this->MaxId;}
233 
235 
241  virtual void SetVoidArray(void *vtkNotUsed(array),
243  int vtkNotUsed(save)) =0;
245 
249  virtual void ExportToVoidPointer(void *vtkNotUsed(out_ptr)) {}
250 
257  virtual unsigned long GetActualMemorySize() = 0;
258 
260 
261  vtkSetStringMacro(Name);
262  vtkGetStringMacro(Name);
264 
266 
267  virtual const char *GetDataTypeAsString( void )
268  { return vtkImageScalarTypeNameMacro( this->GetDataType() ); }
270 
276  static vtkAbstractArray* CreateArray(int dataType);
277 
280  virtual int IsNumeric() = 0;
281 
284  virtual vtkArrayIterator* NewIterator() = 0;
285 
287 
292  {
293  return this->GetNumberOfComponents() * this->GetNumberOfTuples();
294  }
296 
298 
299  virtual vtkIdType LookupValue(vtkVariant value) = 0;
300  virtual void LookupValue(vtkVariant value, vtkIdList* ids) = 0;
302 
304  virtual vtkVariant GetVariantValue(vtkIdType idx);
305 
308  virtual void InsertVariantValue(vtkIdType idx, vtkVariant value);
309 
312  virtual void SetVariantValue(vtkIdType idx, vtkVariant value) = 0;
313 
320  virtual void DataChanged() = 0;
321 
325  virtual void ClearLookup() = 0;
326 
328 
369  virtual void GetProminentComponentValues(int comp, vtkVariantArray* values,
370  double uncertainty = 1.e-6, double minimumProminence = 1.e-3);
372 
373  // TODO: Implement these lookup functions also.
374  //virtual void LookupRange(vtkVariant min, vtkVariant max, vtkIdList* ids,
375  // bool includeMin = true, bool includeMax = true) = 0;
376  //virtual void LookupGreaterThan(vtkVariant min, vtkIdList* ids, bool includeMin = false) = 0;
377  //virtual void LookupLessThan(vtkVariant max, vtkIdList* ids, bool includeMax = false) = 0;
378 
382  vtkInformation* GetInformation();
384 
386  bool HasInformation(){ return this->Information!=0; }
387  //BTX
389 
390 
397  virtual int CopyInformation(vtkInformation *infoFrom, int deep=1);
398  //ETX
400 
403  static vtkInformationIntegerKey* GUI_HIDE();
404 
417  static vtkInformationInformationVectorKey* PER_COMPONENT();
418 
423  static vtkInformationVariantVectorKey* DISCRETE_VALUES();
424 
431  static vtkInformationDoubleVectorKey* DISCRETE_VALUE_SAMPLE_PARAMETERS();
432 
433  // Deprecated. Use vtkAbstractArray::MaxDiscreteValues instead.
434  enum {
435  MAX_DISCRETE_VALUES = 32
436  };
437 
439 
441  vtkGetMacro(MaxDiscreteValues, unsigned int);
442  vtkSetMacro(MaxDiscreteValues, unsigned int);
444 
445  enum {
446  AbstractArray = 0,
450  MappedDataArray
451  };
452 
454 
455  virtual int GetArrayType()
456  {
457  return AbstractArray;
458  }
460 
461 protected:
462  // Construct object with default tuple dimension (number of components) of 1.
464  ~vtkAbstractArray();
465 
469  virtual void SetInformation( vtkInformation* );
470 
478  virtual void UpdateDiscreteValueSet(double uncertainty, double minProminence);
479 
480  vtkIdType Size; // allocated size of data
481  vtkIdType MaxId; // maximum index inserted thus far
482  int NumberOfComponents; // the number of components per tuple
483 
484  // maximum number of prominent values before array is considered continuous.
485  unsigned int MaxDiscreteValues;
486 
487  char* Name;
488 
489  bool RebuildArray; // whether to rebuild the fast lookup data structure.
490 
492 
493  //BTX
494  class vtkInternalComponentNames;
495  vtkInternalComponentNames* ComponentNames; //names for each component
496  //ETX
497 
498 private:
499  vtkAbstractArray(const vtkAbstractArray&); // Not implemented.
500  void operator=(const vtkAbstractArray&); // Not implemented.
501 };
502 
503 #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:131
#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:268
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:619
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
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
#define vtkImageScalarTypeNameMacro(type)
Definition: vtkSetGet.h:41
unsigned int MaxDiscreteValues
#define vtkSetMacro(name, type)
Definition: vtkSetGet.h:69