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 
132  const vtkArrayRange GetExtent(DimensionT dimension);
137  virtual const vtkArrayExtents& GetExtents() = 0;
138 
143  DimensionT GetDimensions();
144 
153  SizeT GetSize();
154 
160  virtual SizeT GetNonNullSize() = 0;
161 
165  void SetName(const vtkStdString& name);
169  vtkStdString GetName();
170 
174  void SetDimensionLabel(DimensionT i, const vtkStdString& label);
175 
179  vtkStdString GetDimensionLabel(DimensionT i);
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:
248  vtkArray();
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 
284 vtkVariant vtkArray::GetVariantValue(CoordinateT i, CoordinateT j)
285 {
286  return this->GetVariantValue(vtkArrayCoordinates(i, j));
287 }
288 
289 vtkVariant vtkArray::GetVariantValue(CoordinateT i, CoordinateT j, CoordinateT k)
290 {
291  return this->GetVariantValue(vtkArrayCoordinates(i, j, k));
292 }
293 
294 void vtkArray::SetVariantValue(CoordinateT i, const vtkVariant& value)
295 {
296  this->SetVariantValue(vtkArrayCoordinates(i), value);
297 }
298 
299 void vtkArray::SetVariantValue(CoordinateT i, CoordinateT j, const vtkVariant& value)
300 {
301  this->SetVariantValue(vtkArrayCoordinates(i, j), value);
302 }
303 
304 void vtkArray::SetVariantValue(CoordinateT i, CoordinateT j, CoordinateT k, const vtkVariant& value)
305 {
306  this->SetVariantValue(vtkArrayCoordinates(i, j, k), value);
307 }
308 
309 #endif
310 
311 // VTK-HeaderTest-Exclude: vtkArray.h
vtkVariant GetVariantValue(CoordinateT i)
Returns the value stored in the array at the given coordinates.
Definition: vtkArray.h:279
Stores coordinate into an N-way array.
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:47
abstract base class for most VTK objects
Definition: vtkObject.h:59
Stores the number of dimensions and valid coordinate ranges along each dimension for vtkArray...
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
Abstract interface for N-dimensional arrays.
Definition: vtkArray.h:70
void DeepCopy(vtkPistonReference *self, vtkPistonReference *other)
Stores a half-open range of array coordinates.
Definition: vtkArrayRange.h:51
A atomic type representing the union of many types.
Definition: vtkVariant.h:75
vtkArrayExtents::DimensionT DimensionT
Definition: vtkArray.h:77
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkTypeUInt64 SizeT
void SetVariantValue(CoordinateT i, const vtkVariant &value)
Overwrites the value stored in the array at the given coordinates.
Definition: vtkArray.h:294
vtkArrayExtents::SizeT SizeT
Definition: vtkArray.h:78
#define VTK_NEWINSTANCE
vtkArrayCoordinates::CoordinateT CoordinateT
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
vtkArrayExtents::CoordinateT CoordinateT
Definition: vtkArray.h:76
vtkArrayCoordinates::DimensionT DimensionT