VTK  9.0.20210920
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 =========================================================================*/
144 #ifndef vtkDataArray_h
145 #define vtkDataArray_h
146 
147 #include "vtkAbstractArray.h"
148 #include "vtkCommonCoreModule.h" // For export macro
149 #include "vtkVTK_USE_SCALED_SOA_ARRAYS.h" // For #define of VTK_USE_SCALED_SOA_ARRAYS
150 
151 class vtkDoubleArray;
152 class vtkIdList;
155 class vtkLookupTable;
156 class vtkPoints;
157 
158 class VTKCOMMONCORE_EXPORT vtkDataArray : public vtkAbstractArray
159 {
160 public:
162  void PrintSelf(ostream& os, vtkIndent indent) override;
163 
170  static vtkDataArray* FastDownCast(vtkAbstractArray* source);
171 
178  int IsNumeric() const override { return 1; }
179 
185  int GetElementComponentSize() const override { return this->GetDataTypeSize(); }
186 
187  // Reimplemented virtuals (doc strings are inherited from superclass):
188  void InsertTuple(vtkIdType dstTupleIdx, vtkIdType srcTupleIdx, vtkAbstractArray* source) override;
190  void InsertTuples(vtkIdList* dstIds, vtkIdList* srcIds, vtkAbstractArray* source) override;
192  vtkIdType dstStart, vtkIdType n, vtkIdType srcStart, vtkAbstractArray* source) override;
193  void GetTuples(vtkIdList* tupleIds, vtkAbstractArray* output) override;
194  void GetTuples(vtkIdType p1, vtkIdType p2, vtkAbstractArray* output) override;
196  double* weights) override;
197  void InterpolateTuple(vtkIdType dstTupleIdx, vtkIdType srcTupleIdx1, vtkAbstractArray* source1,
198  vtkIdType srcTupleIdx2, vtkAbstractArray* source2, double t) override;
199 
205  virtual double* GetTuple(vtkIdType tupleIdx)
206  VTK_EXPECTS(0 <= tupleIdx && tupleIdx < GetNumberOfTuples()) = 0;
207 
213  virtual void GetTuple(vtkIdType tupleIdx, double* tuple)
214  VTK_EXPECTS(0 <= tupleIdx && tupleIdx < GetNumberOfTuples()) = 0;
215 
217 
222  double GetTuple1(vtkIdType tupleIdx) VTK_EXPECTS(0 <= tupleIdx && tupleIdx < GetNumberOfTuples());
223  double* GetTuple2(vtkIdType tupleIdx) VTK_EXPECTS(0 <= tupleIdx && tupleIdx < GetNumberOfTuples())
224  VTK_SIZEHINT(2);
225  double* GetTuple3(vtkIdType tupleIdx) VTK_EXPECTS(0 <= tupleIdx && tupleIdx < GetNumberOfTuples())
226  VTK_SIZEHINT(3);
227  double* GetTuple4(vtkIdType tupleIdx) VTK_EXPECTS(0 <= tupleIdx && tupleIdx < GetNumberOfTuples())
228  VTK_SIZEHINT(4);
229  double* GetTuple6(vtkIdType tupleIdx) VTK_EXPECTS(0 <= tupleIdx && tupleIdx < GetNumberOfTuples())
230  VTK_SIZEHINT(6);
231  double* GetTuple9(vtkIdType tupleIdx) VTK_EXPECTS(0 <= tupleIdx && tupleIdx < GetNumberOfTuples())
232  VTK_SIZEHINT(9);
234 
235  void SetTuple(vtkIdType dstTupleIdx, vtkIdType srcTupleIdx, vtkAbstractArray* source) override;
236 
238 
243  virtual void SetTuple(vtkIdType tupleIdx, const float* tuple)
244  VTK_EXPECTS(0 <= tupleIdx && tupleIdx < GetNumberOfTuples());
245  virtual void SetTuple(vtkIdType tupleIdx, const double* tuple)
246  VTK_EXPECTS(0 <= tupleIdx && tupleIdx < GetNumberOfTuples());
248 
250 
255  void SetTuple1(vtkIdType tupleIdx, double value)
256  VTK_EXPECTS(0 <= tupleIdx && tupleIdx < GetNumberOfTuples());
257  void SetTuple2(vtkIdType tupleIdx, double val0, double val1)
258  VTK_EXPECTS(0 <= tupleIdx && tupleIdx < GetNumberOfTuples());
259  void SetTuple3(vtkIdType tupleIdx, double val0, double val1, double val2)
260  VTK_EXPECTS(0 <= tupleIdx && tupleIdx < GetNumberOfTuples());
261  void SetTuple4(vtkIdType tupleIdx, double val0, double val1, double val2, double val3)
262  VTK_EXPECTS(0 <= tupleIdx && tupleIdx < GetNumberOfTuples());
263  void SetTuple6(vtkIdType tupleIdx, double val0, double val1, double val2, double val3,
264  double val4, double val5) VTK_EXPECTS(0 <= tupleIdx && tupleIdx < GetNumberOfTuples());
265  void SetTuple9(vtkIdType tupleIdx, double val0, double val1, double val2, double val3,
266  double val4, double val5, double val6, double val7, double val8)
267  VTK_EXPECTS(0 <= tupleIdx && tupleIdx < GetNumberOfTuples());
269 
271 
275  virtual void InsertTuple(vtkIdType tupleIdx, const float* tuple) VTK_EXPECTS(0 <= tupleIdx) = 0;
276  virtual void InsertTuple(vtkIdType tupleIdx, const double* tuple) VTK_EXPECTS(0 <= tupleIdx) = 0;
278 
280 
285  void InsertTuple1(vtkIdType tupleIdx, double value) VTK_EXPECTS(0 <= tupleIdx);
286  void InsertTuple2(vtkIdType tupleIdx, double val0, double val1) VTK_EXPECTS(0 <= tupleIdx);
287  void InsertTuple3(vtkIdType tupleIdx, double val0, double val1, double val2)
288  VTK_EXPECTS(0 <= tupleIdx);
289  void InsertTuple4(vtkIdType tupleIdx, double val0, double val1, double val2, double val3)
290  VTK_EXPECTS(0 <= tupleIdx);
291  void InsertTuple6(vtkIdType tupleIdx, double val0, double val1, double val2, double val3,
292  double val4, double val5) VTK_EXPECTS(0 <= tupleIdx);
293  void InsertTuple9(vtkIdType tupleIdx, double val0, double val1, double val2, double val3,
294  double val4, double val5, double val6, double val7, double val8) VTK_EXPECTS(0 <= tupleIdx);
296 
298 
303  virtual vtkIdType InsertNextTuple(const float* tuple) = 0;
304  virtual vtkIdType InsertNextTuple(const double* tuple) = 0;
306 
308 
313  void InsertNextTuple1(double value);
314  void InsertNextTuple2(double val0, double val1);
315  void InsertNextTuple3(double val0, double val1, double val2);
316  void InsertNextTuple4(double val0, double val1, double val2, double val3);
317  void InsertNextTuple6(
318  double val0, double val1, double val2, double val3, double val4, double val5);
319  void InsertNextTuple9(double val0, double val1, double val2, double val3, double val4,
320  double val5, double val6, double val7, double val8);
322 
324 
329  virtual void RemoveTuple(vtkIdType tupleIdx)
330  VTK_EXPECTS(0 <= tupleIdx && tupleIdx < GetNumberOfTuples()) = 0;
331  virtual void RemoveFirstTuple() { this->RemoveTuple(0); }
332  virtual void RemoveLastTuple();
334 
339  virtual double GetComponent(vtkIdType tupleIdx, int compIdx) VTK_EXPECTS(0 <= tupleIdx &&
340  tupleIdx < GetNumberOfTuples()) VTK_EXPECTS(0 <= compIdx && compIdx < GetNumberOfComponents());
341 
349  virtual void SetComponent(vtkIdType tupleIdx, int compIdx, double value)
350  VTK_EXPECTS(0 <= tupleIdx && tupleIdx < GetNumberOfTuples())
351  VTK_EXPECTS(0 <= compIdx && compIdx < GetNumberOfComponents());
352 
357  virtual void InsertComponent(vtkIdType tupleIdx, int compIdx, double value)
358  VTK_EXPECTS(0 <= tupleIdx) VTK_EXPECTS(0 <= compIdx && compIdx < GetNumberOfComponents());
359 
368  virtual void GetData(
369  vtkIdType tupleMin, vtkIdType tupleMax, int compMin, int compMax, vtkDoubleArray* data);
370 
372 
376  void DeepCopy(vtkAbstractArray* aa) override;
377  virtual void DeepCopy(vtkDataArray* da);
379 
389  virtual void ShallowCopy(vtkDataArray* other);
390 
397  virtual void FillComponent(int compIdx, double value)
398  VTK_EXPECTS(0 <= compIdx && compIdx < GetNumberOfComponents());
399 
403  virtual void Fill(double value);
404 
413  virtual void CopyComponent(int dstComponent, vtkDataArray* src, int srcComponent);
414 
420  virtual void* WriteVoidPointer(vtkIdType valueIdx, vtkIdType numValues) = 0;
421 
430  unsigned long GetActualMemorySize() const override;
431 
436  void CreateDefaultLookupTable();
437 
439 
442  void SetLookupTable(vtkLookupTable* lut);
443  vtkGetObjectMacro(LookupTable, vtkLookupTable);
445 
455  void GetRange(double range[2], int comp) { this->ComputeRange(range, comp); }
456 
458 
466  double* GetRange(int comp) VTK_SIZEHINT(2)
467  {
468  this->GetRange(this->Range, comp);
469  return this->Range;
470  }
472 
480  double* GetRange() VTK_SIZEHINT(2) { return this->GetRange(0); }
481 
490  void GetRange(double range[2]) { this->GetRange(range, 0); }
491 
501  void GetFiniteRange(double range[2], int comp) { this->ComputeFiniteRange(range, comp); }
502 
504 
512  double* GetFiniteRange(int comp) VTK_SIZEHINT(2)
513  {
514  this->GetFiniteRange(this->FiniteRange, comp);
515  return this->FiniteRange;
516  }
518 
526  double* GetFiniteRange() VTK_SIZEHINT(2) { return this->GetFiniteRange(0); }
527 
536  void GetFiniteRange(double range[2]) { this->GetFiniteRange(range, 0); }
537 
539 
544  void GetDataTypeRange(double range[2]);
545  double GetDataTypeMin();
546  double GetDataTypeMax();
547  static void GetDataTypeRange(int type, double range[2]);
548  static double GetDataTypeMin(int type);
549  static double GetDataTypeMax(int type);
551 
556  virtual double GetMaxNorm();
557 
567  static vtkDataArray* CreateDataArray(int dataType);
568 
577 
586 
595 
599  void Modified() override;
600 
605 
613  int CopyInformation(vtkInformation* infoFrom, int deep = 1) override;
614 
618  int GetArrayType() const override { return DataArray; }
619 
620 protected:
621  friend class vtkPoints;
622 
630  virtual void ComputeRange(double range[2], int comp);
631 
639  virtual void ComputeFiniteRange(double range[2], int comp);
640 
647  virtual bool ComputeScalarRange(double* ranges);
648 
653  virtual bool ComputeVectorRange(double range[2]);
654 
661  virtual bool ComputeFiniteScalarRange(double* ranges);
662 
667  virtual bool ComputeFiniteVectorRange(double range[2]);
668 
669  // Construct object with default tuple dimension (number of components) of 1.
671  ~vtkDataArray() override;
672 
674  double Range[2];
675  double FiniteRange[2];
676 
677 private:
678  double* GetTupleN(vtkIdType i, int n);
679 
680 private:
681  vtkDataArray(const vtkDataArray&) = delete;
682  void operator=(const vtkDataArray&) = delete;
683 };
684 
685 //------------------------------------------------------------------------------
687 {
688  if (source)
689  {
690  switch (source->GetArrayType())
691  {
694  case TypedDataArray:
695  case DataArray:
696  case MappedDataArray:
697  return static_cast<vtkDataArray*>(source);
698  default:
699  break;
700  }
701  }
702  return nullptr;
703 }
704 
706 
707 // These are used by vtkDataArrayPrivate.txx, but need to be available to
708 // vtkGenericDataArray.h as well.
710 {
711 struct AllValues
712 {
713 };
715 {
716 };
717 }
718 
719 #endif
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:143
vtk::Range
auto Range(IterablePtr iterable, Options &&... opts) -> typename detail::IterableTraits< typename detail::StripPointers< IterablePtr >::type >::RangeType
Generate an iterable STL proxy object for a VTK container.
Definition: vtkRange.h:85
vtkInformationStringKey
Key for string values in vtkInformation.
Definition: vtkInformationStringKey.h:34
vtkDataArray::LookupTable
vtkLookupTable * LookupTable
Definition: vtkDataArray.h:673
vtkArrayDownCast_FastCastMacro
vtkArrayDownCast_FastCastMacro(vtkDataArray)
vtkDataArray::COMPONENT_RANGE
static vtkInformationDoubleVectorKey * COMPONENT_RANGE()
This key is used to hold tight bounds on the range of one component over all tuples of the array.
vtkDataArray::GetTuples
void GetTuples(vtkIdType p1, vtkIdType p2, vtkAbstractArray *output) override
Get the tuples for the range of tuple ids specified (i.e., p1->p2 inclusive).
vtkDataArray::InsertTuple
void InsertTuple(vtkIdType dstTupleIdx, vtkIdType srcTupleIdx, vtkAbstractArray *source) override
Insert the tuple at srcTupleIdx in the source array into this array at dstTupleIdx.
vtkDataArray::GetElementComponentSize
int GetElementComponentSize() const override
Return the size, in bytes, of the lowest-level element of an array.
Definition: vtkDataArray.h:185
VTK_EXPECTS
#define VTK_EXPECTS(x)
Definition: vtkWrappingHints.h:47
vtkX3D::value
@ value
Definition: vtkX3D.h:226
vtkX3D::type
@ type
Definition: vtkX3D.h:522
vtkIdType
int vtkIdType
Definition: vtkType.h:332
vtkX3D::data
@ data
Definition: vtkX3D.h:321
vtkDataArray::RemoveLastTuple
virtual void RemoveLastTuple()
These methods remove tuples from the data array.
vtkDataArray::GetFiniteRange
double * GetFiniteRange(int comp)
Return the range of the data array values for the given component.
Definition: vtkDataArray.h:512
vtkDataArray::CopyInformation
int CopyInformation(vtkInformation *infoFrom, int deep=1) override
Copy information instance.
vtkX3D::range
@ range
Definition: vtkX3D.h:244
vtkDataArray::GetComponent
virtual double GetComponent(vtkIdType tupleIdx, int compIdx)
Return the data component at the location specified by tupleIdx and compIdx.
vtkDataArray::GetTuples
void GetTuples(vtkIdList *tupleIds, vtkAbstractArray *output) override
Given a list of tuple ids, return an array of tuples.
vtkAbstractArray::MappedDataArray
@ MappedDataArray
Definition: vtkAbstractArray.h:640
vtkDataArray::GetDataTypeRange
static void GetDataTypeRange(int type, double range[2])
These methods return the Min and Max possible range of the native data type.
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:159
vtkDataArray::InsertTuples
void InsertTuples(vtkIdList *dstIds, vtkIdList *srcIds, vtkAbstractArray *source) override
Copy the tuples indexed in srcIds from the source array to the tuple locations indexed by dstIds in t...
vtkAbstractArray.h
vtkDataArray::GetTuple
virtual double * GetTuple(vtkIdType tupleIdx)=0
Get the data tuple at tupleIdx.
vtkDataArray::ComputeFiniteScalarRange
virtual bool ComputeFiniteScalarRange(double *ranges)
Computes the range for each component of an array, the length of ranges must be two times the number ...
vtkDataArray::Modified
void Modified() override
Removes out-of-date L2_NORM_RANGE() and L2_NORM_FINITE_RANGE() values.
vtkDataArrayPrivate::FiniteValues
Definition: vtkDataArray.h:715
vtkAbstractArray::GetNumberOfTuples
vtkIdType GetNumberOfTuples() const
Get the number of complete tuples (a component group) in the array.
Definition: vtkAbstractArray.h:172
vtkDataArray::ComputeVectorRange
virtual bool ComputeVectorRange(double range[2])
Returns true if the range was computed.
vtkDataArray::GetMaxNorm
virtual double GetMaxNorm()
Return the maximum norm for the tuples.
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:48
vtkDataArray::ComputeRange
virtual void ComputeRange(double range[2], int comp)
Compute the range for a specific component.
vtkAbstractArray::AoSDataArrayTemplate
@ AoSDataArrayTemplate
Definition: vtkAbstractArray.h:637
vtkDataArray::GetFiniteRange
void GetFiniteRange(double range[2])
The range of the data array values will be returned in the provided range array argument.
Definition: vtkDataArray.h:536
vtkDataArray::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkDataArray::L2_NORM_RANGE
static vtkInformationDoubleVectorKey * L2_NORM_RANGE()
This key is used to hold tight bounds on the $L_2$ norm of tuples in the array.
vtkDataArray::GetFiniteRange
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:501
vtkDataArray::GetRange
void GetRange(double range[2])
The range of the data array values will be returned in the provided range array argument.
Definition: vtkDataArray.h:490
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:113
vtkDataArray::GetDataTypeMax
static double GetDataTypeMax(int type)
These methods return the Min and Max possible range of the native data type.
vtkDataArray::GetTuple2
double * GetTuple2(vtkIdType tupleIdx)
These methods are included as convenience for the wrappers.
vtkDataArray::GetDataTypeRange
void GetDataTypeRange(double range[2])
These methods return the Min and Max possible range of the native data type.
vtkDataArrayPrivate
Definition: vtkDataArray.h:710
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:140
vtkAbstractArray::SoADataArrayTemplate
@ SoADataArrayTemplate
Definition: vtkAbstractArray.h:638
vtkDataArray
#define vtkDataArray
Definition: vtkCharArray.h:65
vtkDataArray::GetRange
double * GetRange(int comp)
Return the range of the data array values for the given component.
Definition: vtkDataArray.h:466
vtkDataArray::GetTuple
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...
vtkDataArray::L2_NORM_FINITE_RANGE
static vtkInformationDoubleVectorKey * L2_NORM_FINITE_RANGE()
This key is used to hold tight bounds on the $L_2$ norm of tuples in the array.
vtkDataArray::vtkDataArray
vtkDataArray()
vtkDataArray::InterpolateTuple
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...
vtkDataArrayPrivate::AllValues
Definition: vtkDataArray.h:712
vtkDataArray::ComputeFiniteVectorRange
virtual bool ComputeFiniteVectorRange(double range[2])
Returns true if the range was computed.
vtkDataArray::GetDataTypeMin
static double GetDataTypeMin(int type)
These methods return the Min and Max possible range of the native data type.
vtkDataArray::ComputeFiniteRange
virtual void ComputeFiniteRange(double range[2], int comp)
Compute the range for a specific component.
vtkAbstractArray
Abstract superclass for all arrays.
Definition: vtkAbstractArray.h:76
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:183
vtkLookupTable
map scalar values into colors via a lookup table
Definition: vtkLookupTable.h:178
vtkDataArray::GetRange
double * GetRange()
Return the range of the data array.
Definition: vtkDataArray.h:480
vtkDataArray::~vtkDataArray
~vtkDataArray() override
vtkDataArray::GetDataTypeMin
double GetDataTypeMin()
These methods return the Min and Max possible range of the native data type.
vtkDataArray::IsNumeric
int IsNumeric() const override
This method is here to make backward compatibility easier.
Definition: vtkDataArray.h:178
vtkInformationDoubleVectorKey
Key for double vector values.
Definition: vtkInformationDoubleVectorKey.h:51
vtkDataArray::UNITS_LABEL
static vtkInformationStringKey * UNITS_LABEL()
A human-readable string indicating the units for the array data.
vtkAbstractArray::TypedDataArray
@ TypedDataArray
Definition: vtkAbstractArray.h:639
vtkAbstractArray::DataArray
@ DataArray
Definition: vtkAbstractArray.h:636
vtkDataArray::ComputeScalarRange
virtual bool ComputeScalarRange(double *ranges)
Computes the range for each component of an array, the length of ranges must be two times the number ...
vtkDataArray::InsertNextTuple
vtkIdType InsertNextTuple(vtkIdType srcTupleIdx, vtkAbstractArray *source) override
Insert the tuple from srcTupleIdx in the source array at the end of this array.
vtkDataArray::GetArrayType
int GetArrayType() const override
Method for type-checking in FastDownCast implementations.
Definition: vtkDataArray.h:618
vtkAbstractArray::GetDataTypeSize
virtual int GetDataTypeSize() const =0
Return the size of the underlying data type.
vtkDataArray::GetDataTypeMax
double GetDataTypeMax()
These methods return the Min and Max possible range of the native data type.
vtkDoubleArray
dynamic, self-adjusting array of double
Definition: vtkDoubleArray.h:145
source
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
Definition: vtkBoostGraphAdapter.h:998
vtkDataArray::FastDownCast
static vtkDataArray * FastDownCast(vtkAbstractArray *source)
Perform a fast, safe cast from a vtkAbstractArray to a vtkDataArray.
Definition: vtkDataArray.h:686
VTK_NEWINSTANCE
#define VTK_NEWINSTANCE
Definition: vtkWrappingHints.h:44
vtkDataArray::CreateDataArray
static vtkDataArray * CreateDataArray(int dataType)
Creates an array for dataType where dataType is one of VTK_BIT, VTK_CHAR, VTK_SIGNED_CHAR,...
vtkIOSSUtilities::GetData
vtkSmartPointer< vtkDataArray > GetData(const Ioss::GroupingEntity *entity, const std::string &fieldname, Ioss::Transform *transform=nullptr, Cache *cache=nullptr, const std::string &cachekey=std::string())
Returns a VTK array for a given field (fieldname) on the chosen block (or set) entity.
vtkDataArray::GetFiniteRange
double * GetFiniteRange()
Return the range of the data array.
Definition: vtkDataArray.h:526
vtkDataArray::GetTuple1
double GetTuple1(vtkIdType tupleIdx)
These methods are included as convenience for the wrappers.
vtkDataArray::InterpolateTuple
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,...
vtkDataArray::InsertTuples
void InsertTuples(vtkIdType dstStart, vtkIdType n, vtkIdType srcStart, vtkAbstractArray *source) override
Copy n consecutive tuples starting at srcStart from the source array to this array,...