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 
59 #ifndef vtkArray_h
60 #define vtkArray_h
61 
62 #include "vtkCommonCoreModule.h" // For export macro
63 #include "vtkArrayCoordinates.h"
64 #include "vtkArrayExtents.h"
65 #include "vtkObject.h"
66 #include "vtkStdString.h"
67 #include "vtkVariant.h"
68 
70 {
71 public:
72  vtkTypeMacro(vtkArray, vtkObject);
73  void PrintSelf(ostream &os, vtkIndent indent);
74 
78 
79 //BTX
80  enum
81  {
83  DENSE = 0,
85  SPARSE = 1
86  };
87 //ETX
88 
95  static vtkArray* CreateArray(int StorageType, int ValueType);
96 
100  virtual bool IsDense() = 0;
101 
103 
111  void Resize(const CoordinateT i);
112  void Resize(const CoordinateT i, const CoordinateT j);
113  void Resize(const CoordinateT i, const CoordinateT j, const CoordinateT k);
114  void Resize(const vtkArrayRange& i);
115  void Resize(const vtkArrayRange& i, const vtkArrayRange& j);
116  void Resize(const vtkArrayRange& i, const vtkArrayRange& j, const vtkArrayRange& k);
117  void Resize(const vtkArrayExtents& extents);
119 
122  const vtkArrayRange GetExtent(DimensionT dimension);
125  virtual const vtkArrayExtents& GetExtents() = 0;
126 
129  DimensionT GetDimensions();
130 
137  SizeT GetSize();
138 
142  virtual SizeT GetNonNullSize() = 0;
143 
145  void SetName(const vtkStdString& name);
147  vtkStdString GetName();
148 
150  void SetDimensionLabel(DimensionT i, const vtkStdString& label);
151 
153  vtkStdString GetDimensionLabel(DimensionT i);
154 
160  virtual void GetCoordinatesN(const SizeT n, vtkArrayCoordinates& coordinates) = 0;
161 
163 
166  inline vtkVariant GetVariantValue(CoordinateT i);
167  inline vtkVariant GetVariantValue(CoordinateT i, CoordinateT j);
168  inline vtkVariant GetVariantValue(CoordinateT i, CoordinateT j, CoordinateT k);
169  virtual vtkVariant GetVariantValue(const vtkArrayCoordinates& coordinates) = 0;
171 
177  virtual vtkVariant GetVariantValueN(const SizeT n) = 0;
178 
180 
183  inline void SetVariantValue(CoordinateT i, const vtkVariant& value);
184  inline void SetVariantValue(CoordinateT i, CoordinateT j, const vtkVariant& value);
185  inline void SetVariantValue(CoordinateT i, CoordinateT j, CoordinateT k, const vtkVariant& value);
186  virtual void SetVariantValue(const vtkArrayCoordinates& coordinates, const vtkVariant& value) = 0;
188 
194  virtual void SetVariantValueN(const SizeT n, const vtkVariant& value) = 0;
195 
197 
199  virtual void CopyValue(vtkArray* source, const vtkArrayCoordinates& source_coordinates, const vtkArrayCoordinates& target_coordinates) = 0;
200  virtual void CopyValue(vtkArray* source, const SizeT source_index, const vtkArrayCoordinates& target_coordinates) = 0;
201  virtual void CopyValue(vtkArray* source, const vtkArrayCoordinates& source_coordinates, const SizeT target_index) = 0;
203 
205  virtual vtkArray* DeepCopy() = 0;
206 
207 protected:
208  vtkArray();
209  ~vtkArray();
210 
211 private:
212  vtkArray(const vtkArray&); // Not implemented
213  void operator=(const vtkArray&); // Not implemented
214 
216  vtkStdString Name;
217 
220  virtual void InternalResize(const vtkArrayExtents&) = 0;
221 
223  virtual void InternalSetDimensionLabel(DimensionT i, const vtkStdString& label) = 0;
224 
226 
227  virtual vtkStdString InternalGetDimensionLabel(DimensionT i) = 0;
228 };
230 
232 {
233  return this->GetVariantValue(vtkArrayCoordinates(i));
234 }
235 
237 {
238  return this->GetVariantValue(vtkArrayCoordinates(i, j));
239 }
240 
242 {
243  return this->GetVariantValue(vtkArrayCoordinates(i, j, k));
244 }
245 
247 {
248  this->SetVariantValue(vtkArrayCoordinates(i), value);
249 }
250 
252 {
253  this->SetVariantValue(vtkArrayCoordinates(i, j), value);
254 }
255 
257 {
258  this->SetVariantValue(vtkArrayCoordinates(i, j, k), value);
259 }
260 
261 #endif
262 
263 // VTK-HeaderTest-Exclude: vtkArray.h
vtkVariant GetVariantValue(CoordinateT i)
Definition: vtkArray.h:231
Stores coordinate into an N-way array.
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:46
abstract base class for most VTK objects
Definition: vtkObject.h:61
Stores the number of dimensions and valid coordinate ranges along each dimension for vtkArray...
#define VTKCOMMONCORE_EXPORT
Abstract interface for N-dimensional arrays.
Definition: vtkArray.h:69
void DeepCopy(vtkPistonReference *self, vtkPistonReference *other)
Stores a half-open range of array coordinates.
Definition: vtkArrayRange.h:50
A atomic type representing the union of many types.
Definition: vtkVariant.h:78
vtkArrayExtents::DimensionT DimensionT
Definition: vtkArray.h:76
virtual void PrintSelf(ostream &os, vtkIndent indent)
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkTypeUInt64 SizeT
void SetVariantValue(CoordinateT i, const vtkVariant &value)
Definition: vtkArray.h:246
vtkArrayExtents::SizeT SizeT
Definition: vtkArray.h:77
vtkArrayCoordinates::CoordinateT CoordinateT
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
vtkArrayExtents::CoordinateT CoordinateT
Definition: vtkArray.h:75
vtkArrayCoordinates::DimensionT DimensionT