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 
290  virtual void Fill(double value);
291 
300  virtual void CopyComponent(int dstComponent, vtkDataArray *src,
301  int srcComponent);
302 
308  virtual void* WriteVoidPointer(vtkIdType valueIdx, vtkIdType numValues) = 0;
309 
318  unsigned long GetActualMemorySize() VTK_OVERRIDE;
319 
324  void CreateDefaultLookupTable();
325 
327 
330  void SetLookupTable(vtkLookupTable *lut);
331  vtkGetObjectMacro(LookupTable,vtkLookupTable);
333 
343  void GetRange(double range[2], int comp)
344  {
345  this->ComputeRange(range, comp);
346  }
347 
349 
357  double* GetRange(int comp)
358  {
359  this->GetRange(this->Range, comp);
360  return this->Range;
361  }
363 
371  double* GetRange()
372  {
373  return this->GetRange(0);
374  }
375 
384  void GetRange(double range[2])
385  {
386  this->GetRange(range,0);
387  }
388 
398  void GetFiniteRange(double range[2], int comp)
399  {
400  this->ComputeFiniteRange(range, comp);
401  }
402 
404 
412  double *GetFiniteRange(int comp)
413  {
414  this->GetFiniteRange(this->FiniteRange, comp);
415  return this->FiniteRange;
416  }
418 
426  double *GetFiniteRange()
427  {
428  return this->GetFiniteRange(0);
429  }
430 
439  void GetFiniteRange(double range[2])
440  {
441  this->GetFiniteRange(range, 0);
442  }
443 
445 
450  void GetDataTypeRange(double range[2]);
451  double GetDataTypeMin();
452  double GetDataTypeMax();
453  static void GetDataTypeRange(int type, double range[2]);
454  static double GetDataTypeMin(int type);
455  static double GetDataTypeMax(int type);
457 
462  virtual double GetMaxNorm();
463 
473  static vtkDataArray* CreateDataArray(int dataType);
474 
482  static vtkInformationDoubleVectorKey* COMPONENT_RANGE();
483 
491  static vtkInformationDoubleVectorKey* L2_NORM_RANGE();
492 
496  static vtkInformationStringKey *UNITS_LABEL();
497 
505  int CopyInformation(vtkInformation *infoFrom, int deep=1) VTK_OVERRIDE;
506 
510  int GetArrayType() VTK_OVERRIDE { return DataArray; }
511 
512 protected:
513 
514  friend class vtkPoints;
515 
522  vtkInformation* GetFiniteInformation();
523 
530  void SetFiniteInformation(vtkInformation *args);
531 
539  virtual void ComputeRange(double range[2], int comp);
540 
548  virtual void ComputeFiniteRange(double range[2], int comp);
549 
556  virtual bool ComputeScalarRange(double* ranges);
557 
558  // Returns true if the range was computed. Will return false
559  // if you try to compute the range of an array of length zero.
560  virtual bool ComputeVectorRange(double range[2]);
561 
568  virtual bool ComputeFiniteScalarRange(double* ranges);
569 
570  // Returns true if the range was computed. Will return false
571  // if you try to compute the range of an array of length zero.
572  virtual bool ComputeFiniteVectorRange(double range[2]);
573 
574  // Construct object with default tuple dimension (number of components) of 1.
575  vtkDataArray();
576  ~vtkDataArray() VTK_OVERRIDE;
577 
578  vtkLookupTable *LookupTable;
579  double Range[2];
580  double FiniteRange[2];
581  vtkInformation *FiniteInformation;
582 
583 private:
584  double* GetTupleN(vtkIdType i, int n);
585 
586 private:
587  vtkDataArray(const vtkDataArray&) VTK_DELETE_FUNCTION;
588  void operator=(const vtkDataArray&) VTK_DELETE_FUNCTION;
589 };
590 
591 //------------------------------------------------------------------------------
592 inline vtkDataArray* vtkDataArray::FastDownCast(vtkAbstractArray *source)
593 {
594  if (source)
595  {
596  switch (source->GetArrayType())
597  {
600  case TypedDataArray:
601  case DataArray:
602  case MappedDataArray:
603  return static_cast<vtkDataArray*>(source);
604  default:
605  break;
606  }
607  }
608  return NULL;
609 }
610 
612 
613 #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:384
#define vtkArrayDownCast_FastCastMacro(ArrayT)
This macro is used to tell vtkArrayDownCast to use FastDownCast instead of SafeDownCast.
void GetFiniteRange(double range[2], int comp)
The range of the data array values for the given component will be returned in the provided range arr...
Definition: vtkDataArray.h:398
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:345
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...
void GetFiniteRange(double range[2])
The the range of the data array values will be returned in the provided range array argument...
Definition: vtkDataArray.h:439
Key for string values in vtkInformation.
void GetRange(double range[2], int comp)
The range of the data array values for the given component will be returned in the provided range arr...
Definition: vtkDataArray.h:343
int GetArrayType() override
Method for type-checking in FastDownCast implementations.
Definition: vtkDataArray.h:510
double * GetFiniteRange(int comp)
Return the range of the data array values for the given component.
Definition: vtkDataArray.h:412
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:357
#define vtkDataArray
Definition: vtkCharArray.h:36
Key for double vector values.
double * GetFiniteRange()
Return the range of the data array.
Definition: vtkDataArray.h:426
a simple class to control print indentation
Definition: vtkIndent.h:39
double * GetRange()
Return the range of the data array.
Definition: vtkDataArray.h:371
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.