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 
64 class VTKCOMMONCORE_EXPORT vtkAbstractArray : public vtkObject
65 {
66 public:
67  vtkTypeMacro(vtkAbstractArray,vtkObject);
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 
145  virtual vtkIdType InsertNextTuple(vtkIdType j, vtkAbstractArray* source) = 0;
146 
150  virtual void GetTuples(vtkIdList *ptIds, vtkAbstractArray* output);
151 
155  virtual void GetTuples(vtkIdType p1, vtkIdType p2, vtkAbstractArray *output);
156 
159  virtual void *GetVoidPointer(vtkIdType id) = 0;
160 
165  virtual void DeepCopy(vtkAbstractArray* da);
166 
168 
172  virtual void InterpolateTuple(vtkIdType i, vtkIdList *ptIndices,
173  vtkAbstractArray* source, double* weights) = 0;
175 
177 
182  virtual void InterpolateTuple(vtkIdType i,
183  vtkIdType id1, vtkAbstractArray* source1,
184  vtkIdType id2, vtkAbstractArray* source2, double t) =0;
186 
189  virtual void Squeeze() = 0;
190 
193  virtual int Resize(vtkIdType numTuples) = 0;
194 
196 
197  void Reset()
198  {this->MaxId = -1;}
200 
202 
204  {return this->Size;}
206 
208 
210  {return this->MaxId;}
212 
214 
220  virtual void SetVoidArray(void *vtkNotUsed(array),
221  vtkIdType vtkNotUsed(size),
222  int vtkNotUsed(save)) =0;
224 
228  virtual void ExportToVoidPointer(void *vtkNotUsed(out_ptr)) {}
229 
236  virtual unsigned long GetActualMemorySize() = 0;
237 
239 
240  vtkSetStringMacro(Name);
241  vtkGetStringMacro(Name);
243 
245 
246  virtual const char *GetDataTypeAsString( void )
247  { return vtkImageScalarTypeNameMacro( this->GetDataType() ); }
249 
255  static vtkAbstractArray* CreateArray(int dataType);
256 
259  virtual int IsNumeric() = 0;
260 
263  virtual vtkArrayIterator* NewIterator() = 0;
264 
266 
271  {
272  return this->GetNumberOfComponents() * this->GetNumberOfTuples();
273  }
275 
277 
278  virtual vtkIdType LookupValue(vtkVariant value) = 0;
279  virtual void LookupValue(vtkVariant value, vtkIdList* ids) = 0;
281 
283  virtual vtkVariant GetVariantValue(vtkIdType idx);
284 
287  virtual void InsertVariantValue(vtkIdType idx, vtkVariant value);
288 
291  virtual void SetVariantValue(vtkIdType idx, vtkVariant value) = 0;
292 
299  virtual void DataChanged() = 0;
300 
304  virtual void ClearLookup() = 0;
305 
307 
348  virtual void GetProminentComponentValues(int comp, vtkVariantArray* values,
349  double uncertainty = 1.e-6, double minimumProminence = 1.e-3);
351 
352  // TODO: Implement these lookup functions also.
353  //virtual void LookupRange(vtkVariant min, vtkVariant max, vtkIdList* ids,
354  // bool includeMin = true, bool includeMax = true) = 0;
355  //virtual void LookupGreaterThan(vtkVariant min, vtkIdList* ids, bool includeMin = false) = 0;
356  //virtual void LookupLessThan(vtkVariant max, vtkIdList* ids, bool includeMax = false) = 0;
357 
361  vtkInformation* GetInformation();
363 
365  bool HasInformation(){ return this->Information!=0; }
366  //BTX
368 
369 
376  virtual int CopyInformation(vtkInformation *infoFrom, int deep=1);
377  //ETX
379 
382  static vtkInformationIntegerKey* GUI_HIDE();
383 
396  static vtkInformationInformationVectorKey* PER_COMPONENT();
397 
402  static vtkInformationVariantVectorKey* DISCRETE_VALUES();
403 
410  static vtkInformationDoubleVectorKey* DISCRETE_VALUE_SAMPLE_PARAMETERS();
411 
412  enum {
413  MAX_DISCRETE_VALUES = 32
414  };
415 
416 protected:
417  // Construct object with default tuple dimension (number of components) of 1.
418  vtkAbstractArray(vtkIdType numComp=1);
419  ~vtkAbstractArray();
420 
424  virtual void SetInformation( vtkInformation* );
425 
433  virtual void UpdateDiscreteValueSet(double uncertainty, double minProminence);
434 
435  vtkIdType Size; // allocated size of data
436  vtkIdType MaxId; // maximum index inserted thus far
437  int NumberOfComponents; // the number of components per tuple
438 
439  char* Name;
440 
441  bool RebuildArray; // whether to rebuild the fast lookup data structure.
442 
444 
445  //BTX
446  class vtkInternalComponentNames;
447  vtkInternalComponentNames* ComponentNames; //names for each component
448  //ETX
449 
450 private:
451  vtkAbstractArray(const vtkAbstractArray&); // Not implemented.
452  void operator=(const vtkAbstractArray&); // Not implemented.
453 };
454 
455 #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 VTK_INT_MAX
Definition: vtkType.h:131
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:268
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:53
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