VTK
vtkDataArray.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkDataArray.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 =========================================================================*/
41 #ifndef vtkDataArray_h
42 #define vtkDataArray_h
43 
44 #include "vtkCommonCoreModule.h" // For export macro
45 #include "vtkAbstractArray.h"
46 
47 class vtkDoubleArray;
48 class vtkIdList;
51 class vtkLookupTable;
52 class vtkPoints;
53 
54 class VTKCOMMONCORE_EXPORT vtkDataArray : public vtkAbstractArray
55 {
56 public:
58  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
59 
66  static vtkDataArray* FastDownCast(vtkAbstractArray *source);
67 
74  int IsNumeric() VTK_OVERRIDE
75  { return 1; }
76 
82  int GetElementComponentSize() VTK_OVERRIDE
83  { return this->GetDataTypeSize(); }
84 
85  // Reimplemented virtuals (doc strings are inherited from superclass):
86  void InsertTuple(vtkIdType dstTupleIdx, vtkIdType srcTupleIdx,
87  vtkAbstractArray* source) VTK_OVERRIDE;
89  vtkAbstractArray* source) VTK_OVERRIDE;
90  void InsertTuples(vtkIdList *dstIds, vtkIdList *srcIds,
91  vtkAbstractArray *source) VTK_OVERRIDE;
92  void InsertTuples(vtkIdType dstStart, vtkIdType n, vtkIdType srcStart,
93  vtkAbstractArray* source) VTK_OVERRIDE;
94  void GetTuples(vtkIdList *tupleIds, vtkAbstractArray *output) VTK_OVERRIDE;
95  void GetTuples(vtkIdType p1, vtkIdType p2, vtkAbstractArray *output) VTK_OVERRIDE;
96  void InterpolateTuple(vtkIdType dstTupleIdx, vtkIdList *ptIndices,
97  vtkAbstractArray* source, double* weights) VTK_OVERRIDE;
98  void InterpolateTuple(vtkIdType dstTupleIdx,
99  vtkIdType srcTupleIdx1, vtkAbstractArray* source1,
100  vtkIdType srcTupleIdx2, vtkAbstractArray* source2, double t) VTK_OVERRIDE;
101 
107  virtual double *GetTuple(vtkIdType tupleIdx) = 0;
108 
114  virtual void GetTuple(vtkIdType tupleIdx, double * tuple) = 0;
115 
117 
122  double GetTuple1(vtkIdType tupleIdx);
123  double* GetTuple2(vtkIdType tupleIdx);
124  double* GetTuple3(vtkIdType tupleIdx);
125  double* GetTuple4(vtkIdType tupleIdx);
126  double* GetTuple6(vtkIdType tupleIdx);
127  double* GetTuple9(vtkIdType tupleIdx);
129 
130  void SetTuple(vtkIdType dstTupleIdx, vtkIdType srcTupleIdx,
131  vtkAbstractArray* source) VTK_OVERRIDE;
132 
134 
139  virtual void SetTuple(vtkIdType tupleIdx, const float * tuple);
140  virtual void SetTuple(vtkIdType tupleIdx, const double * tuple);
142 
144 
149  void SetTuple1(vtkIdType tupleIdx, double value);
150  void SetTuple2(vtkIdType tupleIdx, double val0, double val1);
151  void SetTuple3(vtkIdType tupleIdx, double val0, double val1, double val2);
152  void SetTuple4(vtkIdType tupleIdx, double val0, double val1, double val2,
153  double val3);
154  void SetTuple6(vtkIdType tupleIdx, double val0, double val1, double val2,
155  double val3, double val4, double val5);
156  void SetTuple9(vtkIdType tupleIdx, double val0, double val1, double val2,
157  double val3, double val4, double val5, double val6,
158  double val7, double val8);
160 
162 
166  virtual void InsertTuple(vtkIdType tupleIdx, const float * tuple) = 0;
167  virtual void InsertTuple(vtkIdType tupleIdx, const double * tuple) = 0;
169 
171 
176  void InsertTuple1(vtkIdType tupleIdx, double value);
177  void InsertTuple2(vtkIdType tupleIdx, double val0, double val1);
178  void InsertTuple3(vtkIdType tupleIdx, double val0, double val1, double val2);
179  void InsertTuple4(vtkIdType tupleIdx, double val0, double val1, double val2,
180  double val3);
181  void InsertTuple6(vtkIdType tupleIdx, double val0, double val1, double val2,
182  double val3, double val4, double val5);
183  void InsertTuple9(vtkIdType tupleIdx, double val0, double val1, double val2,
184  double val3, double val4, double val5, double val6,
185  double val7, double val8);
187 
189 
194  virtual vtkIdType InsertNextTuple(const float * tuple) = 0;
195  virtual vtkIdType InsertNextTuple(const double * tuple) = 0;
197 
199 
204  void InsertNextTuple1(double value);
205  void InsertNextTuple2(double val0, double val1);
206  void InsertNextTuple3(double val0, double val1, double val2);
207  void InsertNextTuple4(double val0, double val1, double val2,
208  double val3);
209  void InsertNextTuple6(double val0, double val1, double val2,
210  double val3, double val4, double val5);
211  void InsertNextTuple9(double val0, double val1, double val2,
212  double val3, double val4, double val5, double val6,
213  double val7, double val8);
215 
217 
222  virtual void RemoveTuple(vtkIdType tupleIdx) = 0;
223  virtual void RemoveFirstTuple() { this->RemoveTuple(0); }
224  virtual void RemoveLastTuple();
226 
231  virtual double GetComponent(vtkIdType tupleIdx, int compIdx);
232 
240  virtual void SetComponent(vtkIdType tupleIdx, int compIdx, double value);
241 
246  virtual void InsertComponent(vtkIdType tupleIdx, int compIdx, double value);
247 
256  virtual void GetData(vtkIdType tupleMin, vtkIdType tupleMax, int compMin,
257  int compMax, vtkDoubleArray* data);
258 
260 
264  void DeepCopy(vtkAbstractArray *aa) VTK_OVERRIDE;
265  virtual void DeepCopy(vtkDataArray *da);
267 
277  virtual void ShallowCopy(vtkDataArray *other);
278 
285  virtual void FillComponent(int compIdx, double value);
286 
295  virtual void CopyComponent(int dstComponent, vtkDataArray *src,
296  int srcComponent);
297 
303  virtual void* WriteVoidPointer(vtkIdType valueIdx, vtkIdType numValues) = 0;
304 
313  unsigned long GetActualMemorySize() VTK_OVERRIDE;
314 
319  void CreateDefaultLookupTable();
320 
322 
325  void SetLookupTable(vtkLookupTable *lut);
326  vtkGetObjectMacro(LookupTable,vtkLookupTable);
328 
338  void GetRange(double range[2], int comp)
339  {
340  this->ComputeRange(range, comp);
341  }
342 
344 
352  double* GetRange(int comp)
353  {
354  this->GetRange(this->Range, comp);
355  return this->Range;
356  }
358 
366  double* GetRange()
367  {
368  return this->GetRange(0);
369  }
370 
379  void GetRange(double range[2])
380  {
381  this->GetRange(range,0);
382  }
383 
385 
390  void GetDataTypeRange(double range[2]);
391  double GetDataTypeMin();
392  double GetDataTypeMax();
393  static void GetDataTypeRange(int type, double range[2]);
394  static double GetDataTypeMin(int type);
395  static double GetDataTypeMax(int type);
397 
402  virtual double GetMaxNorm();
403 
413  static vtkDataArray* CreateDataArray(int dataType);
414 
431 
436 
444  int CopyInformation(vtkInformation *infoFrom, int deep=1) VTK_OVERRIDE;
445 
449  int GetArrayType() VTK_OVERRIDE { return DataArray; }
450 
451 protected:
452 
453  friend class vtkPoints;
454 
462  virtual void ComputeRange(double range[2], int comp);
463 
470  virtual bool ComputeScalarRange(double* ranges);
471 
472  // Returns true if the range was computed. Will return false
473  // if you try to compute the range of an array of length zero.
474  virtual bool ComputeVectorRange(double range[2]);
475 
476  // Construct object with default tuple dimension (number of components) of 1.
478  ~vtkDataArray() VTK_OVERRIDE;
479 
480  vtkLookupTable *LookupTable;
481  double Range[2];
482 
483 private:
484  double* GetTupleN(vtkIdType i, int n);
485 
486 private:
487  vtkDataArray(const vtkDataArray&) VTK_DELETE_FUNCTION;
488  void operator=(const vtkDataArray&) VTK_DELETE_FUNCTION;
489 };
490 
491 //------------------------------------------------------------------------------
493 {
494  if (source)
495  {
496  switch (source->GetArrayType())
497  {
500  case TypedDataArray:
501  case DataArray:
502  case MappedDataArray:
503  return static_cast<vtkDataArray*>(source);
504  default:
505  break;
506  }
507  }
508  return NULL;
509 }
510 
512 
513 #endif
Abstract superclass for all arrays.
virtual int GetDataTypeSize()=0
Return the size of the underlying data type.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:55
virtual void InsertTuple(vtkIdType tupleIdx, const double *tuple)=0
void InsertNextTuple1(double value)
These methods are included as convenience for the wrappers.
static double GetDataTypeMin(int type)
virtual void FillComponent(int compIdx, double value)
Fill a component of a data array with a specified value.
virtual void * WriteVoidPointer(vtkIdType valueIdx, vtkIdType numValues)=0
Get the address of a particular data index.
void InterpolateTuple(vtkIdType dstTupleIdx, vtkIdList *ptIndices, vtkAbstractArray *source, double *weights) override
Set the tuple at dstTupleIdx in this array to the interpolated tuple value, given the ptIndices in th...
int IsNumeric() override
This method is here to make backward compatibility easier.
Definition: vtkDataArray.h:74
static vtkInformationDoubleVectorKey * L2_NORM_RANGE()
This key is used to hold tight bounds on the $L_2$ norm of tuples in the array.
virtual void InsertTuple(vtkIdType tupleIdx, const float *tuple)=0
Insert the data tuple at tupleIdx.
virtual void DeepCopy(vtkDataArray *da)
virtual bool ComputeVectorRange(double range[2])
virtual void CopyComponent(int dstComponent, vtkDataArray *src, int srcComponent)
Copy a component from one data array into a component on this data array.
void InsertTuple9(vtkIdType tupleIdx, double val0, double val1, double val2, double val3, double val4, double val5, double val6, double val7, double val8)
void SetTuple4(vtkIdType tupleIdx, double val0, double val1, double val2, double val3)
virtual vtkIdType InsertNextTuple(const double *tuple)=0
void DeepCopy(vtkAbstractArray *aa) override
Deep copy of data.
void SetTuple(vtkIdType dstTupleIdx, vtkIdType srcTupleIdx, vtkAbstractArray *source) override
Set the tuple at dstTupleIdx in this array to the tuple at srcTupleIdx in the source array.
void GetDataTypeRange(double range[2])
These methods return the Min and Max possible range of the native data type.
void InterpolateTuple(vtkIdType dstTupleIdx, vtkIdType srcTupleIdx1, vtkAbstractArray *source1, vtkIdType srcTupleIdx2, vtkAbstractArray *source2, double t) override
Insert the tuple at dstTupleIdx in this array to the tuple interpolated from the two tuple indices,...
virtual void ComputeRange(double range[2], int comp)
Compute the range for a specific component.
virtual bool ComputeScalarRange(double *ranges)
Computes the range for each component of an array, the length of ranges must be two times the number ...
double * GetTuple6(vtkIdType tupleIdx)
virtual void SetTuple(vtkIdType tupleIdx, const float *tuple)
Set the data tuple at tupleIdx.
void SetTuple9(vtkIdType tupleIdx, double val0, double val1, double val2, double val3, double val4, double val5, double val6, double val7, double val8)
void InsertTuples(vtkIdList *dstIds, vtkIdList *srcIds, vtkAbstractArray *source) override
Copy the tuples indexed in srcIds from the source array to the tuple locations indexed by dstIds in t...
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void InsertNextTuple3(double val0, double val1, double val2)
void InsertTuple2(vtkIdType tupleIdx, double val0, double val1)
void InsertNextTuple4(double val0, double val1, double val2, double val3)
~vtkDataArray() override
void SetTuple1(vtkIdType tupleIdx, double value)
These methods are included as convenience for the wrappers.
virtual void RemoveTuple(vtkIdType tupleIdx)=0
These methods remove tuples from the data array.
virtual void RemoveLastTuple()
double * GetRange(int comp)
Return the range of the data array values for the given component.
Definition: vtkDataArray.h:352
void InsertNextTuple6(double val0, double val1, double val2, double val3, double val4, double val5)
static vtkInformationStringKey * UNITS_LABEL()
A human-readable string indicating the units for the array data.
void GetTuples(vtkIdType p1, vtkIdType p2, vtkAbstractArray *output) override
Get the tuples for the range of tuple ids specified (i.e., p1->p2 inclusive).
static VTK_NEWINSTANCE vtkDataArray * CreateDataArray(int dataType)
Creates an array for dataType where dataType is one of VTK_BIT, VTK_CHAR, VTK_SIGNED_CHAR,...
double GetDataTypeMin()
virtual vtkIdType InsertNextTuple(const float *tuple)=0
Insert the data tuple at the end of the array and return the tuple index at which the data was insert...
void InsertTuple6(vtkIdType tupleIdx, double val0, double val1, double val2, double val3, double val4, double val5)
virtual void SetComponent(vtkIdType tupleIdx, int compIdx, double value)
Set the data component at the location specified by tupleIdx and compIdx to value.
virtual void ShallowCopy(vtkDataArray *other)
Create a shallow copy of other into this, if possible.
double * GetTuple4(vtkIdType tupleIdx)
virtual void InsertComponent(vtkIdType tupleIdx, int compIdx, double value)
Insert value at the location specified by tupleIdx and compIdx.
void GetTuples(vtkIdList *tupleIds, vtkAbstractArray *output) override
Given a list of tuple ids, return an array of tuples.
virtual void GetTuple(vtkIdType tupleIdx, double *tuple)=0
Get the data tuple at tupleIdx by filling in a user-provided array, Make sure that your array is larg...
double GetTuple1(vtkIdType tupleIdx)
These methods are included as convenience for the wrappers.
double GetDataTypeMax()
virtual void GetData(vtkIdType tupleMin, vtkIdType tupleMax, int compMin, int compMax, vtkDoubleArray *data)
Get the data as a double array in the range (tupleMin,tupleMax) and (compMin, compMax).
static vtkInformationDoubleVectorKey * COMPONENT_RANGE()
This key is used to hold tight bounds on the range of one component over all tuples of the array.
int CopyInformation(vtkInformation *infoFrom, int deep=1) override
Copy information instance.
void GetRange(double range[2])
The the range of the data array values will be returned in the provided range array argument.
Definition: vtkDataArray.h:379
virtual double * GetTuple(vtkIdType tupleIdx)=0
Get the data tuple at tupleIdx.
double * GetRange()
Return the range of the data array.
Definition: vtkDataArray.h:366
void SetTuple6(vtkIdType tupleIdx, double val0, double val1, double val2, double val3, double val4, double val5)
virtual double GetComponent(vtkIdType tupleIdx, int compIdx)
Return the data component at the location specified by tupleIdx and compIdx.
vtkIdType InsertNextTuple(vtkIdType srcTupleIdx, vtkAbstractArray *source) override
Insert the tuple from srcTupleIdx in the source array at the end of this array.
virtual void SetTuple(vtkIdType tupleIdx, const double *tuple)
void InsertNextTuple2(double val0, double val1)
virtual void RemoveFirstTuple()
Definition: vtkDataArray.h:223
virtual double GetMaxNorm()
Return the maximum norm for the tuples.
double * GetTuple3(vtkIdType tupleIdx)
double * GetTuple2(vtkIdType tupleIdx)
int GetElementComponentSize() override
Return the size, in bytes, of the lowest-level element of an array.
Definition: vtkDataArray.h:82
void InsertTuple(vtkIdType dstTupleIdx, vtkIdType srcTupleIdx, vtkAbstractArray *source) override
Insert the tuple at srcTupleIdx in the source array into this array at dstTupleIdx.
void InsertTuple4(vtkIdType tupleIdx, double val0, double val1, double val2, double val3)
static void GetDataTypeRange(int type, double range[2])
void InsertTuple3(vtkIdType tupleIdx, double val0, double val1, double val2)
void InsertNextTuple9(double val0, double val1, double val2, double val3, double val4, double val5, double val6, double val7, double val8)
void SetTuple3(vtkIdType tupleIdx, double val0, double val1, double val2)
unsigned long GetActualMemorySize() override
Return the memory in kibibytes (1024 bytes) consumed by this data array.
void InsertTuples(vtkIdType dstStart, vtkIdType n, vtkIdType srcStart, vtkAbstractArray *source) override
Copy n consecutive tuples starting at srcStart from the source array to this array,...
void SetTuple2(vtkIdType tupleIdx, double val0, double val1)
void InsertTuple1(vtkIdType tupleIdx, double value)
These methods are included as convenience for the wrappers.
double * GetTuple9(vtkIdType tupleIdx)
static double GetDataTypeMax(int type)
dynamic, self-adjusting array of double
list of point or cell ids
Definition: vtkIdList.h:37
a simple class to control print indentation
Definition: vtkIndent.h:40
Key for string values in vtkInformation.
Store vtkAlgorithm input/output information.
map scalar values into colors via a lookup table
represent and manipulate 3D points
Definition: vtkPoints.h:40
@ value
Definition: vtkX3D.h:220
@ range
Definition: vtkX3D.h:238
@ type
Definition: vtkX3D.h:516
@ data
Definition: vtkX3D.h:315
#define vtkArrayDownCast_FastCastMacro(ArrayT)
This macro is used to tell vtkArrayDownCast to use FastDownCast instead of SafeDownCast.
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
int vtkIdType
Definition: vtkType.h:287
#define VTK_NEWINSTANCE