VTK  9.3.20240727
vtkArray.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-FileCopyrightText: Copyright 2008 Sandia Corporation
3// SPDX-License-Identifier: LicenseRef-BSD-3-Clause-Sandia-USGov
4
40#ifndef vtkArray_h
41#define vtkArray_h
42
43#include "vtkArrayCoordinates.h" // for vtkArrayCoordinates
44#include "vtkArrayExtents.h" // for vtkArrayExtents
45#include "vtkCommonCoreModule.h" // For export macro
46#include "vtkObject.h"
47#include "vtkStdString.h" // for vtkStdString
48#include "vtkVariant.h" // for vtkVariant
49
50VTK_ABI_NAMESPACE_BEGIN
51class VTKCOMMONCORE_EXPORT vtkArray : public vtkObject
52{
53public:
54 vtkTypeMacro(vtkArray, vtkObject);
55 void PrintSelf(ostream& os, vtkIndent indent) override;
56
60
61 enum
62 {
64 DENSE = 0,
66 SPARSE = 1
67 };
68
78 static vtkArray* CreateArray(int StorageType, int ValueType);
79
85 virtual bool IsDense() = 0;
86
88
103 void Resize(const vtkArrayRange& i);
104 void Resize(const vtkArrayRange& i, const vtkArrayRange& j);
105 void Resize(const vtkArrayRange& i, const vtkArrayRange& j, const vtkArrayRange& k);
106 void Resize(const vtkArrayExtents& extents);
108
118 virtual const vtkArrayExtents& GetExtents() = 0;
119
125
135
141 virtual SizeT GetNonNullSize() = 0;
142
146 void SetName(const vtkStdString& name);
151
156
161
169 virtual void GetCoordinatesN(SizeT n, vtkArrayCoordinates& coordinates) = 0;
170
172
177 inline vtkVariant GetVariantValue(CoordinateT i);
178 inline vtkVariant GetVariantValue(CoordinateT i, CoordinateT j);
179 inline vtkVariant GetVariantValue(CoordinateT i, CoordinateT j, CoordinateT k);
180 virtual vtkVariant GetVariantValue(const vtkArrayCoordinates& coordinates) = 0;
182
191
193
198 inline void SetVariantValue(CoordinateT i, const vtkVariant& value);
199 inline void SetVariantValue(CoordinateT i, CoordinateT j, const vtkVariant& value);
200 inline void SetVariantValue(CoordinateT i, CoordinateT j, CoordinateT k, const vtkVariant& value);
201 virtual void SetVariantValue(const vtkArrayCoordinates& coordinates, const vtkVariant& value) = 0;
203
211 virtual void SetVariantValueN(SizeT n, const vtkVariant& value) = 0;
212
214
218 virtual void CopyValue(vtkArray* source, const vtkArrayCoordinates& source_coordinates,
219 const vtkArrayCoordinates& target_coordinates) = 0;
220 virtual void CopyValue(
221 vtkArray* source, SizeT source_index, const vtkArrayCoordinates& target_coordinates) = 0;
222 virtual void CopyValue(
223 vtkArray* source, const vtkArrayCoordinates& source_coordinates, SizeT target_index) = 0;
225
230
231protected:
233 ~vtkArray() override;
234
235private:
236 vtkArray(const vtkArray&) = delete;
237 void operator=(const vtkArray&) = delete;
238
242 vtkStdString Name;
243
248 virtual void InternalResize(const vtkArrayExtents&) = 0;
249
253 virtual void InternalSetDimensionLabel(DimensionT i, const vtkStdString& label) = 0;
254
256
259 virtual vtkStdString InternalGetDimensionLabel(DimensionT i) = 0;
261};
262
264{
265 return this->GetVariantValue(vtkArrayCoordinates(i));
266}
267
269{
270 return this->GetVariantValue(vtkArrayCoordinates(i, j));
271}
272
274{
275 return this->GetVariantValue(vtkArrayCoordinates(i, j, k));
276}
277
279{
280 this->SetVariantValue(vtkArrayCoordinates(i), value);
281}
282
284{
285 this->SetVariantValue(vtkArrayCoordinates(i, j), value);
286}
287
289{
290 this->SetVariantValue(vtkArrayCoordinates(i, j, k), value);
291}
292
293VTK_ABI_NAMESPACE_END
294#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.
Abstract interface for N-dimensional arrays.
Definition vtkArray.h:52
void SetDimensionLabel(DimensionT i, const vtkStdString &label)
Sets the label for the i-th array dimension.
virtual const vtkArrayExtents & GetExtents()=0
Returns the extents (the number of dimensions and size along each dimension) of the array.
virtual void CopyValue(vtkArray *source, SizeT source_index, const vtkArrayCoordinates &target_coordinates)=0
Overwrites a value with a value retrieved from another array.
virtual void SetVariantValue(const vtkArrayCoordinates &coordinates, const vtkVariant &value)=0
Overwrites the value stored in the array at the given coordinates.
void Resize(CoordinateT i)
Resizes the array to the given extents (number of dimensions and size of each dimension).
void SetVariantValue(CoordinateT i, const vtkVariant &value)
Overwrites the value stored in the array at the given coordinates.
Definition vtkArray.h:278
virtual void SetVariantValueN(SizeT n, const vtkVariant &value)=0
Overwrites the n-th value stored in the array, where n is in the range [0, GetNonNullSize()).
virtual bool IsDense()=0
Returns true iff the underlying array storage is "dense", i.e.
void Resize(CoordinateT i, CoordinateT j)
Resizes the array to the given extents (number of dimensions and size of each dimension).
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).
vtkArrayExtents::SizeT SizeT
Definition vtkArray.h:59
virtual void CopyValue(vtkArray *source, const vtkArrayCoordinates &source_coordinates, SizeT target_index)=0
Overwrites a value with a value retrieved from another array.
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(SizeT n)=0
Returns the n-th value stored in the array, where n is in the range [0, GetNonNullSize()).
virtual void GetCoordinatesN(SizeT n, vtkArrayCoordinates &coordinates)=0
Returns the coordinates of the n-th value in the array, where n is in the range [0,...
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.
void Resize(CoordinateT i, CoordinateT j, CoordinateT k)
Resizes the array to the given extents (number of dimensions and size of each dimension).
vtkArrayExtents::DimensionT DimensionT
Definition vtkArray.h:58
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 vtkArrayExtents &extents)
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,...
~vtkArray() override
vtkArrayExtents::CoordinateT CoordinateT
Definition vtkArray.h:57
vtkStdString GetDimensionLabel(DimensionT i)
Returns the label for the i-th array dimension.
void Resize(const vtkArrayRange &i)
Resizes the array to the given extents (number of dimensions and size of each dimension).
virtual vtkArray * DeepCopy()=0
Returns a new array that is a deep copy of this array.
vtkVariant GetVariantValue(CoordinateT i)
Returns the value stored in the array at the given coordinates.
Definition vtkArray.h:263
a simple class to control print indentation
Definition vtkIndent.h:108
abstract base class for most VTK objects
Definition vtkObject.h:162
Wrapper around std::string to keep symbols short.
vtkArray::CoordinateT CoordinateT
A type representing the union of many types.
Definition vtkVariant.h:162
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
#define VTK_NEWINSTANCE