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 =========================================================================*/
42 #ifndef vtkDataArray_h
43 #define vtkDataArray_h
44 
45 #include "vtkCommonCoreModule.h" // For export macro
46 #include "vtkAbstractArray.h"
47 
48 class vtkDoubleArray;
49 class vtkIdList;
51 class vtkLookupTable;
52 class vtkPoints;
53 
55 {
56 public:
58  void PrintSelf(ostream& os, vtkIndent indent);
59 
65  static vtkDataArray* FastDownCast(vtkAbstractArray *source);
66 
68 
72  virtual int IsNumeric()
73  { return 1; }
75 
77 
80  { return this->GetDataTypeSize(); }
82 
88  virtual void SetTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source) = 0;
89 
94  virtual void InsertTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source) = 0;
95 
102 
106  virtual void GetTuples(vtkIdList *ptIds, vtkAbstractArray *output);
107 
111  virtual void GetTuples(vtkIdType p1, vtkIdType p2, vtkAbstractArray *output);
112 
113 
115 
119  virtual void InterpolateTuple(vtkIdType i, vtkIdList *ptIndices,
120  vtkAbstractArray* source, double* weights);
122 
124 
129  virtual void InterpolateTuple(vtkIdType i,
130  vtkIdType id1, vtkAbstractArray* source1,
131  vtkIdType id2, vtkAbstractArray* source2, double t);
133 
138  virtual double *GetTuple(vtkIdType i) = 0;
139 
143  virtual void GetTuple(vtkIdType i, double * tuple) = 0;
144 
146 
149  double GetTuple1(vtkIdType i);
150  double* GetTuple2(vtkIdType i);
151  double* GetTuple3(vtkIdType i);
152  double* GetTuple4(vtkIdType i);
153  double* GetTuple6(vtkIdType i);
154  double* GetTuple9(vtkIdType i);
156 
158 
161  virtual void SetTuple(vtkIdType i, const float * tuple) = 0;
162  virtual void SetTuple(vtkIdType i, const double * tuple) = 0;
164 
166 
169  void SetTuple1(vtkIdType i, double value);
170  void SetTuple2(vtkIdType i, double val0, double val1);
171  void SetTuple3(vtkIdType i, double val0, double val1, double val2);
172  void SetTuple4(vtkIdType i, double val0, double val1, double val2,
173  double val3);
174  void SetTuple6(vtkIdType i, double val0, double val1, double val2,
175  double val3, double val4, double val5);
176  void SetTuple9(vtkIdType i, double val0, double val1, double val2,
177  double val3, double val4, double val5, double val6,
178  double val7, double val8);
180 
182 
184  virtual void InsertTuple(vtkIdType i, const float * tuple) = 0;
185  virtual void InsertTuple(vtkIdType i, const double * tuple) = 0;
187 
189 
192  void InsertTuple1(vtkIdType i, double value);
193  void InsertTuple2(vtkIdType i, double val0, double val1);
194  void InsertTuple3(vtkIdType i, double val0, double val1, double val2);
195  void InsertTuple4(vtkIdType i, double val0, double val1, double val2,
196  double val3);
197  void InsertTuple9(vtkIdType i, double val0, double val1, double val2,
198  double val3, double val4, double val5, double val6,
199  double val7, double val8);
201 
203 
206  virtual vtkIdType InsertNextTuple(const float * tuple) = 0;
207  virtual vtkIdType InsertNextTuple(const double * tuple) = 0;
209 
211 
214  void InsertNextTuple1(double value);
215  void InsertNextTuple2(double val0, double val1);
216  void InsertNextTuple3(double val0, double val1, double val2);
217  void InsertNextTuple4(double val0, double val1, double val2,
218  double val3);
219  void InsertNextTuple9(double val0, double val1, double val2,
220  double val3, double val4, double val5, double val6,
221  double val7, double val8);
223 
225 
228  virtual void RemoveTuple(vtkIdType id) = 0;
229  virtual void RemoveFirstTuple() = 0;
230  virtual void RemoveLastTuple() = 0;
232 
236  virtual double GetComponent(vtkIdType i, int j);
237 
242  virtual void SetComponent(vtkIdType i, int j, double c);
243 
247  virtual void InsertComponent(vtkIdType i, int j, double c);
248 
250 
256  virtual void GetData(vtkIdType tupleMin, vtkIdType tupleMax, int compMin,
257  int compMax, vtkDoubleArray* data);
259 
261 
263  virtual void DeepCopy(vtkAbstractArray *aa);
264  virtual void DeepCopy(vtkDataArray *da);
266 
271  virtual void FillComponent(int j, double c);
272 
274 
280  virtual void CopyComponent(int j, vtkDataArray *from,
281  int fromComponent);
283 
287  virtual void* WriteVoidPointer(vtkIdType id, vtkIdType number) = 0;
288 
295  virtual unsigned long GetActualMemorySize();
296 
299  void CreateDefaultLookupTable();
300 
302 
303  void SetLookupTable(vtkLookupTable *lut);
304  vtkGetObjectMacro(LookupTable,vtkLookupTable);
306 
308 
315  void GetRange(double range[2], int comp)
316  {
317  this->ComputeRange(range, comp);
318  }
320 
322 
328  double* GetRange(int comp)
329  {
330  this->GetRange(this->Range, comp);
331  return this->Range;
332  }
334 
336 
341  double* GetRange()
342  {
343  return this->GetRange(0);
344  }
346 
348 
354  void GetRange(double range[2])
355  {
356  this->GetRange(range,0);
357  }
359 
361 
364  void GetDataTypeRange(double range[2]);
365  double GetDataTypeMin();
366  double GetDataTypeMax();
367  static void GetDataTypeRange(int type, double range[2]);
368  static double GetDataTypeMin(int type);
369  static double GetDataTypeMax(int type);
371 
374  virtual double GetMaxNorm();
375 
381  static vtkDataArray* CreateDataArray(int dataType);
382 
388  static vtkInformationDoubleVectorKey* COMPONENT_RANGE();
393  static vtkInformationDoubleVectorKey* L2_NORM_RANGE();
394 
400  virtual int CopyInformation(vtkInformation *infoFrom, int deep=1);
401 
403  virtual int GetArrayType() { return DataArray; }
404 
405 protected:
406 
407  friend class vtkPoints;
408 
413  virtual void ComputeRange(double range[2], int comp);
414 
419  virtual bool ComputeScalarRange(double* ranges);
420 
421  // Returns true if the range was computed. Will return false
422  // if you try to compute the range of an array of length zero.
423  virtual bool ComputeVectorRange(double range[2]);
424 
425  // Construct object with default tuple dimension (number of components) of 1.
426  vtkDataArray();
427  ~vtkDataArray();
428 
430  double Range[2];
431 
432 private:
433  double* GetTupleN(vtkIdType i, int n);
434 
435 private:
436  vtkDataArray(const vtkDataArray&); // Not implemented.
437  void operator=(const vtkDataArray&); // Not implemented.
438 };
439 
440 //------------------------------------------------------------------------------
442 {
443  switch (source->GetArrayType())
444  {
445  case DataArrayTemplate:
446  case TypedDataArray:
447  case DataArray:
448  case MappedDataArray:
449  return static_cast<vtkDataArray*>(source);
450  default:
451  return NULL;
452  }
453 }
454 
455 #endif
void PrintSelf(ostream &os, vtkIndent indent)
void GetRange(double range[2])
Definition: vtkDataArray.h:354
virtual void DeepCopy(vtkAbstractArray *da)
Store vtkAlgorithm input/output information.
Abstract superclass for all arrays.
virtual int GetDataTypeSize()=0
#define VTKCOMMONCORE_EXPORT
virtual void SetTuple(vtkIdType i, vtkIdType j, vtkAbstractArray *source)=0
map scalar values into colors via a lookup table
virtual int GetArrayType()
Definition: vtkDataArray.h:403
virtual int IsNumeric()
Definition: vtkDataArray.h:72
virtual int GetArrayType()
virtual int GetElementComponentSize()
Definition: vtkDataArray.h:79
int vtkIdType
Definition: vtkType.h:275
void GetRange(double range[2], int comp)
Definition: vtkDataArray.h:315
virtual int CopyInformation(vtkInformation *infoFrom, int deep=1)
dynamic, self-adjusting array of double
double * GetRange(int comp)
Definition: vtkDataArray.h:328
Key for double vector values.
a simple class to control print indentation
Definition: vtkIndent.h:38
double * GetRange()
Definition: vtkDataArray.h:341
list of point or cell ids
Definition: vtkIdList.h:35
virtual void InsertTuple(vtkIdType i, vtkIdType j, vtkAbstractArray *source)=0
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
virtual void GetTuples(vtkIdList *ptIds, vtkAbstractArray *output)
vtkLookupTable * LookupTable
Definition: vtkDataArray.h:429
virtual void InterpolateTuple(vtkIdType i, vtkIdList *ptIndices, vtkAbstractArray *source, double *weights)=0
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
static vtkDataArray * FastDownCast(vtkAbstractArray *source)
Definition: vtkDataArray.h:441
virtual vtkIdType InsertNextTuple(vtkIdType j, vtkAbstractArray *source)=0
virtual unsigned long GetActualMemorySize()=0
#define vtkDataArray
represent and manipulate 3D points
Definition: vtkPoints.h:38