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 "vtkAbstractArray.h"
46 
47 class vtkDoubleArray;
48 class vtkIdList;
51 class vtkLookupTable;
52 
54 {
55 public:
57  void PrintSelf(ostream& os, vtkIndent indent);
58 
60 
64  virtual int IsNumeric()
65  { return 1; }
67 
69 
71  virtual int GetElementComponentSize()
72  { return this->GetDataTypeSize(); }
74 
80  virtual void SetTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source) = 0;
81 
86  virtual void InsertTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source) = 0;
87 
93  virtual vtkIdType InsertNextTuple(vtkIdType j, vtkAbstractArray* source) = 0;
94 
98  virtual void GetTuples(vtkIdList *ptIds, vtkAbstractArray *output);
99 
103  virtual void GetTuples(vtkIdType p1, vtkIdType p2, vtkAbstractArray *output);
104 
105 
107 
111  virtual void InterpolateTuple(vtkIdType i, vtkIdList *ptIndices,
112  vtkAbstractArray* source, double* weights);
114 
116 
121  virtual void InterpolateTuple(vtkIdType i,
122  vtkIdType id1, vtkAbstractArray* source1,
123  vtkIdType id2, vtkAbstractArray* source2, double t);
125 
130  virtual double *GetTuple(vtkIdType i) = 0;
131 
135  virtual void GetTuple(vtkIdType i, double * tuple) = 0;
136 
138 
141  double GetTuple1(vtkIdType i);
142  double* GetTuple2(vtkIdType i);
143  double* GetTuple3(vtkIdType i);
144  double* GetTuple4(vtkIdType i);
145  double* GetTuple9(vtkIdType i);
147 
149 
152  virtual void SetTuple(vtkIdType i, const float * tuple) = 0;
153  virtual void SetTuple(vtkIdType i, const double * tuple) = 0;
155 
157 
160  void SetTuple1(vtkIdType i, double value);
161  void SetTuple2(vtkIdType i, double val0, double val1);
162  void SetTuple3(vtkIdType i, double val0, double val1, double val2);
163  void SetTuple4(vtkIdType i, double val0, double val1, double val2,
164  double val3);
165  void SetTuple9(vtkIdType i, double val0, double val1, double val2,
166  double val3, double val4, double val5, double val6,
167  double val7, double val8);
169 
171 
173  virtual void InsertTuple(vtkIdType i, const float * tuple) = 0;
174  virtual void InsertTuple(vtkIdType i, const double * tuple) = 0;
176 
178 
181  void InsertTuple1(vtkIdType i, double value);
182  void InsertTuple2(vtkIdType i, double val0, double val1);
183  void InsertTuple3(vtkIdType i, double val0, double val1, double val2);
184  void InsertTuple4(vtkIdType i, double val0, double val1, double val2,
185  double val3);
186  void InsertTuple9(vtkIdType i, double val0, double val1, double val2,
187  double val3, double val4, double val5, double val6,
188  double val7, double val8);
190 
192 
195  virtual vtkIdType InsertNextTuple(const float * tuple) = 0;
196  virtual vtkIdType InsertNextTuple(const double * tuple) = 0;
198 
200 
203  void InsertNextTuple1(double value);
204  void InsertNextTuple2(double val0, double val1);
205  void InsertNextTuple3(double val0, double val1, double val2);
206  void InsertNextTuple4(double val0, double val1, double val2,
207  double val3);
208  void InsertNextTuple9(double val0, double val1, double val2,
209  double val3, double val4, double val5, double val6,
210  double val7, double val8);
212 
214 
217  virtual void RemoveTuple(vtkIdType id) = 0;
218  virtual void RemoveFirstTuple() = 0;
219  virtual void RemoveLastTuple() = 0;
221 
225  virtual double GetComponent(vtkIdType i, int j);
226 
231  virtual void SetComponent(vtkIdType i, int j, double c);
232 
236  virtual void InsertComponent(vtkIdType i, int j, double c);
237 
239 
245  virtual void GetData(vtkIdType tupleMin, vtkIdType tupleMax, int compMin,
246  int compMax, vtkDoubleArray* data);
248 
250 
252  virtual void DeepCopy(vtkAbstractArray *aa);
253  virtual void DeepCopy(vtkDataArray *da);
255 
260  virtual void FillComponent(int j, double c);
261 
263 
269  virtual void CopyComponent(int j, vtkDataArray *from,
270  int fromComponent);
272 
276  virtual void* WriteVoidPointer(vtkIdType id, vtkIdType number) = 0;
277 
284  virtual unsigned long GetActualMemorySize();
285 
288  void CreateDefaultLookupTable();
289 
291 
292  void SetLookupTable(vtkLookupTable *lut);
293  vtkGetObjectMacro(LookupTable,vtkLookupTable);
295 
297 
301  void GetRange(double range[2], int comp)
302  {
303  this->ComputeRange(comp);
304  memcpy(range, this->Range, 2*sizeof(double));
305  }
306  double* GetRange(int comp)
307  {
308  this->ComputeRange(comp);
309  return this->Range;
310  }
311  // Description:
312  // Return the range of the array values for the 0th component.
313  // Range is copied into the array provided.
314  double* GetRange()
315  {
316  this->ComputeRange(0);
317  return this->Range;
318  }
319  void GetRange(double range[2])
320  {
321  this->GetRange(range,0);
322  }
323  // Description:
324  // These methods return the Min and Max possible range of the native
325  // data type. For example if a vtkScalars consists of unsigned char
326  // data these will return (0,255).
327  void GetDataTypeRange(double range[2]);
328  double GetDataTypeMin();
329  double GetDataTypeMax();
330  static void GetDataTypeRange(int type, double range[2]);
331  static double GetDataTypeMin(int type);
332  static double GetDataTypeMax(int type);
334 
337  virtual double GetMaxNorm();
338 
344  static vtkDataArray* CreateDataArray(int dataType);
345 
347 
357  static vtkInformationInformationVectorKey* PER_COMPONENT();
358  // Description:
359  // This key is used to hold tight bounds on the range of
360  // one component over all tuples of the array.
361  // Two values (a minimum and maximum) are stored for each component.
362  // When GetRange() is called when no tuples are present in the array
363  // this value is set to { VTK_DOUBLE_MAX, VTK_DOUBLE_MIN }.
364  static vtkInformationDoubleVectorKey* COMPONENT_RANGE();
365  // Description:
366  // This key is used to hold tight bounds on the $L_2$ norm
367  // of tuples in the array.
368  // Two values (a minimum and maximum) are stored for each component.
369  // When GetRange() is called when no tuples are present in the array
370  // this value is set to { VTK_DOUBLE_MAX, VTK_DOUBLE_MIN }.
371  static vtkInformationDoubleVectorKey* L2_NORM_RANGE();
373 
379  virtual int CopyInformation(vtkInformation *infoFrom, int deep=1);
380 
381 protected:
383 
386  virtual void ComputeRange(int comp);
387  // Description:
388  // Slow range computation methods. Reimplement.
389  virtual void ComputeScalarRange(int comp);
390  virtual void ComputeVectorRange();
392 
393  // Construct object with default tuple dimension (number of components) of 1.
394  vtkDataArray(vtkIdType numComp=1);
395  ~vtkDataArray();
396 
398  double Range[2];
399 
400 private:
401  double* GetTupleN(vtkIdType i, int n);
402 
403 private:
404  vtkDataArray(const vtkDataArray&); // Not implemented.
405  void operator=(const vtkDataArray&); // Not implemented.
406 };
407 
408 #endif
void PrintSelf(ostream &os, vtkIndent indent)
void GetRange(double range[2])
Definition: vtkDataArray.h:319
virtual void DeepCopy(vtkAbstractArray *da)
Store vtkAlgorithm input/output information.
Abstract superclass for all arrays.
virtual int GetDataTypeSize()=0
virtual void SetTuple(vtkIdType i, vtkIdType j, vtkAbstractArray *source)=0
map scalar values into colors via a lookup table
virtual int IsNumeric()
Definition: vtkDataArray.h:64
virtual int GetElementComponentSize()
Definition: vtkDataArray.h:71
int vtkIdType
Definition: vtkType.h:255
void GetRange(double range[2], int comp)
Definition: vtkDataArray.h:301
virtual int CopyInformation(vtkInformation *infoFrom, int deep=1)
dynamic, self-adjusting array of double
double * GetRange(int comp)
Definition: vtkDataArray.h:306
Key for double vector values.
a simple class to control print indentation
Definition: vtkIndent.h:37
double * GetRange()
Definition: vtkDataArray.h:314
list of point or cell ids
Definition: vtkIdList.h:34
virtual void InsertTuple(vtkIdType i, vtkIdType j, vtkAbstractArray *source)=0
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:53
virtual void GetTuples(vtkIdList *ptIds, vtkAbstractArray *output)
#define VTK_COMMON_EXPORT
vtkLookupTable * LookupTable
Definition: vtkDataArray.h:397
virtual void InterpolateTuple(vtkIdType i, vtkIdList *ptIndices, vtkAbstractArray *source, double *weights)=0
virtual vtkIdType InsertNextTuple(vtkIdType j, vtkAbstractArray *source)=0
virtual unsigned long GetActualMemorySize()=0
#define vtkDataArray