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 
422  static vtkInformationDoubleVectorKey* COMPONENT_RANGE();
430  static vtkInformationDoubleVectorKey* L2_NORM_RANGE();
431 
435  static vtkInformationStringKey *UNITS_LABEL();
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.
477  vtkDataArray();
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  {
498  case AoSDataArrayTemplate:
499  case SoADataArrayTemplate:
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
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
#define vtkArrayDownCast_FastCastMacro(ArrayT)
This macro is used to tell vtkArrayDownCast to use FastDownCast instead of SafeDownCast.
virtual void DeepCopy(vtkAbstractArray *da)
Deep copy of data.
Store vtkAlgorithm input/output information.
virtual void GetTuples(vtkIdList *tupleIds, vtkAbstractArray *output)
Given a list of tuple ids, return an array of tuples.
Abstract superclass for all arrays.
virtual int GetDataTypeSize()=0
Return the size of the underlying data type.
map scalar values into colors via a lookup table
int vtkIdType
Definition: vtkType.h:287
virtual void InterpolateTuple(vtkIdType dstTupleIdx, vtkIdList *ptIndices, vtkAbstractArray *source, double *weights)=0
Set the tuple at dstTupleIdx in this array to the interpolated tuple value, given the ptIndices in th...
Key for string values in vtkInformation.
virtual int CopyInformation(vtkInformation *infoFrom, int deep=1)
Copy information instance.
dynamic, self-adjusting array of double
double * GetRange(int comp)
Return the range of the data array values for the given component.
Definition: vtkDataArray.h:352
#define vtkDataArray
Definition: vtkCharArray.h:36
Key for double vector values.
a simple class to control print indentation
Definition: vtkIndent.h:39
double * GetRange()
Return the range of the data array.
Definition: vtkDataArray.h:366
list of point or cell ids
Definition: vtkIdList.h:36
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
int GetElementComponentSize() override
Return the size, in bytes, of the lowest-level element of an array.
Definition: vtkDataArray.h:82
#define VTK_NEWINSTANCE
virtual void InsertTuple(vtkIdType dstTupleIdx, vtkIdType srcTupleIdx, vtkAbstractArray *source)=0
Insert the tuple at srcTupleIdx in the source array into this array at dstTupleIdx.
int IsNumeric() override
This method is here to make backward compatibility easier.
Definition: vtkDataArray.h:74
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
virtual vtkIdType InsertNextTuple(vtkIdType srcTupleIdx, vtkAbstractArray *source)=0
Insert the tuple from srcTupleIdx in the source array at the end of this array.
virtual void SetTuple(vtkIdType dstTupleIdx, vtkIdType srcTupleIdx, vtkAbstractArray *source)=0
Set the tuple at dstTupleIdx in this array to the tuple at srcTupleIdx in the source array...
virtual unsigned long GetActualMemorySize()=0
Return the memory in kibibytes (1024 bytes) consumed by this data array.
virtual void InsertTuples(vtkIdList *dstIds, vtkIdList *srcIds, vtkAbstractArray *source)=0
Copy the tuples indexed in srcIds from the source array to the tuple locations indexed by dstIds in t...
represent and manipulate 3D points
Definition: vtkPoints.h:39
virtual void RemoveFirstTuple()
These methods remove tuples from the data array.
Definition: vtkDataArray.h:223
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.