VTK  9.1.20211115
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 
54 #ifndef vtkArray_h
55 #define vtkArray_h
56 
57 #include "vtkArrayCoordinates.h" // for vtkArrayCoordinates
58 #include "vtkArrayExtents.h" // for vtkArrayExtents
59 #include "vtkCommonCoreModule.h" // For export macro
60 #include "vtkObject.h"
61 #include "vtkStdString.h" // for vtkStdString
62 #include "vtkVariant.h" // for vtkVariant
63 
64 class VTKCOMMONCORE_EXPORT vtkArray : public vtkObject
65 {
66 public:
67  vtkTypeMacro(vtkArray, vtkObject);
68  void PrintSelf(ostream& os, vtkIndent indent) override;
69 
73 
74  enum
75  {
77  DENSE = 0,
79  SPARSE = 1
80  };
81 
91  static vtkArray* CreateArray(int StorageType, int ValueType);
92 
98  virtual bool IsDense() = 0;
99 
101 
113  void Resize(const CoordinateT i);
114  void Resize(const CoordinateT i, const CoordinateT j);
115  void Resize(const CoordinateT i, const CoordinateT j, const CoordinateT k);
116  void Resize(const vtkArrayRange& i);
117  void Resize(const vtkArrayRange& i, const vtkArrayRange& j);
118  void Resize(const vtkArrayRange& i, const vtkArrayRange& j, const vtkArrayRange& k);
119  void Resize(const vtkArrayExtents& extents);
121 
131  virtual const vtkArrayExtents& GetExtents() = 0;
132 
138 
148 
154  virtual SizeT GetNonNullSize() = 0;
155 
159  void SetName(const vtkStdString& name);
164 
169 
174 
182  virtual void GetCoordinatesN(const SizeT n, vtkArrayCoordinates& coordinates) = 0;
183 
185 
190  inline vtkVariant GetVariantValue(CoordinateT i);
191  inline vtkVariant GetVariantValue(CoordinateT i, CoordinateT j);
192  inline vtkVariant GetVariantValue(CoordinateT i, CoordinateT j, CoordinateT k);
193  virtual vtkVariant GetVariantValue(const vtkArrayCoordinates& coordinates) = 0;
195 
203  virtual vtkVariant GetVariantValueN(const SizeT n) = 0;
204 
206 
211  inline void SetVariantValue(CoordinateT i, const vtkVariant& value);
212  inline void SetVariantValue(CoordinateT i, CoordinateT j, const vtkVariant& value);
213  inline void SetVariantValue(CoordinateT i, CoordinateT j, CoordinateT k, const vtkVariant& value);
214  virtual void SetVariantValue(const vtkArrayCoordinates& coordinates, const vtkVariant& value) = 0;
216 
224  virtual void SetVariantValueN(const SizeT n, const vtkVariant& value) = 0;
225 
227 
231  virtual void CopyValue(vtkArray* source, const vtkArrayCoordinates& source_coordinates,
232  const vtkArrayCoordinates& target_coordinates) = 0;
233  virtual void CopyValue(
234  vtkArray* source, const SizeT source_index, const vtkArrayCoordinates& target_coordinates) = 0;
235  virtual void CopyValue(
236  vtkArray* source, const vtkArrayCoordinates& source_coordinates, const SizeT target_index) = 0;
238 
242  virtual vtkArray* DeepCopy() = 0;
243 
244 protected:
246  ~vtkArray() override;
247 
248 private:
249  vtkArray(const vtkArray&) = delete;
250  void operator=(const vtkArray&) = delete;
251 
255  vtkStdString Name;
256 
261  virtual void InternalResize(const vtkArrayExtents&) = 0;
262 
266  virtual void InternalSetDimensionLabel(DimensionT i, const vtkStdString& label) = 0;
267 
269 
272  virtual vtkStdString InternalGetDimensionLabel(DimensionT i) = 0;
274 };
275 
277 {
278  return this->GetVariantValue(vtkArrayCoordinates(i));
279 }
280 
282 {
283  return this->GetVariantValue(vtkArrayCoordinates(i, j));
284 }
285 
287 {
288  return this->GetVariantValue(vtkArrayCoordinates(i, j, k));
289 }
290 
292 {
294 }
295 
297 {
299 }
300 
302 {
303  this->SetVariantValue(vtkArrayCoordinates(i, j, k), value);
304 }
305 
306 #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:65
Abstract interface for N-dimensional arrays.
Definition: vtkArray.h:65
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:291
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:72
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:71
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:70
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:276
a simple class to control print indentation
Definition: vtkIndent.h:113
abstract base class for most VTK objects
Definition: vtkObject.h:82
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:105
A atomic type representing the union of many types.
Definition: vtkVariant.h:155
@ value
Definition: vtkX3D.h:226
@ name
Definition: vtkX3D.h:225
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
#define VTK_NEWINSTANCE