VTK  9.2.20220926
vtkArray.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkArray.h
5 
6 -------------------------------------------------------------------------
7  Copyright 2008 Sandia Corporation.
8  Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9  the U.S. Government retains certain rights in this software.
10 -------------------------------------------------------------------------
11 
12  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
13  All rights reserved.
14  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
15 
16  This software is distributed WITHOUT ANY WARRANTY; without even
17  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
18  PURPOSE. See the above copyright notice for more information.
19 
20 =========================================================================*/
21 
57 #ifndef vtkArray_h
58 #define vtkArray_h
59 
60 #include "vtkArrayCoordinates.h" // for vtkArrayCoordinates
61 #include "vtkArrayExtents.h" // for vtkArrayExtents
62 #include "vtkCommonCoreModule.h" // For export macro
63 #include "vtkObject.h"
64 #include "vtkStdString.h" // for vtkStdString
65 #include "vtkVariant.h" // for vtkVariant
66 
67 VTK_ABI_NAMESPACE_BEGIN
68 class VTKCOMMONCORE_EXPORT vtkArray : public vtkObject
69 {
70 public:
71  vtkTypeMacro(vtkArray, vtkObject);
72  void PrintSelf(ostream& os, vtkIndent indent) override;
73 
77 
78  enum
79  {
81  DENSE = 0,
83  SPARSE = 1
84  };
85 
95  static vtkArray* CreateArray(int StorageType, int ValueType);
96 
102  virtual bool IsDense() = 0;
103 
105 
117  void Resize(const CoordinateT i);
118  void Resize(const CoordinateT i, const CoordinateT j);
119  void Resize(const CoordinateT i, const CoordinateT j, const CoordinateT k);
120  void Resize(const vtkArrayRange& i);
121  void Resize(const vtkArrayRange& i, const vtkArrayRange& j);
122  void Resize(const vtkArrayRange& i, const vtkArrayRange& j, const vtkArrayRange& k);
123  void Resize(const vtkArrayExtents& extents);
125 
135  virtual const vtkArrayExtents& GetExtents() = 0;
136 
142 
152 
158  virtual SizeT GetNonNullSize() = 0;
159 
163  void SetName(const vtkStdString& name);
168 
173 
178 
186  virtual void GetCoordinatesN(const SizeT n, vtkArrayCoordinates& coordinates) = 0;
187 
189 
194  inline vtkVariant GetVariantValue(CoordinateT i);
195  inline vtkVariant GetVariantValue(CoordinateT i, CoordinateT j);
196  inline vtkVariant GetVariantValue(CoordinateT i, CoordinateT j, CoordinateT k);
197  virtual vtkVariant GetVariantValue(const vtkArrayCoordinates& coordinates) = 0;
199 
207  virtual vtkVariant GetVariantValueN(const SizeT n) = 0;
208 
210 
215  inline void SetVariantValue(CoordinateT i, const vtkVariant& value);
216  inline void SetVariantValue(CoordinateT i, CoordinateT j, const vtkVariant& value);
217  inline void SetVariantValue(CoordinateT i, CoordinateT j, CoordinateT k, const vtkVariant& value);
218  virtual void SetVariantValue(const vtkArrayCoordinates& coordinates, const vtkVariant& value) = 0;
220 
228  virtual void SetVariantValueN(const SizeT n, const vtkVariant& value) = 0;
229 
231 
235  virtual void CopyValue(vtkArray* source, const vtkArrayCoordinates& source_coordinates,
236  const vtkArrayCoordinates& target_coordinates) = 0;
237  virtual void CopyValue(
238  vtkArray* source, const SizeT source_index, const vtkArrayCoordinates& target_coordinates) = 0;
239  virtual void CopyValue(
240  vtkArray* source, const vtkArrayCoordinates& source_coordinates, const SizeT target_index) = 0;
242 
246  virtual vtkArray* DeepCopy() = 0;
247 
248 protected:
250  ~vtkArray() override;
251 
252 private:
253  vtkArray(const vtkArray&) = delete;
254  void operator=(const vtkArray&) = delete;
255 
259  vtkStdString Name;
260 
265  virtual void InternalResize(const vtkArrayExtents&) = 0;
266 
270  virtual void InternalSetDimensionLabel(DimensionT i, const vtkStdString& label) = 0;
271 
273 
276  virtual vtkStdString InternalGetDimensionLabel(DimensionT i) = 0;
278 };
279 
281 {
282  return this->GetVariantValue(vtkArrayCoordinates(i));
283 }
284 
286 {
287  return this->GetVariantValue(vtkArrayCoordinates(i, j));
288 }
289 
291 {
292  return this->GetVariantValue(vtkArrayCoordinates(i, j, k));
293 }
294 
296 {
298 }
299 
301 {
303 }
304 
306 {
307  this->SetVariantValue(vtkArrayCoordinates(i, j, k), value);
308 }
309 
311 #endif
Stores coordinate into an N-way array.
Stores the number of dimensions and valid coordinate ranges along each dimension for vtkArray.
vtkTypeUInt64 SizeT
vtkArrayCoordinates::CoordinateT CoordinateT
vtkArrayCoordinates::DimensionT DimensionT
Stores a half-open range of array coordinates.
Definition: vtkArrayRange.h:69
Abstract interface for N-dimensional arrays.
Definition: vtkArray.h:69
void SetDimensionLabel(DimensionT i, const vtkStdString &label)
Sets the label for the i-th array dimension.
virtual void SetVariantValue(const vtkArrayCoordinates &coordinates, const vtkVariant &value)=0
Overwrites the value stored in the array at the given coordinates.
void SetVariantValue(CoordinateT i, const vtkVariant &value)
Overwrites the value stored in the array at the given coordinates.
Definition: vtkArray.h:295
virtual void CopyValue(vtkArray *source, const SizeT source_index, const vtkArrayCoordinates &target_coordinates)=0
Overwrites a value with a value retrieved from another array.
virtual bool IsDense()=0
Returns true iff the underlying array storage is "dense", i.e.
virtual void CopyValue(vtkArray *source, const vtkArrayCoordinates &source_coordinates, const SizeT target_index)=0
Overwrites a value with a value retrieved from another array.
void Resize(const vtkArrayRange &i, const vtkArrayRange &j)
Resizes the array to the given extents (number of dimensions and size of each dimension).
void Resize(const vtkArrayRange &i, const vtkArrayRange &j, const vtkArrayRange &k)
Resizes the array to the given extents (number of dimensions and size of each dimension).
void Resize(const CoordinateT i, const CoordinateT j)
Resizes the array to the given extents (number of dimensions and size of each dimension).
vtkArrayExtents::SizeT SizeT
Definition: vtkArray.h:76
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual SizeT GetNonNullSize()=0
Returns the number of non-null values stored in the array.
virtual vtkVariant GetVariantValueN(const SizeT n)=0
Returns the n-th value stored in the array, where n is in the range [0, GetNonNullSize()).
SizeT GetSize()
Returns the number of values stored in the array.
void SetName(const vtkStdString &name)
Sets the array name.
vtkArrayRange GetExtent(DimensionT dimension)
Returns the extent (valid coordinate range) along the given dimension.
virtual const vtkArrayExtents & GetExtents()=0
Returns the extents (the number of dimensions and size along each dimension) of the array.
vtkArrayExtents::DimensionT DimensionT
Definition: vtkArray.h:75
vtkStdString GetName()
Returns the array name.
virtual void CopyValue(vtkArray *source, const vtkArrayCoordinates &source_coordinates, const vtkArrayCoordinates &target_coordinates)=0
Overwrites a value with a value retrieved from another array.
virtual vtkVariant GetVariantValue(const vtkArrayCoordinates &coordinates)=0
Returns the value stored in the array at the given coordinates.
DimensionT GetDimensions()
Returns the number of dimensions stored in the array.
void Resize(const CoordinateT i, const CoordinateT j, const CoordinateT k)
Resizes the array to the given extents (number of dimensions and size of each dimension).
virtual void GetCoordinatesN(const SizeT n, vtkArrayCoordinates &coordinates)=0
Returns the coordinates of the n-th value in the array, where n is in the range [0,...
void Resize(const vtkArrayExtents &extents)
Resizes the array to the given extents (number of dimensions and size of each dimension).
~vtkArray() override
vtkArrayExtents::CoordinateT CoordinateT
Definition: vtkArray.h:74
vtkStdString GetDimensionLabel(DimensionT i)
Returns the label for the i-th array dimension.
virtual vtkArray * DeepCopy()=0
Returns a new array that is a deep copy of this array.
void Resize(const vtkArrayRange &i)
Resizes the array to the given extents (number of dimensions and size of each dimension).
static vtkArray * CreateArray(int StorageType, int ValueType)
Creates a new array where StorageType is one of vtkArray::DENSE or vtkArray::SPARSE,...
virtual void SetVariantValueN(const SizeT n, const vtkVariant &value)=0
Overwrites the n-th value stored in the array, where n is in the range [0, GetNonNullSize()).
void Resize(const CoordinateT i)
Resizes the array to the given extents (number of dimensions and size of each dimension).
vtkVariant GetVariantValue(CoordinateT i)
Returns the value stored in the array at the given coordinates.
Definition: vtkArray.h:280
a simple class to control print indentation
Definition: vtkIndent.h:120
abstract base class for most VTK objects
Definition: vtkObject.h:83
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:110
A atomic type representing the union of many types.
Definition: vtkVariant.h:160
@ value
Definition: vtkX3D.h:232
@ name
Definition: vtkX3D.h:231
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
#define VTK_NEWINSTANCE