VTK  9.2.6
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
56
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
67class VTKCOMMONCORE_EXPORT vtkArray : public vtkObject
68{
69public:
70 vtkTypeMacro(vtkArray, vtkObject);
71 void PrintSelf(ostream& os, vtkIndent indent) override;
72
76
77 enum
78 {
80 DENSE = 0,
83 };
84
94 static vtkArray* CreateArray(int StorageType, int ValueType);
95
101 virtual bool IsDense() = 0;
102
104
116 void Resize(const CoordinateT i);
117 void Resize(const CoordinateT i, const CoordinateT j);
118 void Resize(const CoordinateT i, const CoordinateT j, const CoordinateT k);
119 void Resize(const vtkArrayRange& i);
120 void Resize(const vtkArrayRange& i, const vtkArrayRange& j);
121 void Resize(const vtkArrayRange& i, const vtkArrayRange& j, const vtkArrayRange& k);
122 void Resize(const vtkArrayExtents& extents);
124
134 virtual const vtkArrayExtents& GetExtents() = 0;
135
141
151
157 virtual SizeT GetNonNullSize() = 0;
158
162 void SetName(const vtkStdString& name);
167
172
177
185 virtual void GetCoordinatesN(const SizeT n, vtkArrayCoordinates& coordinates) = 0;
186
188
196 virtual vtkVariant GetVariantValue(const vtkArrayCoordinates& coordinates) = 0;
198
206 virtual vtkVariant GetVariantValueN(const SizeT n) = 0;
207
209
214 inline void SetVariantValue(CoordinateT i, const vtkVariant& value);
215 inline void SetVariantValue(CoordinateT i, CoordinateT j, const vtkVariant& value);
217 virtual void SetVariantValue(const vtkArrayCoordinates& coordinates, const vtkVariant& value) = 0;
219
227 virtual void SetVariantValueN(const SizeT n, const vtkVariant& value) = 0;
228
230
234 virtual void CopyValue(vtkArray* source, const vtkArrayCoordinates& source_coordinates,
235 const vtkArrayCoordinates& target_coordinates) = 0;
236 virtual void CopyValue(
237 vtkArray* source, const SizeT source_index, const vtkArrayCoordinates& target_coordinates) = 0;
238 virtual void CopyValue(
239 vtkArray* source, const vtkArrayCoordinates& source_coordinates, const SizeT target_index) = 0;
241
245 virtual vtkArray* DeepCopy() = 0;
246
247protected:
249 ~vtkArray() override;
250
251private:
252 vtkArray(const vtkArray&) = delete;
253 void operator=(const vtkArray&) = delete;
254
258 vtkStdString Name;
259
264 virtual void InternalResize(const vtkArrayExtents&) = 0;
265
269 virtual void InternalSetDimensionLabel(DimensionT i, const vtkStdString& label) = 0;
270
272
275 virtual vtkStdString InternalGetDimensionLabel(DimensionT i) = 0;
277};
278
283
288
293
295{
296 this->SetVariantValue(vtkArrayCoordinates(i), value);
297}
298
300{
301 this->SetVariantValue(vtkArrayCoordinates(i, j), value);
302}
303
305{
306 this->SetVariantValue(vtkArrayCoordinates(i, j, k), value);
307}
308
309#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:82
@ DENSE
Used with CreateArray() to create dense arrays.
Definition vtkArray.h:80
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 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:294
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:75
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.
vtkArrayExtents::DimensionT DimensionT
Definition vtkArray.h:74
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).
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:73
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.
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:279
a simple class to control print indentation
Definition vtkIndent.h:40
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 atomic type representing the union of many types.
Definition vtkVariant.h:70
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
#define VTK_NEWINSTANCE