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 
110 
113 
118 
124  virtual void SetNumberOfTuples(vtkIdType number) = 0;
125 
127 
129  {return (this->MaxId + 1)/this->NumberOfComponents;}
131 
138 
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 
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),
256  int vtkNotUsed(save)) =0;
258 
262  virtual void ExportToVoidPointer(void *vtkNotUsed(out_ptr)) {}
263 
270  virtual unsigned long GetActualMemorySize() = 0;
271 
273 
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 
298 
300 
305  {
306  return this->GetNumberOfComponents() * this->GetNumberOfTuples();
307  }
309 
311 
313  virtual void LookupValue(vtkVariant value, vtkIdList* ids) = 0;
315 
318 
322 
325  virtual void SetVariantValue(vtkIdType idx, vtkVariant value) = 0;
326 
333  virtual void DataChanged() = 0;
334 
338  virtual void ClearLookup() = 0;
339 
341 
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 
398 
400  bool HasInformation(){ return this->Information!=0; }
401  //BTX
403 
404 
411  virtual int CopyInformation(vtkInformation *infoFrom, int deep=1);
412  //ETX
414 
418 
432 
438 
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.
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
vtkAbstractArray::Initialize
virtual void Initialize()=0
vtkAbstractArray::LookupValue
virtual vtkIdType LookupValue(vtkVariant value)=0
vtkAbstractArray::Name
char * Name
Definition: vtkAbstractArray.h:501
vtkAbstractArray::Squeeze
virtual void Squeeze()=0
vtkAbstractArray::CopyInformation
virtual int CopyInformation(vtkInformation *infoFrom, int deep=1)
VTK_INT_MAX
#define VTK_INT_MAX
Definition: vtkType.h:132
vtkAbstractArray::HasStandardMemoryLayout
virtual bool HasStandardMemoryLayout()
vtkAbstractArray::CopyComponentNames
int CopyComponentNames(vtkAbstractArray *da)
vtkAbstractArray::InterpolateTuple
virtual void InterpolateTuple(vtkIdType i, vtkIdList *ptIndices, vtkAbstractArray *source, double *weights)=0
vtkAbstractArray::GetDataSize
virtual vtkIdType GetDataSize()
Definition: vtkAbstractArray.h:304
VTKCOMMONCORE_EXPORT
#define VTKCOMMONCORE_EXPORT
Definition: vtkCommonCoreModule.h:15
vtkAbstractArray::GetNumberOfComponents
int GetNumberOfComponents()
Definition: vtkAbstractArray.h:101
vtkAbstractArray::ExportToVoidPointer
virtual void ExportToVoidPointer(void *vtkNotUsed(out_ptr))
Definition: vtkAbstractArray.h:262
vtkgl::weights
const GLbyte * weights
Definition: vtkgl.h:12766
vtkVariant.h
vtkAbstractArray::SetVoidArray
virtual void SetVoidArray(void *vtkNotUsed(array), vtkIdType vtkNotUsed(size), int vtkNotUsed(save))=0
vtkAbstractArray::Resize
virtual int Resize(vtkIdType numTuples)=0
vtkX3D::component
@ component
Definition: vtkX3D.h:175
vtkAbstractArray::NewIterator
virtual vtkArrayIterator * NewIterator()=0
vtkIdType
int vtkIdType
Definition: vtkType.h:275
vtkAbstractArray::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
vtkAbstractArray::InsertNextTuple
virtual vtkIdType InsertNextTuple(vtkIdType j, vtkAbstractArray *source)=0
save
void save(Archiver &ar, const vtkUnicodeString &str, const unsigned int vtkNotUsed(version))
Definition: vtkVariantBoostSerialization.h:64
vtkAbstractArray::InsertTuples
virtual void InsertTuples(vtkIdList *dstIds, vtkIdList *srcIds, vtkAbstractArray *source)=0
vtkAbstractArray::InterpolateTuple
virtual void InterpolateTuple(vtkIdType i, vtkIdType id1, vtkAbstractArray *source1, vtkIdType id2, vtkAbstractArray *source2, double t)=0
vtkAbstractArray::Size
vtkIdType Size
Definition: vtkAbstractArray.h:494
vtkTypeMacro
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:642
vtkgl::n
GLclampd n
Definition: vtkgl.h:14370
vtkAbstractArray::Information
vtkInformation * Information
Definition: vtkAbstractArray.h:505
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:62
vtkVariantArray
An array holding vtkVariants.
Definition: vtkVariantArray.h:48
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:55
vtkAbstractArray::ComponentNames
vtkInternalComponentNames * ComponentNames
Definition: vtkAbstractArray.h:508
vtkAbstractArray::HasInformation
bool HasInformation()
Definition: vtkAbstractArray.h:400
vtkAbstractArray::GetTuples
virtual void GetTuples(vtkIdType p1, vtkIdType p2, vtkAbstractArray *output)
vtkAbstractArray::GetInformation
vtkInformation * GetInformation()
vtkAbstractArray::SetTuple
virtual void SetTuple(vtkIdType i, vtkIdType j, vtkAbstractArray *source)=0
vtkAbstractArray::GetSize
vtkIdType GetSize()
Definition: vtkAbstractArray.h:237
source
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
Definition: vtkBoostGraphAdapter.h:821
vtkAbstractArray::InsertVariantValue
virtual void InsertVariantValue(vtkIdType idx, vtkVariant value)
vtkAbstractArray::GetNumberOfTuples
vtkIdType GetNumberOfTuples()
Definition: vtkAbstractArray.h:128
vtkAbstractArray::vtkAbstractArray
vtkAbstractArray()
vtkAbstractArray::~vtkAbstractArray
~vtkAbstractArray()
vtkSetClampMacro
#define vtkSetClampMacro(name, type, min, max)
Definition: vtkSetGet.h:143
vtkgl::name
GLuint const GLchar * name
Definition: vtkgl.h:11983
vtkNotUsed
#define vtkNotUsed(x)
Definition: vtkSetGet.h:557
vtkAbstractArray::GetElementComponentSize
virtual int GetElementComponentSize()=0
vtkgl::value
GLsizei const GLfloat * value
Definition: vtkgl.h:12021
vtkAbstractArray::GetActualMemorySize
virtual unsigned long GetActualMemorySize()=0
vtkAbstractArray::RebuildArray
bool RebuildArray
Definition: vtkAbstractArray.h:503
vtkAbstractArray::GetMaxId
vtkIdType GetMaxId()
Definition: vtkAbstractArray.h:243
vtkImageScalarTypeNameMacro
#define vtkImageScalarTypeNameMacro(type)
Definition: vtkSetGet.h:51
vtkAbstractArray::UpdateDiscreteValueSet
virtual void UpdateDiscreteValueSet(double uncertainty, double minProminence)
vtkCommonCoreModule.h
vtkAbstractArray::GetVoidPointer
virtual void * GetVoidPointer(vtkIdType id)=0
vtkgl::ids
GLuint * ids
Definition: vtkgl.h:11831
vtkgl::values
GLboolean GLenum GLenum GLvoid * values
Definition: vtkgl.h:11354
vtkAbstractArray::Reset
void Reset()
Definition: vtkAbstractArray.h:228
vtkAbstractArray::SetVariantValue
virtual void SetVariantValue(vtkIdType idx, vtkVariant value)=0
vtkInformationIntegerKey
Key for integer values in vtkInformation.
Definition: vtkInformationIntegerKey.h:34
vtkAbstractArray::IsNumeric
virtual int IsNumeric()=0
vtkAbstractArray::GetDataTypeSize
virtual int GetDataTypeSize()=0
vtkAbstractArray::DISCRETE_VALUE_SAMPLE_PARAMETERS
static vtkInformationDoubleVectorKey * DISCRETE_VALUE_SAMPLE_PARAMETERS()
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkInformationVariantVectorKey
Key for variant vector values.
Definition: vtkInformationVariantVectorKey.h:36
vtkAbstractArray::CreateArray
static vtkAbstractArray * CreateArray(int dataType)
vtkAbstractArray::GetDataType
virtual int GetDataType()=0
vtkSetStringMacro
#define vtkSetStringMacro(name)
Definition: vtkSetGet.h:104
vtkVariant
A atomic type representing the union of many types.
Definition: vtkVariant.h:79
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:36
vtkAbstractArray::Allocate
virtual int Allocate(vtkIdType sz, vtkIdType ext=1000)=0
vtkAbstractArray::SetInformation
virtual void SetInformation(vtkInformation *)
vtkGetMacro
#define vtkGetMacro(name, type)
Definition: vtkSetGet.h:93
vtkGetStringMacro
vtkGetStringMacro(ExtensionsString)
vtkAbstractArray::GetDataTypeSize
static int GetDataTypeSize(int type)
vtkDataArrayTemplateHelper
Definition: vtkDataArrayTemplateHelper.h:35
vtkAbstractArray::SetComponentName
void SetComponentName(vtkIdType component, const char *name)
vtkAbstractArray::GetArrayType
virtual int GetArrayType()
Definition: vtkAbstractArray.h:469
vtkAbstractArray::InsertTuples
virtual void InsertTuples(vtkIdType dstStart, vtkIdType n, vtkIdType srcStart, vtkAbstractArray *source)=0
vtkObject.h
vtkAbstractArray::GetVariantValue
virtual vtkVariant GetVariantValue(vtkIdType idx)
vtkAbstractArray::GetComponentName
const char * GetComponentName(vtkIdType component)
vtkAbstractArray
Abstract superclass for all arrays.
Definition: vtkAbstractArray.h:65
vtkAbstractArray::DataArray
@ DataArray
Definition: vtkAbstractArray.h:461
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:86
vtkSetMacro
vtkSetMacro(IgnoreDriverBugs, bool)
vtkAbstractArray::InsertTuple
virtual void InsertTuple(vtkIdType i, vtkIdType j, vtkAbstractArray *source)=0
vtkgl::t
GLdouble GLdouble t
Definition: vtkgl.h:11602
vtkAbstractArray::MaxDiscreteValues
unsigned int MaxDiscreteValues
Definition: vtkAbstractArray.h:499
vtkIdTypeArray
dynamic, self-adjusting array of vtkIdType
Definition: vtkIdTypeArray.h:49
vtkAbstractArray::HasAComponentName
bool HasAComponentName()
vtkAbstractArray::DataArrayTemplate
@ DataArrayTemplate
Definition: vtkAbstractArray.h:463
vtkInformationDoubleVectorKey
Key for double vector values.
Definition: vtkInformationDoubleVectorKey.h:34
vtkAbstractArray::TypedDataArray
@ TypedDataArray
Definition: vtkAbstractArray.h:462
vtkAbstractArray::DeepCopy
virtual void DeepCopy(vtkAbstractArray *da)
vtkArrayIterator
Abstract superclass to iterate over elements in an vtkAbstractArray.
Definition: vtkArrayIterator.h:49
vtkAbstractArray::LookupValue
virtual void LookupValue(vtkVariant value, vtkIdList *ids)=0
vtkInformationInformationVectorKey
Key for vtkInformation vectors.
Definition: vtkInformationInformationVectorKey.h:33
vtkAbstractArray::GUI_HIDE
static vtkInformationIntegerKey * GUI_HIDE()
vtkAbstractArray::SetNumberOfTuples
virtual void SetNumberOfTuples(vtkIdType number)=0
vtkAbstractArray::GetTuples
virtual void GetTuples(vtkIdList *ptIds, vtkAbstractArray *output)
vtkAbstractArray::ClearLookup
virtual void ClearLookup()=0
vtkAbstractArray::MaxId
vtkIdType MaxId
Definition: vtkAbstractArray.h:495
vtkAbstractArray::DISCRETE_VALUES
static vtkInformationVariantVectorKey * DISCRETE_VALUES()
vtkAbstractArray::GetProminentComponentValues
virtual void GetProminentComponentValues(int comp, vtkVariantArray *values, double uncertainty=1.e-6, double minimumProminence=1.e-3)
vtkgl::type
GLuint GLuint GLsizei GLenum type
Definition: vtkgl.h:11315
vtkAbstractArray::PER_COMPONENT
static vtkInformationInformationVectorKey * PER_COMPONENT()
vtkAbstractArray::DataChanged
virtual void DataChanged()=0
vtkgl::size
GLsizeiptr size
Definition: vtkgl.h:11843
vtkAbstractArray::GetDataTypeAsString
virtual const char * GetDataTypeAsString(void)
Definition: vtkAbstractArray.h:280
vtkAbstractArray::NumberOfComponents
int NumberOfComponents
Definition: vtkAbstractArray.h:496