VTK  9.2.5
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 "vtkAbstractArray.h"
45#include "vtkCommonCoreModule.h" // For export macro
46#include "vtkVTK_USE_SCALED_SOA_ARRAYS.h" // For #define of VTK_USE_SCALED_SOA_ARRAYS
47
48class vtkDoubleArray;
49class vtkIdList;
52class vtkLookupTable;
53class vtkPoints;
54
55class VTKCOMMONCORE_EXPORT vtkDataArray : public vtkAbstractArray
56{
57public:
59 void PrintSelf(ostream& os, vtkIndent indent) override;
60
67 static vtkDataArray* FastDownCast(vtkAbstractArray* source);
68
75 int IsNumeric() const override { return 1; }
76
82 int GetElementComponentSize() const override { return this->GetDataTypeSize(); }
83
84 // Reimplemented virtuals (doc strings are inherited from superclass):
86
91 void InsertTuple(vtkIdType dstTupleIdx, vtkIdType srcTupleIdx, vtkAbstractArray* source) override;
93 void InsertTuples(vtkIdList* dstIds, vtkIdList* srcIds, vtkAbstractArray* source) override;
95 vtkIdType dstStart, vtkIdType n, vtkIdType srcStart, vtkAbstractArray* source) override;
97 vtkIdType dstStart, vtkIdList* srcIds, vtkAbstractArray* source) override;
98 void SetTuple(vtkIdType dstTupleIdx, vtkIdType srcTupleIdx, vtkAbstractArray* source) override;
100 void GetTuples(vtkIdList* tupleIds, vtkAbstractArray* output) override;
101 void GetTuples(vtkIdType p1, vtkIdType p2, vtkAbstractArray* output) override;
103 double* weights) override;
104 void InterpolateTuple(vtkIdType dstTupleIdx, vtkIdType srcTupleIdx1, vtkAbstractArray* source1,
105 vtkIdType srcTupleIdx2, vtkAbstractArray* source2, double t) override;
106
112 virtual double* GetTuple(vtkIdType tupleIdx)
113 VTK_EXPECTS(0 <= tupleIdx && tupleIdx < GetNumberOfTuples()) = 0;
114
120 virtual void GetTuple(vtkIdType tupleIdx, double* tuple)
121 VTK_EXPECTS(0 <= tupleIdx && tupleIdx < GetNumberOfTuples()) = 0;
122
124
129 double GetTuple1(vtkIdType tupleIdx) VTK_EXPECTS(0 <= tupleIdx && tupleIdx < GetNumberOfTuples());
130 double* GetTuple2(vtkIdType tupleIdx) VTK_EXPECTS(0 <= tupleIdx && tupleIdx < GetNumberOfTuples())
131 VTK_SIZEHINT(2);
132 double* GetTuple3(vtkIdType tupleIdx) VTK_EXPECTS(0 <= tupleIdx && tupleIdx < GetNumberOfTuples())
133 VTK_SIZEHINT(3);
134 double* GetTuple4(vtkIdType tupleIdx) VTK_EXPECTS(0 <= tupleIdx && tupleIdx < GetNumberOfTuples())
135 VTK_SIZEHINT(4);
136 double* GetTuple6(vtkIdType tupleIdx) VTK_EXPECTS(0 <= tupleIdx && tupleIdx < GetNumberOfTuples())
137 VTK_SIZEHINT(6);
138 double* GetTuple9(vtkIdType tupleIdx) VTK_EXPECTS(0 <= tupleIdx && tupleIdx < GetNumberOfTuples())
139 VTK_SIZEHINT(9);
141
143
148 virtual void SetTuple(vtkIdType tupleIdx, const float* tuple)
149 VTK_EXPECTS(0 <= tupleIdx && tupleIdx < GetNumberOfTuples());
150 virtual void SetTuple(vtkIdType tupleIdx, const double* tuple)
151 VTK_EXPECTS(0 <= tupleIdx && tupleIdx < GetNumberOfTuples());
153
155
160 void SetTuple1(vtkIdType tupleIdx, double value)
161 VTK_EXPECTS(0 <= tupleIdx && tupleIdx < GetNumberOfTuples());
162 void SetTuple2(vtkIdType tupleIdx, double val0, double val1)
163 VTK_EXPECTS(0 <= tupleIdx && tupleIdx < GetNumberOfTuples());
164 void SetTuple3(vtkIdType tupleIdx, double val0, double val1, double val2)
165 VTK_EXPECTS(0 <= tupleIdx && tupleIdx < GetNumberOfTuples());
166 void SetTuple4(vtkIdType tupleIdx, double val0, double val1, double val2, double val3)
167 VTK_EXPECTS(0 <= tupleIdx && tupleIdx < GetNumberOfTuples());
168 void SetTuple6(vtkIdType tupleIdx, double val0, double val1, double val2, double val3,
169 double val4, double val5) VTK_EXPECTS(0 <= tupleIdx && tupleIdx < GetNumberOfTuples());
170 void SetTuple9(vtkIdType tupleIdx, double val0, double val1, double val2, double val3,
171 double val4, double val5, double val6, double val7, double val8)
172 VTK_EXPECTS(0 <= tupleIdx && tupleIdx < GetNumberOfTuples());
174
176
180 virtual void InsertTuple(vtkIdType tupleIdx, const float* tuple) VTK_EXPECTS(0 <= tupleIdx) = 0;
181 virtual void InsertTuple(vtkIdType tupleIdx, const double* tuple) VTK_EXPECTS(0 <= tupleIdx) = 0;
183
185
190 void InsertTuple1(vtkIdType tupleIdx, double value) VTK_EXPECTS(0 <= tupleIdx);
191 void InsertTuple2(vtkIdType tupleIdx, double val0, double val1) VTK_EXPECTS(0 <= tupleIdx);
192 void InsertTuple3(vtkIdType tupleIdx, double val0, double val1, double val2)
193 VTK_EXPECTS(0 <= tupleIdx);
194 void InsertTuple4(vtkIdType tupleIdx, double val0, double val1, double val2, double val3)
195 VTK_EXPECTS(0 <= tupleIdx);
196 void InsertTuple6(vtkIdType tupleIdx, double val0, double val1, double val2, double val3,
197 double val4, double val5) VTK_EXPECTS(0 <= tupleIdx);
198 void InsertTuple9(vtkIdType tupleIdx, double val0, double val1, double val2, double val3,
199 double val4, double val5, double val6, double val7, double val8) VTK_EXPECTS(0 <= tupleIdx);
201
203
208 virtual vtkIdType InsertNextTuple(const float* tuple) = 0;
209 virtual vtkIdType InsertNextTuple(const double* tuple) = 0;
211
213
218 void InsertNextTuple1(double value);
219 void InsertNextTuple2(double val0, double val1);
220 void InsertNextTuple3(double val0, double val1, double val2);
221 void InsertNextTuple4(double val0, double val1, double val2, double val3);
222 void InsertNextTuple6(
223 double val0, double val1, double val2, double val3, double val4, double val5);
224 void InsertNextTuple9(double val0, double val1, double val2, double val3, double val4,
225 double val5, double val6, double val7, double val8);
227
229
234 virtual void RemoveTuple(vtkIdType tupleIdx)
235 VTK_EXPECTS(0 <= tupleIdx && tupleIdx < GetNumberOfTuples()) = 0;
236 virtual void RemoveFirstTuple() { this->RemoveTuple(0); }
237 virtual void RemoveLastTuple();
239
244 virtual double GetComponent(vtkIdType tupleIdx, int compIdx) VTK_EXPECTS(0 <= tupleIdx &&
245 tupleIdx < GetNumberOfTuples()) VTK_EXPECTS(0 <= compIdx && compIdx < GetNumberOfComponents());
246
254 virtual void SetComponent(vtkIdType tupleIdx, int compIdx, double value)
255 VTK_EXPECTS(0 <= tupleIdx && tupleIdx < GetNumberOfTuples())
256 VTK_EXPECTS(0 <= compIdx && compIdx < GetNumberOfComponents());
257
262 virtual void InsertComponent(vtkIdType tupleIdx, int compIdx, double value)
263 VTK_EXPECTS(0 <= tupleIdx) VTK_EXPECTS(0 <= compIdx && compIdx < GetNumberOfComponents());
264
273 virtual void GetData(
274 vtkIdType tupleMin, vtkIdType tupleMax, int compMin, int compMax, vtkDoubleArray* data);
275
277
281 void DeepCopy(vtkAbstractArray* aa) override;
282 virtual void DeepCopy(vtkDataArray* da);
284
294 virtual void ShallowCopy(vtkDataArray* other);
295
302 virtual void FillComponent(int compIdx, double value)
303 VTK_EXPECTS(0 <= compIdx && compIdx < GetNumberOfComponents());
304
308 virtual void Fill(double value);
309
318 virtual void CopyComponent(int dstComponent, vtkDataArray* src, int srcComponent);
319
325 virtual void* WriteVoidPointer(vtkIdType valueIdx, vtkIdType numValues) = 0;
326
335 unsigned long GetActualMemorySize() const override;
336
341 void CreateDefaultLookupTable();
342
344
347 void SetLookupTable(vtkLookupTable* lut);
348 vtkGetObjectMacro(LookupTable, vtkLookupTable);
350
352
369 void GetRange(double range[2], int comp) { this->ComputeRange(range, comp); }
370 void GetRange(double range[2], int comp, const unsigned char* ghosts, unsigned char ghostsToSkip)
371 {
372 this->ComputeRange(range, comp, ghosts, ghostsToSkip);
373 }
375
377
385 double* GetRange(int comp) VTK_SIZEHINT(2)
386 {
387 this->GetRange(this->Range, comp);
388 return this->Range;
389 }
391
399 double* GetRange() VTK_SIZEHINT(2) { return this->GetRange(0); }
400
409 void GetRange(double range[2]) { this->GetRange(range, 0); }
410
412
430 void GetFiniteRange(double range[2], int comp) { this->ComputeFiniteRange(range, comp); }
432 double range[2], int comp, const unsigned char* ghosts, unsigned char ghostsToSkip)
433 {
434 this->ComputeFiniteRange(range, comp, ghosts, ghostsToSkip);
435 }
437
439
447 double* GetFiniteRange(int comp) VTK_SIZEHINT(2)
448 {
449 this->GetFiniteRange(this->FiniteRange, comp);
450 return this->FiniteRange;
451 }
453
461 double* GetFiniteRange() VTK_SIZEHINT(2) { return this->GetFiniteRange(0); }
462
471 void GetFiniteRange(double range[2]) { this->GetFiniteRange(range, 0); }
472
474
479 void GetDataTypeRange(double range[2]);
482 static void GetDataTypeRange(int type, double range[2]);
483 static double GetDataTypeMin(int type);
484 static double GetDataTypeMax(int type);
486
491 virtual double GetMaxNorm();
492
502 static vtkDataArray* CreateDataArray(int dataType);
503
512
521
530
534 void Modified() override;
535
540
548 int CopyInformation(vtkInformation* infoFrom, int deep = 1) override;
549
553 int GetArrayType() const override { return DataArray; }
554
555protected:
556 friend class vtkPoints;
557 friend class vtkFieldData;
558
560
576 virtual void ComputeRange(double range[2], int comp);
577 virtual void ComputeRange(
578 double range[2], int comp, const unsigned char* ghosts, unsigned char ghostsToSkip = 0xff);
580
582
598 virtual void ComputeFiniteRange(double range[2], int comp);
599 virtual void ComputeFiniteRange(
600 double range[2], int comp, const unsigned char* ghosts, unsigned char ghostsToSkip = 0xff);
602
604
619 virtual bool ComputeScalarRange(double* ranges);
620 virtual bool ComputeScalarRange(
621 double* ranges, const unsigned char* ghosts, unsigned char ghostsToSkip = 0xff);
623
625
637 virtual bool ComputeVectorRange(double range[2]);
638 virtual bool ComputeVectorRange(
639 double range[2], const unsigned char* ghosts, unsigned char ghostsToSkip = 0xff);
641
643
657 virtual bool ComputeFiniteScalarRange(double* ranges);
659 double* ranges, const unsigned char* ghosts, unsigned char ghostsToSkip = 0xff);
661
663
675 virtual bool ComputeFiniteVectorRange(double range[2]);
677 double range[2], const unsigned char* ghosts, unsigned char ghostsToSkip = 0xff);
679
680 // Construct object with default tuple dimension (number of components) of 1.
682 ~vtkDataArray() override;
683
685 double Range[2];
686 double FiniteRange[2];
687
688private:
689 double* GetTupleN(vtkIdType i, int n);
690
691private:
692 vtkDataArray(const vtkDataArray&) = delete;
693 void operator=(const vtkDataArray&) = delete;
694};
695
696//------------------------------------------------------------------------------
698{
699 if (source)
700 {
701 switch (source->GetArrayType())
702 {
705 case TypedDataArray:
706 case DataArray:
707 case MappedDataArray:
708 return static_cast<vtkDataArray*>(source);
709 default:
710 break;
711 }
712 }
713 return nullptr;
714}
715
717
718// These are used by vtkDataArrayPrivate.txx, but need to be available to
719// vtkGenericDataArray.h as well.
721{
723{
724};
726{
727};
728}
729
730#endif
Abstract superclass for all arrays.
vtkIdType GetNumberOfTuples() const
Get the number of complete tuples (a component group) in the array.
virtual int GetDataTypeSize() const =0
Return the size of the underlying data type.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:56
virtual double * GetTuple(vtkIdType tupleIdx)=0
Get the data tuple at tupleIdx.
double * GetRange()
Return the range of the data array.
Definition: vtkDataArray.h:399
virtual void ComputeRange(double range[2], int comp, const unsigned char *ghosts, unsigned char ghostsToSkip=0xff)
Compute the range for a specific component.
static double GetDataTypeMin(int type)
These methods return the Min and Max possible range of the native data type.
double * GetTuple2(vtkIdType tupleIdx)
These methods are included as convenience for the wrappers.
void InterpolateTuple(vtkIdType dstTupleIdx, vtkIdList *ptIndices, vtkAbstractArray *source, double *weights) override
Set the tuple at dstTupleIdx in this array to the interpolated tuple value, given the ptIndices in th...
virtual bool ComputeScalarRange(double *ranges, const unsigned char *ghosts, unsigned char ghostsToSkip=0xff)
Computes the range for each component of an array, the length of ranges must be two times the number ...
virtual bool ComputeVectorRange(double range[2])
Returns true if the range was computed.
int IsNumeric() const override
This method is here to make backward compatibility easier.
Definition: vtkDataArray.h:75
void SetTuple(vtkIdType dstTupleIdx, vtkIdType srcTupleIdx, vtkAbstractArray *source) override
See documentation from parent class.
void GetDataTypeRange(double range[2])
These methods return the Min and Max possible range of the native data type.
void InterpolateTuple(vtkIdType dstTupleIdx, vtkIdType srcTupleIdx1, vtkAbstractArray *source1, vtkIdType srcTupleIdx2, vtkAbstractArray *source2, double t) override
Insert the tuple at dstTupleIdx in this array to the tuple interpolated from the two tuple indices,...
virtual void ComputeRange(double range[2], int comp)
Compute the range for a specific component.
double * GetFiniteRange()
Return the range of the data array.
Definition: vtkDataArray.h:461
virtual bool ComputeScalarRange(double *ranges)
Computes the range for each component of an array, the length of ranges must be two times the number ...
void InsertTuples(vtkIdList *dstIds, vtkIdList *srcIds, vtkAbstractArray *source) override
See documentation from parent class.
virtual bool ComputeFiniteVectorRange(double range[2], const unsigned char *ghosts, unsigned char ghostsToSkip=0xff)
Returns true if the range was computed.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual bool ComputeVectorRange(double range[2], const unsigned char *ghosts, unsigned char ghostsToSkip=0xff)
Returns true if the range was computed.
~vtkDataArray() override
int GetArrayType() const override
Method for type-checking in FastDownCast implementations.
Definition: vtkDataArray.h:553
int GetElementComponentSize() const override
Return the size, in bytes, of the lowest-level element of an array.
Definition: vtkDataArray.h:82
virtual bool ComputeFiniteVectorRange(double range[2])
Returns true if the range was computed.
static vtkInformationDoubleVectorKey * COMPONENT_RANGE()
This key is used to hold tight bounds on the range of one component over all tuples of the array.
virtual void RemoveLastTuple()
These methods remove tuples from the data array.
double * GetRange(int comp)
Return the range of the data array values for the given component.
Definition: vtkDataArray.h:385
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:430
void GetTuples(vtkIdType p1, vtkIdType p2, vtkAbstractArray *output) override
Get the tuples for the range of tuple ids specified (i.e., p1->p2 inclusive).
static vtkInformationDoubleVectorKey * L2_NORM_RANGE()
This key is used to hold tight bounds on the $L_2$ norm of tuples in the array.
double GetDataTypeMin()
These methods return the Min and Max possible range of the native data type.
void InsertTuplesStartingAt(vtkIdType dstStart, vtkIdList *srcIds, vtkAbstractArray *source) override
See documentation from parent class.
void GetTuples(vtkIdList *tupleIds, vtkAbstractArray *output) override
Given a list of tuple ids, return an array of tuples.
virtual void GetTuple(vtkIdType tupleIdx, double *tuple)=0
Get the data tuple at tupleIdx by filling in a user-provided array, Make sure that your array is larg...
double GetTuple1(vtkIdType tupleIdx)
These methods are included as convenience for the wrappers.
static vtkInformationDoubleVectorKey * L2_NORM_FINITE_RANGE()
This key is used to hold tight bounds on the $L_2$ norm of tuples in the array.
double GetDataTypeMax()
These methods return the Min and Max possible range of the native data type.
int CopyInformation(vtkInformation *infoFrom, int deep=1) override
Copy information instance.
void GetRange(double range[2])
The range of the data array values will be returned in the provided range array argument.
Definition: vtkDataArray.h:409
static vtkDataArray * FastDownCast(vtkAbstractArray *source)
Perform a fast, safe cast from a vtkAbstractArray to a vtkDataArray.
Definition: vtkDataArray.h:697
virtual double GetComponent(vtkIdType tupleIdx, int compIdx)
Return the data component at the location specified by tupleIdx and compIdx.
vtkIdType InsertNextTuple(vtkIdType srcTupleIdx, vtkAbstractArray *source) override
See documentation from parent class.
virtual void ComputeFiniteRange(double range[2], int comp)
Compute the range for a specific component.
virtual double GetMaxNorm()
Return the maximum norm for the tuples.
void InsertTuple(vtkIdType dstTupleIdx, vtkIdType srcTupleIdx, vtkAbstractArray *source) override
See documentation from parent class.
void GetRange(double range[2], int comp, const unsigned char *ghosts, unsigned char ghostsToSkip)
The range of the data array values for the given component will be returned in the provided range arr...
Definition: vtkDataArray.h:370
static void GetDataTypeRange(int type, double range[2])
These methods return the Min and Max possible range of the native data type.
virtual bool ComputeFiniteScalarRange(double *ranges, const unsigned char *ghosts, unsigned char ghostsToSkip=0xff)
Computes the range for each component of an array, the length of ranges must be two times the number ...
virtual void ComputeFiniteRange(double range[2], int comp, const unsigned char *ghosts, unsigned char ghostsToSkip=0xff)
Compute the range for a specific component.
static vtkDataArray * CreateDataArray(int dataType)
Creates an array for dataType where dataType is one of VTK_BIT, VTK_CHAR, VTK_SIGNED_CHAR,...
void GetFiniteRange(double range[2], int comp, const unsigned char *ghosts, unsigned char ghostsToSkip)
The range of the data array values for the given component will be returned in the provided range arr...
Definition: vtkDataArray.h:431
void GetFiniteRange(double range[2])
The range of the data array values will be returned in the provided range array argument.
Definition: vtkDataArray.h:471
double * GetFiniteRange(int comp)
Return the range of the data array values for the given component.
Definition: vtkDataArray.h:447
void InsertTuples(vtkIdType dstStart, vtkIdType n, vtkIdType srcStart, vtkAbstractArray *source) override
See documentation from parent class.
static vtkInformationStringKey * UNITS_LABEL()
A human-readable string indicating the units for the array data.
virtual bool ComputeFiniteScalarRange(double *ranges)
Computes the range for each component of an array, the length of ranges must be two times the number ...
void Modified() override
Removes out-of-date L2_NORM_RANGE() and L2_NORM_FINITE_RANGE() values.
static double GetDataTypeMax(int type)
These methods return the Min and Max possible range of the native data type.
vtkLookupTable * LookupTable
Definition: vtkDataArray.h:684
dynamic, self-adjusting array of double
represent and manipulate fields of data
Definition: vtkFieldData.h:63
list of point or cell ids
Definition: vtkIdList.h:34
a simple class to control print indentation
Definition: vtkIndent.h:40
Key for string values in vtkInformation.
Store vtkAlgorithm input/output information.
map scalar values into colors via a lookup table
represent and manipulate 3D points
Definition: vtkPoints.h:40
#define vtkArrayDownCast_FastCastMacro(ArrayT)
This macro is used to tell vtkArrayDownCast to use FastDownCast instead of SafeDownCast.
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
#define vtkDataArray
Definition: vtkCharArray.h:49
int vtkIdType
Definition: vtkType.h:332
#define VTK_SIZEHINT(...)
#define VTK_EXPECTS(x)
#define VTK_NEWINSTANCE