VTK
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 
60 #ifndef vtkArray_h
61 #define vtkArray_h
62 
63 #include "vtkCommonCoreModule.h" // For export macro
64 #include "vtkArrayCoordinates.h"
65 #include "vtkArrayExtents.h"
66 #include "vtkObject.h"
67 #include "vtkStdString.h"
68 #include "vtkVariant.h"
69 
70 class VTKCOMMONCORE_EXPORT vtkArray : public vtkObject
71 {
72 public:
73  vtkTypeMacro(vtkArray, vtkObject);
74  void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE;
75 
79 
80  enum
81  {
83  DENSE = 0,
85  SPARSE = 1
86  };
87 
97  static vtkArray* CreateArray(int StorageType, int ValueType);
98 
104  virtual bool IsDense() = 0;
105 
107 
119  void Resize(const CoordinateT i);
120  void Resize(const CoordinateT i, const CoordinateT j);
121  void Resize(const CoordinateT i, const CoordinateT j, const CoordinateT k);
122  void Resize(const vtkArrayRange& i);
123  void Resize(const vtkArrayRange& i, const vtkArrayRange& j);
124  void Resize(const vtkArrayRange& i, const vtkArrayRange& j, const vtkArrayRange& k);
125  void Resize(const vtkArrayExtents& extents);
127 
137  virtual const vtkArrayExtents& GetExtents() = 0;
138 
144 
154 
160  virtual SizeT GetNonNullSize() = 0;
161 
165  void SetName(const vtkStdString& name);
170 
175 
180 
188  virtual void GetCoordinatesN(const SizeT n, vtkArrayCoordinates& coordinates) = 0;
189 
191 
196  inline vtkVariant GetVariantValue(CoordinateT i);
197  inline vtkVariant GetVariantValue(CoordinateT i, CoordinateT j);
198  inline vtkVariant GetVariantValue(CoordinateT i, CoordinateT j, CoordinateT k);
199  virtual vtkVariant GetVariantValue(const vtkArrayCoordinates& coordinates) = 0;
201 
209  virtual vtkVariant GetVariantValueN(const SizeT n) = 0;
210 
212 
217  inline void SetVariantValue(CoordinateT i, const vtkVariant& value);
218  inline void SetVariantValue(CoordinateT i, CoordinateT j, const vtkVariant& value);
219  inline void SetVariantValue(CoordinateT i, CoordinateT j, CoordinateT k, const vtkVariant& value);
220  virtual void SetVariantValue(const vtkArrayCoordinates& coordinates, const vtkVariant& value) = 0;
222 
230  virtual void SetVariantValueN(const SizeT n, const vtkVariant& value) = 0;
231 
233 
237  virtual void CopyValue(vtkArray* source, const vtkArrayCoordinates& source_coordinates, const vtkArrayCoordinates& target_coordinates) = 0;
238  virtual void CopyValue(vtkArray* source, const SizeT source_index, const vtkArrayCoordinates& target_coordinates) = 0;
239  virtual void CopyValue(vtkArray* source, const vtkArrayCoordinates& source_coordinates, const SizeT target_index) = 0;
241 
245  virtual vtkArray* DeepCopy() = 0;
246 
247 protected:
249  ~vtkArray() VTK_OVERRIDE;
250 
251 private:
252  vtkArray(const vtkArray&) VTK_DELETE_FUNCTION;
253  void operator=(const vtkArray&) VTK_DELETE_FUNCTION;
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;
276 };
278 
279 vtkVariant vtkArray::GetVariantValue(CoordinateT i)
280 {
281  return this->GetVariantValue(vtkArrayCoordinates(i));
282 }
283 
285 {
286  return this->GetVariantValue(vtkArrayCoordinates(i, j));
287 }
288 
290 {
291  return this->GetVariantValue(vtkArrayCoordinates(i, j, k));
292 }
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
310 
311 // VTK-HeaderTest-Exclude: vtkArray.h
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:52
Abstract interface for N-dimensional arrays.
Definition: vtkArray.h:71
void SetDimensionLabel(DimensionT i, const vtkStdString &label)
Sets the label for the i-th array dimension.
static VTK_NEWINSTANCE vtkArray * CreateArray(int StorageType, int ValueType)
Creates a new array where StorageType is one of vtkArray::DENSE or vtkArray::SPARSE,...
virtual void SetVariantValue(const vtkArrayCoordinates &coordinates, const vtkVariant &value)=0
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
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
void Resize(const vtkArrayRange &i, const vtkArrayRange &j)
void Resize(const vtkArrayRange &i, const vtkArrayRange &j, const vtkArrayRange &k)
void Resize(const CoordinateT i, const CoordinateT j)
vtkArrayExtents::SizeT SizeT
Definition: vtkArray.h:78
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.
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:77
vtkStdString GetName()
Returns the array name.
const vtkArrayRange GetExtent(DimensionT dimension)
Returns the extent (valid coordinate range) along the given dimension.
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
DimensionT GetDimensions()
Returns the number of dimensions stored in the array.
void Resize(const CoordinateT i, const CoordinateT j, const CoordinateT k)
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)
~vtkArray() override
vtkArrayExtents::CoordinateT CoordinateT
Definition: vtkArray.h:76
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)
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
abstract base class for most VTK objects
Definition: vtkObject.h:60
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:49
A atomic type representing the union of many types.
Definition: vtkVariant.h:76
@ value
Definition: vtkX3D.h:220
@ name
Definition: vtkX3D.h:219
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
#define VTK_NEWINSTANCE