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 =========================================================================*/
35 #ifndef vtkDataArray_h
36 #define vtkDataArray_h
37 
38 #include "vtkCommonCoreModule.h" // For export macro
39 #include "vtkAbstractArray.h"
40 
41 class vtkDoubleArray;
42 class vtkIdList;
45 class vtkLookupTable;
46 class vtkPoints;
47 
48 class VTKCOMMONCORE_EXPORT vtkDataArray : public vtkAbstractArray
49 {
50 public:
52  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
53 
60  static vtkDataArray* FastDownCast(vtkAbstractArray *source);
61 
68  int IsNumeric() VTK_OVERRIDE
69  { return 1; }
70 
76  int GetElementComponentSize() VTK_OVERRIDE
77  { return this->GetDataTypeSize(); }
78 
79  // Reimplemented virtuals (doc strings are inherited from superclass):
80  void InsertTuple(vtkIdType dstTupleIdx, vtkIdType srcTupleIdx,
81  vtkAbstractArray* source) VTK_OVERRIDE;
83  vtkAbstractArray* source) VTK_OVERRIDE;
84  void InsertTuples(vtkIdList *dstIds, vtkIdList *srcIds,
85  vtkAbstractArray *source) VTK_OVERRIDE;
86  void InsertTuples(vtkIdType dstStart, vtkIdType n, vtkIdType srcStart,
87  vtkAbstractArray* source) VTK_OVERRIDE;
88  void GetTuples(vtkIdList *tupleIds, vtkAbstractArray *output) VTK_OVERRIDE;
89  void GetTuples(vtkIdType p1, vtkIdType p2, vtkAbstractArray *output) VTK_OVERRIDE;
90  void InterpolateTuple(vtkIdType dstTupleIdx, vtkIdList *ptIndices,
91  vtkAbstractArray* source, double* weights) VTK_OVERRIDE;
92  void InterpolateTuple(vtkIdType dstTupleIdx,
93  vtkIdType srcTupleIdx1, vtkAbstractArray* source1,
94  vtkIdType srcTupleIdx2, vtkAbstractArray* source2, double t) VTK_OVERRIDE;
95 
101  virtual double *GetTuple(vtkIdType tupleIdx) = 0;
102 
108  virtual void GetTuple(vtkIdType tupleIdx, double * tuple) = 0;
109 
111 
116  double GetTuple1(vtkIdType tupleIdx);
117  double* GetTuple2(vtkIdType tupleIdx);
118  double* GetTuple3(vtkIdType tupleIdx);
119  double* GetTuple4(vtkIdType tupleIdx);
120  double* GetTuple6(vtkIdType tupleIdx);
121  double* GetTuple9(vtkIdType tupleIdx);
123 
124  void SetTuple(vtkIdType dstTupleIdx, vtkIdType srcTupleIdx,
125  vtkAbstractArray* source) VTK_OVERRIDE;
126 
128 
133  virtual void SetTuple(vtkIdType tupleIdx, const float * tuple);
134  virtual void SetTuple(vtkIdType tupleIdx, const double * tuple);
136 
138 
143  void SetTuple1(vtkIdType tupleIdx, double value);
144  void SetTuple2(vtkIdType tupleIdx, double val0, double val1);
145  void SetTuple3(vtkIdType tupleIdx, double val0, double val1, double val2);
146  void SetTuple4(vtkIdType tupleIdx, double val0, double val1, double val2,
147  double val3);
148  void SetTuple6(vtkIdType tupleIdx, double val0, double val1, double val2,
149  double val3, double val4, double val5);
150  void SetTuple9(vtkIdType tupleIdx, double val0, double val1, double val2,
151  double val3, double val4, double val5, double val6,
152  double val7, double val8);
154 
156 
160  virtual void InsertTuple(vtkIdType tupleIdx, const float * tuple) = 0;
161  virtual void InsertTuple(vtkIdType tupleIdx, const double * tuple) = 0;
163 
165 
170  void InsertTuple1(vtkIdType tupleIdx, double value);
171  void InsertTuple2(vtkIdType tupleIdx, double val0, double val1);
172  void InsertTuple3(vtkIdType tupleIdx, double val0, double val1, double val2);
173  void InsertTuple4(vtkIdType tupleIdx, double val0, double val1, double val2,
174  double val3);
175  void InsertTuple6(vtkIdType tupleIdx, double val0, double val1, double val2,
176  double val3, double val4, double val5);
177  void InsertTuple9(vtkIdType tupleIdx, double val0, double val1, double val2,
178  double val3, double val4, double val5, double val6,
179  double val7, double val8);
181 
183 
188  virtual vtkIdType InsertNextTuple(const float * tuple) = 0;
189  virtual vtkIdType InsertNextTuple(const double * tuple) = 0;
191 
193 
198  void InsertNextTuple1(double value);
199  void InsertNextTuple2(double val0, double val1);
200  void InsertNextTuple3(double val0, double val1, double val2);
201  void InsertNextTuple4(double val0, double val1, double val2,
202  double val3);
203  void InsertNextTuple6(double val0, double val1, double val2,
204  double val3, double val4, double val5);
205  void InsertNextTuple9(double val0, double val1, double val2,
206  double val3, double val4, double val5, double val6,
207  double val7, double val8);
209 
211 
216  virtual void RemoveTuple(vtkIdType tupleIdx) = 0;
217  virtual void RemoveFirstTuple() { this->RemoveTuple(0); }
218  virtual void RemoveLastTuple();
220 
225  virtual double GetComponent(vtkIdType tupleIdx, int compIdx);
226 
234  virtual void SetComponent(vtkIdType tupleIdx, int compIdx, double value);
235 
240  virtual void InsertComponent(vtkIdType tupleIdx, int compIdx, double value);
241 
250  virtual void GetData(vtkIdType tupleMin, vtkIdType tupleMax, int compMin,
251  int compMax, vtkDoubleArray* data);
252 
254 
258  void DeepCopy(vtkAbstractArray *aa) VTK_OVERRIDE;
259  virtual void DeepCopy(vtkDataArray *da);
261 
271  virtual void ShallowCopy(vtkDataArray *other);
272 
279  virtual void FillComponent(int compIdx, double value);
280 
284  virtual void Fill(double value);
285 
294  virtual void CopyComponent(int dstComponent, vtkDataArray *src,
295  int srcComponent);
296 
302  virtual void* WriteVoidPointer(vtkIdType valueIdx, vtkIdType numValues) = 0;
303 
312  unsigned long GetActualMemorySize() VTK_OVERRIDE;
313 
318  void CreateDefaultLookupTable();
319 
321 
324  void SetLookupTable(vtkLookupTable *lut);
325  vtkGetObjectMacro(LookupTable,vtkLookupTable);
327 
337  void GetRange(double range[2], int comp)
338  {
339  this->ComputeRange(range, comp);
340  }
341 
343 
351  double* GetRange(int comp)
352  {
353  this->GetRange(this->Range, comp);
354  return this->Range;
355  }
357 
365  double* GetRange()
366  {
367  return this->GetRange(0);
368  }
369 
378  void GetRange(double range[2])
379  {
380  this->GetRange(range,0);
381  }
382 
392  void GetFiniteRange(double range[2], int comp)
393  {
394  this->ComputeFiniteRange(range, comp);
395  }
396 
398 
406  double *GetFiniteRange(int comp)
407  {
408  this->GetFiniteRange(this->FiniteRange, comp);
409  return this->FiniteRange;
410  }
412 
420  double *GetFiniteRange()
421  {
422  return this->GetFiniteRange(0);
423  }
424 
433  void GetFiniteRange(double range[2])
434  {
435  this->GetFiniteRange(range, 0);
436  }
437 
439 
444  void GetDataTypeRange(double range[2]);
445  double GetDataTypeMin();
446  double GetDataTypeMax();
447  static void GetDataTypeRange(int type, double range[2]);
448  static double GetDataTypeMin(int type);
449  static double GetDataTypeMax(int type);
451 
456  virtual double GetMaxNorm();
457 
467  static vtkDataArray* CreateDataArray(int dataType);
468 
476  static vtkInformationDoubleVectorKey* COMPONENT_RANGE();
477 
485  static vtkInformationDoubleVectorKey* L2_NORM_RANGE();
486 
490  static vtkInformationStringKey *UNITS_LABEL();
491 
499  int CopyInformation(vtkInformation *infoFrom, int deep=1) VTK_OVERRIDE;
500 
504  int GetArrayType() VTK_OVERRIDE { return DataArray; }
505 
506 protected:
507 
508  friend class vtkPoints;
509 
516  vtkInformation* GetFiniteInformation();
517 
524  void SetFiniteInformation(vtkInformation *args);
525 
533  virtual void ComputeRange(double range[2], int comp);
534 
542  virtual void ComputeFiniteRange(double range[2], int comp);
543 
550  virtual bool ComputeScalarRange(double* ranges);
551 
552  // Returns true if the range was computed. Will return false
553  // if you try to compute the range of an array of length zero.
554  virtual bool ComputeVectorRange(double range[2]);
555 
562  virtual bool ComputeFiniteScalarRange(double* ranges);
563 
564  // Returns true if the range was computed. Will return false
565  // if you try to compute the range of an array of length zero.
566  virtual bool ComputeFiniteVectorRange(double range[2]);
567 
568  // Construct object with default tuple dimension (number of components) of 1.
569  vtkDataArray();
570  ~vtkDataArray() VTK_OVERRIDE;
571 
572  vtkLookupTable *LookupTable;
573  double Range[2];
574  double FiniteRange[2];
575  vtkInformation *FiniteInformation;
576 
577 private:
578  double* GetTupleN(vtkIdType i, int n);
579 
580 private:
581  vtkDataArray(const vtkDataArray&) VTK_DELETE_FUNCTION;
582  void operator=(const vtkDataArray&) VTK_DELETE_FUNCTION;
583 };
584 
585 //------------------------------------------------------------------------------
586 inline vtkDataArray* vtkDataArray::FastDownCast(vtkAbstractArray *source)
587 {
588  if (source)
589  {
590  switch (source->GetArrayType())
591  {
594  case TypedDataArray:
595  case DataArray:
596  case MappedDataArray:
597  return static_cast<vtkDataArray*>(source);
598  default:
599  break;
600  }
601  }
602  return NULL;
603 }
604 
606 
607 #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:378
#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:392
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:433
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:337
int GetArrayType() override
Method for type-checking in FastDownCast implementations.
Definition: vtkDataArray.h:504
double * GetFiniteRange(int comp)
Return the range of the data array values for the given component.
Definition: vtkDataArray.h:406
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:351
#define vtkDataArray
Definition: vtkCharArray.h:33
Key for double vector values.
double * GetFiniteRange()
Return the range of the data array.
Definition: vtkDataArray.h:420
a simple class to control print indentation
Definition: vtkIndent.h:33
double * GetRange()
Return the range of the data array.
Definition: vtkDataArray.h:365
list of point or cell ids
Definition: vtkIdList.h:30
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:48
int GetElementComponentSize() override
Return the size, in bytes, of the lowest-level element of an array.
Definition: vtkDataArray.h:76
#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:68
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:33
virtual void RemoveFirstTuple()
These methods remove tuples from the data array.
Definition: vtkDataArray.h:217
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.