VTK  9.5.20251207
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
39
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,
67 };
68
78 static vtkArray* CreateArray(int StorageType, int ValueType);
79
85 virtual bool IsDense() VTK_FUTURE_CONST = 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() VTK_FUTURE_CONST = 0;
119
124 DimensionT GetDimensions() VTK_FUTURE_CONST;
125
134 SizeT GetSize() VTK_FUTURE_CONST;
135
141 virtual SizeT GetNonNullSize() VTK_FUTURE_CONST = 0;
142
146 void SetName(const vtkStdString& name);
150 vtkStdString GetName() VTK_FUTURE_CONST;
151
156
161
169 virtual void GetCoordinatesN(SizeT n, vtkArrayCoordinates& coordinates) VTK_FUTURE_CONST = 0;
170
172
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);
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) VTK_FUTURE_CONST = 0;
261};
262
267
272
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.
@ SPARSE
Used with CreateArray() to create sparse arrays.
Definition vtkArray.h:66
@ DENSE
Used with CreateArray() to create dense arrays.
Definition vtkArray.h:64
void SetDimensionLabel(DimensionT i, const vtkStdString &label)
Sets the label for the i-th array dimension.
virtual const vtkArrayExtents & GetExtents() VTK_FUTURE_CONST=0
Returns the extents (the number of dimensions and size along each dimension) of the array.
DimensionT GetDimensions() VTK_FUTURE_CONST
Returns the number of dimensions stored in the array.
vtkStdString GetDimensionLabel(DimensionT i) VTK_FUTURE_CONST
Returns the label for the i-th array dimension.
virtual void GetCoordinatesN(SizeT n, vtkArrayCoordinates &coordinates) VTK_FUTURE_CONST=0
Returns the coordinates of the n-th value in the array, where n is in the range [0,...
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()).
vtkArrayExtents::SizeT SizeT
Definition vtkArray.h:59
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual vtkVariant GetVariantValueN(SizeT n)=0
Returns the n-th value stored in the array, where n is in the range [0, GetNonNullSize()).
void SetName(const vtkStdString &name)
Sets the array name.
vtkArrayRange GetExtent(DimensionT dimension)
Returns the extent (valid coordinate range) along the given dimension.
vtkArrayExtents::DimensionT DimensionT
Definition vtkArray.h:58
virtual bool IsDense() VTK_FUTURE_CONST=0
Returns true iff the underlying array storage is "dense", i.e.
virtual SizeT GetNonNullSize() VTK_FUTURE_CONST=0
Returns the number of non-null values stored in the array.
vtkStdString GetName() VTK_FUTURE_CONST
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.
static vtkArray * CreateArray(int StorageType, int ValueType)
Creates a new array where StorageType is one of vtkArray::DENSE or vtkArray::SPARSE,...
SizeT GetSize() VTK_FUTURE_CONST
Returns the number of values stored in the array.
vtkArrayExtents::CoordinateT CoordinateT
Definition vtkArray.h:57
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
Wrapper around std::string to keep symbols short.
vtkVariant GetVariantValue(const vtkArrayCoordinates &coordinates) override
Returns the value stored in the array at the given coordinates.
vtkArray::CoordinateT CoordinateT
void SetVariantValue(const vtkArrayCoordinates &coordinates, const vtkVariant &value) override
Overwrites the value stored in the array at the given coordinates.
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