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
vtkArray::GetSize
SizeT GetSize()
Returns the number of values stored in the array.
vtkStdString.h
vtkArray::SetName
void SetName(const vtkStdString &name)
Sets the array name.
vtkVariant.h
vtkArrayExtents::SizeT
vtkTypeUInt64 SizeT
Definition: vtkArrayExtents.h:79
vtkArray::SizeT
vtkArrayExtents::SizeT SizeT
Definition: vtkArray.h:78
vtkArray::Resize
void Resize(const CoordinateT i, const CoordinateT j, const CoordinateT k)
vtkX3D::value
@ value
Definition: vtkX3D.h:220
vtkArray::Resize
void Resize(const vtkArrayExtents &extents)
vtkArray::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkArrayRange
Stores a half-open range of array coordinates.
Definition: vtkArrayRange.h:52
vtkArray::Resize
void Resize(const CoordinateT i, const CoordinateT j)
vtkArray::Resize
void Resize(const vtkArrayRange &i, const vtkArrayRange &j, const vtkArrayRange &k)
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:60
vtkArray::GetDimensionLabel
vtkStdString GetDimensionLabel(DimensionT i)
Returns the label for the i-th array dimension.
vtkArray::~vtkArray
~vtkArray() override
vtkArray::IsDense
virtual bool IsDense()=0
Returns true iff the underlying array storage is "dense", i.e.
vtkArray::CopyValue
virtual void CopyValue(vtkArray *source, const vtkArrayCoordinates &source_coordinates, const SizeT target_index)=0
vtkArray::SetVariantValue
void SetVariantValue(CoordinateT i, const vtkVariant &value)
Overwrites the value stored in the array at the given coordinates.
Definition: vtkArray.h:294
vtkArray::GetExtent
const vtkArrayRange GetExtent(DimensionT dimension)
Returns the extent (valid coordinate range) along the given dimension.
source
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
Definition: vtkBoostGraphAdapter.h:822
vtkArray::SetVariantValueN
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()).
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.
vtkArrayCoordinates.h
vtkArray::GetDimensions
DimensionT GetDimensions()
Returns the number of dimensions stored in the array.
vtkArray::vtkArray
vtkArray()
vtkArray::Resize
void Resize(const vtkArrayRange &i)
vtkArray::GetVariantValue
vtkVariant GetVariantValue(CoordinateT i)
Returns the value stored in the array at the given coordinates.
Definition: vtkArray.h:279
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:40
vtkArray::CreateArray
static VTK_NEWINSTANCE vtkArray * CreateArray(int StorageType, int ValueType)
Creates a new array where StorageType is one of vtkArray::DENSE or vtkArray::SPARSE,...
vtkArray::GetVariantValueN
virtual vtkVariant GetVariantValueN(const SizeT n)=0
Returns the n-th value stored in the array, where n is in the range [0, GetNonNullSize()).
vtkVariant
A atomic type representing the union of many types.
Definition: vtkVariant.h:76
vtkArray::GetCoordinatesN
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,...
vtkArray::Resize
void Resize(const vtkArrayRange &i, const vtkArrayRange &j)
vtkX3D::name
@ name
Definition: vtkX3D.h:219
vtkArray
Abstract interface for N-dimensional arrays.
Definition: vtkArray.h:71
vtkObject.h
vtkArray::GetExtents
virtual const vtkArrayExtents & GetExtents()=0
Returns the extents (the number of dimensions and size along each dimension) of the array.
vtkArray::CopyValue
virtual void CopyValue(vtkArray *source, const SizeT source_index, const vtkArrayCoordinates &target_coordinates)=0
vtkArray::GetNonNullSize
virtual SizeT GetNonNullSize()=0
Returns the number of non-null values stored in the array.
vtkArrayExtents.h
vtkArray::Resize
void Resize(const CoordinateT i)
Resizes the array to the given extents (number of dimensions and size of each dimension).
vtkArray::DeepCopy
virtual vtkArray * DeepCopy()=0
Returns a new array that is a deep copy of this array.
vtkArray::GetName
vtkStdString GetName()
Returns the array name.
VTK_NEWINSTANCE
#define VTK_NEWINSTANCE
Definition: vtkWrappingHints.h:30
vtkStdString
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:49
vtkArray::CoordinateT
vtkArrayExtents::CoordinateT CoordinateT
Definition: vtkArray.h:76
vtkArrayExtents::DimensionT
vtkArrayCoordinates::DimensionT DimensionT
Definition: vtkArrayExtents.h:77
vtkArray::SetDimensionLabel
void SetDimensionLabel(DimensionT i, const vtkStdString &label)
Sets the label for the i-th array dimension.
vtkArrayExtents
Stores the number of dimensions and valid coordinate ranges along each dimension for vtkArray.
Definition: vtkArrayExtents.h:75
vtkArrayCoordinates
Stores coordinate into an N-way array.
Definition: vtkArrayCoordinates.h:58
vtkArrayExtents::CoordinateT
vtkArrayCoordinates::CoordinateT CoordinateT
Definition: vtkArrayExtents.h:78
vtkArray::DimensionT
vtkArrayExtents::DimensionT DimensionT
Definition: vtkArray.h:77