VTK: Common/Core/vtkArray.h Source File

| VTK 9.3.1

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
50 VTK_ABI_NAMESPACE_BEGIN
51 class VTKCOMMONCORE_EXPORT vtkArray : public vtkObject
52 {
53 public:
54 vtkTypeMacro(vtkArray, vtkObject);
55 void PrintSelf(ostream& os, vtkIndent indent) override;
56
57 typedef vtkArrayExtents::CoordinateT CoordinateT;
58 typedef vtkArrayExtents::DimensionT DimensionT;
59 typedef vtkArrayExtents::SizeT SizeT;
60
61 enum
62 {
64 DENSE = 0,
66 SPARSE = 1
67 };
68
77 VTK_NEWINSTANCE
78 static vtkArray* CreateArray(int StorageType, int ValueType);
79
85 virtual bool IsDense() = 0;
86
88
100 void Resize(CoordinateT i);
101 void Resize(CoordinateT i, CoordinateT j);
102 void Resize(CoordinateT i, CoordinateT j, CoordinateT k);
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
113 vtkArrayRange GetExtent(DimensionT dimension);
118 virtual const vtkArrayExtents& GetExtents() = 0;
119
124 DimensionT GetDimensions();
125
134 SizeT GetSize();
135
141 virtual SizeT GetNonNullSize() = 0;
142
146 void SetName(const vtkStdString& name);
150 vtkStdString GetName();
151
155 void SetDimensionLabel(DimensionT i, const vtkStdString& label);
156
160 vtkStdString GetDimensionLabel(DimensionT i);
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
190 virtual vtkVariant GetVariantValueN(SizeT n) = 0;
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
229 virtual VTK_NEWINSTANCE vtkArray* DeepCopy() = 0;
230
231 protected:
232 vtkArray();
233 ~vtkArray() override;
234
235 private:
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
263 vtkVariant vtkArray::GetVariantValue(CoordinateT i)
264 {
265 return this->GetVariantValue(vtkArrayCoordinates(i));
266 }
267
268 vtkVariant vtkArray::GetVariantValue(CoordinateT i, CoordinateT j)
269 {
270 return this->GetVariantValue(vtkArrayCoordinates(i, j));
271 }
272
273 vtkVariant vtkArray::GetVariantValue(CoordinateT i, CoordinateT j, CoordinateT k)
274 {
275 return this->GetVariantValue(vtkArrayCoordinates(i, j, k));
276 }
277
278 void vtkArray::SetVariantValue(CoordinateT i, const vtkVariant& value)
279 {
280 this->SetVariantValue(vtkArrayCoordinates(i), value);
281 }
282
283 void vtkArray::SetVariantValue(CoordinateT i, CoordinateT j, const vtkVariant& value)
284 {
285 this->SetVariantValue(vtkArrayCoordinates(i, j), value);
286 }
287
288 void vtkArray::SetVariantValue(CoordinateT i, CoordinateT j, CoordinateT k, const vtkVariant& value)
289 {
290 this->SetVariantValue(vtkArrayCoordinates(i, j, k), value);
291 }
292
293 VTK_ABI_NAMESPACE_END
294 #endif
vtkArrayCoordinates
Stores coordinate into an N-way array.
Definition: vtkArrayCoordinates.h:39
vtkArrayExtents
Stores the number of dimensions and valid coordinate ranges along each dimension for vtkArray.
Definition: vtkArrayExtents.h:56
vtkArrayExtents::SizeT
vtkTypeUInt64 SizeT
Definition: vtkArrayExtents.h:60
vtkArrayExtents::CoordinateT
vtkArrayCoordinates::CoordinateT CoordinateT
Definition: vtkArrayExtents.h:59
vtkArrayExtents::DimensionT
vtkArrayCoordinates::DimensionT DimensionT
Definition: vtkArrayExtents.h:58
vtkArrayRange
Stores a half-open range of array coordinates.
Definition: vtkArrayRange.h:33
vtkArray
Abstract interface for N-dimensional arrays.
Definition: vtkArray.h:52
vtkArray::SetDimensionLabel
void SetDimensionLabel(DimensionT i, const vtkStdString &label)
Sets the label for the i-th array dimension.
vtkArray::CopyValue
virtual void CopyValue(vtkArray *source, SizeT source_index, const vtkArrayCoordinates &target_coordinates)=0
Overwrites a value with a value retrieved from another array.
vtkArray::SetVariantValue
virtual void SetVariantValue(const vtkArrayCoordinates &coordinates, const vtkVariant &value)=0
Overwrites the value stored in the array at the given coordinates.
vtkArray::Resize
void Resize(CoordinateT i)
Resizes the array to the given extents (number of dimensions and size of each dimension).
vtkArray::SetVariantValue
void SetVariantValue(CoordinateT i, const vtkVariant &value)
Overwrites the value stored in the array at the given coordinates.
Definition: vtkArray.h:278
vtkArray::SetVariantValueN
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()).
vtkArray::IsDense
virtual bool IsDense()=0
Returns true iff the underlying array storage is "dense", i.e.
vtkArray::Resize
void Resize(CoordinateT i, CoordinateT j)
Resizes the array to the given extents (number of dimensions and size of each dimension).
vtkArray::vtkArray
vtkArray()
vtkArray::Resize
void Resize(const vtkArrayRange &i, const vtkArrayRange &j)
Resizes the array to the given extents (number of dimensions and size of each dimension).
vtkArray::Resize
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).
vtkArray::SizeT
vtkArrayExtents::SizeT SizeT
Definition: vtkArray.h:59
vtkArray::CopyValue
virtual void CopyValue(vtkArray *source, const vtkArrayCoordinates &source_coordinates, SizeT target_index)=0
Overwrites a value with a value retrieved from another array.
vtkArray::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkArray::GetNonNullSize
virtual SizeT GetNonNullSize()=0
Returns the number of non-null values stored in the array.
vtkArray::GetVariantValueN
virtual vtkVariant GetVariantValueN(SizeT n)=0
Returns the n-th value stored in the array, where n is in the range [0, GetNonNullSize()).
vtkArray::GetCoordinatesN
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,...
vtkArray::GetSize
SizeT GetSize()
Returns the number of values stored in the array.
vtkArray::SetName
void SetName(const vtkStdString &name)
Sets the array name.
vtkArray::GetExtent
vtkArrayRange GetExtent(DimensionT dimension)
Returns the extent (valid coordinate range) along the given dimension.
vtkArray::Resize
void Resize(CoordinateT i, CoordinateT j, CoordinateT k)
Resizes the array to the given extents (number of dimensions and size of each dimension).
vtkArray::GetExtents
virtual const vtkArrayExtents & GetExtents()=0
Returns the extents (the number of dimensions and size along each dimension) of the array.
vtkArray::DimensionT
vtkArrayExtents::DimensionT DimensionT
Definition: vtkArray.h:58
vtkArray::GetName
vtkStdString GetName()
Returns the array name.
vtkArray::CopyValue
virtual void CopyValue(vtkArray *source, const vtkArrayCoordinates &source_coordinates, const vtkArrayCoordinates &target_coordinates)=0
Overwrites a value with a value retrieved from another array.
vtkArray::GetVariantValue
virtual vtkVariant GetVariantValue(const vtkArrayCoordinates &coordinates)=0
Returns the value stored in the array at the given coordinates.
vtkArray::GetDimensions
DimensionT GetDimensions()
Returns the number of dimensions stored in the array.
vtkArray::Resize
void Resize(const vtkArrayExtents &extents)
Resizes the array to the given extents (number of dimensions and size of each dimension).
vtkArray::~vtkArray
~vtkArray() override
vtkArray::CoordinateT
vtkArrayExtents::CoordinateT CoordinateT
Definition: vtkArray.h:57
vtkArray::GetDimensionLabel
vtkStdString GetDimensionLabel(DimensionT i)
Returns the label for the i-th array dimension.
vtkArray::DeepCopy
virtual vtkArray * DeepCopy()=0
Returns a new array that is a deep copy of this array.
vtkArray::Resize
void Resize(const vtkArrayRange &i)
Resizes the array to the given extents (number of dimensions and size of each dimension).
vtkArray::CreateArray
static vtkArray * CreateArray(int StorageType, int ValueType)
Creates a new array where StorageType is one of vtkArray::DENSE or vtkArray::SPARSE,...
vtkArray::GetVariantValue
vtkVariant GetVariantValue(CoordinateT i)
Returns the value stored in the array at the given coordinates.
Definition: vtkArray.h:263
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:61
vtkStdString
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:38
vtkVariant
A type representing the union of many types.
Definition: vtkVariant.h:62
vtkX3D::value
@ value
Definition: vtkX3D.h:220
vtkX3D::name
@ name
Definition: vtkX3D.h:219
vtkArrayCoordinates.h
vtkArrayExtents.h
source
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
Definition: vtkBoostGraphAdapter.h:964
vtkObject.h
vtkStdString.h
vtkVariant.h
VTK_NEWINSTANCE
#define VTK_NEWINSTANCE
Definition: vtkWrappingHints.h:32